li.shaoyi 2 years ago
parent
commit
1edc76f843

+ 6 - 4
src/packages/gstj/views/home/Index.vue

@@ -25,7 +25,7 @@ import plus from '@/utils/h5plus'
 import AppTabbar from '@mobile/components/base/tabbar/index.vue'
 import RouterTransition from '@mobile/components/base/router-transition/index.vue'
 
-const { route, routerTo, getGlobalUrlParams } = useNavigation()
+const { route, routerTo, getGlobalUrlParams, setGlobalUrlParams } = useNavigation()
 const { userLogin } = useLogin()
 const loginStore = useLoginStore()
 const cssTransition = shallowRef(true) // 是否使用css动画
@@ -157,10 +157,12 @@ watch(() => route.name, () => {
   } else if (tabIndex.value > -1) {
     onTabClick(tabIndex.value)
   } else {
-    nextTick(() => {
-      cssTransition.value = true
-    })
+    // 如果参数不是 tabIndex ,需要保留到下一个路由
+    setGlobalUrlParams(params)
   }
+  nextTick(() => {
+    cssTransition.value = true
+  })
 })
 </script>
 

+ 2 - 1
src/packages/mobile/router/navigation.ts

@@ -27,8 +27,9 @@ export function useNavigation() {
         }
     }
 
-    // 获取参数字符串
+    // 获取参数字符串----废弃待优化
     const getParamString = (name: string) => {
+        // https://github.com/vuejs/router/releases/tag/v4.1.0
         return route.params[name] ?? ''
     }
 

+ 2 - 3
src/packages/mobile/views/ballot/detail/Index.vue

@@ -71,10 +71,9 @@ const componentMap = new Map<string, unknown>([
     ['delisting', defineAsyncComponent(() => import('./components/delisting/index.vue'))], // 摘牌
 ])
 
-const { getParamString } = useNavigation()
+const { getGlobalUrlParams } = useNavigation()
 const { componentRef, componentId, openComponent, closeComponent } = useComponent()
