小程序跳转企业微信客服
下文中路径都是以完整包前端代码:view/uniapp
1、文件view/uniapp/utils/util.js
/**
* 处理客服不同的跳转;
*
*/
getCustomer(userInfo,url){
let self = this;
customerType().then(res=>{
let data = res.data;
if (data.customer_type == 1) {
uni.makePhoneCall({
phoneNumber: data.customer_phone
});
} else if (data.customer_type == 2) {
let href = data.customer_url;
let hrefO = href + '?uid=' + userInfo.uid + '&nickName=' + userInfo.nickname + '&phone=' +
userInfo.phone + '&sex=' + userInfo.sex + '&avatar=' + userInfo.avatar +
'&openid=' + userInfo.openid;
let hrefT = href + '&uid=' + userInfo.uid + '&nickName=' + userInfo.nickname + '&phone=' +
userInfo.phone + '&sex=' + userInfo.sex + '&avatar=' + userInfo.avatar +
'&openid=' + userInfo.openid;
let urls = encodeURIComponent(href.indexOf('?') === -1 ? hrefO : hrefT);
// #ifdef MP
if (data.customer_url.indexOf('work.weixin.qq.com') > 0){
uni.openCustomerServiceChat({
extInfo: {
url: data.customer_url
},
corpId: data.wechat_work_corpid,
success(res) {},
fail(err) {
self.Tips({
title: err.errMsg
});
}
})
}else{
uni.navigateTo({
url: `/pages/annex/web_view/index?url=${urls}`
});
}
// #endif
// #ifndef MP
uni.navigateTo({
url: `/pages/annex/web_view/index?url=${urls}`
});
// #endif
} else {
uni.navigateTo({
url: url || '/pages/extension/customer_list/chat'
})
}
}).catch(err=>{
self.Tips({
title: err
});
})
},
分别在用到的页面进行调用(路径):
2、view/uniapp/pages/user/index.vue
替换:this.kefuInfo(url); 整体为下图所示部分
3、view/uniapp/pages/users/order_details/index.vue
goGoodCall方法:替换成如下截图
4、view/uniapp/components/kefuIcon/index.vue
licks(){
let userInfo = {}
if(typeof this.userInfo === 'string'){
userInfo = JSON.parse(this.userInfo)
}else{
userInfo = this.userInfo
}
let url = `/pages/extension/customer_list/chat?productId=${this.ids}`
this.$util.getCustomer(userInfo,url)
}
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}