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

---
 apps/bMiniApp/src/stores/modules/user.ts |   47 ++++++++++++++++++++++++++---------------------
 1 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/apps/bMiniApp/src/stores/modules/user.ts b/apps/bMiniApp/src/stores/modules/user.ts
index 43999ef..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;
@@ -85,6 +85,10 @@
       return getAccountInfoFromAccessToken(this.userInfo?.accessToken);
     },
 
+    userId: (state) => {
+      return state.userDetail?.id;
+    },
+
     // matchMakingIdentity(state): MatchMakingIdentityEnum {
 
     // },
@@ -97,15 +101,16 @@
     ) {
       try {
         let res: API.LoginCommandCallback = wxMiniAppUserLoginRes;
-        if (!wxMiniAppUserLoginRes.isBindPhoneNumber) {
+        if (!wxMiniAppUserLoginRes?.isBindPhoneNumber) {
           let bindRes = await authServices.bindWxmpUserInfo({
             encryptedData: detail.encryptedData,
             iv: detail.iv,
             sessionKey: wxMiniAppUserLoginRes.sessionKey,
+            accessToken: wxMiniAppUserLoginRes.accessToken,
           });
           res.accessToken = bindRes.accessToken;
+          this.loginSuccess(res);
         }
-        this.loginSuccess(res);
         return res;
       } catch (error) {
         console.log('error3: ', error);
@@ -151,7 +156,7 @@
       try {
         this.setUserInfoAction(res);
         this.setTokenAction(res);
-        // await this.getCurrentUserInfo();
+        await this.getCurrentUserInfo();
       } catch (error) {}
     },
 
@@ -186,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;
@@ -212,7 +217,7 @@
       setUserInfo(info);
     },
 
-    setUserDetail(detail: API.UserInfoV2) {
+    setUserDetail(detail: API.GetEnterpriseLoginInfoQueryResult) {
       this.userDetail = detail;
       setUserDetail(detail);
     },
@@ -231,7 +236,7 @@
      */
     logout() {
       this.resetState();
-      myClient.removeQueries();
+      // myClient.removeQueries();
       goAuthorization();
     },
 

--
Gitblit v1.9.1