云函数调用 订阅消息发送报错 40037 有大佬能帮忙看看什么问题吗
模板id : QSWiWXWVX5TNFLPK4n4QMNs_KofnjvkR4Dlhfgl2ZH0
appId:wx63462f3ba0201235
openapi.subscribeMessage.send:fail invalid template_id rid: 64300265-0451f298-143cb2bf"
云函数代码:
exports.main = async (event, context) => {
try {
const result = await cloud.openapi.subscribeMessage.send({
touser: event.openid,
templateId: 'QSWiWXWVX5TNFLPK4n4QMNs_KofnjvkR4Dlhfgl2ZH0',
page: event.page,
data: {
thing1:{
value:'wangzha'
},
character_string2:{
value:'232323'
}
}
})
console.log(result)
return result
} catch (err) {
console.log(err)
return err
}
}
调用方代码:
onConfirm: function() {
console.log('进入了这个方法')
console.log('openid-----',this.data.openId)
if (!this.data.openId){ return}
wx.requestSubscribeMessage({
tmplIds: ['QSWiWXWVX5TNFLPK4n4QMNs_KofnjvkR4Dlhfgl2ZH0'],
success(res) {
console.log('授权成功',res)
wx.cloud.callFunction({
name:'sendWxMessage',
data:{
openid:'osshl5I7EyPnTrPtf5efwLXAvx6E'
}
}).then(res=>{
console.log('发送成功',res)
}).catch(res=>{
console.log('发送失败',res)
})
},
fail(res) {
console.log('授权失败',res)
}
});
提示已经很明显了啊,模板ID无效,确认一下后台有没有这个订阅消息,ID有没有错