step1.vue
3.18 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
<template>
<el-card style="min-height: 50vh">
<div class="pt30">
<el-form class="d-form" size="large" label-width="120" style="max-width: 500px;margin: auto">
<el-form-item label="手机/邮箱" required>
<el-input type="text" v-model="form.account" @change="resetCode" @blur="verifyCode"/>
</el-form-item>
<el-form-item label="验证码" 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 }} 秒
</count-down>
<span v-else>
发送验证码
</span>
</el-button>
</template>
</el-input>
<div class="vcodeBox" :style="isShow?'height:240px':'height:0'">
<Vcode :show="isShow" type="inside" @success="codeSuccess" @close="codeClose" @fail='codeFail'></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">下一步</el-button>
</div>
</el-card>
</template>
<script setup>
import {reactive} from "@vue/runtime-core";
import {toRefs} from "@vueuse/shared/index";
import Vcode from "vue3-puzzle-vcode"
import { ElMessage } from 'element-plus'
import CountDown from '@chenfengyuan/vue-countdown'
import {getCaptchaSms,checkRegisterCode} from "@/apiPc/match";
const data = reactive({
isShow:false,
isCodeTrue:false,
counting:false,
form:{},
activeStep: 0
})
const {isShow,isCodeTrue,counting,form,activeStep} = toRefs(data)
const emit = defineEmits(['submit','userName'])
function sendsmsMsg() {
if(!form.value.account){
ElMessage.error('请填写手机/邮箱')
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
isCodeTrue.value = true
counting.value = true
// getCaptchaSms({account:form.value.account}).then(res=>{
//
// })
}
function resetCode() {
isCodeTrue.value = false
}
function codeFail() {
}
function codeClose() {
}
const goBack = () => {
router.go(-1)
}
const next = () => {
if(!form.value.account){
ElMessage.error('请填写手机/邮箱')
return
}
if(!form.value.code){
ElMessage.error('请填写验证码')
return
}
if(!isCodeTrue.value){
return
}
checkRegisterCode(form.value).then(res=>{
emit('submit')
emit('userName',form.value.account)
})
}
</script>
<style scoped lang="scss">
.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;}
</style>