之前一直用模板消息,自从最近更新了订阅消息,第一是尝试,一直调试不成功
这是云函数push.js
const cloud = require( 'wx-server-sdk' ) cloud.init() exports.main = async(event, context) => { return sendSubscribeMessage(event) } async function sendSubscribeMessage(event) { const sendResult = await cloud.openapi.subscribeMessage.send({ touser: cloud.getWXContext().OPENID, page: 'pages/index/index' , data: { name1: { value: '4542312' }, date3: { value: '2015年01月05日' }, }, templateId: 'yyFvDHU6xbrik5jQwYDpJuix8OOiBIvNrNTyC6u4anB' }) return sendResult } |
这是页面的调用index.js(其中formSubmit是表单提交是点击保存按钮事件)
formSubmit: function(event) {
tmplIds: [ 'yyFvDHU6xbrik5jQwYDpJuix8OOiBIvNrNTyC6u4anB' ], success(res) { wx.cloud.callFunction({ name: "push" , success(res) { console.log( "推送成功" + res) }, fail(res) { console.log( "推送失败" + res) } }) }
} |
有大佬帮帮忙吗?
网友回复
Stephen:云函数的 config.json 文件有配置权限声明?