收藏
回答

模板消息失效

API/组件名称 终端类型 微信版本 基础库版本
模板消息 客户端 6.6.1 1.7.0

模板消息6.6.1版本微信下无效,之前微信使用的是6.5.几版本,模板消息无论是否开调试模式都可以正常接收,但是将微信版本升级到最新的6.6.1版本后,模板消息功能失效了,调试模式下是正常的,苹果端和安卓端一样的问题,求大佬解惑,谢谢

wx.request({
  url: util.Apis + '/h5/**/****',
  method: 'POST',
  data: {
    'userId': that.data.uid,
    //个人-地址信息
    'addrId': that.data.addrId,
    'receiveName': that.data.address.name,
    'receivePhone': that.data.address.phone,
    'receiveAddress': that.data.address.address,
    //商品信息
    'totalPriceNow': that.data.orderinfo.totalPriceNow, // 现在的总价
    'freight': that.data.orderinfo.freight,//运费
    'needPay': that.data.needpay, // 应付金额
    'skuid': sid, // 类型id
    'num': num,  // 购买数量
    'cartid': cid,
    'saleorderid': that.data.orderStateID,// 满减id
    'remarkText': that.data.leaveMessage, // 买家留言
    'couponId': that.data.couponID, // 优惠券ID
  },
  header: {
    'content-type''application/x-www-form-urlencoded'
  },
  success: function (res) {
    var oidS = res.data.data.orderBean.order.orderid
    var goodNames="" //商品名字
    var orderItem = res.data.data.orderBean.orderItem
    for (let i = 0; i < orderItem.length;i++){
      goodNames+=orderItem[i].name
    }
    var orderMes = res.data.data.orderBean.order
    var ordercode = orderMes.ordercode//订单号
    var createTime = util.newDate(orderMes.createTime, 'Y-M')//下单时间
    var needPay = orderMes.needPay/100//金额
    var toastMes = '请在' + util.newDate((orderMes.createTime - 1800000), 'HM')+'之前完成支付'//截至时间
    wx.request({
      url: 'https://api.weixin.qq.com/cgi-bin/token',
      data: {
        grant_type: 'client_credential',
        appid: "****",
        secret: '****'
      },
      header: {
        'content-type''application/x-www-form-urlencoded'  // 默认值
      },
      method: 'GET',
      success: function (res) {
        var accessToken = res.data.access_token
        that.setData({
          access_token: accessToken
        })
        wx.request({
          url: 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=' + that.data.access_token,
          data: {
            "touser": that.data.openidLocal,
            "template_id""z-EL5eCPRPwFgIe6IjGZj9bAAzX3qKRxgoQ*****",
            "page"'pages/payment/payment?orid=' + oidS,
            "form_id": that.data.formId,
            "data": {
              "keyword1": {
                "value": ordercode,
                "color""#173177"
              },
              "keyword2": {
                "value": createTime,
                "color""#173177"
              },
              "keyword3": {
                "value"'¥'+needPay,
                "color""#173177"
              },
              "keyword4": {
                "value": toastMes,
                "color""#173177"
              },
              "keyword5": {
                "value": goodNames,
                "color""#173177"
              }
            },
          },
          header: {
            'content-type''application/json'
          },
          method: 'POST',
          success: function (res) {
            wx.navigateTo({
              url: '../payment/payment?orid=' + oidS
            })
            wx.removeStorageSync('skuids')
            wx.removeStorageSync('sid')
            wx.removeStorageSync('num')
          }
        })
      }
    })
  }
})



回答关注问题邀请回答
收藏

2 个回答

  • 工号 9527
    工号 9527
    2018-01-05

    为啥要在前端写?

    2018-01-05
    有用
    回复
  • 子游
    子游
    2018-01-08

    汗,文档上也没特别标注必须后端写啊,而且6.5.几版本是好的啊,官方升级是不是把这功能给封了

    2018-01-08
    有用
    回复
登录 后发表内容