Uniapp-接入企业微信客服
参考
uniapp接入企业微信客服 – 月半猪博客 (fatterpig.com)
步骤
打开企业微信-应用管理-微信客服
启用微信客服
客服账号-创建账号,选择公司
人工接待配置,添加人员
选择接入场景
- 在App中接入:在App中接入 (qq.com)
代码示例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53//界面代码
<u-tag :text="$t('联系客服')" shape="circle" class="u-m-r-30" @click="chat" type="info" />
//方法
chat() {
//WORKWXCORPID 企业ID
//WORKWXURL 企业客服链接
// #ifdef H5
// 触发跳转外链
// 此处参考:
// https://blog.fatterpig.com/uniapp跳转到外部链接/
uni.navigateTo({
url: '/pagesC/webview/webview?url='+WORKWXURL
});
// #endif
// #ifdef MP-WEIXIN
wx.openCustomerServiceChat({
extInfo: {url: WORKWXURL},
corpId: WORKWXCORPID,
success(res) {}
})
// #endif
// #ifdef APP-PLUS
let sweixin = null
plus.share.getServices(res => {
sweixin = res.find(i => i.id === 'weixin')
if (sweixin) {
sweixin?sweixin.openCustomerServiceChat({
corpid: WORKWXCORPID,
url:WORKWXURL
}, res => {
console.log(res)
}, error=>{
console.log(error)
}):plus.nativeUI.alert('当前环境不支持微信操作!');
} else {
uni.showToast({
title: "当前环境不支持微信操作",
icon: 'error'
})
}
}, function() {
uni.showToast({
title: "获取服务失败,不支持该操作。" + JSON.stringify(e),
icon: 'error'
})
})
// #endif
}
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 王文哲的博客!