| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 | 
							- // pages/form/index.js
 
- var api = require('../../utils/api.js')
 
- Page({
 
-   /**
 
-    * 页面的初始数据
 
-    */
 
-   data: {
 
-     data: {
 
-       formContainerClass: 'mode-1-container'
 
-     }
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面加载
 
-    */
 
-   onLoad: function (options) {
 
-     var that = this;
 
-     wx.request({
 
-       url: api.getFormSetUrl,
 
-       method: 'GET',
 
-       success: res => {
 
-         if(res.data.status == 'success') {
 
-           var formContainerClass = res.data.data.mode == 1 ? 'mode-1-container' : 'mode-2-container'
 
-           that.setData({
 
-             data: res.data.data,
 
-             formContainerClass: formContainerClass
 
-           })
 
-           if(res.data.data.top_title) {
 
-             wx.setNavigationBarTitle({
 
-               title: res.data.data.top_title
 
-             })
 
-           }
 
-           
 
-         }
 
-       }
 
-     })
 
-   },
 
-   formSubmit: function(e) {
 
-     var that = this,
 
-         data = that.data.data,
 
-         value = e.detail.value;
 
-     
 
-     if(data.money && data.money != '0') {
 
-       value.type = 'pay';
 
-     } else {
 
-       value.type = 'form';
 
-     }
 
-     value.id = wx.getStorageSync('we_chat_user_id')
 
-     if(data.text_1_need == 1 && !value.text_1) {
 
-       wx.showToast({
 
-         icon: 'none',
 
-         title: data.text_1 + '必填',
 
-       })
 
-       return false;
 
-     }
 
-     if (data.text_2_need == 1 && !value.text_2) {
 
-       wx.showToast({
 
-         icon: 'none',
 
-         title: data.text_2 + '必填',
 
-       })
 
-       return false;
 
-     }
 
-     if (data.text_3_need == 1 && !value.text_3) {
 
-       wx.showToast({
 
-         icon: 'none',
 
-         title: data.text_3 + '必填',
 
-       })
 
-       return false;
 
-     }
 
-     if (data.text_4_need == 1 && !value.text_4) {
 
-       wx.showToast({
 
-         icon: 'none',
 
-         title: data.text_4 + '必填',
 
-       })
 
-       return false;
 
-     }
 
-     if (data.multi_text_need == 1 && !value.multi_text) {
 
-       wx.showToast({
 
-         icon: 'none',
 
-         title: data.multi_text + '必填',
 
-       })
 
-       return false;
 
-     }
 
-     if (data.radio_need == 1 && !value.radio) {
 
-       wx.showToast({
 
-         icon: 'none',
 
-         title: data.radio + '必填',
 
-       })
 
-       return false;
 
-     }
 
-     if (data.checkbox_need == 1 && !value.checkbox) {
 
-       wx.showToast({
 
-         icon: 'none',
 
-         title: data.checkbox + '必填',
 
-       })
 
-       return false;
 
-     }
 
-     wx.request({
 
-       url: api.submitFormUrl,
 
-       method: 'POST',
 
-       data: {
 
-         data: value
 
-       },
 
-       success: res => {
 
-         console.log(res)
 
-         if (res.data.status == 'success') {
 
-           if(value.type == 'pay') {
 
-             console.log(res);
 
-           } else {
 
-             wx.showToast({
 
-               icon: 'none',
 
-               title: '提交成功',
 
-             })
 
-           }
 
-         }
 
-       }
 
-     })
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面初次渲染完成
 
-    */
 
-   onReady: function () {
 
-   
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面显示
 
-    */
 
-   onShow: function () {
 
-   
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面隐藏
 
-    */
 
-   onHide: function () {
 
-   
 
-   },
 
-   /**
 
-    * 生命周期函数--监听页面卸载
 
-    */
 
-   onUnload: function () {
 
-   
 
-   },
 
-   /**
 
-    * 页面相关事件处理函数--监听用户下拉动作
 
-    */
 
-   onPullDownRefresh: function () {
 
-   
 
-   },
 
-   /**
 
-    * 页面上拉触底事件的处理函数
 
-    */
 
-   onReachBottom: function () {
 
-   
 
-   },
 
-   /**
 
-    * 用户点击右上角分享
 
-    */
 
-   onShareAppMessage: function (t) {
 
-     var a = this;
 
-     return {
 
-       path: "/pages/index/index",
 
-       success: function (t) {
 
-       },
 
-       title:"钢琴时间打卡"
 
-     };
 
-   },
 
- })
 
 
  |