blob: 3ca4c4c8899c0a2a526a57d7b0a824451016087d [file] [log] [blame]
binquan.qiu7f2665f2020-03-27 17:19:57 +08001// pages/bindcheck/bindcheck.js
2Page({
3
4 /**
5 * 页面的初始数据
6 */
7 data: {
8 phone: '',
9 code: '',
10 sendTime: '获取验证码',
11 sendColor: 'rgb(124, 255, 112)',
12 snsMsgWait: 30,
13 smsFlag: true,
14
15 },
16
17 /**
18 * 生命周期函数--监听页面加载
19 */
20 onLoad: function(options) {
21 wx.setNavigationBarTitle({
22 title: '获取验证码',
23 })
24
25 var phone = wx.getStorageSync('phoneX');
26 if (!wx.$isEmpty(phone)) {
27 this.setData({
28 phone: phone
29 })
30 } else {
31 phone = wx.getStorageSync('phone');
32 this.setData({
33 phone: phone
34 })
35 }
36 },
37
38 /**
39 * 生命周期函数--监听页面初次渲染完成
40 */
41 onReady: function() {
42
43 },
44
45 /**
46 * 生命周期函数--监听页面显示
47 */
48 onShow: function() {
49
50 },
51
52 /**
53 * 生命周期函数--监听页面隐藏
54 */
55 onHide: function() {
56
57 },
58
59 /**
60 * 生命周期函数--监听页面卸载
61 */
62 onUnload: function() {
63
64 },
65
66 /**
67 * 页面相关事件处理函数--监听用户下拉动作
68 */
69 onPullDownRefresh: function() {
70
71 },
72
73 /**
74 * 页面上拉触底事件的处理函数
75 */
76 onReachBottom: function() {
77
78 },
79 setCode:function(e){
80 this.setData({
81 code: e.detail.value
82 })
83 },
84
85 /**
86 * 用户点击右上角分享
87 */
88 onShareAppMessage: function() {
89
90 },
91 doNext: function () {
92 var code = this.data.code;
93 if (wx.$isEmpty(code)) {
94 return;
95 }
96
97 var personid = wx.getStorageSync("personid");
98
99 var param = {
100 "personid": personid,
101 "code": code,
102 }
103 wx.$doPost('/v1/checkcode',param, function (ok, ret) {
104 if (ok) {
105
106 console.log(ret)
107 if (ret.data.code == 200) {
108 wx.setStorageSync("paypwdtype", "new");
109 wx.setStorageSync("userid", personid);
110 var signed = wx.getStorageSync("signed");
111 var paypwdset = wx.getStorageSync("paypwdset");
112 console.log(paypwdset)
113 if (!paypwdset || 'false' == paypwdset) {
114 wx.navigateTo({
115 url: '../paypwdset/paypwdset',
116 })
117
118 } else {
119 if (!wx.$isEmpty(signed) && signed == 'yes') {
120 wx.navigateTo({
121 url: '../index/index',
122 })
123
124 } else {
125 wx.navigateTo({
126 url: '../signxy/signxy',
127 })
128
129 }
130 }
131 } else {
132 wx.showModal({
133 title: '错误',
134 content: ret.data.message,
135 duration: 2000
136 })
137
138 }
139 } else {
140 wx.showModal({
141 title: '错误',
142 content: ret.data.message,
143 duration: 2000
144 })
145
146 }
147 })
148 },
149 getCode: function() {
150 if (false == this.data.smsFlag) {
151 return;
152 }
153
154 wx.$doCountdown(this);
155
156 var name = wx.getStorageSync("name");
157 var cardno = wx.getStorageSync("cardno");
158 var idtype = wx.getStorageSync("idtype");
159 var idno = wx.getStorageSync("idno");
160
161 var param = {
162 "cardno": cardno,
163 "idtype": idtype,
164 "name": name,
165 "idno": idno
166 }
167 wx.$doPost('/v1/bindcard', param, function(ok, ret) {
168 console.log(ret.data);
169 if (ok) {
170 if (ret.data.code == 200) {} else {
171 wx.showModal({
172 title: '错误',
173 content: ret.data.msg,
174
175 duration: 2000
176 })
177 }
178 } else {
179 wx.showModal({
180 title: '错误',
181 content: "请求失败了" + ret.data.status + ",请稍后再试",
182 duration: 2000
183 })
184 }
185 })
186 }
187})