From 76f59685bd7d475578d36523bf1a3bd418f4c226 Mon Sep 17 00:00:00 2001 From: dzq Date: Mon, 28 Apr 2025 17:13:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=99=BB=E5=BD=95):=20=E6=B7=BB=E5=8A=A0u?= =?UTF-8?q?serid=E5=8F=82=E6=95=B0=E4=BB=A5=E6=94=AF=E6=8C=81=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=99=BB=E5=BD=95=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在登录流程中,新增userid参数以增强用户验证功能。修改了相关API和页面逻辑,确保在登录时能够正确传递和处理userid,提升系统的安全性和用户体验。 --- src/App.vue | 28 +++++++++++++++++----------- src/common/apis/ab98/index.ts | 4 ++-- src/common/apis/ab98/type.ts | 1 + src/pages/login/Ab98Login.vue | 17 ++++++++++------- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/App.vue b/src/App.vue index 4a1beca..2695f34 100644 --- a/src/App.vue +++ b/src/App.vue @@ -35,27 +35,33 @@ onMounted(() => { const state = urlParams.get('state') || undefined; const corpid = urlParams.get('corpid') || undefined; const isAdmin = urlParams.get('isAdmin') || undefined; - + if (state && state.indexOf('token') !== -1) { const token = state.split('token_')[1]; if (token) { ab98UserStore.setTokenLogin(token); - tokenLogin(token).then(res => { - if (res && res.code == 0) { - if (res.data.success) { - ab98UserStore.setTel(res.data.tel) - ab98UserStore.setUserInfo(res.data) - ab98UserStore.setIsLogin(true) - router.push('/') + watch( + () => wxStore.userid, + (newVal) => { + if (newVal && !ab98UserStore.isLogin) { + tokenLogin(ab98UserStore.tokenLogin, newVal).then(res => { + if (res?.code === 0 && res.data?.success) { + ab98UserStore.setTel(res.data.tel) + ab98UserStore.setUserInfo(res.data) + ab98UserStore.setIsLogin(true) + router.push('/') + } + }) } - } - }) + }, + { immediate: true } + ) } } if (isAdmin == '1') { - wxStore.setIsCabinetAdmin(true); + wxStore.setIsCabinetAdmin(true); } if (code || state) { wxStore.handleWxCallback({ corpid, code, state }) diff --git a/src/common/apis/ab98/index.ts b/src/common/apis/ab98/index.ts index 27e0df8..cea2f24 100644 --- a/src/common/apis/ab98/index.ts +++ b/src/common/apis/ab98/index.ts @@ -55,10 +55,10 @@ export function logoutApi(token: string) { } /** ab98Token登录 */ -export function tokenLogin(token: string) { +export function tokenLogin(token: string, userid: string) { return request>({ url: '/wx/login/tokenLogin', method: 'get', - params: { token } + params: { token, userid } }) } \ No newline at end of file diff --git a/src/common/apis/ab98/type.ts b/src/common/apis/ab98/type.ts index 44d9025..63cc5c8 100644 --- a/src/common/apis/ab98/type.ts +++ b/src/common/apis/ab98/type.ts @@ -56,4 +56,5 @@ export type VerifySmsParams = { tel: string /** 验证码 */ vcode: string + userid: string } \ No newline at end of file diff --git a/src/pages/login/Ab98Login.vue b/src/pages/login/Ab98Login.vue index 8601b37..ad77de0 100644 --- a/src/pages/login/Ab98Login.vue +++ b/src/pages/login/Ab98Login.vue @@ -40,13 +40,15 @@