From 538e4f454ba3126ef92278ab9cb675adb9e3b287 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期四, 27 三月 2025 09:30:55 +0800 Subject: [PATCH] Merge branch 'master' into dev-1.3 --- apps/taro/src/hooks/user.ts | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-) diff --git a/apps/taro/src/hooks/user.ts b/apps/taro/src/hooks/user.ts index 757a837..711c45e 100644 --- a/apps/taro/src/hooks/user.ts +++ b/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() { @@ -26,7 +30,7 @@ return userStore.getCurrentUserInfo(); } - const isChannelAccount = computed(() => true); + const isChannelAccount = computed(() => !!virtualUserId.value && true); return { user: userInfo, @@ -98,11 +102,13 @@ } if (!!code && !wxCode.value) { userStore.setWxCode(router.params.code ?? ''); - // getLifePayWxIndentity(code); + getLifePayWxIndentity(code); } } catch (error) {} }); } + +let wxIndentityPromise: Promise<WxMiniAppIndentityInfo>; export function useLifePayWxIndentity() { const { blLifeRecharge } = useLifeRechargeContext(); @@ -113,9 +119,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); } -- Gitblit v1.9.1