| // pages/bindcheck/bindcheck.js |
| Page({ |
| |
| /** |
| * 页面的初始数据 |
| */ |
| data: { |
| phone: '', |
| code: '', |
| sendTime: '获取验证码', |
| sendColor: 'rgb(124, 255, 112)', |
| snsMsgWait: 30, |
| smsFlag: true, |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面加载 |
| */ |
| onLoad: function(options) { |
| wx.setNavigationBarTitle({ |
| title: '获取验证码', |
| }) |
| |
| var phone = wx.getStorageSync('phoneX'); |
| if (!wx.$isEmpty(phone)) { |
| this.setData({ |
| phone: phone |
| }) |
| } else { |
| phone = wx.getStorageSync('phone'); |
| this.setData({ |
| phone: phone |
| }) |
| } |
| }, |
| |
| /** |
| * 生命周期函数--监听页面初次渲染完成 |
| */ |
| onReady: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面显示 |
| */ |
| onShow: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面隐藏 |
| */ |
| onHide: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面卸载 |
| */ |
| onUnload: function() { |
| |
| }, |
| |
| /** |
| * 页面相关事件处理函数--监听用户下拉动作 |
| */ |
| onPullDownRefresh: function() { |
| |
| }, |
| |
| /** |
| * 页面上拉触底事件的处理函数 |
| */ |
| onReachBottom: function() { |
| |
| }, |
| setCode:function(e){ |
| this.setData({ |
| code: e.detail.value |
| }) |
| }, |
| |
| /** |
| * 用户点击右上角分享 |
| */ |
| onShareAppMessage: function() { |
| |
| }, |
| doNext: function () { |
| var code = this.data.code; |
| if (wx.$isEmpty(code)) { |
| return; |
| } |
| |
| var personid = wx.getStorageSync("personid"); |
| |
| var param = { |
| "personid": personid, |
| "code": code, |
| } |
| wx.$doPost('/v1/checkcode',param, function (ok, ret) { |
| if (ok) { |
| |
| console.log(ret) |
| if (ret.data.code == 200) { |
| wx.setStorageSync("paypwdtype", "new"); |
| wx.setStorageSync("userid", personid); |
| var signed = wx.getStorageSync("signed"); |
| var paypwdset = wx.getStorageSync("paypwdset"); |
| console.log(paypwdset) |
| if (!paypwdset || 'false' == paypwdset) { |
| wx.navigateTo({ |
| url: '../paypwdset/paypwdset', |
| }) |
| |
| } else { |
| if (!wx.$isEmpty(signed) && signed == 'yes') { |
| wx.navigateTo({ |
| url: '../index/index', |
| }) |
| |
| } else { |
| wx.navigateTo({ |
| url: '../signxy/signxy', |
| }) |
| |
| } |
| } |
| } else { |
| wx.showModal({ |
| title: '错误', |
| content: ret.data.message, |
| duration: 2000 |
| }) |
| |
| } |
| } else { |
| wx.showModal({ |
| title: '错误', |
| content: ret.data.message, |
| duration: 2000 |
| }) |
| |
| } |
| }) |
| }, |
| getCode: function() { |
| if (false == this.data.smsFlag) { |
| return; |
| } |
| |
| wx.$doCountdown(this); |
| |
| var name = wx.getStorageSync("name"); |
| var cardno = wx.getStorageSync("cardno"); |
| var idtype = wx.getStorageSync("idtype"); |
| var idno = wx.getStorageSync("idno"); |
| |
| var param = { |
| "cardno": cardno, |
| "idtype": idtype, |
| "name": name, |
| "idno": idno |
| } |
| wx.$doPost('/v1/bindcard', param, function(ok, ret) { |
| console.log(ret.data); |
| if (ok) { |
| if (ret.data.code == 200) {} else { |
| wx.showModal({ |
| title: '错误', |
| content: ret.data.msg, |
| |
| duration: 2000 |
| }) |
| } |
| } else { |
| wx.showModal({ |
| title: '错误', |
| content: "请求失败了" + ret.data.status + ",请稍后再试", |
| duration: 2000 |
| }) |
| } |
| }) |
| } |
| }) |