From 63ee93a94b28034432d2026c14ba4b6ae6836fd5 Mon Sep 17 00:00:00 2001 From: ktianc Date: Mon, 19 Jun 2023 14:24:09 +0800 Subject: [PATCH] =?UTF-8?q?perf=EF=BC=9A=E8=8E=B7=E5=8F=96=E7=9F=AD?= =?UTF-8?q?=E4=BF=A1=E9=AA=8C=E8=AF=81=E7=A0=81=E5=8A=9F=E8=83=BD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0try/catch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Login/components/TelephoneCodeForm.vue | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/kinit-admin/src/views/Login/components/TelephoneCodeForm.vue b/kinit-admin/src/views/Login/components/TelephoneCodeForm.vue index 4b1c811..8004477 100644 --- a/kinit-admin/src/views/Login/components/TelephoneCodeForm.vue +++ b/kinit-admin/src/views/Login/components/TelephoneCodeForm.vue @@ -130,17 +130,21 @@ const getSMSCode = async () => { SMSCodeNumber.value = 60 const { getFormData } = methods const formData = await getFormData() - 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 } }