From 2c0d4143e3a3de21bddb5c8383513cc052c6a9dd Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 24 三月 2025 19:53:19 +0800
Subject: [PATCH] fix: 三期bug

---
 apps/taro/src/hooks/user.ts |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/apps/taro/src/hooks/user.ts b/apps/taro/src/hooks/user.ts
index dfabcc6..26d5535 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() {
@@ -95,11 +99,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();
@@ -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);
       }

--
Gitblit v1.9.1