zhengyiming
2025-03-24 c7ab8c4fca1c690f3e5536dff520eaa9c4010fd1
apps/taro/src/hooks/user.ts
@@ -6,7 +6,11 @@
import { useRefeshDidShow } from './infiniteLoading';
import { LoginFormTabs } from '@/subpackages/login/constants';
import { useLoginedJump } from './login';
import { useLifeRechargeContext, APIgetLifePayWxIndentityParams } from '@life-payment/core-vue';
import {
  useLifeRechargeContext,
  APIgetLifePayWxIndentityParams,
  WxMiniAppIndentityInfo,
} from '@life-payment/core-vue';
import { isInWeChat } from '@/utils/env';
export function useUser() {
@@ -101,6 +105,8 @@
  });
}
let wxIndentityPromise: Promise<WxMiniAppIndentityInfo>;
export function useLifePayWxIndentity() {
  const { blLifeRecharge } = useLifeRechargeContext();
  const userStore = useUserStore();
@@ -110,9 +116,17 @@
      let params: APIgetLifePayWxIndentityParams = {
        code: code,
      };
      let res = await blLifeRecharge.services.getLifePayWxIndentity(params, {
        showLoading: false,
      });
      if (!wxIndentityPromise) {
        wxIndentityPromise = blLifeRecharge.services
          .getLifePayWxIndentity(params, {
            showLoading: false,
          })
          .finally(() => {
            wxIndentityPromise = undefined;
          });
      }
      let res = await wxIndentityPromise;
      if (res.openId) {
        userStore.setWxOpenId(res.openId);
      }