verificationCodeDialog.vue
4.79 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
<!-- 安全验证码 -->
<template>
<!-- btn-ok-label="全部下载" -->
<d2-dialog title="安全验证码"
:is-visible="verificationCodeVisible"
class="verificationCode"
width="750px"
@closeDialog="handleClose"
@confirmDialog="handleConfirm">
<el-form ref="form"
:model="form"
:rules="rules"
label-suffix=":"
label-width="180px">
<el-form-item label="规则生效"
prop="ruleChoose">
<el-radio-group v-model="form.ruleChoose">
<el-radio :label="1">立即生效</el-radio>
<el-radio :label="2">定时生效</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="规则生效日期"
prop="effectStartDate"
:rules="[{ required: true, message: '请选择生效开始日期', trigger: 'blur' }]"
v-if="form.ruleChoose == 2">
<!-- placeholder="请输入服务开始时间"
prefix-icon="0" -->
<el-date-picker value-format="yyyy-MM-dd"
v-model="form.effectStartDate"
type="date"
:picker-options="expireTimeOPtion">
</el-date-picker>
<!-- <span v-else>立即生效</span> -->
<!-- <el-input placeholder="请填写验证码"
v-model="form.smsCode"
:size="size"
style="width: 220px;" /> -->
</el-form-item>
<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>
<!-- <p class="title-tips">注意:成功提交并完成审核后,首次设置规则立即生效,修改规则在到达指定生效日期后生效!</p> -->
</d2-dialog>
</template>
<script>
import { sendSms, getAdminInfo } from '@api/merchant'
export default {
name: 'VerificationCodeDialog',
props: {
visible: {
// 弹窗是否展示
type: Boolean,
default: false
},
effectStartDate: {
type: Boolean
}
},
computed: {
verificationCodeVisible: {
// return this.
get() {
return this.visible
},
set(val) {
this.$emit('update:visible', false)
}
}
},
data() {
return {
size: 'small',
expireTimeOPtion: {
disabledDate(time) {
return Date.now() > time.getTime() // 如果没有后面的-8.64e6就是不可以选择今天的
}
},
form: {
merchantId: '',
bizType: '1',
effectStartDate: '',
ruleChoose: 1
},
rules: {
smsCode: [{ required: true, message: '请输入验证码', trigger: 'blur' }]
// effectStartDate: [{ 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)
this.handleClose()
// this.$refs['step' + this.stepStat].handleConfirm()
}
})
}
}
}
</script>
<style></style>