zhengyiming
2025-03-28 381c97332e567a1b95a9a5220275461d0ae3f74e
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;
}
@@ -54,20 +55,32 @@
  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) => {
    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({