zhengyiming
2025-03-13 a1dfc1313e0bf9647c7d3a4046d62cf242177276
fix: 二期需求
8个文件已修改
86 ■■■■ 已修改文件
apps/taro/.eslintrc-auto-import.json 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/auto-imports.d.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/config/index.js 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/components/Policy/Policy.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/hooks/router.ts 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/pages/mine/index.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/order/order/InnerPage.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/utils/page.ts 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/.eslintrc-auto-import.json
@@ -89,6 +89,7 @@
    "useTemplateRef": true,
    "DirectiveBinding": true,
    "MaybeRef": true,
    "MaybeRefOrGetter": true
    "MaybeRefOrGetter": true,
    "RouteHelper": true
  }
}
apps/taro/auto-imports.d.ts
@@ -6,6 +6,7 @@
export {}
declare global {
  const EffectScope: typeof import('vue')['EffectScope']
  const RouteHelper: typeof import('@/utils')['RouteHelper']
  const RouterPath: typeof import('@/constants')['RouterPath']
  const acceptHMRUpdate: typeof import('pinia')['acceptHMRUpdate']
  const computed: typeof import('vue')['computed']
apps/taro/config/index.js
@@ -116,7 +116,13 @@
      chain.plugin('unplugin-auto-import').use(
        AutoImport({
          imports: ['vue', 'pinia', 'vue-router', { '@/constants': ['RouterPath'] }],
          imports: [
            'vue',
            'pinia',
            'vue-router',
            { '@/constants': ['RouterPath'] },
            { '@/utils': ['RouteHelper'] },
          ],
          eslintrc: {
            enabled: true, // Default `false`
            filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
@@ -230,7 +236,13 @@
    webpackChain(chain, webpack) {
      chain.plugin('unplugin-auto-import').use(
        AutoImport({
          imports: ['vue', 'pinia', 'vue-router', { '@/constants': ['RouterPath'] }],
          imports: [
            'vue',
            'pinia',
            'vue-router',
            { '@/constants': ['RouterPath'] },
            { '@/utils': ['RouteHelper'] },
          ],
          eslintrc: {
            enabled: true, // Default `false`
            filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
apps/taro/src/components/Policy/Policy.vue
@@ -38,7 +38,7 @@
});
function goPolicy() {
  Taro.navigateTo({
  RouteHelper.navigateTo({
    url: RouterPath.userPolicy,
  });
}
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();
@@ -54,21 +55,26 @@
  const router = Taro.useRouter();
  const channelId = router.params?.channelId ?? '';
  console.log('router.params: ', router);
  console.log('router: params', router, blLifeRecharge.accountModel.channlesNum);
  Taro.useDidShow(() => {
    console.log('latestRoute.value: ', latestRoute.value);
    const isTabbarPage = Object.values(TabBarPageRouterForCheck).some((x) =>
      latestRoute.value.toLowerCase().includes(x.toLowerCase())
    );
    // if (blLifeRecharge.accountModel.channlesNum && !channelId) {
    //   Taro.reLaunch({
    //     // url: `${getRouterPath(router.path)}?channelId=${blLifeRecharge.accountModel.channlesNum}`,
    //     url: `${router.path}&channelId=${blLifeRecharge.accountModel.channlesNum}`,
    //     success() {
    //       appStore.setLatestRoute('');
    //     },
    //   });
    // }
    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,
apps/taro/src/pages/mine/index.vue
@@ -56,7 +56,7 @@
}
function goPage(routeName: string) {
  Taro.navigateTo({
  RouteHelper.navigateTo({
    url: routeName,
  });
}
apps/taro/src/subpackages/order/order/InnerPage.vue
@@ -23,7 +23,7 @@
const orderType = ref('1');
function goApplyRefund(id: string) {
  Taro.navigateTo({
  RouteHelper.navigateTo({
    url: `${RouterPath.orderApplyRefund}?id=${id}`,
    // events: {
    //   submitApplyRefund: function () {},
@@ -31,7 +31,7 @@
  });
}
function goRefundDetail(orderNo: string) {
  Taro.navigateTo({
  RouteHelper.navigateTo({
    url: `${RouterPath.orderRefundResult}?orderNo=${orderNo}`,
  });
}
apps/taro/src/utils/page.ts
@@ -1,6 +1,8 @@
import { TabBarPageRouter } from '@/constants';
import Taro from '@tarojs/taro';
import { useSystemStoreWithOut } from '@/stores/modules/system';
import { query2object, object2query } from '@life-payment/utils';
import { blLifeRecharge } from './blLifeRecharge';
export function goBack(delta = 1) {
  const pages = Taro.getCurrentPages();
@@ -23,3 +25,33 @@
    url: TabBarPageRouter['Home'],
  });
}
export function pathAddExtraParam(path: string, object: Record<string, string | number>) {
  console.log('path: ', path, object);
  const pathList = path.split('?');
  if (pathList.length > 1) {
    const query = query2object(pathList[1]);
    for (const key in object) {
      query[key] = object[key] as any;
    }
    return `${pathList[0]}?${object2query(query)}`;
  } else {
    return `${pathList[0]}?${object2query(object)}`;
  }
}
export class RouteHelper {
  static switchTab(option: Taro.switchTab.Option) {
    return Taro.switchTab({
      ...option,
      url: pathAddExtraParam(option.url, { channelId: blLifeRecharge.accountModel.channlesNum }),
    });
  }
  static navigateTo(option: Taro.navigateTo.Option) {
    Taro.navigateTo({
      ...option,
      url: pathAddExtraParam(option.url, { channelId: blLifeRecharge.accountModel.channlesNum }),
    });
  }
}