需要用到的平台

企业微信:https://work.weixin.qq.com/
微信客服:https://work.weixin.qq.com/kf
微信开放平台:https://open.weixin.qq.com/
微信公众平台(小程序):https://mp.weixin.qq.com/

需要绑定的步骤

APP相关
1.注册企业微信并认证。获取【企业ID】
2.注册微信开放平台,获取【APPID】。
「移动应用-能力专区- APP跳转微信客服- 关联设置」
3.(接2-关联设置) 微信客服:「开始接入 - 在微信外App/网页中接入 - 去接入」填写【APPID】。
成功后 「微信开放平台-关联设置」刷新,即可看到绑定信息。
4.UNIAPP中配置Share模块:appid填写微信开放平台【APPID】
成功绑定APP和客服

小程序相关
小程序管理后台的「功能-客服-微信客服」处,填写对应的【企业ID】。
成功绑定小程序和客服

遇到报错可能的原因

openCustomerServiceChat:fail not bind errCode:6

(小程序后台没有绑定【企业ID】)

deeplink customservice no permission

(微信客服后台没有关联接入微信开放平台的【APPID】)

相关代码

toKF(){
    const that = this
    // #ifdef APP-PLUS
    plus.share.getServices(res => {
        const wechat = res.find(i => i.id === 'weixin')
        if (wechat) { 
            wechat.openCustomerServiceChat({
                corpid: 'ww8xxxxxxxxx', //第三步获取
                url: 'https://work.weixin.qq.com/kfid/kfcbxxxxxx'
            }, src => {
                console.log("success:")
            }, err => {
                console.log("error:")
                uni.showToast({
                    title: '打开微信失败',
                    icon: "error"
                });
            })
        } else {
            uni.showToast({
                title: '当前环境不支持',
                icon: "error"
            });
        }
    });
// #endif

// #ifdef MP-WEIXIN
    wx.openCustomerServiceChat({
      extInfo: {url: 'https://work.weixin.qq.com/kfid/kfcbxxxxxx'},// url客服链接
      corpId: 'ww8xxxxxxxxx',//企业ID
      success(res) {},
      fail(res) {
        uni.showToast({
            title: '当前环境不支持',
            icon: "error"
        });
        console.log(res)
      }
    })
// #endif

// #ifdef H5
    uni.showModal({
        title:'提示',
        content:'即将离开网页跳转至微信,是否继续',
        success:function(res){
            if(res.confirm){
                window.location.href = 'https://work.weixin.qq.com/kfid/kfcbxxxxxx'
            }else if(res.cancel){
            }
        }
    })
// #endif
},

其他可能遇到的问题

1.微信开放平台创建移动应用时,官网问题。
写一个响应式官网,可以只有首页,首页内容包括:顶部LOGO、banner、平台介绍文字、平台功能介绍文字、平台操作流程文字配截图、底部标注联系电话。
2.微信客服 -「在微信外App/网页中接入」没有接入按钮
如图

解决:【微信客服】页上滑到最上方,点击开始使用(同时企业微信内会被关闭)。此时会出现去接入按钮。

配置好后,回到【企业微信-微信客服页】页面,点击启用,重新开启企业微信客服

参考文章

uniapp APP使用微信客服(超详细,保姆级教学)
uniapp app打开微信客服


毛线团阿阳
17 声望1 粉丝