| // pages/paypwdset/paypwdset.js |
| Page({ |
| |
| /** |
| * 页面的初始数据 |
| */ |
| data: { |
| password: '', |
| password2: '' |
| }, |
| |
| /** |
| * 生命周期函数--监听页面加载 |
| */ |
| onLoad: function(options) { |
| wx.setNavigationBarTitle({ |
| title: '设置支付密码', |
| }) |
| }, |
| |
| setPassword: function(e) { |
| this.setData({ |
| password: e.detail.value |
| }) |
| }, |
| |
| setPassword2: function(e) { |
| this.setData({ |
| password2: e.detail.value |
| }) |
| }, |
| /** |
| * 生命周期函数--监听页面初次渲染完成 |
| */ |
| onReady: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面显示 |
| */ |
| onShow: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面隐藏 |
| */ |
| onHide: function() { |
| |
| }, |
| |
| /** |
| * 生命周期函数--监听页面卸载 |
| */ |
| onUnload: function() { |
| |
| }, |
| |
| /** |
| * 页面相关事件处理函数--监听用户下拉动作 |
| */ |
| onPullDownRefresh: function() { |
| |
| }, |
| |
| /** |
| * 页面上拉触底事件的处理函数 |
| */ |
| onReachBottom: function() { |
| |
| }, |
| |
| /** |
| * 用户点击右上角分享 |
| */ |
| onShareAppMessage: function() { |
| |
| }, |
| doNext: function() { |
| var pwd = this.data.password; |
| var repwd = this.data.password2; |
| if (wx.$isEmpty(pwd) || wx.$isEmpty(repwd)) { |
| return; |
| } |
| if (pwd.length < 6) { |
| wx.showModal({ |
| title: '提示', |
| content: '密码为6位以上字符', |
| }) |
| return; |
| } |
| if (pwd != repwd) { |
| wx.showModal({ |
| title: '提示', |
| content: '两次密码不一致', |
| }) |
| return; |
| } |
| |
| var uid = wx.getStorageSync("uid"); |
| var code = wx.getStorageSync("code"); |
| wx.showLoading({ |
| title: '正在保存', |
| }) |
| var param = { |
| "pwd": pwd, |
| "repwd": repwd, |
| "id": uid, |
| "random": code |
| } |
| wx.$doPost('/i/register', param, function(ok, ret) { |
| wx.hideLoading(); |
| if (ok) { |
| |
| if (ret.data.code == 200) { |
| wx.removeStorageSync("code"); |
| |
| wx.setStorageSync("phoneX", ret.phone); |
| wx.setStorageSync("token", ret.token); |
| wx.setStorageSync("userid", ret.userid); |
| wx.setStorageSync("tenantid", ret.tenantid); |
| wx.setStorageSync("tokenexpire", ret.expire); |
| wx.setStorageSync("tokentime", ret.now); |
| wx.setStorageSync("signed", ret.signed); |
| wx.setStorageSync("paypwdset", ret.paypwdsetd); |
| |
| |
| wx.showModal({ |
| title: '提示', |
| content: '密码设置成功,您可以登录系统了', |
| showCancel: false, |
| success(res) { |
| wx.navigateTo({ |
| url: '../wxlogin/wxlogin', |
| }) |
| } |
| }) |
| |
| |
| } else { |
| wx.showModal({ |
| title: '错误', |
| content: ret.data.msg, |
| }) |
| |
| } |
| } else { |
| wx.showModal({ |
| title: '错误', |
| content: "请求失败了" + ret.data.status + ",请稍后再试", |
| }) |
| |
| } |
| }) |
| } |
| }) |