美文网首页
批量获取form_id无限发送模板消息

批量获取form_id无限发送模板消息

作者: 张大娃创业笔记 | 来源:发表于2019-01-14 18:02 被阅读0次

    在页面必要点击的地方批量获取formid保存下来,代码如下:
    wxml:

    <form bindsubmit="formSubmit" report-submit="{{true}}">
                  <button formType="submit" class='btn'>
                                <form bindsubmit="formSubmit" report-submit="{{true}}">
                                                <button formType="submit" class='btn'>
                                                  <view class='u-publish-btn' bindtap='test'>立即下单</view>
                                                </button>
                                              </form>
                                            </button>
                                          </form>
    

    wxss:

    form button{
      padding: 0;
    }
    
    form button::after{
      content: '';
      display: none;
    }
    
    .u-publish-btn{
      position: fixed;
      bottom: 0;
      right:0;
      width: 180rpx;
      line-height: 100rpx;
      border-radius: 4rpx;
      background: #fcd15e;
      font-size: 38rpx;
      font-weight: bolder;
      color: #fff;
    }
    

    js:

    //批量存储formid
     formSubmit: function(e) {
        if (e.detail.formId != 'the formId is a mock one') {
          var form = this.data.formIds;
          form.push(e.detail.formId)
          this.setData({
            formId: form
          })
          console.log(form)
          wx.setStorageSync("formids", form)
        }
        console.log(e.detail)
      }
    

    注:注意fromid存储的异步问题,把需要取得formid的事件延迟执行,最好批量获取id时加一个弹窗事件已解决这个问题。

    相关文章

      网友评论

          本文标题:批量获取form_id无限发送模板消息

          本文链接:https://www.haomeiwen.com/subject/wcpjdqtx.html