Jelajahi Sumber

feat: cwg-dropdown.vue

ljc 2 minggu lalu
induk
melakukan
decbdb5549
2 mengubah file dengan 12 tambahan dan 1 penghapusan
  1. 9 1
      components/cwg-dropdown.vue
  2. 3 0
      utils/request.js

+ 9 - 1
components/cwg-dropdown.vue

@@ -25,7 +25,7 @@
 </template>
 
 <script setup>
-import { ref, reactive, nextTick, onMounted } from 'vue'
+import { ref, reactive, nextTick, onMounted, onUnmounted } from 'vue'
 import { queryElementRect } from '@/uni_modules/x-tools/tools/sugar.js'
 import { str2px, commonProps } from '@/uni_modules/x-tools/tools/com.js'
 
@@ -154,6 +154,14 @@ const close = () => {
 onMounted(() => {
     getSystemInfo()
     innerInterspace.value = str2px(props.interspace)
+    
+    uni.$on('logout', () => {
+        close()
+    })
+})
+
+onUnmounted(() => {
+    uni.$off('logout')
 })
 // 暴露方法
 defineExpose({

+ 3 - 0
utils/request.js

@@ -99,6 +99,8 @@ const responseInterceptor = (response, options = {}) => {
           icon: "none",
         });
         
+        uni.$emit('logout');
+        
         setTimeout(() => {
           uni.reLaunch({
             url: LOGIN_PAGE_PATH,
@@ -106,6 +108,7 @@ const responseInterceptor = (response, options = {}) => {
               uni.setStorageSync('logoutToSystem',1)
               ls.set('mode', 'customer');
               // globalStore.setMode('customer');
+              // uni.clearStorageSync()
               isRedirectingToLogin = false;
             },
             fail: () => {