cashDialog.vue
3.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
<!-- 提现弹窗 -->
<template>
<d2-dialog
title="提现"
:is-visible.sync="cashVisible"
width="60%"
@confirmDialog="handleCashConfirm"
@closeDialog="handleCashClose">
<span slot="sub-title">提现后不能撤回,确保资金安全,请谨慎操作!</span>
<el-form
ref="cashDialog"
:model="cashForm"
:rules="cashRules"
label-width="120px">
<el-form-item label="可提现余额:">
<span>¥ {{ cashForm.balance }}</span>
</el-form-item>
<el-form-item label="提现金额:">
<span>¥ {{ +cashForm.balance - 2 }}</span><span style="margin-left: 40px;">注:每提现一笔会扣除2元手续费</span>
</el-form-item>
<el-form-item label="到账账户:">
<p>{{ cashForm.bankAccountName }}</p>
<p>{{ cashForm.bankName }}({{ cashForm.bankAccountNo }})<span>预计24小时内到账</span></p>
</el-form-item>
<el-form-item
label="验证码:"
prop="smsCode">
<el-input
v-model="cashForm.smsCode"
placeholder="请输入验证码"
style="width: 200px" />
<el-button
type="primary"
size="small"
@click="handleSend"
:disabled="isSend"
class="cash-btn">
{{ isSend ? sendMsg + '秒后,重试' : '获取验证码' }}
</el-button>
<p v-show="showtips">
已向尾号为{{ cashForm.withdrawPhone ? cashForm.withdrawPhone.slice(-4) : '' }}的手机号发送验证码,验证码30分钟内有效
</p>
</el-form-item>
</el-form>
</d2-dialog>
</template>
<script>
import { createWithdraw } from '@api/account'
import { sendToSmsCodeApi } from '@/api/sys.base'
export default {
data() {
return {
cashRules: {
smsCode: [{ required: true, message: '请输入验证码', trigger: 'change' }]
},
// 验证码
showtips: false,
isSend: false,
sendMsg: '获取验证码',
time: ''
}
},
props: {
cashVisible: {
type: Boolean,
default: false
},
cashForm: {
type: Object,
default: () => { }
}
},
watch: {
cashVisible(newVal, val) {
newVal ? this.reset() : this.closeReset()
}
},
mounted() { },
methods: {
reset() {
this.$refs.cashDialog && this.$refs.cashDialog.resetFields()
},
closeReset() {
this.isSend = false
this.showtips = false
this.time && clearTimeout(this.time)
},
handleCashConfirm() {
this.$refs.cashDialog.validate(valid => {
if (valid) {
createWithdraw({ totalAmount: (+this.cashForm.balance - 2), smsCode: this.cashForm.smsCode }).then(res => {
this.notice.okTips()
this.$emit('handleCashConfirm')
})
}
})
},
handleCashClose() {
this.$emit('handleCashClose')
},
handleSend() {
sendToSmsCodeApi({ phone: this.cashForm.withdrawPhone }).then((res) => {
this.notice.okTips('已发送,30分钟内有效')
this.isSend = true
this.showtips = true
this.sendMsg = 60
this.msgDown()
})
},
msgDown() {
this.time = setTimeout(() => {
clearTimeout(this.time)
if (this.sendMsg > 1) {
--this.sendMsg
this.msgDown()
} else {
this.isSend = false
}
}, 1000)
}
}
}
</script>
<style scoped>
p {
margin: 0 0;
}
.cash-btn {
margin-left: 20px;
}
</style>