想做一个审核通知,用户在提交审核页同意订阅后,运营者对其提交的内容进行审核,通过才发送订阅消息给用户。我却几次测试都收不到是怎么回事呢?
//用户提交页的申请订阅消息代码
wx.requestSubscribeMessage({
tmplIds: ['KaDMyAKk_66eHHraZz086vxwxubOrfhPRdt1AF6fEKY','5xu06HVmngucF7M3FmrhHk_EtUUlF2stYcmTWP38xmw'],
//前者为审核通过消息模板,后者是未通过模板
success(res) {},
fail(res) {
if (res.errCode == 20004) {
that.setData({
isShowSetModel: true
})
} else {
console.log(res)
wx.showToast({
title: '出错了!',
icon: 'error'
})
}
})
这里调试的时候也出现了点问题,就是手机上申请消息模板只显示了一条而不是两条
//运营者通过审核代码
wx.cloud.callFunction({
name: "audit",
data: {
organ: this.data.application[index].name,
openid: this.data.application[index]._openid,
code: code
},
success: res => {
console.log(res)
},
fail: err => {
console.error(err)
}
})
//驳回代码
wx.cloud.callFunction({
name: "reject",
data: {
organ: this.data.application[index].name,
openid: this.data.application[index]._openid,
reason: res.content
}
})
//审核通过发送订阅消息云函数
//audit.json
{
"permissions": {
"openapi": ["subscribeMessage.send"]
}
}
//audit.js
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
exports.main = async (event, context) => {
try {
await cloud.openid.subscribeMessage.send({
touser: event.openid,
page: 'pages/enter/enter',
data: {
thing2: {
value: event.organ
},
phrase1: {
value: '申请通过'
},
thing5: {
value: '初始邀请码为' + event.code + ',点击进入组织吧'
}
},
templateId: 'KaDMyAKk_66eHHraZz086vxwxubOrfhPRdt1AF6fEKY'
});
console.log("pass");
return Promise.all(sendPromises);
} catch (err) {
console.log(err);
return err;
}
}
//审核未通过发送订阅消息云函数
//reject.json略
//reject.js
const cloud = require('wx-server-sdk')
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV })
exports.main = async (event, context) => {
try {
await cloud.openid.subscribeMessage.send({
touser: event.openid,
page: 'pages/home/home',
data: {
thing16: {
value: event.organ
},
phrase1: {
value: '申请未通过'
},
thing48: {
value: event.reason
}
},
templateId: '5xu06HVmngucF7M3FmrhHk_EtUUlF2stYcmTWP38xmw'
})
console.log("reject");
return Promise.all(sendPromises);
} catch (err) {
console.log(err);
return err;
}
}
模板内容应该都没有超过字数限制,日志上两个云函数都调用成功了,但返回结果是什么都没有。求求各位大侠帮我看看哪里出问题了