瀏覽代碼

refactor(app): 优化返回商城首页逻辑

- 移除固定后退层级,改为动态查找商城首页
- 若已打开商城首页,则直接返回该页面
- 若未打开商城首页,则跳转到商城首页
- 删除无用的 console.log 和空的 onLoad 函数
EvilDragon 4 月之前
父節點
當前提交
55b22b19c0
共有 1 個文件被更改,包括 9 次插入5 次删除
  1. 9 5
      packages/app/src/pages/home/mall/purchased/success/index.vue

+ 9 - 5
packages/app/src/pages/home/mall/purchased/success/index.vue

@@ -17,12 +17,16 @@ const handle2Orders = () => {
   router.replace('/pages/mine/orders/index')
 }
 const handle2Mall = () => {
-  // router.replace('/pages/home/mall/index')
-  router.back(2)
+  const pages = getCurrentPages()
+  const mallIndex = pages.findIndex((it) => it.route === 'pages/home/mall/index')
+  if (mallIndex > -1) {
+    console.log(pages.length - mallIndex - 1)
+    router.back(pages.length - mallIndex - 1)
+  } else {
+    router.replace('/pages/home/mall/index')
+  }
 }
-onLoad(() => {
-  console.log(getCurrentPages())
-})
+onLoad(() => {})
 </script>
 <template>
   <div class="flex-grow flex flex-col px-3.5 justify-center items-center gap-7 bg-white">