binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 1 | // pages/bindcard/bindcard.js |
| 2 | Page({ |
| 3 | |
| 4 | /** |
| 5 | * 页面的初始数据 |
| 6 | */ |
| 7 | data: { |
| 8 | index: 0, |
| 9 | idno: '', |
| 10 | name: '', |
| 11 | cardnum: '', |
| 12 | array: [ |
| 13 | '身份证', |
| 14 | '驾照', |
| 15 | '外国人居留证', |
| 16 | '港澳居民来往内地通行证', |
| 17 | |
| 18 | '军官证', |
| 19 | '护照', |
| 20 | '户口簿', |
| 21 | '其他' |
| 22 | ], |
| 23 | idtypes: [ |
| 24 | 'idcard', |
| 25 | 'driving_license', |
| 26 | 'foreigner_residence_permit', |
| 27 | 'hk_macau_pass', |
| 28 | |
| 29 | 'military_idcard', |
| 30 | 'passport', |
| 31 | 'residence_booklet', |
| 32 | 'unknown' |
| 33 | ], |
| 34 | // idtypes: [{ |
| 35 | // val: 'driving_license', |
| 36 | // name: '驾照' |
| 37 | // }, |
| 38 | // { |
| 39 | // val: 'foreigner_residence_permit', |
| 40 | // name: '外国人居留证' |
| 41 | // }, |
| 42 | // { |
| 43 | // val: 'hk_macau_pass', |
| 44 | // name: '港澳居民来往内地通行证' |
| 45 | // }, |
| 46 | // { |
| 47 | // val: 'idcard', |
| 48 | // name: '身份证' |
| 49 | // }, |
| 50 | // { |
| 51 | // val: 'military_idcard', |
| 52 | // name: '军官证' |
| 53 | // }, |
| 54 | // { |
| 55 | // val: 'passport', |
| 56 | // name: '护照' |
| 57 | // }, |
| 58 | // { |
| 59 | // val: 'residence_booklet', |
| 60 | // name: '户口簿' |
| 61 | // }, |
| 62 | // { |
| 63 | // val: 'unknown', |
| 64 | // name: '其他' |
| 65 | // } |
| 66 | // ] |
| 67 | }, |
| 68 | setName: function(e) { |
| 69 | this.setData({ |
| 70 | name: e.detail.value |
| 71 | }) |
| 72 | }, |
| 73 | bindPickerChange: function(e) { |
| 74 | this.setData({ |
| 75 | index: e.detail.value |
| 76 | }) |
| 77 | |
| 78 | }, |
| 79 | setIdCode: function(e) { |
| 80 | this.setData({ |
| 81 | idno: e.detail.value |
| 82 | }) |
| 83 | }, |
| 84 | setBankcard: function(e) { |
| 85 | this.setData({ |
| 86 | cardnum: e.detail.value |
| 87 | }) |
| 88 | }, |
| 89 | |
| 90 | /** |
| 91 | * 生命周期函数--监听页面加载 |
| 92 | */ |
| 93 | onLoad: function(options) { |
| 94 | |
| 95 | }, |
| 96 | |
| 97 | /** |
| 98 | * 生命周期函数--监听页面初次渲染完成 |
| 99 | */ |
| 100 | onReady: function() { |
| 101 | |
| 102 | }, |
| 103 | |
| 104 | /** |
| 105 | * 生命周期函数--监听页面显示 |
| 106 | */ |
| 107 | onShow: function() { |
| 108 | |
| 109 | }, |
| 110 | |
| 111 | /** |
| 112 | * 生命周期函数--监听页面隐藏 |
| 113 | */ |
| 114 | onHide: function() { |
| 115 | |
| 116 | }, |
| 117 | |
| 118 | /** |
| 119 | * 生命周期函数--监听页面卸载 |
| 120 | */ |
| 121 | onUnload: function() { |
| 122 | |
| 123 | }, |
| 124 | |
| 125 | /** |
| 126 | * 页面相关事件处理函数--监听用户下拉动作 |
| 127 | */ |
| 128 | onPullDownRefresh: function() { |
| 129 | |
| 130 | }, |
| 131 | |
| 132 | /** |
| 133 | * 页面上拉触底事件的处理函数 |
| 134 | */ |
| 135 | onReachBottom: function() { |
| 136 | |
| 137 | }, |
| 138 | |
| 139 | /** |
| 140 | * 用户点击右上角分享 |
| 141 | */ |
| 142 | onShareAppMessage: function() { |
| 143 | |
| 144 | }, |
| 145 | doNext: function() { |
| 146 | var name=this.data.name; |
| 147 | var idno=this.data.idno; |
| 148 | var cardnum=this.data.cardnum; |
| 149 | |
| 150 | if (wx.$isEmpty(name) || wx.$isEmpty(cardnum) || wx.$isEmpty(idno)) { |
| 151 | return; |
| 152 | } |
| 153 | cardnum = cardnum.trim(); |
| 154 | name = name.trim(); |
| 155 | idno = idno.trim(); |
| 156 | |
| 157 | wx.showLoading({ |
| 158 | title: '正在处理', |
| 159 | }) |
| 160 | var index=this.data.index; |
| 161 | var idtype = this.data.idtypes[index]; |
| 162 | |
| 163 | var param = { |
| 164 | "cardno": cardnum, |
| 165 | "idtype": idtype, |
| 166 | "name": name, |
| 167 | "idno": idno |
| 168 | } |
| 169 | wx.$doPost('/v1/bindcard', param, function(ok, ret) { |
| 170 | wx.hideLoading(); |
| 171 | if (ok) { |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 172 | console.log(ret) |
| 173 | if (ret.data.code == 200) { |
| 174 | wx.setStorageSync("name", name); |
| 175 | wx.setStorageSync("cardno", cardnum); |
| 176 | wx.setStorageSync("idtype", idtype); |
| 177 | wx.setStorageSync("idno", idno); |
| 178 | wx.setStorageSync("phoneX", ret.data.phonex); |
| 179 | wx.setStorageSync("personid", ret.data.personid); |
| 180 | wx.setStorageSync("signed", ret.data.signed); |
| 181 | wx.setStorageSync("paypwdset", ret.data.paypwdset); |
binquan.qiu | f9647a2 | 2020-05-08 15:43:24 +0800 | [diff] [blame] | 182 | var signed = wx.getStorageSync("signed"); |
| 183 | if (!wx.$isEmpty(signed) && signed == 'yes') { |
| 184 | wx.navigateTo({ |
| 185 | url: '../index/index', |
| 186 | }) |
| 187 | } |
binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame] | 188 | wx.navigateTo({ |
| 189 | url: '../bindcheck/bindcheck', |
| 190 | }) |
| 191 | } else { |
| 192 | wx.showModal({ |
| 193 | title: '错误', |
| 194 | content: ret.data.msg, |
| 195 | duration: 2000 |
| 196 | }) |
| 197 | |
| 198 | } |
| 199 | } else { |
| 200 | wx.showModal({ |
| 201 | title: '错误', |
| 202 | content: "请求失败了" + ret.data.status + ",请稍后再试", |
| 203 | duration: 2000 |
| 204 | }) |
| 205 | } |
| 206 | }) |
| 207 | } |
| 208 | |
| 209 | |
| 210 | }) |