收集formid

wxml:

wxss:

/* formid */
.formid_collect2 button.form_button{
    background:transparent;
    height:auto;
    width:100%;
    display:block;
    padding:0;
    margin:0;
    line-height:inherit;
    font-size:inherit;
    text-align:inherit;
    position:static;
    border:none;
    border-radius:0;
}
.formid_collect2 button.form_button:after{
    border:none;
    width:0;
    height:0;
    padding:0;
    margin:0;
}

js:

sendFormId: function () {
    setTimeout(function () {
      app.sendFormId();
    }, 500);
  },
  hideFormCover: function (ev) {
    var id = ev.detail.formId;
    console.log(id);
    app.hideFormCover(this, id);
  },

app.js:

formId_arr: [],
had_formid: false,

hideFormCover: function (that, formId) {
    if (this.had_formid) return;
    if (!formId || formId == "the formId is a mock one" || !this.data.session_3rd) {
      return;
    }
    this.formId_arr.push(formId);
  },
  sendFormId: function () {
    if (this.had_formid) return;
    var _this = this;
    var formIds = this.formId_arr.slice(0);
    this.formId_arr = [];
    var time = this.getTimeStamp(new Date());
    var post_data = {
      form_id: formIds,
      time: time
    };
    if (this.appid) {
      post_data["appid"] = this.appid;
    }
    if (!formIds || !formIds.length) {
      return;
    }
    console.log(post_data, "session_3rd:", this.data.session_3rd);
    this.had_formid = true;
    wx.request({
      method: "POST",
      url: this.domain + '/index.php?g=Wap&m=Wxaapi&a=save_form_id&session_3rd=' + this.data.session_3rd,
      data: post_data,
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res);
      },
      fail: function (res) {
        console.log(res);
      }
    });
  },

你可能感兴趣的:(收集formid)