binquan.qiu | 7f2665f | 2020-03-27 17:19:57 +0800 | [diff] [blame^] | 1 | // pages/paypwdset/paypwdset.js |
| 2 | Page({ |
| 3 | |
| 4 | /** |
| 5 | * 页面的初始数据 |
| 6 | */ |
| 7 | data: { |
| 8 | password:'', |
| 9 | password2:'' |
| 10 | }, |
| 11 | |
| 12 | /** |
| 13 | * 生命周期函数--监听页面加载 |
| 14 | */ |
| 15 | onLoad: function (options) { |
| 16 | wx.setNavigationBarTitle({ |
| 17 | title: '设置支付密码', |
| 18 | }) |
| 19 | }, |
| 20 | |
| 21 | setPassword: function (e) { |
| 22 | this.setData({ |
| 23 | password: e.detail.value |
| 24 | }) |
| 25 | }, |
| 26 | |
| 27 | setPassword2: function (e) { |
| 28 | this.setData({ |
| 29 | password2: e.detail.value |
| 30 | }) |
| 31 | }, |
| 32 | /** |
| 33 | * 生命周期函数--监听页面初次渲染完成 |
| 34 | */ |
| 35 | onReady: function () { |
| 36 | |
| 37 | }, |
| 38 | |
| 39 | /** |
| 40 | * 生命周期函数--监听页面显示 |
| 41 | */ |
| 42 | onShow: function () { |
| 43 | |
| 44 | }, |
| 45 | |
| 46 | /** |
| 47 | * 生命周期函数--监听页面隐藏 |
| 48 | */ |
| 49 | onHide: function () { |
| 50 | |
| 51 | }, |
| 52 | |
| 53 | /** |
| 54 | * 生命周期函数--监听页面卸载 |
| 55 | */ |
| 56 | onUnload: function () { |
| 57 | |
| 58 | }, |
| 59 | |
| 60 | /** |
| 61 | * 页面相关事件处理函数--监听用户下拉动作 |
| 62 | */ |
| 63 | onPullDownRefresh: function () { |
| 64 | |
| 65 | }, |
| 66 | |
| 67 | /** |
| 68 | * 页面上拉触底事件的处理函数 |
| 69 | */ |
| 70 | onReachBottom: function () { |
| 71 | |
| 72 | }, |
| 73 | |
| 74 | /** |
| 75 | * 用户点击右上角分享 |
| 76 | */ |
| 77 | onShareAppMessage: function () { |
| 78 | |
| 79 | }, |
| 80 | doNext: function () { |
| 81 | var pwd = this.data.password; |
| 82 | var repwd = this.data.password2; |
| 83 | if (wx.$isEmpty(pwd) || wx.$isEmpty(repwd)) { |
| 84 | return; |
| 85 | } |
| 86 | if (pwd.length != 6) { |
| 87 | wx.showModal({ |
| 88 | title: '提示', |
| 89 | content: '密码为6位数字', |
| 90 | }) |
| 91 | return; |
| 92 | } |
| 93 | if (pwd != repwd) { |
| 94 | wx.showModal({ |
| 95 | title: '提示', |
| 96 | content: '两次密码不一致', |
| 97 | }) |
| 98 | return; |
| 99 | } |
| 100 | var paypwdtype = wx.getStorageSync("paypwdtype"); |
| 101 | if (wx.$isEmpty(paypwdtype)) { |
| 102 | paypwdtype = "new" |
| 103 | } |
| 104 | var randomcode = wx.getStorageSync("randomcode"); |
| 105 | if (wx.$isEmpty(randomcode)) { |
| 106 | randomcode = "" |
| 107 | } |
| 108 | wx.showLoading({ |
| 109 | title: '正在保存', |
| 110 | }) |
| 111 | var param = { |
| 112 | "pwd": pwd, |
| 113 | "repwd": repwd, |
| 114 | "type": paypwdtype, |
| 115 | "randcode": randomcode |
| 116 | } |
| 117 | wx.$doPost('/v1/paypwd',param, function (ok, ret) { |
| 118 | if (ok) { |
| 119 | wx.hideLoading(); |
| 120 | if (ret.data.code == 200) { |
| 121 | wx.removeStorageSync("randomcode"); |
| 122 | |
| 123 | var signed = wx.getStorageSync("signed"); |
| 124 | wx.setStorageSync("paypwdset", ret.data.paypwdset); |
| 125 | wx.removeStorageSync("paypwdtype"); |
| 126 | if (wx.$isEmpty(signed) || signed != 'yes') { |
| 127 | wx.navigateTo({ |
| 128 | url: '../signxy/signxy', |
| 129 | }) |
| 130 | |
| 131 | } else { |
| 132 | wx.showModal({ |
| 133 | title: '提示', |
| 134 | content: '支付密码设置成功', |
| 135 | showCancel:false, |
| 136 | success(res) { |
| 137 | wx.navigateTo({ |
| 138 | url: '../index/index', |
| 139 | }) |
| 140 | } |
| 141 | }) |
| 142 | $.alert("支付密码设置成功", "提示", function () { |
| 143 | if (paypwdtype == 'find') { |
| 144 | window.location = 'security.html' |
| 145 | } else { |
| 146 | window.location = 'main.html' |
| 147 | } |
| 148 | }); |
| 149 | } |
| 150 | } else { |
| 151 | wx.showModal({ |
| 152 | title: '错误', |
| 153 | content: ret.data.msg, |
| 154 | }) |
| 155 | |
| 156 | } |
| 157 | } else { |
| 158 | wx.showModal({ |
| 159 | title: '错误', |
| 160 | content: "请求失败了" + ret.data.status + ",请稍后再试", |
| 161 | }) |
| 162 | |
| 163 | } |
| 164 | }) |
| 165 | } |
| 166 | }) |