From 28a1ee009fdeb6bbd71e8263be704e2988204e04 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期日, 19 十月 2025 19:50:53 +0800
Subject: [PATCH] feat: 1.2.0.1
---
apps/bMiniApp/src/stores/modules/user.ts | 107 +++++++++++++++++++++++++++--------------------------
1 files changed, 54 insertions(+), 53 deletions(-)
diff --git a/apps/bMiniApp/src/stores/modules/user.ts b/apps/bMiniApp/src/stores/modules/user.ts
index 78f699f..58c2255 100644
--- a/apps/bMiniApp/src/stores/modules/user.ts
+++ b/apps/bMiniApp/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.GetEnterpriseLoginInfoQueryResult>;
firstGetUserDetail?: boolean;
locationCity?: string;
@@ -88,6 +85,10 @@
return getAccountInfoFromAccessToken(this.userInfo?.accessToken);
},
+ userId: (state) => {
+ return state.userDetail?.id;
+ },
+
// matchMakingIdentity(state): MatchMakingIdentityEnum {
// },
@@ -96,19 +97,18 @@
// 鎵嬫満鍙锋巿鏉僀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;
@@ -140,7 +140,8 @@
let res = await authServices.passwordLogin(
{
userName: params.userName,
- password: md5Encrypt(params.password),
+ password: params.password,
+ // password: md5Encrypt(params.password),
type: AppLocalConfig.userType,
clientType: AppLocalConfig.clientType,
},
@@ -156,20 +157,20 @@
try {
this.setUserInfoAction(res);
this.setTokenAction(res);
- // await this.getCurrentUserInfo();
+ await this.getCurrentUserInfo();
} catch (error) {}
},
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,35 +178,35 @@
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) {}
- // },
+ 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;
@@ -217,7 +218,7 @@
setUserInfo(info);
},
- setUserDetail(detail: API.UserInfoV2) {
+ setUserDetail(detail: API.GetEnterpriseLoginInfoQueryResult) {
this.userDetail = detail;
setUserDetail(detail);
},
@@ -236,7 +237,7 @@
*/
logout() {
this.resetState();
- myClient.removeQueries();
+ // myClient.removeQueries();
goAuthorization();
},
--
Gitblit v1.9.1