微信咨询

微信咨询

13610*910*9

服务热线 7*24小时

电话咨询

微信小程序云函数传参

iamdu2022-04-29 16:24:13 浏览: 91178

页面JS文件

wx.cloud.callFunction({
  // 云函数名称
  name: 'message', 
  // 传给云函数的参数
  data: {
	time1:'17:00',
        text1:'去旅游了'
  },

云函数JS文件

exports.main = async (event, context) => {
try {
  const result = await cloud.openapi.subscribeMessage.send({
      "touser": 'of0NI5X-ei8B6JdcLVOEh_uLCpMI',
      "page": 'pages/index/index',
      "lang": 'zh_CN',
      "data": {
        "thing1": { //参数根据后台订阅消息模板字段填写thing3.DATA 则填写thing3
          "value": event.text1
        },
        "time3": {
          "value": event.time1
        }
      },
      "templateId": 'FUi650ckopOkJHWJo2CR8SNa8Sb4j5tCmTjJyRzmkws',
      "miniprogramState": 'developer'
    })
  return result
} catch (err) {
  return err
}
}