- 订阅消息的授权和发送的问题?求各位老师赐教,谢谢
我首先点击页面的一个“订阅”按钮,弹出一个订阅消息的对话框。按下此按钮执行的代码是: dingyue:function(){ wx.requestSubscribeMessage({ tmplIds: ['sgpdaXKoFFystyA_TUxzk86PoEsgqWr3J4Rl88toWBA'], success(res) { console.log('调用订阅消息接口成功'); console.log(res) }, fail(res) { console.log('fail 失败') console.log(res) logger.warn('订阅消息fail', res) }, }) } 然后在点击消息“发送”按钮,此按钮执行的代码是: send:function(){ wx.cloud.callFunction({ name:'sendNotice', data:{ openid:'我微信的openid' }, success:res=>{ console.log('打印:模板消息发送成功') } }) }, 然后对应的云函数“sendNotice”的具体代码是这么写的: const cloud = require('wx-server-sdk') cloud.init() exports.main = async (event, context) => { try{ const result=await cloud.openapi.subscribeMessage.send({ touser:event.openid, page:'applyVacation/applyVacation', lang:'zh_CN', data:{ thing1:{ value:'张三' }, time2:{ value:'2月6日-2月10日 共5天' }, thing3:{ value:'已获批准,准予休假' }, thing4:{ value:'备注' } }, templateId:'sgpdaXKoFFystyA_TUxzk86PoEsgqWr3J4Rl88toWBA', miniprogramState:'developer', }) console.log(result) return result }catch(err){ console.log(err) return err } } 我是先点击订阅按钮,弹出对话框,点击“接受”,然后再点击“发送”,就怎么都收不到订阅消息了,各位老师请指教我这个小白吧,谢谢大家了
2020-04-01 - 小程序wx.showModal()中的顺序执行的问题,这个该如何解决?谢谢大家
我在.js文件中遇到关于wx.showModal()函数的执行问题:具体代码是这样 var that = this; wx.showModal({ title: '提示', content: '是否确认提交?', confirmColor: 'blue', success: function (res) { if (res.confirm) { function1{} function2{} } else if (res.cancel) { //按下取消键 return } } }) 我希望先执行function1,执行完再执行function2,但是实际执行起来有时候先f1后f2,有时候先f2后f1,有什么办法一定要先执行f1,执行成功后再执行f2 ?谢谢大家
2020-03-06