From e47c70d32e6fa7c9cb16ca19a79338ea36a83e94 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期二, 10 六月 2025 16:38:37 +0800 Subject: [PATCH] fix: v1.4 --- apps/taro/src/hooks/router.ts | 25 ++++++++++++++++++++----- 1 files changed, 20 insertions(+), 5 deletions(-) diff --git a/apps/taro/src/hooks/router.ts b/apps/taro/src/hooks/router.ts index d571b8f..a7400ce 100644 --- a/apps/taro/src/hooks/router.ts +++ b/apps/taro/src/hooks/router.ts @@ -5,6 +5,7 @@ import { isInAlipay } from '@/utils/env'; import { useLifeRechargeContext } from '@life-payment/core-vue'; import { getRouterPath } from '@life-payment/utils'; +import { pathAddExtraParam } from '@/utils'; export function useSwitchTab() { const systemStore = useSystemStore(); @@ -13,7 +14,7 @@ const index = Object.values(TabBarPageRouterForCheck).findIndex((x) => option.url.includes(x)); console.log('index: ', index); systemStore.setTabIndex(index); - Taro.switchTab(option); + RouteHelper.switchTab(option); }; return switchTab; } @@ -50,24 +51,38 @@ const appStore = useAppStore(); const { latestRoute } = storeToRefs(appStore); const { blLifeRecharge } = useLifeRechargeContext(); + const system = useSystemStore(); const router = Taro.useRouter(); const channelId = router.params?.channelId ?? ''; - console.log('router.params: ', router); + console.log('router: params', router, blLifeRecharge.accountModel.channlesNum); + + Taro.useTabItemTap((item) => { + system.setTabIndex(item.index as any); + Taro.reLaunch({ + url: pathAddExtraParam(item.pagePath, { channelId: blLifeRecharge.accountModel.channlesNum }), + success() { + appStore.setLatestRoute(''); + }, + }); + }); Taro.useDidShow(() => { const isTabbarPage = Object.values(TabBarPageRouterForCheck).some((x) => latestRoute.value.toLowerCase().includes(x.toLowerCase()) ); - // if (blLifeRecharge.accountModel.channlesNum && !channelId) { + // const currentIsTabbarPage = Object.values(TabBarPageRouterForCheck).some((x) => + // getRouterPath(router.path).toLowerCase().includes(x.toLowerCase()) + // ); + // if (currentIsTabbarPage && blLifeRecharge.accountModel.channlesNum && !channelId) { // Taro.reLaunch({ - // // url: `${getRouterPath(router.path)}?channelId=${blLifeRecharge.accountModel.channlesNum}`, - // url: `${router.path}&channelId=${blLifeRecharge.accountModel.channlesNum}`, + // url: pathAddExtraParam(router.path, { channelId: blLifeRecharge.accountModel.channlesNum }), // success() { // appStore.setLatestRoute(''); // }, // }); + // return; // } if (isTabbarPage && isInAlipay) { Taro.reLaunch({ -- Gitblit v1.9.1