| | |
| | | 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'; |
| | |
| | | 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'; |
| | |
| | | // 手机号授权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, |
| | | }); |
| | | res.accessToken = bindRes.accessToken; |
| | | this.loginSuccess(res); |
| | | } |
| | | return res; |
| | |
| | | }, |
| | | |
| | | 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( |
| | |
| | | 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() { |
| | |
| | | }, |
| | | |
| | | setUserInfoAction(info: API.LoginCommandCallback) { |
| | | this.userInfo = info; |
| | | setUserInfo(info); |
| | | this.userInfo = { |
| | | ...this.userInfo, |
| | | ...info, |
| | | }; |
| | | setUserInfo(this.userInfo); |
| | | }, |
| | | |
| | | setUserDetail(detail: API.UserInfoV2) { |