收藏
回答

各位这个问题怎么解决?模板41028

{errcode: 41028, errmsg: "invalid form id hint: [1pwgKa02394120]"}



testSubmit: function(e) {
    console.log(e,"===")
    var self = this;
    wx.login({
      success: res => {
        wx.request({
          url: 'https://api.weixin.qq.com/sns/jscode2session?appid=' + 'wx58b7b8691fefde0a' + '&&secret=' + 'd8fc503b909a40eefc9a3b3471636ddd' + '&&js_code=' + res.code + '&&grant_type=' + 'authorization_code',
          method: 'GET',
          header: {
            'Content-Type': 'application/json'
          },
          success: res => {
            var openid = res.data.openid;
            wx.request({
              url: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid= wx58b7b8691fefde0a&secret=d8fc503b909a40eefc9a3b3471636ddd',
              method: 'GET',
              header: {
                'Content-Type': 'application/json'
              },
              success: res => {
                self.data._access_token = res.data.access_token;
 
                let _jsonData = {
                  "access_token": self.data._access_token,
                  "touser": openid,
                  "page": "index",
                  "form_id": "FORMID",
                  "template_id": 'xyM8GiLLiZVw1iJGy3HrrWPHqFIaDcobM27H2FvVB7Y',
                  "data": {
                    "keyword1": {
                      "value": "TIT造舰快递",
                      "color": "#173177"
                    },
                    "keyword2": {
                      "value": "2019年01月12日",
                      "color": "#173177"
                    },
                    "keyword3": {
                      "value": "2019年01月9日",
                      "color": "#173177"
                    },
                    "keyord4": {
                      "value": "电风扇",
                      "color": "#173177"
                    }
                  }
                }
                wx.request({
                  url: 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=' + self.data._access_token,
                  data: _jsonData,
                  method: 'post',
                  success: function (res) {
                    console.log(res)
                  },
                  fail: function (err) {
                    console.log('request fail ', err);
                  },
                  complete: function (res) {
                    console.log("request completed!");
                  }
 
                })
              }
 
            })
          }
        })
      }
    })
 
 
 
 
 
  },


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

2 个回答

  • I'am  大豆博文    ark
    I'am 大豆博文 ark
    2019-01-24

    呵呵呵,细心点

    2019-01-24
    有用
    回复
  • Helen
    Helen
    2019-01-17

    我也遇到这个问题了,不知道这么解决

    2019-01-17
    有用
    回复 18
    • I'am  大豆博文    ark
      I'am 大豆博文 ark
      2019-01-17

      已经解决了,这个form_id必须在前端提交表单时传给后台去调用微信接口处理,前端不要去写后台的http://weixin.qq.com//这样子不安全,上线了也不会运行,

      2019-01-17
      回复
    • Helen
      Helen
      2019-01-17回复I'am 大豆博文 ark

      我现在也是后台调用微信的API,但是总是返回formId无效

      2019-01-17
      回复
    • Helen
      Helen
      2019-01-17回复I'am 大豆博文 ark

      大神,请问你是怎么解决的?

      2019-01-17
      回复
    • I'am  大豆博文    ark
      I'am 大豆博文 ark
      2019-01-17回复Helen

      让前端传给你,前端必须是表单提交

      <form bindsubmit='subOrder' report-submit='true'>

      <button form-type='submit'></button>

      </form>

      subOrder(e){

      formId=e.detail.formId

      }

      2019-01-17
      回复
    • Helen
      Helen
      2019-01-17回复I'am 大豆博文 ark

      是的,我这边前端小程序也是这样写的,在真机环境也有返回formId

      2019-01-17
      回复
    查看更多(13)
登录 后发表内容