diff --git a/src/App.vue b/src/App.vue index 8d548ca..3687a23 100644 --- a/src/App.vue +++ b/src/App.vue @@ -47,7 +47,7 @@ onMounted(() => { () => wxStore.userid, (newVal) => { if (newVal && !ab98UserStore.isLogin) { - tokenLogin(ab98UserStore.tokenLogin, newVal).then(res => { + tokenLogin(ab98UserStore.tokenLogin, newVal, wxStore.openid).then(res => { if (res?.code === 0 && res.data?.success) { ab98UserStore.setTel(res.data.tel) ab98UserStore.setUserInfo(res.data) diff --git a/src/common/apis/ab98/index.ts b/src/common/apis/ab98/index.ts index cea2f24..ecfbb60 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, userid: string) { +export function tokenLogin(token: string, userid: string, openid: string) { return request>({ url: '/wx/login/tokenLogin', method: 'get', - params: { token, userid } + params: { token, userid, openid } }) } \ No newline at end of file diff --git a/src/common/apis/ab98/type.ts b/src/common/apis/ab98/type.ts index c063181..2f1e78a 100644 --- a/src/common/apis/ab98/type.ts +++ b/src/common/apis/ab98/type.ts @@ -57,4 +57,5 @@ export type VerifySmsParams = { /** 验证码 */ vcode: string userid: string + openid: string } \ No newline at end of file diff --git a/src/pages/login/Ab98Login.vue b/src/pages/login/Ab98Login.vue index a81cd76..ccee5c6 100644 --- a/src/pages/login/Ab98Login.vue +++ b/src/pages/login/Ab98Login.vue @@ -111,7 +111,8 @@ const handleSubmit = async () => { token: userStore.token, tel: form.value.tel, vcode: form.value.vcode, - userid: wxStore.userid + userid: wxStore.userid, + openid: wxStore.openid }) if (data.success) { diff --git a/src/pinia/stores/ab98-user.ts b/src/pinia/stores/ab98-user.ts index 98e50c7..5fc646c 100644 --- a/src/pinia/stores/ab98-user.ts +++ b/src/pinia/stores/ab98-user.ts @@ -9,7 +9,8 @@ const STORAGE_KEYS = { USERID: 'ab98_userid', REGISTERED: 'ab98_registered', TEL: 'ab98_tel', - TOKEN: 'ab98_token' + TOKEN: 'ab98_token', + LOGIN_CODE: 'ab98_login_code' } /** @@ -39,9 +40,12 @@ export const useAb98UserStore = defineStore("ab98User", () => { const token = ref(storedToken ? decodeURIComponent(storedToken) : ""); const tokenLogin = ref(""); + // 登录验证码 + const loginCode = '1'; // 默认验证码 // 用户登录状态 const isLogin = ref(false); - isLogin.value = tel.value ? true : false; + const storedLoginCode = localStorage.getItem(STORAGE_KEYS.LOGIN_CODE); + isLogin.value = tel.value && storedLoginCode === String(loginCode) ? true : false; /** * 更新用户基本信息 @@ -60,6 +64,7 @@ export const useAb98UserStore = defineStore("ab98User", () => { localStorage.setItem(STORAGE_KEYS.REGISTERED, JSON.stringify(data.registered)) tel.value = data.tel localStorage.setItem(STORAGE_KEYS.TEL, encodeURIComponent(data.tel)) + localStorage.setItem(STORAGE_KEYS.LOGIN_CODE, encodeURIComponent(loginCode)) } /** @@ -80,6 +85,7 @@ export const useAb98UserStore = defineStore("ab98User", () => { tel.value = "" localStorage.removeItem(STORAGE_KEYS.TEL) localStorage.removeItem(STORAGE_KEYS.TOKEN) + localStorage.removeItem(STORAGE_KEYS.LOGIN_CODE) } /**