-const qs = getParamString('item')
-const detail: Model.PresaleAuctionsRsp = JSON.parse(qs.toString() || '{}')
+const detail: Model.PresaleAuctionsRsp = getGlobalUrlParams()
 
 // 商品banner
 const detailBanners = computed(() => {

+ 3 - 2
src/packages/mobile/views/ballot/list/Index.vue

@@ -95,7 +95,7 @@ defineProps({
 })
 
 const isWaterfall = shallowRef(false)
-const { router } = useNavigation()
+const { router, setGlobalUrlParams } = useNavigation()
 const bannerList = shallowRef<string[]>([])
 
 const { dataList } = useRequest(queryPresaleAuctions, {
@@ -128,7 +128,8 @@ const onBannerClick = (index: number) => {
 
 // 打开详情页
 const toDetail = (item: Model.PresaleAuctionsRsp) => {
-    router.push({ name: 'ballot-detail', params: { item: JSON.stringify(item) } })
+    setGlobalUrlParams(item)
+    router.push({ name: 'ballot-detail' })
 }
 </script>
 

+ 6 - 4
src/packages/mobile/views/home/Index.vue

@@ -25,7 +25,7 @@ import plus from '@/utils/h5plus'
 import AppTabbar from '@mobile/components/base/tabbar/index.vue'
 import RouterTransition from '@mobile/components/base/router-transition/index.vue'
 
-const { route, routerTo, getGlobalUrlParams } = useNavigation()
+const { route, routerTo, getGlobalUrlParams, setGlobalUrlParams } = useNavigation()
 const { userLogin } = useLogin()
 const loginStore = useLoginStore()
 const cssTransition = shallowRef(true) // 是否使用css动画
@@ -157,10 +157,12 @@ watch(() => route.name, () => {
   } else if (tabIndex.value > -1) {
     onTabClick(tabIndex.value)
   } else {
-    nextTick(() => {
-      cssTransition.value = true
-    })
+    // 如果参数不是 tabIndex ,需要保留到下一个路由
+    setGlobalUrlParams(params)
   }
+  nextTick(() => {
+    cssTransition.value = true
+  })
 })
 </script>
 

+ 2 - 3
src/packages/mobile/views/presale/detail/Index.vue

@@ -71,10 +71,9 @@ const componentMap = new Map<string, unknown>([
     ['delisting', defineAsyncComponent(() => import('./components/delisting/index.vue'))], // 摘牌
 ])
 
-const { getParamString } = useNavigation()
+const { getGlobalUrlParams } = useNavigation()
 const { componentRef, componentId, openComponent, closeComponent } = useComponent()
-const qs = getParamString('item')
-const detail: Model.PresaleAuctionsRsp = JSON.parse(qs.toString() || '{}')
+const detail: Model.PresaleAuctionsRsp = getGlobalUrlParams()
 
 // 商品banner
 const detailBanners = computed(() => {

+ 3 - 2
src/packages/mobile/views/presale/list/Index.vue

@@ -89,7 +89,7 @@ import Banner from '@mobile/components/base/banner/index.vue'
 import Waterfall from '@mobile/components/base/waterfall/index.vue'
 
 const isWaterfall = shallowRef(false)
-const { router } = useNavigation()
+const { router, setGlobalUrlParams } = useNavigation()
 const bannerList = shallowRef<string[]>([])
 
 // 预售准备
@@ -125,7 +125,8 @@ const onBannerClick = (index: number) => {
 
 // 打开详情页
 const toDetail = (item: Model.PresaleAuctionsRsp) => {
-    router.push({ name: 'presale-detail', params: { item: JSON.stringify(item) } })
+    setGlobalUrlParams(item)
+    router.push({ name: 'presale-detail' })
 }
 </script>
 

+ 2 - 2
src/packages/mobile/views/swap/detail/Index.vue

@@ -55,8 +55,8 @@ const componentMap = new Map<string, unknown>([
 ])
 const pullRefreshRef = shallowRef()
 const loginStore = useLoginStore()
-const { getParamString } = useNavigation()
-const item: Model.QuoteGoodsListRsp = JSON.parse(getParamString('item')?.toString() || '{}')
+const { getGlobalUrlParams } = useNavigation()
+const item: Model.QuoteGoodsListRsp = getGlobalUrlParams()
 const tabIndex = shallowRef(0)
 const selectedRow = shallowRef<Model.TjmdTradeOrderDetailRsp>()
 const error = shallowRef(false)

+ 3 - 7
src/packages/mobile/views/swap/list/Index.vue

@@ -47,7 +47,7 @@ import { useFuturesStore, useUserStore } from '@/stores'
 import quoteSocket from '@/services/websocket/quote'
 import AppList from '@mobile/components/base/list/index.vue'
 
-const { router } = useNavigation()
+const { router, setGlobalUrlParams } = useNavigation()
 const futuresStore = useFuturesStore()
 const userStore = useUserStore()
 const subscribe = quoteSocket.createSubscribe()
@@ -99,12 +99,8 @@ const columns: Model.TableColumn[] = [
 ]
 
 const rowClick = (row: Model.QuoteGoodsListRsp) => {
-    router.push({
-        name: 'swap-detail',
-        params: {
-            item: JSON.stringify(row)
-        }
-    })
+    setGlobalUrlParams(row)
+    router.push({ name: 'swap-detail' })
 }
 
 onUnmounted(() => subscribe.stop())

+ 6 - 4
src/packages/qdhs/views/home/Index.vue

@@ -25,7 +25,7 @@ import plus from '@/utils/h5plus'
 import AppTabbar from '@mobile/components/base/tabbar/index.vue'
 import RouterTransition from '@mobile/components/base/router-transition/index.vue'
 
-const { route, routerTo, getGlobalUrlParams } = useNavigation()
+const { route, routerTo, getGlobalUrlParams, setGlobalUrlParams } = useNavigation()
 const { userLogin } = useLogin()
 const loginStore = useLoginStore()
 const cssTransition = shallowRef(true) // 是否使用css动画
@@ -151,10 +151,12 @@ watch(() => route.name, () => {
   } else if (tabIndex.value > -1) {
     onTabClick(tabIndex.value)
   } else {
-    nextTick(() => {
-      cssTransition.value = true
-    })
+    // 如果参数不是 tabIndex ,需要保留到下一个路由
+    setGlobalUrlParams(params)
   }
+  nextTick(() => {
+    cssTransition.value = true
+  })
 })
 </script>
 

+ 6 - 4
src/packages/qxst/views/home/Index.vue

@@ -25,7 +25,7 @@ import plus from '@/utils/h5plus'
 import AppTabbar from '@mobile/components/base/tabbar/index.vue'
 import RouterTransition from '@mobile/components/base/router-transition/index.vue'
 
-const { route, routerTo, getGlobalUrlParams } = useNavigation()
+const { route, routerTo, getGlobalUrlParams, setGlobalUrlParams } = useNavigation()
 const { userLogin } = useLogin()
 const loginStore = useLoginStore()
 const cssTransition = shallowRef(true) // 是否使用css动画
@@ -145,10 +145,12 @@ watch(() => route.name, () => {
   } else if (tabIndex.value > -1) {
     onTabClick(tabIndex.value)
   } else {
-    nextTick(() => {
-      cssTransition.value = true
-    })
+    // 如果参数不是 tabIndex ,需要保留到下一个路由
+    setGlobalUrlParams(params)
   }
+  nextTick(() => {
+    cssTransition.value = true
+  })
 })
 </script>
 

+ 6 - 4
src/packages/sbyj/views/home/index.vue

@@ -24,7 +24,7 @@ import plus from '@/utils/h5plus'
 import AppTabbar from '@mobile/components/base/tabbar/index.vue'
 import RouterTransition from '@mobile/components/base/router-transition/index.vue'
 
-const { route, routerTo, getGlobalUrlParams } = useNavigation()
+const { route, routerTo, getGlobalUrlParams, setGlobalUrlParams } = useNavigation()
 const { userLogin } = useLogin()
 const loginStore = useLoginStore()
 const cssTransition = shallowRef(true) // 是否使用css动画
@@ -165,10 +165,12 @@ watch(() => route.name, () => {
   } else if (tabIndex.value > -1) {
     onTabClick(tabIndex.value)
   } else {
-    nextTick(() => {
-      cssTransition.value = true
-    })
+    // 如果参数不是 tabIndex ,需要保留到下一个路由
+    setGlobalUrlParams(params)
   }
+  nextTick(() => {
+    cssTransition.value = true
+  })
 })
 </script>
 

+ 6 - 4
src/packages/tc/views/home/Index.vue

@@ -25,7 +25,7 @@ import plus from '@/utils/h5plus'
 import AppTabbar from '@mobile/components/base/tabbar/index.vue'
 import RouterTransition from '@mobile/components/base/router-transition/index.vue'
 
-const { route, routerTo, getGlobalUrlParams } = useNavigation()
+const { route, routerTo, getGlobalUrlParams, setGlobalUrlParams } = useNavigation()
 const { userLogin } = useLogin()
 const loginStore = useLoginStore()
 const cssTransition = shallowRef(true) // 是否使用css动画
@@ -157,10 +157,12 @@ watch(() => route.name, () => {
   } else if (tabIndex.value > -1) {
     onTabClick(tabIndex.value)
   } else {
-    nextTick(() => {
-      cssTransition.value = true
-    })
+    // 如果参数不是 tabIndex ,需要保留到下一个路由
+    setGlobalUrlParams(params)
   }
+  nextTick(() => {
+    cssTransition.value = true
+  })
 })
 </script>
 

+ 6 - 4
src/packages/zrwyt/views/home/Index.vue

@@ -25,7 +25,7 @@ import plus from '@/utils/h5plus'
 import AppTabbar from '@mobile/components/base/tabbar/index.vue'
 import RouterTransition from '@mobile/components/base/router-transition/index.vue'
 
-const { route, routerTo, getGlobalUrlParams } = useNavigation()
+const { route, routerTo, getGlobalUrlParams, setGlobalUrlParams } = useNavigation()
 const { userLogin } = useLogin()
 const loginStore = useLoginStore()
 const cssTransition = shallowRef(true) // 是否使用css动画
@@ -157,10 +157,12 @@ watch(() => route.name, () => {
   } else if (tabIndex.value > -1) {
     onTabClick(tabIndex.value)
   } else {
-    nextTick(() => {
-      cssTransition.value = true
-    })
+    // 如果参数不是 tabIndex ,需要保留到下一个路由
+    setGlobalUrlParams(params)
   }
+  nextTick(() => {
+    cssTransition.value = true
+  })
 })
 </script>