binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 1 | // pages/bindcheck/bindcheck.js |
| 2 | Page({ |
| 3 | |
| 4 | /** |
| 5 | * 页面的初始数据 |
| 6 | */ |
| 7 | data: { |
| 8 | phone: '', |
| 9 | code: '', |
| 10 | sendTime: '获取验证码', |
| 11 | sendColor: 'rgb(124, 255, 112)', |
| 12 | snsMsgWait: 30, |
| 13 | smsFlag: true, |
binquan.qiu | f9647a2 | 2020-05-08 15:43:24 +0800 | [diff] [blame] | 14 | privacyCheck:'' |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 15 | }, |
| 16 | |
| 17 | /** |
| 18 | * 生命周期函数--监听页面加载 |
| 19 | */ |
| 20 | onLoad: function(options) { |
| 21 | wx.setNavigationBarTitle({ |
| 22 | title: '获取验证码', |
| 23 | }) |
| 24 | |
| 25 | var phone = wx.getStorageSync('phoneX'); |
| 26 | if (!wx.$isEmpty(phone)) { |
| 27 | this.setData({ |
| 28 | phone: phone |
| 29 | }) |
| 30 | } else { |
| 31 | phone = wx.getStorageSync('phone'); |
| 32 | this.setData({ |
| 33 | phone: phone |
| 34 | }) |
| 35 | } |
| 36 | }, |
| 37 | |
binquan.qiu | f9647a2 | 2020-05-08 15:43:24 +0800 | [diff] [blame] | 38 | |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 39 | /** |
| 40 | * 生命周期函数--监听页面初次渲染完成 |
| 41 | */ |
| 42 | onReady: function() { |
| 43 | |
| 44 | }, |
| 45 | |
| 46 | /** |
| 47 | * 生命周期函数--监听页面显示 |
| 48 | */ |
| 49 | onShow: function() { |
| 50 | |
| 51 | }, |
| 52 | |
| 53 | /** |
| 54 | * 生命周期函数--监听页面隐藏 |
| 55 | */ |
| 56 | onHide: function() { |
| 57 | |
| 58 | }, |
| 59 | |
| 60 | /** |
| 61 | * 生命周期函数--监听页面卸载 |
| 62 | */ |
| 63 | onUnload: function() { |
| 64 | |
| 65 | }, |
| 66 | |
| 67 | /** |
| 68 | * 页面相关事件处理函数--监听用户下拉动作 |
| 69 | */ |
| 70 | onPullDownRefresh: function() { |
| 71 | |
| 72 | }, |
| 73 | |
| 74 | /** |
| 75 | * 页面上拉触底事件的处理函数 |
| 76 | */ |
| 77 | onReachBottom: function() { |
| 78 | |
| 79 | }, |
| 80 | setCode:function(e){ |
| 81 | this.setData({ |
| 82 | code: e.detail.value |
| 83 | }) |
| 84 | }, |
| 85 | |
| 86 | /** |
| 87 | * 用户点击右上角分享 |
| 88 | */ |
| 89 | onShareAppMessage: function() { |
| 90 | |
| 91 | }, |
binquan.qiu | f9647a2 | 2020-05-08 15:43:24 +0800 | [diff] [blame] | 92 | checkboxChange:function(e){ |
| 93 | console.log(e.detail.value); |
| 94 | this.setData({ |
| 95 | privacyCheck: e.detail.value |
| 96 | }) |
| 97 | }, |
| 98 | showXy:function(){ |
| 99 | wx.navigateTo({ |
| 100 | url: '../signxy/signxy', |
| 101 | }) |
| 102 | }, |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 103 | doNext: function () { |
| 104 | var code = this.data.code; |
| 105 | if (wx.$isEmpty(code)) { |
| 106 | return; |
| 107 | } |
| 108 | |
binquan.qiu | f9647a2 | 2020-05-08 15:43:24 +0800 | [diff] [blame] | 109 | var agree =this.data.privacyCheck; |
| 110 | if (wx.$isEmpty(agree)) { |
| 111 | wx.showModal({ |
| 112 | title: '提示', |
| 113 | content: '请同意民卡免密代扣签约协议', |
| 114 | }) |
| 115 | return; |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 116 | } |
binquan.qiu | f9647a2 | 2020-05-08 15:43:24 +0800 | [diff] [blame] | 117 | var personid = wx.getStorageSync("personid"); |
| 118 | var param={ |
| 119 | "agree":code |
| 120 | } |
| 121 | wx.$doPost('/v1/signbxy',param, function (ok, ret) { |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 122 | if (ok) { |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 123 | if (ret.data.code == 200) { |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 124 | wx.setStorageSync("userid", personid); |
binquan.qiu | f9647a2 | 2020-05-08 15:43:24 +0800 | [diff] [blame] | 125 | wx.setStorageSync("signed", ret.data.signed); |
| 126 | wx.navigateTo({ |
| 127 | url: '../index/index', |
| 128 | }) |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 129 | } else { |
| 130 | wx.showModal({ |
| 131 | title: '错误', |
| 132 | content: ret.data.message, |
| 133 | duration: 2000 |
| 134 | }) |
| 135 | |
| 136 | } |
| 137 | } else { |
| 138 | wx.showModal({ |
| 139 | title: '错误', |
| 140 | content: ret.data.message, |
| 141 | duration: 2000 |
| 142 | }) |
| 143 | |
| 144 | } |
| 145 | }) |
| 146 | }, |
| 147 | getCode: function() { |
| 148 | if (false == this.data.smsFlag) { |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | wx.$doCountdown(this); |
| 153 | |
binquan.qiu | f9647a2 | 2020-05-08 15:43:24 +0800 | [diff] [blame] | 154 | // var name = wx.getStorageSync("name"); |
| 155 | // var cardno = wx.getStorageSync("cardno"); |
| 156 | // var idtype = wx.getStorageSync("idtype"); |
| 157 | // var idno = wx.getStorageSync("idno"); |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 158 | |
| 159 | var param = { |
binquan.qiu | f9647a2 | 2020-05-08 15:43:24 +0800 | [diff] [blame] | 160 | // "cardno": cardno, |
| 161 | // "idtype": idtype, |
| 162 | // "name": name, |
| 163 | // "idno": idno |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 164 | } |
binquan.qiu | f9647a2 | 2020-05-08 15:43:24 +0800 | [diff] [blame] | 165 | wx.$doPost('/v1/bindcardcode', param, function(ok, ret) { |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 166 | console.log(ret.data); |
| 167 | if (ok) { |
| 168 | if (ret.data.code == 200) {} else { |
| 169 | wx.showModal({ |
| 170 | title: '错误', |
| 171 | content: ret.data.msg, |
| 172 | |
| 173 | duration: 2000 |
| 174 | }) |
| 175 | } |
| 176 | } else { |
| 177 | wx.showModal({ |
| 178 | title: '错误', |
| 179 | content: "请求失败了" + ret.data.status + ",请稍后再试", |
| 180 | duration: 2000 |
| 181 | }) |
| 182 | } |
| 183 | }) |
| 184 | } |
| 185 | }) |