소스 검색

feat:全局认证状态

ljc 1 개월 전
부모
커밋
20157338a4
5개의 변경된 파일28개의 추가작업 그리고 20개의 파일을 삭제
  1. 3 4
      components/PrefectInfo.vue
  2. 1 0
      pages/ib/customer.vue
  3. 1 0
      stores/pinia.types.ts
  4. 7 1
      stores/use-global-store.ts
  5. 16 15
      utils/request.js

+ 3 - 4
components/PrefectInfo.vue

@@ -27,6 +27,7 @@
 <script setup lang="ts">
   import { computed, ref,onMounted } from 'vue'
   import { useI18n } from 'vue-i18n'
+  import useGlobalStore from '@/stores/use-global-store'
   import useUserStore from '@/stores/use-user-store'
   import useRouter from '@/hooks/useRouter'
   import useRoute from '@/hooks/useRoute'
@@ -35,15 +36,14 @@
   const router = useRouter()
   const route = useRoute()
   const { userInfo } = useUserStore()
+  const { setApplyStatus } = useGlobalStore()
   const { t } = useI18n()
   // 认证弹窗,
   const dialogCheck = ref(null)
-  const customInfo = computed(() => {
-    return userInfo.customInfo
-  })
 
   const isPerfectInfo = computed(() => {
     const {status,applyRealStatus} = userInfo.customInfo
+    setApplyStatus(!(status == 2 || applyRealStatus == 1|| applyRealStatus ==2))
     return !(status == 2 || applyRealStatus == 1|| applyRealStatus ==2) && route.path != '/pages/mine/improveImmediately'
   })
   const info = computed(() => {
@@ -51,7 +51,6 @@
   })
 
   function immediately() {
-    console.log(customInfo.value)
     router.push({
       path:'/pages/mine/improveImmediately'
     })

+ 1 - 0
pages/ib/customer.vue

@@ -217,6 +217,7 @@
   listApi.value = ibApi.customerSubs
 
   const handleSearch = (params: any) => {
+    console.log(params)
     // 合并表单的过滤参数,同时保留当前的 belongsType 标签选中状态
     search.value = {
       ...params,

+ 1 - 0
stores/pinia.types.ts

@@ -11,4 +11,5 @@ export interface GlobalState {
     theme: string
     statusBarHeight: number
     mode: 'customer' | 'ib'
+    applyStatus: boolean
 }

+ 7 - 1
stores/use-global-store.ts

@@ -11,7 +11,9 @@ const useStore = defineStore("globalStore", () => {
     isPageSwitching: false,
     statusBarHeight: 0,
     mode: 'customer',
-    theme: "light"
+    theme: "light",
+    // 认证状态
+    applyStatus: false
   });
 
   const setGlobalTheme = (payload: string) => {
@@ -40,6 +42,9 @@ const useStore = defineStore("globalStore", () => {
   const setFullScreenLoading = (payload: boolean) => {
     state.fullScreenLoading = payload;
   };
+  const setApplyStatus = (payload: boolean) => {
+    state.applyStatus = payload;
+  };
   initMode()
   return {
     ...toRefs(state),
@@ -50,6 +55,7 @@ const useStore = defineStore("globalStore", () => {
     setRouterLoading,
     setRequestLoading,
     setFullScreenLoading,
+    setApplyStatus,
   };
 });
 

+ 16 - 15
utils/request.js

@@ -43,12 +43,13 @@ const requestInterceptor = (config) => {
   const userStore = useUserStore();
   const cId = userStore.userInfo?.cId;
 
-  const method = String(config.method || "GET").toUpperCase();
-  if (method === "GET") {
-    config.data = { ...(config.data || {}), cId };
-  } else {
-    config.data = { ...(config.data || {}), cId };
-  }
+  const method = String(config.method || "GET").toUpperCase();
+  if (method === "GET") {
+    config.data = { ...(config.data || {}) };
+  } else {
+    console.log(config.data,'ccc')
+    config.data = { ...(config.data || {}) };
+  }
   if (!config.header["Content-Type"]) {
     config.header["Content-Type"] = "application/json";
   }
@@ -60,9 +61,9 @@ const responseInterceptor = (response, options = {}) => {
   const { data, statusCode } = response;
   // 处理业务错误
   if (statusCode === 200) {
-    if (options.responseType === "arraybuffer" || data instanceof ArrayBuffer) {
-      return data;
-    }
+    if (options.responseType === "arraybuffer" || data instanceof ArrayBuffer) {
+      return data;
+    }
     // 1. 捕获 401 未授权错误
     if (data.code === 401 || data.code === 600) {
       // 关键:判断当前页面是否为登录页,避免循环跳转
@@ -312,16 +313,16 @@ export const uploadFile = (url, file, data = {}, header = {}, checkCode = true)
 };
 
 // 快捷方法
-export const get = (url, data = {}, typeOrOptions = {}, options = {}) => {
-  const mergedOptions =
-    typeof typeOrOptions === "string"
-      ? { type: typeOrOptions, ...(options || {}) }
-      : (typeOrOptions || {});
+export const get = (url, data = {}, typeOrOptions = {}, options = {}) => {
+  const mergedOptions =
+    typeof typeOrOptions === "string"
+      ? { type: typeOrOptions, ...(options || {}) }
+      : (typeOrOptions || {});
   return request({
     url,
     method: "GET",
     data,
-    ...mergedOptions,
+    ...mergedOptions,
   });
 };