From 8597ad67f067aecc7cbc8de78da4206681b08c64 Mon Sep 17 00:00:00 2001 From: rd <1344903914@qq.com> Date: Mon, 8 Sep 2025 17:36:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=99=BB=E5=BD=95=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.ts | 4 ++-- src/views/login/components/login-form/index.vue | 10 ++++++---- src/views/login/components/register-form/index.vue | 13 +++++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index 752c186..4bc4561 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -60,8 +60,8 @@ export class Request { this.instance.interceptors.response.use( (res: AxiosResponse) => { - const { data } = res; - switch (data.code) { + const { data, status } = res; + switch (status) { case HttpStatusCode.Success: return data; default: diff --git a/src/views/login/components/login-form/index.vue b/src/views/login/components/login-form/index.vue index b93d1b3..fff1791 100644 --- a/src/views/login/components/login-form/index.vue +++ b/src/views/login/components/login-form/index.vue @@ -303,6 +303,12 @@ const handleSubmit = async () => { const _fn = isCaptchaLogin.value ? fetchAuthorizationsCaptcha : postLoginPassword; const { code, data, message: errorInfo } = await _fn(loginForm); + console.log(code, errorInfo); + if (code === 10001) { + errMsg.value = errorInfo; + return; + } + if (code === 200) { // 处理登录成功逻辑 message.success('登录成功'); @@ -318,10 +324,6 @@ const handleSubmit = async () => { getProfileInfo(); } - } catch (error) { - if (error?.status === 400) { - errMsg.value = error.data?.message; - } } finally { submitting.value = false; } diff --git a/src/views/login/components/register-form/index.vue b/src/views/login/components/register-form/index.vue index 381be4e..5732982 100644 --- a/src/views/login/components/register-form/index.vue +++ b/src/views/login/components/register-form/index.vue @@ -48,6 +48,9 @@ +

+ {{ errMsg }} +

@@ -130,6 +133,7 @@ const mobileNumber = ref(''); const selectAccountModalRef = ref(null); const accounts = ref([]); const isLegalMobile = ref(false); +const errMsg = ref(''); const formData = ref({ mobile: '', @@ -315,6 +319,11 @@ const handleSubmit = async () => { const _fn = isResetPassword.value ? postForgetPassword : postRegister; const { code, data, message: errorInfo } = await _fn(formData.value); + if (code === 10001) { + errMsg.value = errorInfo; + return; + } + if (code === 200) { message.success(isResetPassword.value ? '重置成功' : '注册成功'); // 注册成功后跳转登录页 @@ -337,10 +346,6 @@ const handleSubmit = async () => { getProfileInfo(); } - } catch (error) { - if (error?.status === 400) { - errMsg.value = error.data?.message; - } } finally { submitting.value = false; }