<template>
<el-input size="small" placeholder="請輸入驗證碼" v-model="phoneCode">
<el-button :disabled="disSend" size="small" slot="append" @click="send">{{BtnName}}</el-button>
</el-input>
</template>
<script>
export default {
data() {
return {
phoneCode: '',
BtnName: '發送驗證碼',
disSend:false
}
},
methods: {
send() {
this.disSend = true
this.$alert('已向手機號13908056224發送短信', '溫馨提示', {
confirmButtonText: '確定',
callback: action => {
let count = 60;
let timer = null
if (!timer) {
timer = setInterval(() => {
if (count > 1) {
count--;
this.BtnName = count + '秒後重發'
} else {
clearInterval(timer);
timer = null;
this.disSend = false
this.BtnName = '發送驗證碼'
}
}, 1000)
}
}
});
}
}
}
</script>