kfMixin.js 1.38 KB
// const kf_list = [{
//     sapCode: 5036,
//     url: 'https://work.weixin.qq.com/kfid/kfc82ffd378b8649621'
//   },
//   {
//     sapCode: 5028,
//     url: 'https://work.weixin.qq.com/kfid/kfcd636da4134201fbb'
//   },
//   {
//     sapCode: 5016,
//     url: 'https://work.weixin.qq.com/kfid/kfcdef92056fc8ef091'
//   },
// ]
module.exports = Behavior({
  data: {},
  methods: {
    filterKfList(data) {
      let showKF = false,
        customerlist = [],
        kfUrl = ''
      if (data.customerServerType) {
        if (data.customerServerType == 1)
          customerlist[0] = {
            thumbAvatar: data.customerServerAvatar,
            staffName: data.customerServerName,
            qrCode: data.customerServerOrCode
          }
        else kfUrl = data.customerServerUrl
        showKF = true
      }

      this.setData({
        showKF,
        kfUrl,
        customerlist
      })
    },
    openKF(e) {
      let { kfUrl, widgetStatus } = this.data
      if (kfUrl)
        wx.openCustomerServiceChat({
          extInfo: {
            url: kfUrl
          },
          corpId: 'wx51bda2e574d24a91',
          success(res) {
            console.log(res)
          },
          fail({ errMsg }) {
            console.log(errMsg)
             wx.p.wxApi.showToast(errMsg)
          }
        })
      else
        this.setData({
          widgetStatus: !widgetStatus
        })
    }
  }
})