##Title: When we log in, we often need to obtain the verification code through the mobile phone number. Let's directly upload the dry goods below;
## code:
changeCode(index) {
console.log('12312312')
if (index == 1) {
if (this.loginForm.phone) {
const phone = this.loginForm.phone
api.phoneRepeatNew({ phone: phone })
.then(res => {
if (res.code == 200) {
this.ifPhones = res.data
if (this.ifPhones === true) {
const TIME_COUNT = 60
if ((/^1[3456789]\d{9}$/.test(this.loginForm.phone))) {
this.codeStyle = 'color: #DDE2EE'
let apiCode = ''
if (this.getCode === '1') {
apiCode = api.phoneForgetCode
} else {
apiCode = api.phoneCode
}
apiCode((this.loginForm.phone))
.then((res) => {
if (res.success) {
this.$notify({
type: 'success',
message: '手机验证码发送成功'
})
this.getCode === '0'
//使用防抖
if (!this.timer) {
this.count = TIME_COUNT
this.resgisterLoading = true
this.timer = setInterval(() => {
if (this.count > 0 && this.count <= TIME_COUNT) {
this.count--
this.codeText = this.count + 's 后重新发送'
} else {
this.clearPhone()
// this.resgisterLoading = false
// clearInterval(this.timer)
// this.timer = null
// // this.mobileCode = res.data
// this.codeStyle = 'color: #3874F6'
// this.codeText = '获取验证码'
}
}, 1000)
}
} else {
this.codeStyle = 'color: #3874F6'
}
})
} else {
this.$message.error('请输入正确的手机号码')
this.isDisabled = false
}
} else {
this.$message.error('该手机号未注册')
this.isDisabled = false
}
}
})
} else {
this.$message.error('请输入手机号码')
this.isDisabled = false
}
} else {
}
},
This is a direct job. You can directly convert the corresponding interface object into the interface of your own work in your work. In addition, you must like it! ! !