فهرست منبع

refactor(user): 优化微信小程序页面跳转逻辑

- 将页面跳转方法封装为handleCommonWx,统一调用方式
- 替换index.vue中直接修改window.location.href的写法为调用封装方法
- 更新user状态管理中相关跳转调用为封装方法以提升代码复用性与可维护性
zhangtao 22 ساعت پیش
والد
کامیت
59aad8a842
2فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  1. 1 1
      src/pages/refuelDetaile/index.vue
  2. 4 1
      src/store/user.ts

+ 1 - 1
src/pages/refuelDetaile/index.vue

@@ -38,7 +38,7 @@ function handleExchange(item: CouponInfoAppVo) {
   showModel.value = true
 }
 function handleKf() {
-  window.location.href = `weixin://dl/business/?appid=wx43b5b906cc30ed0b&path=pages/my/index&env_version=trial`
+  useUserStore().handleCommonWx('pages/my/index', '')
 }
 </script>
 

+ 4 - 1
src/store/user.ts

@@ -257,7 +257,10 @@ export const useUserStore = defineStore('user', {
       const queryString = Object.entries(query)
         .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
         .join('&')
-      window.location.href = `weixin://dl/business/?appid=wx43b5b906cc30ed0b&path=subPack-refueling/orderDetaile/index&query=${queryString}&env_version=trial`
+      this.handleCommonWx('subPack-refueling/orderDetaile/index', queryString)
+    },
+    handleCommonWx(path: string, queryString: string) {
+      window.location.href = `weixin://dl/business/?appid=wx43b5b906cc30ed0b&path=${path}&query=${queryString}&env_version=trial`
     },
     async handleCommonGoXiaoJuPay(orderNumber: string) {
       try {