step1.vue
5.39 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
<template>
<el-card style="min-height: 50vh">
<div class="pt30">
<el-form class="d-form" size="large" :label-width="language==0?120:200" style="max-width: 500px;margin: auto">
<el-form-item :label="language==0?'邮箱':'E-mail'" required>
<el-input type="text" v-model="form.account" @change="resetCode" @blur="verifyCode"
/>
<div class="tip" v-if="language==0">
(请填写正确的邮箱信息,邮箱信息在注册完成后无法修改。
该邮箱后续会作为您登录的账户,
并接收报名审核结果、支付账单、签证邀请函等相关信息。)
</div>
<div v-else class="tip">
Please fill in the correct email, which cannot be changed after the registration is completed. The email will be used as your login account and to receive relevant information including results of registration review, payment bills, visa invitation letters, etc.
</div>
</el-form-item>
<el-form-item :label="language==0?'验证码':'Code'" required>
<el-input v-model="form.code">
<template #append>
<el-button type="primary" plain style="width: 110px" @click="sendsmsMsg">
<count-down v-if="counting" v-slot="{ totalSeconds }" :time="60000" @end="counting=false">
{{ totalSeconds }} {{ language == 0 ? '秒' : 's' }}
</count-down>
<span v-else>
{{ language == 0 ? '发送验证码' : 'Send' }}
</span>
</el-button>
</template>
</el-input>
<div class="vcodeBox" :style="isShow?'height:240px':'height:0'">
<Vcode :show="isShow" :successText="successVcode" :failText="failVcode" :slider-text="sliderText"
type="inside" @success="codeSuccess"></Vcode>
</div>
</el-form-item>
</el-form>
</div>
<div class="text-center">
<!-- <el-button class="primary-kx" round @click="goBack">取消</el-button>-->
<el-button type="primary" class="btn-lineG w200px" round @click="next">{{
language == 0 ? '下一步' : 'NEXT'
}}
</el-button>
</div>
</el-card>
</template>
<script setup>
import {reactive, toRefs} from 'vue'
import Vcode from "vue3-puzzle-vcode"
import {ElMessage} from 'element-plus'
import CountDown from '@chenfengyuan/vue-countdown'
import {getCaptchaSms, checkRegisterCode} from "@/apiPc/match";
import {onMounted} from "@vue/runtime-core";
import {useStorage} from "@vueuse/core/index";
const language = useStorage('language', 0)
const data = reactive({
isShow: false,
isCodeTrue: false,
counting: false,
form: {},
activeStep: 0,
failVcode: '验证失败,请重试',
successVcode: '验证通过!',
sliderText: '拖动滑块完成拼图',
})
const {isShow, isCodeTrue, counting, form, activeStep, failVcode, successVcode, sliderText} = toRefs(data)
const emit = defineEmits(['submit', 'userName'])
onMounted(() => {
if (language.value == 1) {
failVcode.value = 'Error!'
successVcode.value = 'Success!'
sliderText.value = 'Drag the slider to complete the puzzle'
}
})
function sendsmsMsg() {
if (!form.value.account) {
if (language.value == 0) {
ElMessage.warning('请填写手机/邮箱')
} else {
ElMessage.warning('Please fill in your phone/email address')
}
return
}
if (form.value.account.indexOf('@') == -1) {
if (language.value == 0) {
ElMessage.warning('请填写正确的邮箱')
} else {
ElMessage.warning('Please fill in the correct email')
}
return
}
if (counting.value) {
return
} else {
isShow.value = true
}
}
function verifyCode() {
if (!form.value.account) {
return
}
if (form.value.account.indexOf('@') > -1) {
//邮箱
}
}
function codeSuccess(msg) {
console.log('验证通过' + msg);
isShow.value = false
getCaptchaSms({account: form.value.account}).then(res => {
counting.value = true
isCodeTrue.value = true
ElMessage.success(language.value == 0 ? '发送成功,请关注邮箱邮件' :'Send success, please check your email')
})
}
function resetCode() {
isCodeTrue.value = false
}
const goBack = () => {
router.go(-1)
}
const next = () => {
if (!form.value.account) {
if (language.value == 0) {
ElMessage.warning('请填写邮箱')
} else {
ElMessage.warning('Please fill in your phone/email address')
}
return
}
if (!form.value.code) {
if (language.value == 0) {
ElMessage.warning('请填写验证码')
} else {
ElMessage.warning('Please fill in Code')
}
return
}
if (!isCodeTrue.value) {
if (language.value == 0) {
ElMessage.warning('请发送验证码')
} else {
ElMessage.warning('Please send the verification code')
}
return
}
checkRegisterCode(form.value).then(res => {
emit('submit')
emit('userName', form.value.account)
})
}
</script>
<style scoped lang="scss">
.d-form{min-height: 50vh}
.el-input-group__append button.el-button, .el-input-group__append button.el-button:hover {
color: var(--el-color-primary);
background: #efefff;
border: var(--el-color-primary) solid 1px;
border-radius: 0;
}
.vcodeBox {
position: relative;
margin: 20px 0 0;
width: 320px;
overflow: hidden;
height: auto;
}
.tip {
line-height: 1.6;
margin-top: 10px;
}
</style>