| // 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 paypwdtype = wx.getStorageSync("paypwdtype"); |
| if (wx.$isEmpty(paypwdtype)) { |
| paypwdtype = "new" |
| } |
| var randomcode = wx.getStorageSync("randomcode"); |
| if (wx.$isEmpty(randomcode)) { |
| randomcode = "" |
| } |
| wx.showLoading({ |
| title: '正在保存', |
| }) |
| var param = { |
| "pwd": pwd, |
| "repwd": repwd, |
| "type": paypwdtype, |
| "randcode": randomcode |
| } |
| wx.$doPost('/v1/paypwd',param, function (ok, ret) { |
| if (ok) { |
| wx.hideLoading(); |
| if (ret.data.code == 200) { |
| wx.removeStorageSync("randomcode"); |
| |
| var signed = wx.getStorageSync("signed"); |
| wx.setStorageSync("paypwdset", ret.data.paypwdset); |
| wx.removeStorageSync("paypwdtype"); |
| if (wx.$isEmpty(signed) || signed != 'yes') { |
| wx.navigateTo({ |
| url: '../signxy/signxy', |
| }) |
| |
| } else { |
| wx.showModal({ |
| title: '提示', |
| content: '支付密码设置成功', |
| showCancel:false, |
| success(res) { |
| wx.navigateTo({ |
| url: '../index/index', |
| }) |
| } |
| }) |
| $.alert("支付密码设置成功", "提示", function () { |
| if (paypwdtype == 'find') { |
| window.location = 'security.html' |
| } else { |
| window.location = 'main.html' |
| } |
| }); |
| } |
| } else { |
| wx.showModal({ |
| title: '错误', |
| content: ret.data.msg, |
| }) |
| |
| } |
| } else { |
| wx.showModal({ |
| title: '错误', |
| content: "请求失败了" + ret.data.status + ",请稍后再试", |
| }) |
| |
| } |
| }) |
| } |
| }) |