79 lines
2.8 KiB
Vue
79 lines
2.8 KiB
Vue
|
|
<template lang="html">
|
||
|
|
<el-button :class="type" :type="type=='theme1'?'primary':'text'" size="medium" @click="sendClick()"
|
||
|
|
:disabled="sendSuccess">
|
||
|
|
{{sendSuccess?time+$t('message.sign.resend_verificationText'):$t('message.sign.verificationText')}}
|
||
|
|
</el-button>
|
||
|
|
</template>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
import {checkPhone} from '@/assets/js/util.js'
|
||
|
|
// changePhoneIsRegist
|
||
|
|
import {getSmsRegCodeApi} from '@/assets/js/api/loginSign'
|
||
|
|
|
||
|
|
export default {
|
||
|
|
props: ['phone', 'type'],
|
||
|
|
data() {
|
||
|
|
return {
|
||
|
|
sendSuccess: false, //true验证码发送 false验证码未发送
|
||
|
|
time: 60 //时间
|
||
|
|
};
|
||
|
|
},
|
||
|
|
methods: {
|
||
|
|
//定时器
|
||
|
|
finish() {
|
||
|
|
//禁用以下表单
|
||
|
|
this.sendSuccess = true;
|
||
|
|
//进行倒计时提示
|
||
|
|
let Time = setInterval(() => {
|
||
|
|
if (this.time <= 1) {
|
||
|
|
//当时间小于等于一的时候清除定时器
|
||
|
|
//初始化一下数据参数
|
||
|
|
clearInterval(Time);
|
||
|
|
this.sendSuccess = false;
|
||
|
|
this.time = 60;
|
||
|
|
} else {
|
||
|
|
this.time--;
|
||
|
|
}
|
||
|
|
}, 1000);
|
||
|
|
},
|
||
|
|
//发送验证码请求
|
||
|
|
sendClick() {
|
||
|
|
|
||
|
|
if (checkPhone(this.phone)) {
|
||
|
|
window._paq.push(['trackEvent', '点击', '获取','获取短信验证码'])
|
||
|
|
// changePhoneIsRegist({phone:this.phone}).then((res) => {
|
||
|
|
// this.canuse = res.canuse
|
||
|
|
// if(res.canuse){
|
||
|
|
//调用定时器
|
||
|
|
this.finish();
|
||
|
|
//发送请求
|
||
|
|
console.log(this.phone)
|
||
|
|
getSmsRegCodeApi({phone: this.phone}).then(res => {
|
||
|
|
// if(res.STATUS=="1"){
|
||
|
|
this.$message.success(this.$t('message.sign.verificationSendSuccess'));//验证码发送成功
|
||
|
|
this.$emit('getCode', res.VerificationCode)
|
||
|
|
// }else{
|
||
|
|
// this.$message.error('验证码发送失败');
|
||
|
|
// }
|
||
|
|
})
|
||
|
|
// }else{
|
||
|
|
// this.$message.error('新手机号不可用')
|
||
|
|
// }
|
||
|
|
// })
|
||
|
|
|
||
|
|
} else {
|
||
|
|
this.$message.error(this.$t('message.sign.verificationSendError'));//发送失败,手机号码格式不正确
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<style lang="less" scoped>
|
||
|
|
.theme1 {
|
||
|
|
margin-right: -5px;
|
||
|
|
border-radius: 0 3px 3px 0;
|
||
|
|
}
|
||
|
|
</style>
|