From afb9410b3794275c180cdd66e3ca54fd32888d33 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 14 八月 2025 16:00:27 +0800
Subject: [PATCH] fix: 灵工管理

---
 apps/bMiniApp/src/hooks/user.ts          |   12 ++--
 apps/bMiniApp/src/stores/modules/user.ts |   42 +++++++------
 apps/bMiniApp/src/pages/mine/index.vue   |   23 +++++--
 apps/bMiniApp/src/utils/storage/auth.ts  |    4 
 apps/cMiniApp/src/hooks/user.ts          |    2 
 packages/services/apiV2/typings.d.ts     |    3 +
 apps/cMiniApp/src/utils/storage/auth.ts  |    4 
 apps/cMiniApp/src/stores/modules/user.ts |   33 +++++-----
 apps/cMiniApp/src/pages/mine/index.vue   |   32 ++--------
 types/api.d.ts                           |   13 +++
 10 files changed, 85 insertions(+), 83 deletions(-)

diff --git a/apps/bMiniApp/src/hooks/user.ts b/apps/bMiniApp/src/hooks/user.ts
index 28b1083..8e97ad1 100644
--- a/apps/bMiniApp/src/hooks/user.ts
+++ b/apps/bMiniApp/src/hooks/user.ts
@@ -11,9 +11,9 @@
 
   const { userDetail, userInfo, locationCity } = storeToRefs(userStore);
 
-  // function updateUserInfo() {
-  //   return userStore.getCurrentUserInfo();
-  // }
+  function updateUserInfo() {
+    return userStore.getCurrentUserInfo();
+  }
 
   // const isCompanyAudited = computed(() => {
   //   return userDetail.value?.openHRSiteStatus === ParkOrHRStatus.Running;
