Explorar o código

修复 pushRecordId 问题

yuanmingze hai 2 semanas
pai
achega
5431ab008b
Modificáronse 3 ficheiros con 11 adicións e 15 borrados
  1. 3 3
      src/services/request/index.ts
  2. 0 1
      src/stores/modules/user.ts
  3. 8 11
      src/views/login/index.vue

+ 3 - 3
src/services/request/index.ts

@@ -102,16 +102,16 @@ const handleNetworkError = (response: AxiosResponse, silent?: boolean) => {
   if (status === 401) {
     showToast('您的登录状态已失效,请重新登录')
     abortAllRequests()
+    const pushRecordId = userStore.pushRecordId
 
-    // 🔁 跳转到登录页
     setTimeout(() => {
+      useUserStoreWithOut().LogOut()
       router.replace({
         path: '/login',
         query: {
-          pushRecordId: userStore.pushRecordId,
+          pushRecordId: pushRecordId,
         },
       })
-      useUserStoreWithOut().LogOut()
     }, 1500)
   }
 

+ 0 - 1
src/stores/modules/user.ts

@@ -28,7 +28,6 @@ export const useUserStore = defineStore('user', {
     },
     LogOut() {
       this.access_token = ''
-      this.pushRecordId = ''
       this.needFaceId = false
     },
   },

+ 8 - 11
src/views/login/index.vue

@@ -393,19 +393,16 @@ onActivated(() => {
 })
 
 onBeforeMount(() => {
-  userStore.LogOut()
   registerUrlParams.value.returnUrl = `${location.origin}/h5${route.fullPath}`
-  const pushRecordId = route?.query.pushRecordId || ''
-  console.log('pushRecordId', pushRecordId)
-
-  if (pushRecordId) {
-    sendEtsSms.pushRecordId = pushRecordId as string
-    userStore.setPushRecordId(pushRecordId as string)
-    formData.pushRecordId = pushRecordId as string
-    getPubName()
-  } else {
-    showToast('登录链接存在不完整或者输入错误,请重新复制链接登录')
+  const pushRecordId = route.query.pushRecordId
+  if (!pushRecordId) {
+    showToast('登录链接存在不完整或者输入错误')
+    return
   }
+  userStore.setPushRecordId(pushRecordId as string)
+  sendEtsSms.pushRecordId = pushRecordId as string
+  formData.pushRecordId = pushRecordId as string
+  getPubName()
 })
 </script>