From 92264a516c8c695c38d4cc9358c50bcfbed36f06 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期三, 03 九月 2025 14:00:15 +0800 Subject: [PATCH] fix: bug --- apps/cMiniApp/src/stores/modules/user.ts | 60 +++++++++++++++++++++++++++++++++--------------------------- 1 files changed, 33 insertions(+), 27 deletions(-) diff --git a/apps/cMiniApp/src/stores/modules/user.ts b/apps/cMiniApp/src/stores/modules/user.ts index 39b8df7..cf8e0bf 100644 --- a/apps/cMiniApp/src/stores/modules/user.ts +++ b/apps/cMiniApp/src/stores/modules/user.ts @@ -31,8 +31,9 @@ userInfo?: Nullable<API.LoginCommandCallback>; token?: Nullable<string>; refreshToken?: Nullable<string>; - userDetail?: Nullable<API.UserInfoV2>; + userDetail?: Nullable<API.GetPersonalLoginInfoQueryResult>; firstGetUserDetail?: boolean; + firstLaunch?: boolean; locationCity?: string; locationProvince?: string; @@ -71,6 +72,7 @@ refreshToken: userInfo?.refreshToken ?? '', userDetail: userDetail, firstGetUserDetail: true, + firstLaunch: true, locationCity: storageLocation?.city ?? '鍖椾含甯�', locationProvince: storageLocation?.province ?? '鍖椾含', firstSetLocation: true, @@ -86,26 +88,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; @@ -137,7 +138,8 @@ let res = await authServices.passwordLogin( { userName: params.userName, - password: md5Encrypt(params.password), + // password: md5Encrypt(params.password), + password: params.password, type: AppLocalConfig.userType, clientType: AppLocalConfig.clientType, }, @@ -189,19 +191,19 @@ }, 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) { @@ -217,7 +219,7 @@ setUserInfo(this.userInfo); }, - setUserDetail(detail: API.UserInfoV2) { + setUserDetail(detail: API.GetPersonalLoginInfoQueryResult) { this.userDetail = detail; setUserDetail(detail); }, @@ -236,7 +238,7 @@ */ logout() { this.resetState(); - myClient.removeQueries(); + // myClient.removeQueries(); goAuthorization(); }, @@ -277,6 +279,10 @@ // } LocationUtils.currentProvinceName = provinceName; }, + + setFirstLaunch(firstLaunch: boolean) { + this.firstLaunch = firstLaunch; + }, }, }); -- Gitblit v1.9.1