zhuli 1 місяць тому
батько
коміт
cfe8545a17
1 змінених файлів з 95 додано та 90 видалено
  1. 95 90
      HBuilderProjects/shareUndefined.html

+ 95 - 90
HBuilderProjects/shareUndefined.html

@@ -500,8 +500,8 @@
 		 * 更多推荐:POST http://124.93.18.180:9100/ai/life-manager/api/v1/second_hand/global-recommend
 		 * 更多推荐:POST http://124.93.18.180:9100/ai/life-manager/api/v1/second_hand/global-recommend
 		 * 常用 query:userId、userLat/userLng 或 lat/weidu、lon/jingdu、radiusKm、page、pageSize、categoryOneId、categoryTwoId
 		 * 常用 query:userId、userLat/userLng 或 lat/weidu、lon/jingdu、radiusKm、page、pageSize、categoryOneId、categoryTwoId
 		 *
 		 *
-		 * 商品已卖出 / 下架 / 删除(secondShareGoods 跳转时带 goodsUnavailable=1 或 goodsStatus=2|4|5):
-		 * 点「APP内打开」深链为 shopro://pages/index/login?…(与 shareIndex.html 关店 businessStatus=99 一致)
+		 * 本页仅展示「已卖出 / 下架 / 删除」占位与推荐,无有效商品详情:点「APP内打开」一律进 App 登录页
+		 * shopro://pages/index/login?…(与 shareIndex.html 关店唤起一致)。在 App 内嵌 H5 且存在 uni 时优先 uni.navigateTo
 		 *
 		 *
 		 * 注意:用 file:// 打开本页时,浏览器可能因 CORS 拦截跨域请求。
 		 * 注意:用 file:// 打开本页时,浏览器可能因 CORS 拦截跨域请求。
 		 */
 		 */
@@ -548,42 +548,9 @@
 			return params;
 			return params;
 		}
 		}
 
 
