diff --git a/pages/auth/index.vue b/pages/auth/index.vue index 282c772..da81b6d 100644 --- a/pages/auth/index.vue +++ b/pages/auth/index.vue @@ -89,11 +89,6 @@ - - - - {{ authStatus.message }} - @@ -124,8 +119,7 @@ const codeCountdown = ref(0); const codeTimer = ref(null); const codeBtnText = ref('发送验证码'); -// 认证状态 -const authStatus = ref(null); + const canSendCode = computed(() => { @@ -304,9 +298,9 @@ const sendCode = async () => { await $api.createRequest('/app/auth/send-code', params, 'post'); - // 发送成功提示 - showAuthStatus('success', '验证码已发送至您的手机'); - playTextDirectly('验证码已发送,请注意查收'); + + $api.msg('验证码已发送') + playTextDirectly('验证码已发送'); } catch (error) { @@ -315,10 +309,6 @@ const sendCode = async () => { clearInterval(codeTimer.value); codeTimer.value = null; updateCodeBtnText(); - - // 错误提示 - showAuthStatus('error', '验证码发送失败,请重试'); - playTextDirectly('验证码发送失败'); } }; @@ -331,38 +321,7 @@ const updateCodeBtnText = () => { } }; -// 显示认证状态 -const showAuthStatus = (type, message) => { - const statusMap = { - success: { - icon: 'check-circle-filled', - color: '#52c41a', - message - }, - error: { - icon: 'close-circle-filled', - color: '#ff4d4f', - message - }, - loading: { - icon: 'loading', - color: '#1677ff', - message - } - }; - - authStatus.value = { - type, - ...statusMap[type] - }; - - // 3秒后自动清除成功/错误状态 - if (type !== 'loading') { - setTimeout(() => { - authStatus.value = null; - }, 3000); - } -}; + // 提交认证 const submitAuth = async () => { @@ -373,10 +332,6 @@ const submitAuth = async () => { validateCode(); return; } - - // 显示加载状态 - showAuthStatus('loading', '正在认证中...'); - try { // 调用身份认证接口 const params = { @@ -388,7 +343,7 @@ const submitAuth = async () => { const result = await $api.createRequest('/app/auth/verify', params, 'post'); // 认证成功 - showAuthStatus('success', '身份认证成功'); + $api.msg('身份认证成功') playTextDirectly('身份认证成功'); // 保存认证信息到store @@ -398,22 +353,7 @@ const submitAuth = async () => { }, 500); }) } catch (error) { - // 认证失败 - let errorMsg = '身份认证失败'; - - if (error.code === 'ID_CARD_ERROR') { - idCardError.value = '身份证号验证失败'; - errorMsg = '身份证信息有误'; - } else if (error.code === 'PHONE_ERROR') { - phoneError.value = '手机号与身份证不匹配'; - errorMsg = '手机号与身份证信息不匹配'; - } else if (error.code === 'CODE_ERROR') { - codeError.value = '验证码错误或已过期'; - errorMsg = '验证码错误,请重新获取'; - } - - showAuthStatus('error', errorMsg); - playTextDirectly(errorMsg); + } };