微信小程序获取formid组件

2019-04-16  本文已影响0人  轩辕夜空

wxml

<form bindsubmit="saveFormId" report-submit="{{true}}" class='form_class' data-id='0'>
  <button formType="submit" class='form_button'>
    <slot />
  </button>
</form>

wxss

button::after {
  border: none;
}
button{
  padding: 0;
}

js

 saveFormId(v) {
      this.wxlogin(v.detail.formId)
      this.resdata()
    },
    wxlogin(id) {
      var that = this;
      wx.login({
        success: res => {
//将formid提交到api
          let companyCode = wx.getStorageSync('userinfo').companyCode
          let techId = wx.getStorageSync('userinfo').techId
          const subFormid = Models.subFormid(id, res.code, companyCode, techId)
          subFormid.then(res => {
              
          })
        }
      })
    },
    resdata: function() {
      this.triggerEvent('resdata', 1)
    },

调用组件

//goAnalysis执行自己的点击函数
        <formid bind:resdata="goAnalysis">
            <view class='menu-box'>
              <image src='../../images/data_menu8.png' class='menu-lgpic'></image>
              <view>客户分析</view>
            </view>
          </formid>
上一篇下一篇

猜你喜欢

热点阅读