From d908b049fae66dce67370eb87b2e64bedefd648f Mon Sep 17 00:00:00 2001 From: chenghuan Date: Wed, 5 Nov 2025 10:27:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9A=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=A4=B1=E8=B4=A5=E6=8F=90=E7=A4=BA=E5=8F=8D?= =?UTF-8?q?=E9=A6=88=E9=97=AE=E9=A2=98=EF=BC=9B=E4=BF=AE=E6=94=B9=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 16 ++++++++------ pages/login/login.vue | 49 ++++++++++++++++++++++++++++++++++--------- static/tailwind.css | 1 + utils/index.ts | 5 +++++ 4 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 utils/index.ts diff --git a/App.vue b/App.vue index 591909b..168b57a 100644 --- a/App.vue +++ b/App.vue @@ -14,11 +14,15 @@ diff --git a/pages/login/login.vue b/pages/login/login.vue index cf20980..04cf85e 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -99,6 +99,10 @@ + + 登录遇到问题?去反馈 + + @@ -142,6 +146,7 @@ import { useUserStore } from '@/stores/user' import { loginWithCode, loginWithPassword } from '@/api/modules/auth' import { commonApi } from '@/api/modules/common' import { validateEmail } from '@/utils/validator' +import { onPageJump } from '@/utils' import { useI18n } from 'vue-i18n' const { t } = useI18n() @@ -178,6 +183,9 @@ const yszcText = ref({ let codeTimer: any = null +// 提交点击次数 +const submitClickNum = ref(0) + /** * 切换登录方式 * @param type 1000-密码登录,2000-验证码登录 @@ -278,9 +286,13 @@ const verifyCodeLogin = async () => { if (!isCodeEmpty()) return false - const res = await loginWithCode(email.value, code.value) - - return res + try { + const res = await loginWithCode(email.value, code.value) + return res + } catch (error) { + console.error('验证码登录失败:', error) + return null + } } // 密码登录 const passwordLogin = async () => { @@ -288,11 +300,15 @@ const passwordLogin = async () => { if (!isEmailVerified(phoneEmail.value)) return false - if (!isPasswordEmpty) return false + if (!isPasswordEmpty()) return false - const res = await loginWithPassword(phoneEmail.value, password.value) - - return res + try { + const res = await loginWithPassword(phoneEmail.value, password.value) + return res + } catch (error) { + console.error('密码登录失败:', error) + return null + } } // 提交登录 const onSubmit = async () => { @@ -309,11 +325,8 @@ const onSubmit = async () => { break } - console.log('res', res) - if (res && res.userInfo && res.token) { res.userInfo.token = res.token.token - console.log('设置用户信息login', res.userInfo) userStore.setUserInfo(res.userInfo) uni.showToast({ title: t('login.loginSuccess'), @@ -324,6 +337,9 @@ const onSubmit = async () => { url: '/pages/index/index' }) }, 600) + } else { + // 登录失败时增加提交点击次数 + submitClickNum.value++ } } @@ -352,6 +368,7 @@ const onSetCode = async () => { getCodeState() } catch (error) { uni.hideLoading() + submitClickNum.value++ // 发送验证码失败时增加提交点击次数 console.error('Send code error:', error) } } @@ -664,4 +681,16 @@ onMounted(() => { line-height: 45rpx; } } +.loginHelp{ + border: 1px solid #f5dab1; + margin-top: 16rpx; + font-size: 26rpx; + text-align: center; + padding: 10rpx; + background-color: #fdf6ec; + border-radius: 15rpx; + .link{ + color: #e6a23c; + } +} diff --git a/static/tailwind.css b/static/tailwind.css index e5814d9..0ae3471 100644 --- a/static/tailwind.css +++ b/static/tailwind.css @@ -8,6 +8,7 @@ --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; --color-red-500: oklch(63.7% 0.237 25.331); + --color-emerald-600: oklch(59.6% 0.145 163.225); --ease-out: cubic-bezier(0, 0, 0.2, 1); --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1); --default-transition-duration: 150ms; diff --git a/utils/index.ts b/utils/index.ts new file mode 100644 index 0000000..b2be9bb --- /dev/null +++ b/utils/index.ts @@ -0,0 +1,5 @@ +export const onPageJump = (path: string) => { + uni.navigateTo({ + url: path + }) +} \ No newline at end of file