发送订阅消息报erroCode:604100

您所在的位置:网站首页 60104故障 发送订阅消息报erroCode:604100

发送订阅消息报erroCode:604100

2023-12-14 17:05| 来源: 网络整理| 查看: 265

// 云函数入口文件

const cloud = require('wx-server-sdk')

cloud.init({

  env:"campusapp-tbke2"

})

cloud.init()

// 云函数入口函数

//某人接收后给用户推送消息

exports.main = async (event, context) => {

  let date=new Date();

  try{

      const result = await cloud.openapi.subscribMessage.send({

        touser:event.openid,

        page:'pages/mine/mine',

        data:{

            thing1:{

              value:'有人替你跑腿啦!!!'

            },

            date2:{

              value:date

            },

            thing3:{

              value:'电话:'+event.phone

            },

            thing4:{

              value:'请随时注意跑腿动态'

            }

        },

        templateId:'Cca3spIn4kIIRs8rSBuZgWMO4WWw0GYL1gKkfQ-qNb0'

      })

      console.log(result)

      return result;

  }catch(err){

    return err

  }

}

前端代码:

      //发送订阅消息

              wx.cloud.callFunction({

                name:'sendmsg',

                data:{

                  openid:o_id._openid,

                  phone:that.data.myphone

                },success:function(res){

                  console.log("send msg successfully")

                  console.log(res);

                },fail:function(res){

                  console.log("fail!!!")

                }

              })



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3