@@ -31,13 +31,13 @@
   // });
 
   const isCertified = computed(() => {
-    return false;
+    return userDetail.value?.isReal;
   });
 
   return {
     user: userInfo,
     userDetail: userDetail,
-    // updateUserInfo,
+    updateUserInfo,
     // isCompletePersonalInfo,
     // isCompanyAudited,
     isCertified,
@@ -67,7 +67,7 @@
 
   Taro.useReady(async () => {
     if (isLogin.value && userStore.firstGetUserDetail) {
-      // userStore.getCurrentUserInfo();
+      userStore.getCurrentUserInfo();
     }
     if (needAuth && !isLogin.value) {
       Taro.navigateTo({
diff --git a/apps/bMiniApp/src/pages/mine/index.vue b/apps/bMiniApp/src/pages/mine/index.vue
index 66b072b..27499bb 100644
--- a/apps/bMiniApp/src/pages/mine/index.vue
+++ b/apps/bMiniApp/src/pages/mine/index.vue
@@ -17,17 +17,25 @@
             <UserAvatar :size="60" class="mine-avatar" />
             <div class="user-info" v-if="isLogin">
               <div class="user-info-item">
-                <div class="user-info-item-name">{{ userDetail?.userName ?? '123' }}</div>
+                <div class="user-info-item-name">{{ userDetail?.name ?? '' }}</div>
                 <div class="user-info-item-gender">
-                  <img v-if="1" :src="IconMale" class="user-info-item-gender-icon" />
-                  <img v-else :src="IconFemale" class="user-info-item-gender-icon" />
+                  <img
+                    v-if="userDetail?.gender === EnumUserGender.Male"
+                    :src="IconMale"
+                    class="user-info-item-gender-icon"
+                  />
+                  <img
+                    v-else-if="userDetail?.gender === EnumUserGender.Female"
+                    :src="IconFemale"
+                    class="user-info-item-gender-icon"
+                  />
                 </div>
-                <div class="user-info-item-position">绠$悊鍛�</div>
+                <div class="user-info-item-position">{{ (userDetail?.roles ?? []).join(',') }}</div>
               </div>
               <div class="user-info-item">
                 <template v-if="isCertified">
                   <div class="user-info-certified-text">
-                    {{ userDetail?.customerName ?? '123' }}
+                    {{ userDetail?.enterpriseName ?? '' }}
                   </div>
                   <div class="user-info-certified-btn">宸茶璇�</div>
                 </template>
@@ -112,6 +120,7 @@
 import { useUserStore } from '@/stores/modules/user';
 import { useQueryClient } from '@tanstack/vue-query';
 import { TaskDetailWelfareItem } from '@12333/components';
+import { EnumUserGender } from '@12333/constants';
 
 const userStore = useUserStore();
 const queryClient = useQueryClient();
@@ -144,9 +153,9 @@
 
 Taro.useShareAppMessage((res) => {
   return {
-    title: `${userDetail.value?.contacter}鍚嶇墖`,
+    title: `${userDetail.value?.name}鍚嶇墖`,
     // path: `${RouterPath.userHomePage}?userId=${userDetail.value?.userId}`,
-    imageUrl: userDetail.value?.avatarUrl,
+    imageUrl: userDetail.value?.avatar,
   };
 });
 
diff --git a/apps/bMiniApp/src/stores/modules/user.ts b/apps/bMiniApp/src/stores/modules/user.ts
index 3683e94..af03a0b 100644
--- a/apps/bMiniApp/src/stores/modules/user.ts
+++ b/apps/bMiniApp/src/stores/modules/user.ts
@@ -31,7 +31,7 @@
   userInfo?: Nullable<API.LoginCommandCallback>;
   token?: Nullable<string>;
   refreshToken?: Nullable<string>;
-  userDetail?: Nullable<API.UserInfoV2>;
+  userDetail?: Nullable<API.GetEnterpriseLoginInfoQueryResult>;
   firstGetUserDetail?: boolean;
 
   locationCity?: string;
@@ -83,6 +83,10 @@
 
     accountInfo(): Partial<AccountInfo> {
       return getAccountInfoFromAccessToken(this.userInfo?.accessToken);
+    },
+
+    userId: (state) => {
+      return state.userDetail?.id;
     },
 
     // matchMakingIdentity(state): MatchMakingIdentityEnum {
@@ -152,9 +156,7 @@
       try {
         this.setUserInfoAction(res);
         this.setTokenAction(res);
-        console.log('22', 22);
-        myClient.refetchQueries();
-        // await this.getCurrentUserInfo();
+        await this.getCurrentUserInfo();
       } catch (error) {}
     },
 
@@ -189,21 +191,21 @@
       // } catch (error) {}
     },
 
-    // async getCurrentUserInfo() {
-    //   try {
-    //     let res = await userServices.getUserInfo({ showLoading: false });
-    //     if (res) {
-    //       res.frontStatus = getUserCertificationFrontStatusAdapter(
-    //         res.userCertificationStatus,
-    //         res.userCertificationAuditStatus
-    //       );
-    //       res.originalAvatarUrl = res.avatarUrl;
-    //       res.avatarUrl = res.avatarUrl ? setOSSLink(res.avatarUrl) : DefaultAvatar;
-    //       this.setUserDetail(res);
-    //       this.firstGetUserDetail = false;
-    //     }
-    //   } catch (error) {}
-    // },
+    async getCurrentUserInfo() {
+      try {
+        let res = await authServices.getEnterpriseLoginInfo({}, { showLoading: false });
+        if (res) {
+          // res.frontStatus = getUserCertificationFrontStatusAdapter(
+          //   res.userCertificationStatus,
+          //   res.userCertificationAuditStatus
+          // );
+          res.originalAvatar = res.avatar;
+          res.avatar = res.avatar ? setOSSLink(res.avatar) : DefaultAvatar;
+          this.setUserDetail(res);
+          this.firstGetUserDetail = false;
+        }
+      } catch (error) {}
+    },
 
     setTokenAction(tokenInfo: API.IdentityModelTokenCacheItem) {
       this.token = tokenInfo?.accessToken;
@@ -215,7 +217,7 @@
       setUserInfo(info);
     },
 
-    setUserDetail(detail: API.UserInfoV2) {
+    setUserDetail(detail: API.GetEnterpriseLoginInfoQueryResult) {
       this.userDetail = detail;
       setUserDetail(detail);
     },
diff --git a/apps/bMiniApp/src/utils/storage/auth.ts b/apps/bMiniApp/src/utils/storage/auth.ts
index ecf237f..e5e8fda 100644
--- a/apps/bMiniApp/src/utils/storage/auth.ts
+++ b/apps/bMiniApp/src/utils/storage/auth.ts
@@ -29,10 +29,10 @@
 }
 
 export function getUserDetail() {
-  return storageLocal.getItem<API.UserInfoV2>(StorageKey.USER_DETAIL_KEY);
+  return storageLocal.getItem<API.GetEnterpriseLoginInfoQueryResult>(StorageKey.USER_DETAIL_KEY);
 }
 
-export function setUserDetail(userDetail: API.UserInfoV2) {
+export function setUserDetail(userDetail: API.GetEnterpriseLoginInfoQueryResult) {
   return storageLocal.setItem(StorageKey.USER_DETAIL_KEY, userDetail);
 }
 
diff --git a/apps/cMiniApp/src/hooks/user.ts b/apps/cMiniApp/src/hooks/user.ts
index a0d6025..e78bd97 100644
--- a/apps/cMiniApp/src/hooks/user.ts
+++ b/apps/cMiniApp/src/hooks/user.ts
@@ -33,7 +33,7 @@
   });
 
   const isCertified = computed(() => {
-    return false;
+    return userDetail.value?.isReal;
   });
 
   return {
diff --git a/apps/cMiniApp/src/pages/mine/index.vue b/apps/cMiniApp/src/pages/mine/index.vue
index 0c53077..7bddbbd 100644
--- a/apps/cMiniApp/src/pages/mine/index.vue
+++ b/apps/cMiniApp/src/pages/mine/index.vue
@@ -16,7 +16,7 @@
           <div class="mine-avatar-wrapper" @click="goLogin">
             <UserAvatar :size="52" class="mine-avatar" />
             <div class="user-info" v-if="isLogin">
-              <div class="user-info-item">{{ detail?.name ?? '' }}</div>
+              <div class="user-info-item">{{ userDetail?.name ?? '' }}</div>
               <div class="user-info-auth">
                 <div class="user-info-auth-item">
                   <div class="user-info-unCertified" v-if="isCertified">
@@ -67,7 +67,7 @@
           <nut-badge
             class="mine-order-list-item"
             top="8"
-            :value="detail?.taskCount ?? 0"
+            :value="userDetail?.taskCount ?? 0"
             @click="goMineSign"
           >
             <img :src="IconOrderSign" class="mine-order-list-icon" />
@@ -76,7 +76,7 @@
           <nut-badge
             class="mine-order-list-item"
             top="8"
-            :value="detail?.hirePassTaskCount ?? 0"
+            :value="userDetail?.hirePassTaskCount ?? 0"
             @click="goMineHire"
           >
             <img :src="IconOrderHire" class="mine-order-list-icon" />
@@ -85,7 +85,7 @@
           <nut-badge
             class="mine-order-list-item"
             top="8"
-            :value="detail?.hireRefuseTaskCount ?? 0"
+            :value="userDetail?.hireRefuseTaskCount ?? 0"
             @click="goMineCancel"
           >
             <img :src="IconOrderCancel" class="mine-order-list-icon" />
@@ -124,35 +124,15 @@
 import { useQuery } from '@tanstack/vue-query';
 import * as authServices from '@12333/services/apiV2/auth';
 
-const { userDetail, isCertified } = useUser();
-console.log('isCertified: ', isCertified);
+const { userDetail, isCertified, updateUserInfo } = useUser();
 const isLogin = useIsLogin();
 const systemStore = useSystemStore();
 
 const { goLoginFn } = useGoLogin();
 const bgHeight = computed(() => 133 + systemStore.navHeight);
 
-const {
-  isLoading,
-  isError,
-  data: detail,
-  refetch,
-} = useQuery({
-  queryKey: ['authServices/getPersonalLoginInfo'],
-  queryFn: async () => {
-    return await authServices.getPersonalLoginInfo(
-      {},
-      {
-        showLoading: false,
-      }
-    );
-  },
-  placeholderData: () => ({} as API.GetPersonalLoginInfoQueryResult),
-  enabled: isLogin,
-});
-
 Taro.useDidShow(() => {
-  refetch();
+  updateUserInfo();
 });
 
 function goLogin() {
diff --git a/apps/cMiniApp/src/stores/modules/user.ts b/apps/cMiniApp/src/stores/modules/user.ts
index e654cf3..1606ae7 100644
--- a/apps/cMiniApp/src/stores/modules/user.ts
+++ b/apps/cMiniApp/src/stores/modules/user.ts
@@ -31,7 +31,7 @@
   userInfo?: Nullable<API.LoginCommandCallback>;
   token?: Nullable<string>;
   refreshToken?: Nullable<string>;
-  userDetail?: Nullable<API.UserInfoV2>;
+  userDetail?: Nullable<API.GetPersonalLoginInfoQueryResult>;
   firstGetUserDetail?: boolean;
 
   locationCity?: string;
@@ -86,7 +86,7 @@
     },
 
     userId: (state) => {
-      return state.userInfo?.id ?? '';
+      return state.userDetail?.id ?? '';
     },
   },
   actions: {
@@ -152,7 +152,6 @@
       try {
         this.setUserInfoAction(res);
         this.setTokenAction(res);
-        myClient.refetchQueries();
         await this.getCurrentUserInfo();
       } catch (error) {}
     },
@@ -189,19 +188,19 @@
     },
 
     async getCurrentUserInfo() {
-      // try {
-      //   let res = await userServices.getUserInfo({ showLoading: false });
-      //   if (res) {
-      //     res.frontStatus = getUserCertificationFrontStatusAdapter(
-      //       res.userCertificationStatus,
-      //       res.userCertificationAuditStatus
-      //     );
-      //     res.originalAvatarUrl = res.avatarUrl;
-      //     res.avatarUrl = res.avatarUrl ? setOSSLink(res.avatarUrl) : DefaultAvatar;
-      //     this.setUserDetail(res);
-      //     this.firstGetUserDetail = false;
-      //   }
-      // } catch (error) {}
+      try {
+        let res = await authServices.getPersonalLoginInfo({}, { showLoading: false });
+        if (res) {
+          // res.frontStatus = getUserCertificationFrontStatusAdapter(
+          //   res.userCertificationStatus,
+          //   res.userCertificationAuditStatus
+          // );
+          res.originalAvatar = res.avatar;
+          res.avatar = res.avatar ? setOSSLink(res.avatar) : DefaultAvatar;
+          this.setUserDetail(res);
+          this.firstGetUserDetail = false;
+        }
+      } catch (error) {}
     },
 
     setTokenAction(tokenInfo: API.LoginCommandCallback) {
@@ -217,7 +216,7 @@
       setUserInfo(this.userInfo);
     },
 
-    setUserDetail(detail: API.UserInfoV2) {
+    setUserDetail(detail: API.GetPersonalLoginInfoQueryResult) {
       this.userDetail = detail;
       setUserDetail(detail);
     },
diff --git a/apps/cMiniApp/src/utils/storage/auth.ts b/apps/cMiniApp/src/utils/storage/auth.ts
index ecf237f..d82d35c 100644
--- a/apps/cMiniApp/src/utils/storage/auth.ts
+++ b/apps/cMiniApp/src/utils/storage/auth.ts
@@ -29,10 +29,10 @@
 }
 
 export function getUserDetail() {
-  return storageLocal.getItem<API.UserInfoV2>(StorageKey.USER_DETAIL_KEY);
+  return storageLocal.getItem<API.GetPersonalLoginInfoQueryResult>(StorageKey.USER_DETAIL_KEY);
 }
 
-export function setUserDetail(userDetail: API.UserInfoV2) {
+export function setUserDetail(userDetail: API.GetPersonalLoginInfoQueryResult) {
   return storageLocal.setItem(StorageKey.USER_DETAIL_KEY, userDetail);
 }
 
diff --git a/packages/services/apiV2/typings.d.ts b/packages/services/apiV2/typings.d.ts
index e209d27..073461a 100644
--- a/packages/services/apiV2/typings.d.ts
+++ b/packages/services/apiV2/typings.d.ts
@@ -1936,6 +1936,7 @@
     avatar?: string;
     /** 濮撳悕 */
     name?: string;
+    gender?: EnumUserGender;
     /** 浼佷笟鍏ㄧО */
     enterpriseName?: string;
     /** 瑙掕壊 */
@@ -2324,6 +2325,8 @@
   interface GetPersonalLoginInfoQueryResult {
     /** Id */
     id?: string;
+    /** 澶村儚 */
+    avatar?: string;
     /** 濮撳悕 */
     name?: string;
     /** 鏄惁瀹炲悕 */
diff --git a/types/api.d.ts b/types/api.d.ts
index f610eb0..03f010b 100644
--- a/types/api.d.ts
+++ b/types/api.d.ts
@@ -20,13 +20,22 @@
      */
     frontStatus?: number
   }
-  interface UserInfoV2 {
+  interface GetEnterpriseLoginInfoQueryResult {
     /**
      * 鍓嶇鐢ㄤ簬鍒ゆ柇鐘舵�佺殑status
      */
     frontStatus?: number
     /**鎺ュ彛杩斿洖鐨勫師濮嬪ご鍍� */
-    originalAvatarUrl?: string
+    originalAvatar?: string
+  }
+
+  interface GetPersonalLoginInfoQueryResult {
+    /**
+     * 鍓嶇鐢ㄤ簬鍒ゆ柇鐘舵�佺殑status
+     */
+    frontStatus?: number
+    /**鎺ュ彛杩斿洖鐨勫師濮嬪ご鍍� */
+    originalAvatar?: string
   }
 
   interface SelectQueryResultOptionGuidGetDictionaryCategorySelectQueryOptionMap{

--
Gitblit v1.9.1