-		/**
-		 * 二手商品不可用(已卖出 / 下架 / 删除):URL(含 hash)带 goodsUnavailable=1 或 goodsStatus 为 2、4、5;
-		 * businessStatus=99 与 shareIndex 关店唤起登录一致。
-		 */
-		function isSecondGoodsUnavailableForAppOpen() {
-			function checkGoodsUnavailableParam(raw) {
-				var s = String(raw == null ? '' : raw).trim().toLowerCase();
-				return s === '1' || s === 'true' || s === 'yes';
-			}
-			function checkGoodsStatusParam(raw) {
-				var s = String(raw == null ? '' : raw).trim();
-				if (s === '2' || s === '4' || s === '5') return true;
-				var n = Number(s);
-				return !isNaN(n) && (n === 2 || n === 4 || n === 5);
-			}
-			function checkBusiness99(raw) {
-				var s = String(raw == null ? '' : raw).trim();
-				return s === '99' || Number(s) === 99;
-			}
-			try {
-				var p = mergeSearchAndHashParams();
-				if (checkGoodsUnavailableParam(p.get('goodsUnavailable'))) return true;
-				if (checkGoodsStatusParam(p.get('goodsStatus'))) return true;
-				if (checkBusiness99(p.get('businessStatus'))) return true;
-			} catch (e0) {}
-			if (checkGoodsUnavailableParam(q('goodsUnavailable'))) return true;
-			if (checkGoodsStatusParam(q('goodsStatus'))) return true;
-			if (checkBusiness99(q('businessStatus'))) return true;
-			return false;
-		}
-
+		/** 本 HTML 仅为不可用商品落地页,唤起路径固定为登录(不依赖 URL 是否带 goodsUnavailable,避免旧链/丢参) */
 		function getAppUniPathForShareUndefined() {
 		function getAppUniPathForShareUndefined() {
-			if (isSecondGoodsUnavailableForAppOpen()) {
-				return 'pages/index/login';
-			}
-			return String(APP_UNI_STORE_PATH || 'pages/secondHandTransactions/pages/detail/index').replace(/^\//, '');
+			return 'pages/index/login';
 		}
 		}
 
 
 		function buildAppOpenQueryStringMerged() {
 		function buildAppOpenQueryStringMerged() {
@@ -600,6 +567,13 @@
 			return qsOut ? ('?' + qsOut) : '';
 			return qsOut ? ('?' + qsOut) : '';
 		}
 		}
 
 
+		/** 供 App 内嵌 WebView:uni 路由到登录页,query 与深链一致 */
+		function buildUniLoginPageUrl() {
+			var tail = buildAppOpenQueryStringMerged();
+			var u = '/pages/index/login' + (tail || '');
+			return u.length > 1800 ? '/pages/index/login' : u;
+		}
+
 		function buildAppDeepLink() {
 		function buildAppDeepLink() {
 			var path = getAppUniPathForShareUndefined().replace(/^\//, '');
 			var path = getAppUniPathForShareUndefined().replace(/^\//, '');
 			var s = buildAppOpenQueryStringMerged();
 			var s = buildAppOpenQueryStringMerged();
@@ -630,71 +604,102 @@
 
 
 		/**
 		/**
 		 * App-Plus:检测是否已安装;H5:scheme 唤起 + 超时提示(与 secondShareGoods 一致)。
 		 * App-Plus:检测是否已安装;H5:scheme 唤起 + 超时提示(与 secondShareGoods 一致)。
+		 * App 内嵌 H5 若注入 uni.navigateTo,优先走页面路由进登录(scheme 在 WebView 内常无效)。
 		 */
 		 */
 		function tryOpenUShopApp() {
 		function tryOpenUShopApp() {
-			var deepLink = buildAppDeepLink();
-
-			if (typeof plus !== 'undefined' && plus.runtime) {
-				var installed = null;
-				try {
-					if (typeof plus.runtime.isApplicationExist === 'function') {
-						installed = plus.runtime.isApplicationExist({
-							pname: APP_ANDROID_PACKAGE,
-							action: APP_IOS_URL_SCHEME
-						});
+			function openBySchemeOrPlus() {
+				var deepLink = buildAppDeepLink();
+
+				if (typeof plus !== 'undefined' && plus.runtime) {
+					var installed = null;
+					try {
+						if (typeof plus.runtime.isApplicationExist === 'function') {
+							installed = plus.runtime.isApplicationExist({
+								pname: APP_ANDROID_PACKAGE,
+								action: APP_IOS_URL_SCHEME
+							});
+						}
+					} catch (e) {
+						console.warn(e);
+					}
+					if (installed === false) {
+						showDownloadTip();
+						return;
+					}
+					try {
+						plus.runtime.openURL(deepLink);
+					} catch (e2) {
+						console.warn(e2);
+						showDownloadTip();
 					}
 					}
-				} catch (e) {
-					console.warn(e);
-				}
-				if (installed === false) {
-					showDownloadTip();
 					return;
 					return;
 				}
 				}
-				try {
-					plus.runtime.openURL(deepLink);
-				} catch (e2) {
-					console.warn(e2);
-					showDownloadTip();
+
+				var t0 = Date.now();
+				var done = false;
+				function finish() {
+					if (done) return;
+					done = true;
+					document.removeEventListener('visibilitychange', onVis);
+					window.removeEventListener('pagehide', onHide);
 				}
 				}
-				return;
-			}
+				function onVis() {
+					if (document.visibilityState === 'hidden') finish();
+				}
+				function onHide() {
+					finish();
+				}
+				document.addEventListener('visibilitychange', onVis);
+				window.addEventListener('pagehide', onHide);
 
 
-			var t0 = Date.now();
-			var done = false;
-			function finish() {
-				if (done) return;
-				done = true;
-				document.removeEventListener('visibilitychange', onVis);
-				window.removeEventListener('pagehide', onHide);
-			}
-			function onVis() {
-				if (document.visibilityState === 'hidden') finish();
-			}
-			function onHide() {
-				finish();
-			}
-			document.addEventListener('visibilitychange', onVis);
-			window.addEventListener('pagehide', onHide);
+				if (isWeChatInAppBrowser()) {
+					window.alert('若点击后无法打开 App:请先点右上角「···」,选择「在浏览器中打开」,再点「APP内打开」。');
+				}
 
 
-			if (isWeChatInAppBrowser()) {
-				window.alert('若点击后无法打开 App:请先点右上角「···」,选择「在浏览器中打开」,再点「APP内打开」。');
-			}
+				try {
+					launchAppDeepLink(deepLink);
+				} catch (e3) {
+					finish();
+					showDownloadTip();
+					return;
+				}
 
 
-			try {
-				launchAppDeepLink(deepLink);
-			} catch (e3) {
-				finish();
-				showDownloadTip();
-				return;
+				window.setTimeout(function () {
+					if (done) return;
+					if (document.visibilityState === 'visible' && Date.now() - t0 < 3500) {
+						showDownloadTip();
+					}
+					finish();
+				}, 2600);
 			}
 			}
 
 
-			window.setTimeout(function () {
-				if (done) return;
-				if (document.visibilityState === 'visible' && Date.now() - t0 < 3500) {
-					showDownloadTip();
+			if (typeof uni !== 'undefined' && typeof uni.navigateTo === 'function') {
+				var loginUrl = buildUniLoginPageUrl();
+				try {
+					uni.navigateTo({
+						url: loginUrl,
+						fail: function () {
+							if (typeof uni.reLaunch === 'function') {
+								try {
+									uni.reLaunch({
+										url: loginUrl.length > 1800 ? '/pages/index/login' : loginUrl,
+										fail: function () {
+											openBySchemeOrPlus();
+										}
+									});
+									return;
+								} catch (eRl) {}
+							}
+							openBySchemeOrPlus();
+						}
+					});
+					return;
+				} catch (eUni) {
+					openBySchemeOrPlus();
+					return;
 				}
 				}
-				finish();
-			}, 2600);
+			}
+			openBySchemeOrPlus();
 		}
 		}
 
 
 		function qs() {
 		function qs() {