From 84bbc4a13aa8283aa417182376e1eb0024596582 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期五, 08 八月 2025 16:38:00 +0800
Subject: [PATCH] feat: 接口对接
---
apps/bMiniApp/src/stores/modules/user.ts | 83 ++++++++++++++---------------------------
1 files changed, 29 insertions(+), 54 deletions(-)
diff --git a/apps/bMiniApp/src/stores/modules/user.ts b/apps/bMiniApp/src/stores/modules/user.ts
index 9425112..2643b91 100644
--- a/apps/bMiniApp/src/stores/modules/user.ts
+++ b/apps/bMiniApp/src/stores/modules/user.ts
@@ -8,12 +8,9 @@
setUserDetail,
getUserDetail,
removeUserDetail,
- removeMatchMakingIdentity,
- getMatchMakingIdentity,
- setMatchMakingIdentity,
} from '@/utils/storage/auth';
import * as accountServices from '@12333/services/api/Account';
-import * as userServices from '@12333/services/api/User';
+// import * as userServices from '@12333/services/api/User';
import Taro, { useRouter } from '@tarojs/taro';
import { ButtonProps } from '@tarojs/components';
import { debounce } from 'lodash';
@@ -24,14 +21,17 @@
setOSSLink,
getUserCertificationFrontStatusAdapter,
LocationUtils,
+ 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';
+import { AppLocalConfig } from '@/constants';
interface UserState {
- userInfo?: Nullable<API.IdentityModelTokenCacheItem>;
+ userInfo?: Nullable<API.PasswordLoginCommandCallback>;
token?: Nullable<string>;
refreshToken?: Nullable<string>;
userDetail?: Nullable<API.UserInfoV2>;
@@ -80,15 +80,6 @@
};
},
getters: {
- cacheToken: (state) => {
- if (!state.token) {
- const storageToken = getCacheToken() as API.IdentityModelTokenCacheItem;
-
- state.token = storageToken.accessToken;
- }
- return state.token || null;
- },
-
cacheRefreshToken: (state) => {
return state.refreshToken;
},
@@ -115,7 +106,7 @@
sessionKey: wxMiniAppUserLoginRes.sessionKey,
encryptedData: detail.encryptedData,
iv: detail.iv,
- wxMiniApp: WxMiniAppEnum.浜哄崟鍚堜竴,
+ wxMiniApp: WxMiniAppEnum.C绔皬绋嬪簭,
};
res = await accountServices.wxMiniAppPhoneAuthLogin(params);
this.loginSuccess(res);
@@ -143,11 +134,13 @@
},
// 鐢ㄦ埛璐﹀彿瀵嗙爜鐧诲叆
- async loginByPassword(data: API.AccessRequestDto) {
- let res = await accountServices.passwordLogin(
+ async loginByPassword(params: API.PasswordLoginCommand) {
+ let res = await authServices.passwordLogin(
{
- loginName: data.userName,
- password: data.userPassword,
+ userName: params.userName,
+ password: md5Encrypt(params.password),
+ type: AppLocalConfig.userType,
+ clientType: AppLocalConfig.clientType,
},
{ showLoading: false }
);
@@ -161,7 +154,7 @@
try {
this.setUserInfoAction(res);
this.setTokenAction(res);
- await this.getCurrentUserInfo();
+ // await this.getCurrentUserInfo();
} catch (error) {}
},
@@ -189,28 +182,28 @@
sessionKey: wxIndentityRes.sessionKey,
encryptedData: detail.encryptedData,
iv: detail.iv,
- wxMiniApp: WxMiniAppEnum.浜哄崟鍚堜竴,
+ 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 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) {}
+ // },
setTokenAction(tokenInfo: API.IdentityModelTokenCacheItem) {
this.token = tokenInfo?.accessToken;
@@ -234,7 +227,6 @@
this.userDetail = null;
removeUserInfo();
removeUserDetail();
- removeMatchMakingIdentity();
},
/**
@@ -268,23 +260,6 @@
Taro.redirectTo({
url: `/packageLogin/authLogin/index`,
});
- }
- },
-
- async getTokenByRefreshToken(params: API.AccessRefreshToken) {
- try {
- const res = await accountServices.getTokenByRefreshToken(params, {
- showLoading: false,
- });
- if (res) {
- this.setTokenAction(res);
- this.setUserInfoAction(res);
- return res;
- } else {
- throw new Error('鍒锋柊token澶辫触');
- }
- } catch (error) {
- throw new Error('error');
}
},
--
Gitblit v1.9.1