Sfoglia il codice sorgente

feat: 新增带编号跳转数据包首页逻辑并更新开发环境API地址

适配路由参数中的bianhao参数,自动跳转至对应数据包首页
根据当前页面栈和冷启动状态选择合适的跳转方式避免重复跳转
更新开发环境API基础地址为 https://bpi.shuhi.com
ylong 2 giorni fa
parent
commit
a9b0fada48
2 ha cambiato i file con 35 aggiunte e 1 eliminazioni
  1. 1 1
      .env.dev.js
  2. 34 0
      App.vue

+ 1 - 1
.env.dev.js

@@ -1,5 +1,5 @@
 export default {
     "NODE_ENV": 'development',
-    "apiUrl":"https://bk.shuhi.com",
+    "apiUrl":"https://bpi.shuhi.com",
     "apiUrlPrefix":"/api",
 };

+ 34 - 0
App.vue

@@ -127,12 +127,46 @@ export default {
 			if (!Object.keys(params).length) return;
 
 			this.cacheEntryParams(params);
+			if (params.bianhao) {
+				this.routeToPacketIndex(params.bianhao);
+			}
 			if (this.globalData.isColdLaunch) return;
 
 			if (params.upsellCode || params.reduceCode) {
 				eventBus.emit('appShowActivity', { params });
 			}
 		},
+		routeToPacketIndex(bianhao) {
+			const targetUrl = '/packet/pages/index?bianhao=' + bianhao;
+			setTimeout(() => {
+				const pages = getCurrentPages();
+				const currentPage = pages[pages.length - 1];
+				const currentRoute = currentPage?.route || '';
+				const currentBianhao = currentPage?.options?.bianhao || '';
+
+				if (currentRoute === 'packet/pages/index' && currentBianhao === String(bianhao)) {
+					return;
+				}
+
+				if (!pages.length || this.globalData.isColdLaunch) {
+					uni.reLaunch({
+						url: targetUrl
+					});
+					return;
+				}
+
+				if (currentRoute === 'packet/pages/index') {
+					uni.redirectTo({
+						url: targetUrl
+					});
+					return;
+				}
+
+				uni.navigateTo({
+					url: targetUrl
+				});
+			}, 0);
+		},
 		slientLogin(params = {}) {
 			let that = this;
 			uni.login({