| | |
| | | import Taro from '@tarojs/taro'; |
| | | import { TabBarPageRouter } from '@/constants'; |
| | | import { TabBarPageRouterForCheck } from '@/constants'; |
| | | import { useSystemStore } from '@/stores/modules/system'; |
| | | import { useAppStore } from '@/stores/modules/app'; |
| | | 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(); |
| | | |
| | | const switchTab = (option: Taro.switchTab.Option) => { |
| | | const index = Object.values(TabBarPageRouter).findIndex((x) => option.url.includes(x)); |
| | | 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; |
| | | } |
| | |
| | | export function useTabRouteEnhance() { |
| | | const appStore = useAppStore(); |
| | | const { latestRoute } = storeToRefs(appStore); |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | |
| | | const router = Taro.useRouter(); |
| | | |
| | | const channelId = router.params?.channelId ?? ''; |
| | | console.log('router: params', router, blLifeRecharge.accountModel.channlesNum); |
| | | |
| | | Taro.useDidShow(() => { |
| | | const isTabbarPage = Object.values(TabBarPageRouter).some((x) => |
| | | console.log('latestRoute.value: ', latestRoute.value); |
| | | const isTabbarPage = Object.values(TabBarPageRouterForCheck).some((x) => |
| | | latestRoute.value.toLowerCase().includes(x.toLowerCase()) |
| | | ); |
| | | if (isTabbarPage) { |
| | | const currentIsTabbarPage = Object.values(TabBarPageRouterForCheck).some((x) => |
| | | getRouterPath(router.path).toLowerCase().includes(x.toLowerCase()) |
| | | ); |
| | | console.log('currentIsTabbarPage: ', currentIsTabbarPage); |
| | | if (currentIsTabbarPage && blLifeRecharge.accountModel.channlesNum && !channelId) { |
| | | Taro.reLaunch({ |
| | | url: pathAddExtraParam(router.path, { channelId: blLifeRecharge.accountModel.channlesNum }), |
| | | success() { |
| | | appStore.setLatestRoute(''); |
| | | }, |
| | | }); |
| | | return; |
| | | } |
| | | if (isTabbarPage && isInAlipay) { |
| | | Taro.reLaunch({ |
| | | url: router.path, |
| | | success() { |