| | |
| | | userInfo?: Nullable<API.LoginCommandCallback>; |
| | | token?: Nullable<string>; |
| | | refreshToken?: Nullable<string>; |
| | | userDetail?: Nullable<API.UserInfoV2>; |
| | | userDetail?: Nullable<API.GetPersonalLoginInfoQueryResult>; |
| | | firstGetUserDetail?: boolean; |
| | | |
| | | locationCity?: string; |
| | |
| | | }, |
| | | |
| | | userId: (state) => { |
| | | return state.userInfo?.id ?? ''; |
| | | return state.userDetail?.id ?? ''; |
| | | }, |
| | | }, |
| | | actions: { |
| | | // 手机号授权Code登录 |
| | | 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; |
| | |
| | | }, |
| | | |
| | | 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) { |
| | |
| | | setUserInfo(this.userInfo); |
| | | }, |
| | | |
| | | setUserDetail(detail: API.UserInfoV2) { |
| | | setUserDetail(detail: API.GetPersonalLoginInfoQueryResult) { |
| | | this.userDetail = detail; |
| | | setUserDetail(detail); |
| | | }, |
| | |
| | | */ |
| | | logout() { |
| | | this.resetState(); |
| | | myClient.removeQueries(); |
| | | // myClient.removeQueries(); |
| | | goAuthorization(); |
| | | }, |
| | | |