verificationCodeDialog.vue
3.28 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
<!-- 安全验证码 -->
<template>
<!-- btn-ok-label="全部下载" -->
<d2-dialog title="安全验证码"
:is-visible="verificationCodeVisible"
class="verificationCode"
width="750px"
@closeDialog="handleClose"
@confirmDialog="handleConfirm">
<p class="title-tips">注意: 成功提交后,首次设置规则立即生效,修改规则第二天生效!</p>
<el-form ref="form"
:model="form"
:rules="rules"
label-suffix=":"
label-width="180px">
<el-form-item label="管理员手机号验证">
{{ adminInfo.name }} {{ adminInfo.phone }}
<el-button :size="size"
@click="handleSend"
:disabled="isSend">
{{ isSend ? sendMsg + '秒后,重试' : '发送验证短信' }}
</el-button>
</el-form-item>
<el-form-item label="验证码"
prop="smsCode">
<el-input placeholder="请填写验证码"
v-model="form.smsCode"
:size="size"
style="width: 220px;" />
</el-form-item>
</el-form>
</d2-dialog>
</template>
<script>
import { sendSms, getAdminInfo } from '@api/merchant'
export default {
name: 'VerificationCodeDialog',
props: {
visible: {
// 弹窗是否展示
type: Boolean,
default: false
}
},
computed: {
verificationCodeVisible: {
// return this.
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', false)
}
}
},
data() {
return {
size: 'small',
form: {
merchantId: '',
bizType: '1'
},
rules: {
smsCode: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
},
// 短信模块
isSend: false,
sendMsg: '发送验证短信',
adminInfo: {
name: '',
phone: ''
}
}
},
mounted() {
getAdminInfo({}).then(res => {
this.adminInfo = res
})
},
methods: {
handleClose() {
// this.$emit('dialogClose')
// this.$update
this.verificationCodeVisible = false
},
// 短信模块-start
handleSend() {
sendSms({}).then((res) => {
this.notice.okTips('已发送,30分钟内有效')
this.isSend = true
this.sendMsg = 60
this.msgDown()
})
},
msgDown() {
var time = setTimeout(() => {
clearTimeout(time)
if (this.sendMsg > 1) {
--this.sendMsg
this.msgDown()
} else {
this.isSend = false
}
}, 1000)
},
// 短信模块-end
handleConfirm() {
// if (this.stepStat === 3) {
// this.$refs['step' + this.stepStat].handleConfirm()
// return true
// }
this.$refs.form.validate((valid) => {
if (valid) {
// 清空倒计时
this.sendMsg = 1
this.$emit('handleConfirm', this.form.smsCode)
this.handleClose()
// this.$refs['step' + this.stepStat].handleConfirm()
}
})
}
}
}
</script>
<style>
</style>