addCard.vue
10.6 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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
<template>
<view class="page">
<view class="tixianbox">
<view class='tixiantype'>提现方式</view>
<view class="tixianlist flexone">
<view class="tixianlistitem flexone" :class="sel==1?'selactivek':''" @click="selitem" :data-id="1">
<view class="tixianimg">
<image src="../../static/icon_wechat.png"></image>
</view>
<view class="tixianname">微信</view>
</view>
<view class="tixianlistitem flexone" :class="sel==2?'selactivek':''" @click="selitem" :data-id="2">
<view class="tixianimg">
<image src="../../static/icon_zhifu.png"></image>
</view>
<view class="tixianname">支付宝</view>
</view>
<view class="tixianlistitem flexone" :class="sel==3?'selactivek':''" @click="selitem" :data-id="3">
<view class="tixianimg">
<image src="../../static/ticard.png"></image>
</view>
<view class="tixianname">银行卡</view>
</view>
</view>
</view>
<!-- 微信 -->
<view class="cardboxk" v-if="sel==1">
<view class="title">请输入绑定信息</view>
<view class="box">
<view class="item">
<text class="name">姓名</text>
<input type="text" value="" placeholder="请输入姓名" :value="name2" class="fill" @input="enternamew" />
</view>
<view class="item">
<text class="name">账号</text>
<input type="text" value="" placeholder="请输入微信账号" :value="account" class="fill" @input="enteraccount" />
</view>
</view>
</view>
<!--支付宝 -->
<view class="cardboxk" v-if="sel==2">
<view class="title">请输入绑定信息</view>
<view class="box">
<view class="item">
<text class="name">姓名</text>
<input type="text" value="" placeholder="请输入姓名" :value="name2" class="fill" @input="enternamew" />
</view>
<view class="item">
<text class="name">账号</text>
<input type="text" value="" placeholder="请输入支付宝账号" :value="account" class="fill" @input="enteraccount" />
</view>
</view>
</view>
<!-- 银行卡 -->
<view class="cardboxk" v-if="sel==3">
<view class="title">请绑定持卡人本人的银行卡</view>
<view class="box">
<view class="item">
<text class="name">持卡人</text>
<input type="text" value="" placeholder="请输入持卡人" :value="people" class="fill" @input="enterpeople" />
</view>
<view class="item">
<text class="name">卡号</text>
<input type="text" value="" placeholder="请输入卡号" :value="card" class="fill" @input="entercard" />
</view>
<picker @change="bindbankPickerChange" :value="index" :range="bankarray" range-key="name">
<!-- <view class="uni-input">{{array[index]}}</view> -->
<view class="item">
<text class="name">开户行</text>
<view class="fill">{{bankname}}</view>
<!-- <input type="text" value="" placeholder="请输入开户行" class="fill" @input="enterbank" /> -->
</view>
</picker>
<view class="item">
<text class="name">手机号</text>
<input type="number" value="" placeholder="请输入手机号" :value="phone" class="fill" @input="enterphone" />
</view>
</view>
</view>
<view class="add" @click="type==1?editcard():surecard()">
<view class="addcount">确认</view>
</view>
</view>
</template>
<script>
import app from "../../App.vue";
export default {
data() {
return {
people: '',
card: '',
bank: '',
phone: '',
item: '',
type: '',
sel: 1,
name2: '',
account: '',
index:0,
bankid:'',
bankname:'请选择开户行',
bankarray:[],
chosecard:''
}
},
onLoad(options) {
if (options.item) {
this.item = JSON.parse(options.item);
this.type = options.type;
this.sel=this.item.type;
this.name2=this.item.name2;
this.account=this.item.account;
this.people=this.item.name;
this.phone=this.item.mobile;
this.card=this.item.card_number;
this.bankid=this.item.open_account_id;
this.bankname=this.item.bank_name
}
if(options.seltype){
this.chosecard=1
this.sel=options.seltype
}
console.log('438843934',this.item)
this.getbanklist()
},
methods: {
enterpeople(e) {
this.people = e.detail.value
},
entercard(e) {
this.card = e.detail.value
},
enterbank(e) {
this.bank = e.detail.value
},
enterphone(e) {
console.log(e.detail.value)
this.phone = e.detail.value;
console.log(this.phone)
},
selitem(e) {
this.sel = e.currentTarget.dataset.id;
this.people= '';
this.card= '';
this.bankid='';
this.bankname='请选择开户行';
this.phone= '';
this.item='';
this.name2='';
this.account= '';
},
// 输入姓名
enternamew(e) {
this.name2 = e.detail.value
},
// 输入账号
enteraccount(e) {
this.account = e.detail.value
},
// 选择开户行
bindbankPickerChange(e){
this.bankname=this.bankarray[e.target.value].name;
this.bankid=this.bankarray[e.target.value].id
},
// 获取开户行
getbanklist(){
let that=this;
var url = 'bank/open_account';
var params = {
}
console.log('7766554', params)
app.post(url, params).then((res) => {
console.log(res);
that.bankarray=res.data.data;
that.bankarray.forEach(function(value,indexk,array){
if(value.id==that.bankid){
that.index=indexk
}
})
}).catch((err) => {
})
},
// 添加银行卡
surecard() {
let that = this;
if(that.sel==3){
if (that.people == '') {
uni.showToast({
title: "请输入持卡人",
icon: "none"
})
return false
}
if (that.card == '') {
uni.showToast({
title: "请输入卡号",
icon: "none"
})
return false
}
if (!(/^1[3456789]\d{9}$/.test(that.phone))) {
wx.showToast({
title: '请输入正确手机号',
icon: 'none'
})
return false;
}
}else{
if(that.name2==''){
uni.showToast({
title:'请输入姓名',
icon:'none'
})
return false
}
if(that.sel==1){
if(that.account==''){
uni.showToast({
title:'请输入微信账号',
icon:'none'
})
return false
}
}else{
if(that.account==''){
uni.showToast({
title:'请输入支付宝账号',
icon:'none'
})
return false
}
}
}
var url = 'bank/add_user_address';
var params = {
type: that.sel,
name: that.people,
card_number: that.card,
open_account_id: that.bankid,
mobile: that.phone,
name2: that.name2,
account: that.account
}
console.log('7766554', params)
app.post(url, params).then((res) => {
console.log(res);
if(that.sel==3){
uni.showToast({
title: '添加银行卡成功',
icon: 'none'
})
}else if(that.sel==1){
uni.showToast({
title: '添加微信账户成功',
icon: 'none'
})
}else if(that.sel==2){
uni.showToast({
title: '添加支付宝账户成功',
icon: 'none'
})
}
setTimeout(function() {
if(that.chosecard==1){
uni.redirectTo({
url:'/pages/usercenter/account'
})
}else{
uni.navigateBack({
checked: true
})
}
}, 1500)
}).catch((err) => {
})
},
// 编辑银行卡
editcard() {
let that = this;
if(that.sel==3){
if (that.people == '') {
uni.showToast({
title: "请输入持卡人",
icon: "none"
})
return false
}
if (that.card == '') {
uni.showToast({
title: "请输入卡号",
icon: "none"
})
return false
}
if (!(/^1[3456789]\d{9}$/.test(that.phone))) {
wx.showToast({
title: '请输入正确手机号',
icon: 'none'
})
return false;
}
}else{
if(that.name2==''){
uni.showToast({
title:'请输入姓名',
icon:'none'
})
return false
}
if(that.sel==1){
if(that.account==''){
uni.showToast({
title:'请输入微信账号',
icon:'none'
})
return false
}
}else{
if(that.account==''){
uni.showToast({
title:'请输入支付宝账号',
icon:'none'
})
return false
}
}
}
var url = 'bank/edit_user_address';
var params = {
bank_id:that.item.id,
type: that.sel,
name: that.people,
card_number: that.card,
open_account_id: that.bankid,
mobile: that.phone,
name2: that.name2,
account: that.account
}
console.log('7766554', params)
app.post(url, params).then((res) => {
console.log(res);
if(that.sel==3){
uni.showToast({
title: '编辑银行卡成功',
icon: 'none'
})
}else if(that.sel==1){
uni.showToast({
title: '编辑微信账户成功',
icon: 'none'
})
}else if(that.sel==2){
uni.showToast({
title: '编辑支付宝账户成功',
icon: 'none'
})
}
setTimeout(function() {
uni.navigateBack({
checked: true
})
}, 1500)
}).catch((err) => {
console.log(err)
})
}
}
}
</script>
<style>
.tixianlist {
margin-top: 22rpx;
}
.tixianlistitem {
width: 184rpx;
height: 72rpx;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16rpx;
border: 1rpx solid transparent;
}
.selactivek {
border: 1rpx solid #C29445;
border-radius: 8rpx;
}
.tixianname {
color: #3D454C;
font-size: 28rpx;
margin-left: 8rpx;
}
.tixianbox {
padding: 0 40rpx;
box-sizing: border-box;
}
.tixiantype {
color: #3D454C;
font-size: 28rpx;
}
.tixianimg {
width: 48rpx;
height: 48rpx;
font-size: 0;
}
image {
width: 100%;
height: 100%;
}
.title {
font-size: 28rpx;
font-family: PingFangHK-Regular, PingFangHK;
font-weight: 400;
color: rgba(61, 6 9, 76, 1);
line-height: 104rpx;
padding: 0 40rpx;
box-sizing: border-box;
}
.box {
background: #fff;
padding: 0 40rpx;
box-sizing: border-box;
}
.item {
height: 108rpx;
display: flex;
align-items: center;
border-bottom: 1px solid #EEEEEE;
}
.name {
width: 84rpx;
font-size: 28rpx;
font-family: PingFangHK-Medium, PingFangHK;
font-weight: 600;
color: rgba(8, 18, 31, 1);
margin-right: 16rpx;
}
.fill {
width: 232rpx;
font-size: 28rpx;
font-family: PingFangHK-Regular, PingFangHK;
font-weight: 400;
color: rgba(91, 94, 100, 1);
}
</style>