From 7ed1e4f30ba4d8204152cb157ceaee07374da080 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期一, 17 三月 2025 14:29:14 +0800
Subject: [PATCH] fix: 修改支付方式选择

---
 apps/taro/src/utils/page.ts |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/apps/taro/src/utils/page.ts b/apps/taro/src/utils/page.ts
index 8670a6f..1d45c4e 100644
--- a/apps/taro/src/utils/page.ts
+++ b/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();
@@ -10,7 +12,7 @@
   if (pages.length > 1) {
     Taro.navigateBack({ delta: delta });
   } else {
-    Taro.switchTab({
+    RouteHelper.switchTab({
       url: Object.values(TabBarPageRouter)[systemStore.activeTab],
     });
   }
@@ -19,7 +21,44 @@
 export function goHome() {
   const systemStore = useSystemStoreWithOut();
   systemStore.setTabIndex(0);
-  Taro.switchTab({
+  RouteHelper.switchTab({
     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) {
+    return Taro.navigateTo({
+      ...option,
+      url: pathAddExtraParam(option.url, { channelId: blLifeRecharge.accountModel.channlesNum }),
+    });
+  }
+
+  static redirectTo(option: Taro.redirectTo.Option) {
+    return Taro.redirectTo({
+      ...option,
+      url: pathAddExtraParam(option.url, { channelId: blLifeRecharge.accountModel.channlesNum }),
+    });
+  }
+}

--
Gitblit v1.9.1