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/cMiniApp/src/stores/modules/user.ts |  103 +++++++++++++++++++++++++--------------------------
 1 files changed, 51 insertions(+), 52 deletions(-)

diff --git a/apps/cMiniApp/src/stores/modules/user.ts b/apps/cMiniApp/src/stores/modules/user.ts
index 21cf5ab..1606ae7 100644
--- a/apps/cMiniApp/src/stores/modules/user.ts
+++ b/apps/cMiniApp/src/stores/modules/user.ts
@@ -9,8 +9,6 @@
   getUserDetail,
   removeUserDetail,
 } from '@/utils/storage/auth';
-import * as accountServices from '@12333/services/api/Account';
-import * as userServices from '@12333/services/api/User';
 import Taro, { useRouter } from '@tarojs/taro';
 import { ButtonProps } from '@tarojs/components';
 import { debounce } from 'lodash';
@@ -24,7 +22,6 @@
   md5Encrypt,
 } from '@12333/utils';
 import DefaultAvatar from '@/assets/components/icon-default-avatar.png';
-import { WxMiniAppEnum } from '@12333/constants';
 import { myClient } from '@/constants/query';
 import { globalEventEmitter } from '@12333/hooks';
 import * as authServices from '@12333/services/apiV2/auth';
@@ -34,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;
@@ -89,26 +86,25 @@
     },
 
     userId: (state) => {
-      return state.userInfo?.id ?? '';
+      return state.userDetail?.id ?? '';
     },
   },
   actions: {
     // 鎵嬫満鍙锋巿鏉僀ode鐧诲綍
     async getTokenByPhone(
       detail: ButtonProps.onGetPhoneNumberEventDetail,
-      wxMiniAppUserLoginRes: any
+      wxMiniAppUserLoginRes: API.LoginCommandCallback
     ) {
       try {
-        let res: API.IdentityModelTokenCacheItem;
-        if (!wxMiniAppUserLoginRes.accessToken) {
-          let params: API.WxMiniAppPhoneLoginInput = {
-            openId: wxMiniAppUserLoginRes.openId,
-            sessionKey: wxMiniAppUserLoginRes.sessionKey,
+        let res: API.LoginCommandCallback = wxMiniAppUserLoginRes;
+        if (!wxMiniAppUserLoginRes?.isBindPhoneNumber) {
+          let bindRes = await authServices.bindWxmpUserInfo({
             encryptedData: detail.encryptedData,
             iv: detail.iv,
-            wxMiniApp: WxMiniAppEnum.C绔皬绋嬪簭,
-          };
-          res = await accountServices.wxMiniAppPhoneAuthLogin(params);
+            sessionKey: wxMiniAppUserLoginRes.sessionKey,
+            accessToken: wxMiniAppUserLoginRes.accessToken,
+          });
+          res.accessToken = bindRes.accessToken;
           this.loginSuccess(res);
         }
         return res;
@@ -161,15 +157,15 @@
     },
 
     async wxMiniAppUserLoginFromScan(wxIndentityRes: API.WxMiniAppIndentityInfo, uuid: string) {
-      try {
-        let res = await accountServices.wxMiniAppUserLoginFromScan({
-          uId: uuid,
-          userName: wxIndentityRes.userName,
-          openId: wxIndentityRes.openId,
-        });
-        this.loginSuccess(res);
-        return res;
-      } catch (error) {}
+      // try {
+      //   let res = await accountServices.wxMiniAppUserLoginFromScan({
+      //     uId: uuid,
+      //     userName: wxIndentityRes.userName,
+      //     openId: wxIndentityRes.openId,
+      //   });
+      //   this.loginSuccess(res);
+      //   return res;
+      // } catch (error) {}
     },
 
     async wxMiniAppPhoneAuthLoginFromScan(
@@ -177,34 +173,34 @@
       wxIndentityRes: API.WxMiniAppIndentityInfo,
       uuid: string
     ) {
-      try {
-        let res = await accountServices.wxMiniAppPhoneAuthLoginFromScan({
-          uId: uuid,
-          openId: wxIndentityRes.openId,
-          sessionKey: wxIndentityRes.sessionKey,
-          encryptedData: detail.encryptedData,
-          iv: detail.iv,
-          wxMiniApp: WxMiniAppEnum.C绔皬绋嬪簭,
-        });
-        this.loginSuccess(res);
-        return res;
-      } catch (error) {}
+      // try {
+      //   let res = await accountServices.wxMiniAppPhoneAuthLoginFromScan({
+      //     uId: uuid,
+      //     openId: wxIndentityRes.openId,
+      //     sessionKey: wxIndentityRes.sessionKey,
+      //     encryptedData: detail.encryptedData,
+      //     iv: detail.iv,
+      //     wxMiniApp: WxMiniAppEnum.C绔皬绋嬪簭,
+      //   });
+      //   this.loginSuccess(res);
+      //   return res;
+      // } 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) {}
+      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) {
@@ -213,11 +209,14 @@
     },
 
     setUserInfoAction(info: API.LoginCommandCallback) {
-      this.userInfo = info;
-      setUserInfo(info);
+      this.userInfo = {
+        ...this.userInfo,
+        ...info,
+      };
+      setUserInfo(this.userInfo);
     },
 
-    setUserDetail(detail: API.UserInfoV2) {
+    setUserDetail(detail: API.GetPersonalLoginInfoQueryResult) {
       this.userDetail = detail;
       setUserDetail(detail);
     },
@@ -236,7 +235,7 @@
      */
     logout() {
       this.resetState();
-      myClient.removeQueries();
+      // myClient.removeQueries();
       goAuthorization();
     },
 

--
Gitblit v1.9.1