bring.js
11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
var t = getApp(),
a = t.request,
o = t.globalData.setting,
os = o,
i = require("../../../../../utils/util.js"),
ut = i,
s = require("../../../../../utils/common.js");
var regeneratorRuntime = require('../../../../../utils/runtime.js');
var oo = t.globalData.setting;
Page({
/**
* 页面的初始数据
*/
data: {
usernames: null,
val: null, //提现金额内容
current: 1, //单选框判断的参数
user_money: 0, //可提现余额
// money:0,//提现金额
account_bank: "", //银行卡号
bank_name: "", //银行名字
button: 0, //按钮样式控制器、
submit: null, //点击控制器
weixin: 0,
cardInfo: '',
user_infor: {}, //获取初始对象
needmon:0,
distribut_min:0,
},
// 银行卡失去焦点事件
blurInputEvent: function(e) {
var inputvalue = e.detail.value.length;
if (inputvalue > 14) {
var value = e.detail.value;
var account_bank = value.replace(/\s+/g, "");
this.yhk(account_bank);
}
},
/** 获取提现输入框的值 bindinput='genre' */
money: function(e) {
this.setData({
money: Number(e.detail.value)
})
},
// 单选框控制器
onClickItem(e) {
console.log(" 单选框控制器", e.currentTarget.dataset.idx) //获取自定义的值
let idx = e.currentTarget.dataset.idx;
this.setData({
current: idx
})
},
/*点击确定提现后表现的形式*/
Gettime: function(e) {
var th=this;
var user_info=getApp().globalData.userInfo;
//提现是零钱的时候,同时是发红包的时候
if(this.data.current==2 && parseInt(this.data.tx_wx_type)==2){
if(!user_info.openid){
ut.m_toast("未绑定公众号微会员,无法提现!");
return false
}
}
var user_money = this.data.user_money;
var money = e.detail.value.moneys; //typeof判断数据类型
var current = this.data.current;
var money = Number(money);
if (user_money<this.data.needmon) return false;
if (money == 0 || money == "" || money == null) {
getApp().showWarning("请输入提现金额");
return false;
}
if (this.data.distribut_min > money){
getApp().showWarning("提现需大于"+this.data.distribut_min+"元");
return false;
}
if (Number(user_money) < Number(money)) {
console.log(money + "有qq吗" + user_money + typeof this.data.money);
getApp().showWarning("提现金额大于余额");
return false;
} else if (money > 0 || user_money >= money && user_money > 99) {
if (current == 1) {
console.log(user_money + "有进来吗eeee" + money);
// 获取输入框中的值
var moneys = e.detail.value.moneys; //钱
var cardname = this.data.bank_name; //卡名
var userName = e.detail.value.userName; //名字
var card = e.detail.value.card; //卡号
if (card.length < 15) {
getApp().showWarning("卡号错误");
this.setData({
bank_name: "",
usernames: ""
});
return false;
}
console.log("钱", moneys, "卡", cardname, "名字", userName, "卡的长度", card.length);
var len = userName.length; //名字的长度
if (userName.indexOf(" ") >= 0) {
getApp().showWarning("名字不能有空");
return false;
}
console.log("字符串的长度", len);
if (this.data.current == 1) {
if (cardname == null || cardname == "") {
getApp().showWarning("银行卡不存在");
return false;
}
if (userName == "" || userName == null) {
getApp().showWarning("名字不能为空");
return false;
}
if (len < 2) {
getApp().showWarning("名字错误");
return false;
}
if (!/^[\u4e00-\u9fa5]+$/i.test(userName)) {
getApp().showWarning("您输入不是中文");
return false;
}
}
var that = this;
//控制器参数
var user_id = getApp().globalData.user_id;
var store_id = os.stoid;
var current = that.data.current;
var userName = e.detail.value.userName; //名字
console.log('微信余额名字', userName, "控制器", current);
this.data.user_infor.money = moneys;
this.data.user_infor.user_id = user_id;
this.data.user_infor.store_id = store_id;
this.data.user_infor.account_name = userName;
this.data.user_infor.account_bank = card;
this.data.user_infor.bank_name = cardname;
this.data.user_infor.bank_type = this.data.current;
var user_infor = this.data.user_infor;
this.Cashwithdrawal(user_infor)
} else {
var userName = e.detail.value.userName; //名字
var len = userName.length; //名字的长度
if (userName.indexOf(" ") >= 0) {
getApp().showWarning("名字不能有空");
return false;
}
if (userName == "" || userName == null) {
getApp().showWarning("名字不能为空");
return false;
}
if (len < 2) {
getApp().showWarning("名字错误");
return false;
}
if (!/^[\u4e00-\u9fa5]+$/i.test(userName)) {
getApp().showWarning("您输入不是中文");
return false;
}
var moneys = e.detail.value.moneys; //钱
var user_id = getApp().globalData.user_id;
var store_id = os.stoid;
var len = userName.length;
this.data.user_infor.money = moneys;
this.data.user_infor.user_id = user_id;
this.data.user_infor.store_id = store_id;
this.data.user_infor.account_name = userName;
this.data.user_infor.bank_type = this.data.current;
var user_infor = this.data.user_infor;
console.log("控制器2", user_infor);
this.Cashwithdrawal(user_infor);
}
} else {
console.log( "提现金额小于",this.data.distribut_min);
getApp().showWarning("提现金额小于"+this.data.distribut_min);
}
},
// 提现
Cashwithdrawal: function(user_infor) {
if(this.data.tx_ing) return false;
this.data.tx_ing=1;
var th=this;
delete user_infor.rmon;
delete user_infor.isck;
delete user_infor.needmon;
delete user_infor.liudong_money;
delete user_infor.distribut_min;
delete user_infor.type;
user_infor.source_type=1;
//var str = JSON.stringify(user_infor);
// wx.showLoading({ title: "加载中" });
getApp().request.promisePost("/api/weshop/users/saveWithdrawals", {
data: user_infor,is_json:1,is_normal:1
}).then(res => {
th.data.tx_ing=0;
if (res.data.code != -1) {
wx.navigateTo({
url: 'msg/msg',
})
} else {
getApp().showWarning("提现金额不足");
}
}).catch(function(err) {
getApp().showWarning("网络繁忙,请稍后重试");
th.data.tx_ing=0;
})
},
// 初始化判断微信余额
async weixin() {
var user_id = getApp().globalData.user_id;
var store_id = os.stoid;
await getApp().request.promiseGet("/api/weshop/users/getWithdrawals", {
data: {
user_id: user_id,
store_id: store_id
}
}).then(res => {
var a = res.data;
var user_infor = a.data;
var user_money = user_infor.liudong_money;
var distribut_min=user_infor.distribut_min;
console.log( user_money,distribut_min,user_infor, "初始化出来的数据", a.data.account_bank);
if (user_money > distribut_min) {
this.setData({
submit: "submit",
button: user_money,
user_money: user_money,
distribut_min: distribut_min
});
} else {
this.setData({
submit: " ",
button: user_money,
user_money:user_money,
distribut_min: distribut_min
})
}
console.log(typeof user_money, "ooo" + user_money);
if (a.code != -1) {
this.setData({
user_infor: user_infor,
});
if (a.data.account_bank != null) {
var account_bank = a.data.account_bank.replace(/\s+/g, "");
console.log("卡号", account_bank, "初始化", a.data.isck);
if (a.data.isck == 1) {
this.setData({
bank_name: a.data.bank_name,
account_bank: account_bank,
usernames: a.data.account_name,
distribut_min: a.data.distribut_min,
user_money: user_money,
needmon:a.data.needmon,
});
} else {
this.setData({
bank_name: a.data.bank_name,
account_bank: account_bank,
usernames: a.data.account_name,
distribut_min: a.data.distribut_min,
user_money: user_money,
needmon:a.data.needmon,
});
}
}
}
})
},
//银行卡
async yhk(account_bank) {
console.log("有进来吗银行卡" + account_bank);
var e = this,
bank_name = "";
await getApp().request.promiseGet("/api/weshop/users/getBankName", {
data: {
bankno: account_bank,
}
}).then(res => {
var a = res.data;
if (a.data == null) {
console.log("来了吗");
getApp().showWarning("银行卡不存在");
this.setData({
bank_name: " "
});
return false;
}
console.log(a);
bank_name = a.data.bank_name;
console.log("s1w" + bank_name);
})
e.setData({
bank_name: bank_name
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
getApp().check_can_share();
var th=this;
this.weixin();
this.setData({
button: 0
});
var user_info = getApp().globalData.userInfo;
if (user_info == null || user_info.mobile == undefined || user_info.mobile == " " || user_info.mobile == null) {
wx.navigateTo({
url: '/packageE/pages/togoin/togoin',
})
return false;
}
this.setData({
val: null
})
wx.setNavigationBarTitle({
title: "流动资金提现",
});
//优惠券要实时更新
getApp().getConfig2(function(e) {
var json_d = JSON.parse(e.switch_list);
var is_closetxbank=json_d.is_closetxbank;
var is_tx_wx=json_d.is_tx_wx;
var tx_wx_type=json_d.tx_wx_type;
var data={
is_closetxbank:is_closetxbank,is_tx_wx:is_tx_wx,tx_wx_type:tx_wx_type
};
if(is_closetxbank) data.current=2;
th.setData(data);
},1)
},
//提取金额的输入框事件
defocus: function (event){
var money = Number(event.detail.value);
var val =this.data.distribut_min;
console.log(Number(val).length, "sss", val, "提取金额的输入框事件", money.length, typeof Number(event.detail.value), money);
console.log("keyCode", event.detail.keyCode);
if (event.detail.keyCode ==8){
return false};
if (money<this.data.distribut_min){
var val = this.data.distribut_min;
console.log("提取金额的输入框事件");
console.log(val,"提取金额的输入框事件");
getApp().showWarning("提现需大于"+val+"元");
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function (event){
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
getApp().globalData.no_clear=1;
}
})