uniapp接入微信客服聊天流程(企业微信)

1.注册并认证企业微信

多平台开发企业微信客服是最好的解决方案
企业微信

2.打开微信客服

在这里插入图片描述

3.启用微信客服,并添加客服账号

在这里插入图片描述

4.接入场景

如果多平台开发可以都接入
在这里插入图片描述
里面有步骤,按照步骤走即可(看完官方教程一定回来继续看代码!!

4.1微信小程序接入

在这里插入图片描述
客服连接有用复制一下,然后
看教程即可在这里插入图片描述
在这里插入图片描述

附上代码:

	wx.openCustomerServiceChat({
		//企业微信的企业id
		corpId: 'xxx',
		extInfo: {
			//客服链接
			url: 'https://xxx'
		},
		success: (e) => {
			console.log('e', e)
		},
		fail: (err) => {
			console.log('err', err)
		}
	})

4.2app接入

接入流程和小程序类似,直接上代码

let sweixin = null
plus.share.getServices(res => {
	sweixin = res.find(i => i.id === 'weixin')
	if (sweixin) {
		sweixin.openCustomerServiceChat({
			corpid: 'xxx',
			url:'https://xxx'
		})
	} else {
		// plus.nativeUI.alert('当前环境不支持微信操作')
		uni.showToast({
			title: "当前环境不支持微信操作",
			icon: 'error'
		})
	}
}, function() {
	uni.showToast({
		title: "获取服务失败,不支持该操作。" + JSON.stringify(e),
		icon: 'error'
	})
})

uniapp接入客服到此结束
接下来就是繁琐的调试调试。。。。。

  • 15
    点赞
  • 53
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在uniapp中使用企业微信小程序登录获取用户信息,需要完成以下步骤: 1. 在企业微信开发者中心创建小程序,并获取AppID和AppSecret。 2. 在uniapp中引入wx-server-sdk插件,并初始化: ``` import { init } from 'wx-server-sdk' init({ env: 'your-env-id', traceUser: true, }) ``` 3. 创建云函数,用于获取企业微信小程序登录凭证code: ``` const cloud = require('wx-server-sdk') const qywx = require('wx-server-sdk/qywx') exports.main = async (event, context) => { const wxContext = cloud.getWXContext() const code = event.code const res = await qywx.getQrCodeLoginInfo({ appid: 'your-appid', secret: 'your-appsecret', code: code, }) return res } ``` 4. 在uniapp中调用云函数,获取登录凭证code: ``` wx.qy.login({ success: res => { const code = res.code // 调用云函数,获取登录凭证信息 uniCloud.callFunction({ name: 'getQrCodeLoginInfo', data: { code: code }, success: res => { const loginInfo = res.result console.log(loginInfo) }, fail: err => { console.log(err) } }) }, fail: err => { console.log(err) } }) ``` 5. 使用登录凭证code获取用户信息: ``` wx.qy.getUserInfo({ withCredentials: true, success: res => { const userInfo = res.userInfo console.log(userInfo) }, fail: err => { console.log(err) } }) ``` 注意:在使用企业微信小程序登录时,需要在企业微信管理后台配置登录授权域名和JS安全域名,并且需要在小程序中配置企业微信授权登录的AppID和AppSecret。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值