withdrawal.vue
10.0 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
<template>
<view class="">
<image class="bg" src="/static/takeMoneyBg.png" mode=""></image>
<view class="top">
<view v-if="type==1">账户余额:</view>
<view v-else>保证金余额:</view>
<view> <text style="32rpx">¥</text>{{money}}</view>
</view>
<view class="center">
<view class="title" v-if="type==1">提现金额</view>
<view class="inputPrice" v-if="type==1">
<view class="">
¥<input type="text" @input="checkNumber" v-model="form.price" />
</view>
<view class="right" @click="takePrice">全部提现</view>
</view>
<!-- 支付要输入的信息 -->
<view class="payInput" v-if="form.withdraw_type==2">
<view class="list">
<view class="input">支付宝收款姓名:</view>
<input type="text" v-model="form.withdraw_name" placeholder="请输入" value="" />
</view>
<view class="list">
<view class="input">支付宝绑定的账号:</view>
<input type="text" v-model="form.withdraw_mobile" placeholder="请输入" value="" />
</view>
</view>
<view class="payInput" v-if="form.withdraw_type==3">
<view class="list">
<view class="input">提现银行:</view>
<input type="text" v-model="form.bank_name" placeholder="请选择" value="" />
</view>
<view class="list">
<view class="input">银行卡号:</view>
<input type="number" v-model="form.bank_num" placeholder="请输入" value="" />
</view>
<view class="list">
<view class="input">持卡人姓名:</view>
<input type="text" v-model="form.name" placeholder="请输入" value="" />
</view>
</view>
<view class="line" v-if="type==1"></view>
<view class="title" style="margin-top: 30rpx;">提现方式</view>
<!-- 提现方式 -->
<view class="payType">
<view class="list" @click="toggleType(1)">
<view class="left flexA">
<image src="/static/wechat.png" mode=""></image>
微信
</view>
<view class="right">
<image v-if="form.withdraw_type==1" src="/static/checked.png" mode=""></image>
<image v-else src="/static/notCheck.png" mode=""></image>
</view>
</view>
<view class="list" @click="toggleType(2)">
<view class="left flexA">
<image src="/static/zhifubao.png" mode=""></image>
支付宝
</view>
<view class="right">
<image v-if="form.withdraw_type==2" src="/static/checked.png" mode=""></image>
<image v-else src="/static/notCheck.png" mode=""></image>
</view>
</view>
<view class="list" @click="toggleType(3)">
<view class="left flexA">
<image src="/static/yinlian.png" mode=""></image>
银行卡支付
</view>
<view class="right">
<image v-if="form.withdraw_type==3" src="/static/checked.png" mode=""></image>
<image v-else src="/static/notCheck.png" mode=""></image>
</view>
</view>
</view>
<view class="Withdrawal flexC" @click="takeMoney">提现</view>
<view class="tips" v-if="type==1">
温馨提示:为了能给您带来更好的服务,琉璃藏宝阁平台将抽取订单余额的{{withdraw_percent}}%作为交易手续费,账户余额为抽取手续费之后的金额,提现足额到账。
</view>
<view class="tips" v-else>
温馨提示:保证金不收取任何手续费,可随时提现。若您违反了琉璃藏宝阁平台用户规则,平台将扣除部分保证金。
</view>
</view>
</view>
</template>
<script>
import {
toa
} from '@/utils/toast.js'
import {
getUserInfo,
takeMoney,
takeBail
} from '@/api/mine.js'
export default {
data() {
return {
payType: '1',
money: 0,
price: '',
form: {
price: '', // integer 否 提现金额
withdraw_type: 1, // integer 是 提现方式:1=微信2=支付宝3=银行卡
withdraw_name: '', // string 否 支付宝收款姓名
withdraw_mobile: '', // string 否 支付宝绑定的手机号
bank_name: '', // string 否 提现银行
bank_num: '', // string 否 银行卡号
name: '', // string 否 持卡人姓名
},
type: 1,
withdraw_percent:"",
}
},
onLoad(e) {
// 1 是余额 2是保证金
this.type = e.type
},
onShow() {
this.getUserInfo()
},
methods: {
async getUserInfo() {
try {
const res = await getUserInfo()
if (this.type == 1) {
this.money = res.user.money
this.withdraw_percent=res.user.withdraw_percent
} else {
this.money = res.user.score
this.form.price = res.user.score
}
console.log('getUserInfo', res)
// 保存数据
} catch (err) {
uni.showToast({
title: err,
icon: 'none'
})
console.log('getUserInfo', err)
}
},
// 切换支付方式
toggleType(type) {
this.form.withdraw_type = type
},
// 提现全部按钮
takePrice() {
if (this.money <= 0) return toa.toast('账户余额不足')
this.form.price = this.money
},
checkNumber(e) {
let val = e.target.value.replace(/(^\s*)|(\s*$)/g, "")
var reg = /[^\d.]/g
// 只能是数字和小数点,不能是其他输入
val = val.replace(reg, "")
// // 保证第一位只能是数字,不能是点
val = val.replace(/^\./g, "");
// // 小数只能出现1位
val = val.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
// // 小数点后面保留2位
val = val.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
// console.log(val);
this.$nextTick(() => {
this.form.price = val;
})
},
// 提现功能按钮
takeMoney() {
if (this.money <= 0) return toa.toast('账户余额不足')
if (!this.money) return toa.toast('请输入提现金额')
if (this.form.withdraw_type == 1 && this.form.price < 1) return toa.toast('微信提现最少提现1元')
if (this.form.withdraw_type == 2 && !this.form.withdraw_name) return toa.toast('请输入支付宝收款姓名')
if (this.form.withdraw_type == 2 && !this.form.withdraw_mobile) return toa.toast('请输入支付宝收款手机号')
if (this.form.withdraw_type == 3 && !this.form.bank_name) return toa.toast('请输入银行卡提现银行')
if (this.form.withdraw_type == 3 && !this.form.bank_num) return toa.toast('请输入银行卡号')
if (this.form.withdraw_type == 3 && !this.form.name) return toa.toast('请输入持卡人姓名')
console.log(this.form);
if (this.type == 1) {
if (this.form.withdraw_type == 1) {
toa.toast('微信提现暂未开放,敬请期待')
} else {
this.toTakeMoney()
}
} else {
if (this.form.withdraw_type == 1) {
toa.toast('微信提现暂未开放,敬请期待')
} else {
this.takeBail()
}
}
},
async toTakeMoney() {
try {
const res = await takeMoney(this.form)
setTimeout(() => {
toa.success('提现提交成功,请等待审核')
}, 200)
for (let key in this.form) {
this.form[key] = ''
}
this.form.withdraw_type = 1
this.getUserInfo()
console.log('takeMoney', res)
// 保存数据
} catch (err) {
uni.showToast({
title: err,
icon: 'none'
})
console.log('takeMoney', err)
}
},
async takeBail() {
try {
const res = await takeBail(this.form)
setTimeout(() => {
toa.success('提现提交成功,请等待审核')
}, 200)
for (let key in this.form) {
this.form[key] = ''
}
this.form.withdraw_type = 1
this.getUserInfo()
console.log('takeMoney', res)
// 保存数据
} catch (err) {
uni.showToast({
title: err,
icon: 'none'
})
console.log('takeMoney', err)
}
}
},
}
</script>
<style lang="less">
page {
background: #f6f6f6;
}
.bg {
overflow: hidden;
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 366rpx;
}
.top {
position: absolute;
left: 32rpx;
top: 64rpx;
view:nth-child(1) {
color: rgba(0, 0, 0, 0.4);
font-size: 28rpx;
}
view:nth-child(2) {
color: rgba(0, 0, 0, 0.9);
font-size: 64rpx;
font-weight: 700;
}
}
.center {
position: absolute;
width: 686rpx;
left: 50%;
top: 220rpx;
border-radius: 24rpx;
padding: 40rpx 30rpx;
transform: translateX(-50%);
background: #fff;
box-sizing: border-box;
.line {
margin: 32rpx 0;
width: 622rpx;
height: 1rpx;
background: rgba(240, 242, 245, 1);
}
// 收到的信息
.payInput {
.list {
display: flex;
justify-content: space-between;
font-size: 28rpx;
margin: 32rpx 0;
.input {
flex: 1;
font-weight: 700;
}
input {
text-align: right;
width: 300rpx;
}
}
}
.title {
font-weight: 700;
margin-bottom: 32rpx;
font-weight: 700;
}
.inputPrice {
display: flex;
justify-content: space-between;
align-items: center;
view {
font-weight: 700;
display: flex;
align-items: center;
font-size: 52rpx;
input {
margin-left: 20rpx;
font-weight: 400;
}
}
.right {
color: rgba(33, 83, 212, 1);
font-size: 28rpx;
font-weight: 400;
}
}
}
.payType {
.list {
margin-bottom: 32rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.left {
image {
margin-right: 24rpx;
width: 48rpx;
height: 48rpx;
}
}
.right {
image {
width: 36rpx;
height: 36rpx;
}
}
}
.Withdrawal {
margin: 100rpx auto 0;
width: 622rpx;
height: 88rpx;
color: rgba(0, 0, 0, 0.9);
font-size: 32rpx;
font-weight: 700;
border-radius: 28rpx;
background: linear-gradient(90deg, rgba(255, 230, 89, 1) 0%, rgba(255, 216, 0, 1) 100%);
}
.tips {
margin-top: 16rpx;
color: rgba(0, 0, 0, 0.4);
font-size: 24rpx;
}
</style>