From e3ae5da789eb35217a4a377cab0ff3241ceaf72a Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期一, 11 八月 2025 13:42:07 +0800
Subject: [PATCH] feat: 接口对接
---
apps/bMiniApp/src/stores/modules/user.ts | 53 +++++++++++++++--------------------------------------
1 files changed, 15 insertions(+), 38 deletions(-)
diff --git a/apps/bMiniApp/src/stores/modules/user.ts b/apps/bMiniApp/src/stores/modules/user.ts
index a2cf9cf..78f699f 100644
--- a/apps/bMiniApp/src/stores/modules/user.ts
+++ b/apps/bMiniApp/src/stores/modules/user.ts
@@ -8,9 +8,6 @@
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';
@@ -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.LoginCommandCallback>;
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;
},
@@ -127,11 +118,13 @@
},
// 鐢ㄦ埛鎵嬫満楠岃瘉鐮佺櫥鍏�
- async loginByUsername(data: API.PhoneMesssageCodeLoginInput) {
- let res = await accountServices.phoneMesssageCodeLogin(
+ async loginByUsername(data: API.SmsLoginCommand) {
+ let res = await authServices.smsLogin(
{
phoneNumber: data.phoneNumber,
- code: data.code,
+ verifyCode: data.verifyCode,
+ type: AppLocalConfig.userType,
+ clientType: AppLocalConfig.clientType,
},
{ showLoading: false }
);
@@ -143,11 +136,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 }
);
@@ -234,7 +229,6 @@
this.userDetail = null;
removeUserInfo();
removeUserDetail();
- removeMatchMakingIdentity();
},
/**
@@ -268,23 +262,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