blob: c9f97eb36657d8a447035bc4b454a47971e91047 [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,
binquan.qiuf9647a22020-05-08 15:43:24 +080014 privacyCheck:''
binquan.qiu7f2665f2020-03-27 17:19:57 +080015 },
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
binquan.qiuf9647a22020-05-08 15:43:24 +080038
binquan.qiu7f2665f2020-03-27 17:19:57 +080039 /**
40 * 生命周期函数--监听页面初次渲染完成
41 */
42 onReady: function() {
43
44 },
45
46 /**
47 * 生命周期函数--监听页面显示
48 */
49 onShow: function() {
50
51 },
52
53 /**
54 * 生命周期函数--监听页面隐藏
55 */
56 onHide: function() {
57
58 },
59
60 /**
61 * 生命周期函数--监听页面卸载
62 */
63 onUnload: function() {
64
65 },
66
67 /**
68 * 页面相关事件处理函数--监听用户下拉动作
69 */
70 onPullDownRefresh: function() {
71
72 },
73
74 /**
75 * 页面上拉触底事件的处理函数
76 */
77 onReachBottom: function() {
78
79 },
80 setCode:function(e){
81 this.setData({
82 code: e.detail.value
83 })
84 },
85
86 /**
87 * 用户点击右上角分享
88 */
89 onShareAppMessage: function() {
90
91 },
binquan.qiuf9647a22020-05-08 15:43:24 +080092 checkboxChange:function(e){
93 console.log(e.detail.value);
94 this.setData({
95 privacyCheck: e.detail.value
96 })
97 },
98 showXy:function(){
99 wx.navigateTo({
100 url: '../signxy/signxy',
101 })
102 },
binquan.qiu7f2665f2020-03-27 17:19:57 +0800103 doNext: function () {
104 var code = this.data.code;
105 if (wx.$isEmpty(code)) {
106 return;
107 }
108
binquan.qiuf9647a22020-05-08 15:43:24 +0800109 var agree =this.data.privacyCheck;
110 if (wx.$isEmpty(agree)) {
111 wx.showModal({
112 title: '提示',
113 content: '请同意民卡免密代扣签约协议',
114 })
115 return;
binquan.qiu7f2665f2020-03-27 17:19:57 +0800116 }
binquan.qiuf9647a22020-05-08 15:43:24 +0800117 var personid = wx.getStorageSync("personid");
118 var param={
119 "agree":code
120 }
121 wx.$doPost('/v1/signbxy',param, function (ok, ret) {
binquan.qiu7f2665f2020-03-27 17:19:57 +0800122 if (ok) {
binquan.qiu7f2665f2020-03-27 17:19:57 +0800123 if (ret.data.code == 200) {
binquan.qiu7f2665f2020-03-27 17:19:57 +0800124 wx.setStorageSync("userid", personid);
binquan.qiuf9647a22020-05-08 15:43:24 +0800125 wx.setStorageSync("signed", ret.data.signed);
126 wx.navigateTo({
127 url: '../index/index',
128 })
binquan.qiu7f2665f2020-03-27 17:19:57 +0800129 } else {
130 wx.showModal({
131 title: '错误',
132 content: ret.data.message,
133 duration: 2000
134 })
135
136 }
137 } else {
138 wx.showModal({
139 title: '错误',
140 content: ret.data.message,
141 duration: 2000
142 })
143
144 }
145 })
146 },
147 getCode: function() {
148 if (false == this.data.smsFlag) {
149 return;
150 }
151
152 wx.$doCountdown(this);
153
binquan.qiuf9647a22020-05-08 15:43:24 +0800154 // var name = wx.getStorageSync("name");
155 // var cardno = wx.getStorageSync("cardno");
156 // var idtype = wx.getStorageSync("idtype");
157 // var idno = wx.getStorageSync("idno");
binquan.qiu7f2665f2020-03-27 17:19:57 +0800158
159 var param = {
binquan.qiuf9647a22020-05-08 15:43:24 +0800160 // "cardno": cardno,
161 // "idtype": idtype,
162 // "name": name,
163 // "idno": idno
binquan.qiu7f2665f2020-03-27 17:19:57 +0800164 }
binquan.qiuf9647a22020-05-08 15:43:24 +0800165 wx.$doPost('/v1/bindcardcode', param, function(ok, ret) {
binquan.qiu7f2665f2020-03-27 17:19:57 +0800166 console.log(ret.data);
167 if (ok) {
168 if (ret.data.code == 200) {} else {
169 wx.showModal({
170 title: '错误',
171 content: ret.data.msg,
172
173 duration: 2000
174 })
175 }
176 } else {
177 wx.showModal({
178 title: '错误',
179 content: "请求失败了" + ret.data.status + ",请稍后再试",
180 duration: 2000
181 })
182 }
183 })
184 }
185})