binDing.vue
1.7 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
<template>
<div>
<mt-field label="手机号" placeholder="请输入正确的手机号" type="tel" v-model="phone" :attr="{ maxlength: 13 }"></mt-field>
<mt-field label="验证码" v-model="codeText" :disabled="disabled">
<div class="getCode" @click="getCode">{{timeNum}}</div>
</mt-field>
<div style="margin-top: 34px" class="leftRightPadding">
<mt-button type="danger" size="large">绑定</mt-button>
</div>
</div>
</template>
<script>
export default {
name: 'binDing',
data() {
return {
codeText: '',
phone: '',
timeText: '获取验证码',
time: 0,
disabled:false
}
},
created(){
this.timeNum = this.timeText
},
methods: {
getCode: function () {
var reg=11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/;
//var url="/nptOfficialWebsite/apply/sendSms?mobile="+this.ruleForm.phone;
if(this.phone==''){
this.$vux.toast.text('请输入手机号码', 'top')
}else if(!reg.test(this.phone)){
this.$vux.toast.text('手机格式不正确', 'top')
}else{
this.time=60;
this.disabled=true;
this.timer();
/*axios.post(url).then(
res=>{
this.phonedata=res.data;
})*/
}
},
timer() {
if (this.time > 0) {
this.time--;
this.btntxt=this.time+"s后重新获取";
setTimeout(this.timer, 1000);
} else{
this.time=0;
this.btntxt="获取验证码";
this.disabled=false;
}
},
}
}
</script>
<style scoped lang="scss">
.getCode {
width: 100px;
height: 48px;
line-height: 48px;
background: #ef4f4f;
color: #fff;
text-align: center;
}
</style>