perf:获取短信验证码功能增加try/catch

This commit is contained in:
ktianc 2023-06-19 14:24:09 +08:00
parent f9cc24e84c
commit 63ee93a94b

View File

@ -130,17 +130,21 @@ const getSMSCode = async () => {
SMSCodeNumber.value = 60
const { getFormData } = methods
const formData = await getFormData<UserLoginType>()
const res = await postSMSCodeApi({ telephone: formData.telephone })
if (res?.data) {
let timer = setInterval(() => {
SMSCodeNumber.value--
if (SMSCodeNumber.value < 1) {
SMSCodeStatus.value = true
clearInterval(timer)
}
}, 1000)
} else {
ElMessage.error('发送失败,请联系管理员')
try {
const res = await postSMSCodeApi({ telephone: formData.telephone })
if (res?.data) {
let timer = setInterval(() => {
SMSCodeNumber.value--
if (SMSCodeNumber.value < 1) {
SMSCodeStatus.value = true
clearInterval(timer)
}
}, 1000)
} else {
ElMessage.error('发送失败,请联系管理员')
SMSCodeStatus.value = true
}
} catch (e: any) {
SMSCodeStatus.value = true
}
}