通过<button>进入客服对话页面,发送小程序卡片给客服,自动回复一张图片,发送成功后,要退出聊天窗口才能收到图片,这是为社么啊?
加入社群
js
handleContact: function (e) {
console.log(e)
console.log(this.data.flockInfo.mediaId)
wx.cloud.callFunction({
name: 'serviceMsg',
data: {
content: 'qrCode',
mediaId: this.data.flockInfo.mediaId
}
}).then(res => {
console.log("客服消息下发成功:", res)
}).catch(err => {
console.error(err)
})
},
云函数
function sendFlockQRcode() {
try {
cloud.openapi.customerServiceMessage.setTyping({
touser: wxContext.OPENID,
command: 'Typing'
})
cloud.openapi.customerServiceMessage.send({
touser: wxContext.OPENID,
msgtype: 'image',
image: {
mediaId: event.mediaId
}
})
cloud.openapi.customerServiceMessage.setTyping({
touser: wxContext.OPENID,
command: 'CancelTyping'
})
} catch (error) {
console.log(error)
return error
}
}
刚进入不能发,用户发条消息,后台才能调用客服消息接口