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 @@