zhengyiming
2025-02-21 a3be4bd8a96df6b27e4f0d3883d661d9cb64d1fc
apps/taro/src/stores/modules/user.ts
@@ -8,6 +8,9 @@
  setUserDetail,
  getUserDetail,
  removeUserDetail,
  setStorageVirtualUserId,
  getStorageVirtualUserId,
  removeStorageVirtualUserId,
} from '@/utils/storage/auth';
import * as accountServices from '@life-payment/services/api/Account';
import * as userServices from '@life-payment/services/api/User';
@@ -29,6 +32,8 @@
  locationCity?: string;
  locationProvince?: string;
  firstSetLocation?: boolean;
  virtualUserId?: string;
}
const goAuthorization = debounce(
@@ -62,6 +67,8 @@
      refreshToken: userInfo?.refreshToken ?? '',
      userDetail: userDetail,
      firstGetUserDetail: true,
      virtualUserId: getStorageVirtualUserId() ?? '',
    };
  },
  getters: {
@@ -113,7 +120,7 @@
    // 用户手机验证码登入
    async loginByUsername(data: API.PhoneMesssageCodeLoginInput) {
      let res = await accountServices.phoneMesssageCodeLogin(
      let res = await accountServices.lifePayPhoneMesssageCodeLogin(
        {
          phoneNumber: data.phoneNumber,
          code: data.code,
@@ -122,7 +129,7 @@
      );
      if (res) {
        this.loginSuccess(res);
        this.loginVirtualSuccess(res);
      }
      return res;
    },
@@ -143,11 +150,23 @@
    },
    async loginSuccess(res: API.IdentityModelTokenCacheItem) {
      console.log('res: ', res);
      try {
        this.setUserInfoAction(res);
        this.setTokenAction(res);
        await this.getCurrentUserInfo();
      } catch (error) {}
    },
    async loginVirtualSuccess(virtualUserId: string) {
      try {
        this.setVirtualUserId(virtualUserId);
      } catch (error) {}
    },
    setVirtualUserId(virtualUserId: string) {
      this.virtualUserId = virtualUserId;
      setStorageVirtualUserId(virtualUserId);
    },
    async wxMiniAppUserLoginFromScan(wxIndentityRes: API.WxMiniAppIndentityInfo, uuid: string) {
@@ -215,6 +234,7 @@
      this.userDetail = null;
      removeUserInfo();
      removeUserDetail();
      removeStorageVirtualUserId();
    },
    /**