blob: 5b64a28241926087cf2cc31f6cfae225d823412e [file] [log] [blame]
binquan.qiu7f2665f2020-03-27 17:19:57 +08001// pages/paypwdset/paypwdset.js
2Page({
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
101 var uid = wx.getStorageSync("uid");
102 var code = wx.getStorageSync("code");
103 wx.showLoading({
104 title: '正在保存',
105 })
106 var param = {
107 "pwd": pwd,
108 "repwd": repwd,
109 "id": uid,
110 "random": code
111 }
112 wx.$doPost('/i/register', param, function(ok, ret) {
113 wx.hideLoading();
114 if (ok) {
115
116 if (ret.data.code == 200) {
117 wx.removeStorageSync("code");
118
119 wx.setStorageSync("phoneX", ret.phone);
120 wx.setStorageSync("token", ret.token);
121 wx.setStorageSync("userid", ret.userid);
122 wx.setStorageSync("tenantid", ret.tenantid);
123 wx.setStorageSync("tokenexpire", ret.expire);
124 wx.setStorageSync("tokentime", ret.now);
125 wx.setStorageSync("signed", ret.signed);
126 wx.setStorageSync("paypwdset", ret.paypwdsetd);
127
128
129 wx.showModal({
130 title: '提示',
131 content: '密码设置成功,您可以登录系统了',
132 showCancel: false,
133 success(res) {
134 wx.navigateTo({
135 url: '../wxlogin/wxlogin',
136 })
137 }
138 })
139
140
141 } else {
142 wx.showModal({
143 title: '错误',
144 content: ret.data.msg,
145 })
146
147 }
148 } else {
149 wx.showModal({
150 title: '错误',
151 content: "请求失败了" + ret.data.status + ",请稍后再试",
152 })
153
154 }
155 })
156 }
157})