zhuli 1 неделя назад
Родитель
Сommit
f70604bfa9
1 измененных файлов с 629 добавлено и 34 удалено
  1. 629 34
      HBuilderProjects/shareDynamic.html

+ 629 - 34
HBuilderProjects/shareDynamic.html

@@ -486,6 +486,62 @@
 			pointer-events: none;
 		}
 
+		.fab-dock__slot {
+			width: 100%;
+			max-width: 320px;
+			height: 48px;
+			margin: 0 auto;
+			pointer-events: auto;
+		}
+
+		#openApp img {
+			display: block;
+			width: 100%;
+			height: 48px;
+			object-fit: contain;
+			pointer-events: none;
+		}
+
+		#launch-btn {
+			display: none;
+			width: 100%;
+			height: 48px;
+			min-height: 48px;
+			border-radius: 24px;
+			overflow: hidden;
+			opacity: 1;
+		}
+
+		body.is-wechat.wx-jssdk-ready #launch-btn {
+			display: block;
+		}
+
+		body.is-wechat.wx-jssdk-ready #openApp {
+			display: none !important;
+		}
+
+		#openAppToast {
+			display: none;
+			position: fixed;
+			left: 16px;
+			right: 16px;
+			bottom: calc(72px + var(--safe-bottom));
+			z-index: 10001;
+			padding: 10px 14px;
+			font-size: 13px;
+			line-height: 1.45;
+			color: #fff;
+			text-align: center;
+			background: rgba(0, 0, 0, 0.78);
+			border-radius: 8px;
+			pointer-events: none;
+			word-break: break-all;
+		}
+
+		#openApp {
+			touch-action: manipulation;
+		}
+
 		.fab-wrap .fab {
 			pointer-events: auto;
 		}
@@ -588,18 +644,70 @@
 	</div>
 	</div>
 
+	<div id="openAppToast" role="status" aria-live="polite"></div>
 	<div class="fab-wrap">
-		<button type="button" class="fab" id="openApp">
-			<img src="images/uBtn.png" alt="APP内打开" decoding="async">
-		</button>
+		<div class="fab-dock__slot">
+			<button type="button" class="fab" id="openApp">
+				<img src="images/uBtn.png" alt="APP内打开" decoding="async">
+			</button>
+			<wx-open-launch-app id="launch-btn" appid="wxf5f1efe3a9f5012e" extinfo="">
+				<script type="text/wxtag-template">
+					<style>
+						.wx-open-app-btn {
+							display: block;
+							width: 100%;
+							height: 48px;
+							margin: 0;
+							padding: 0;
+							border: none;
+							border-radius: 24px;
+							background: #F47D1F;
+							box-shadow: 0 4px 16px rgba(245, 130, 32, 0.45);
+							cursor: pointer;
+							overflow: hidden;
+							-webkit-tap-highlight-color: transparent;
+						}
+						.wx-open-app-btn img {
+							display: block;
+							width: 100%;
+							height: 48px;
+							object-fit: contain;
+							opacity: 1;
+							pointer-events: none;
+							-webkit-user-drag: none;
+						}
+					</style>
+					<button class="wx-open-app-btn" aria-label="APP内打开">
+						<img src="https://test.ailien.shop/h5/HBuilderProjects/images/uBtn.png" alt="APP内打开" width="320" height="48" />
+					</button>
+				</script>
+			</wx-open-launch-app>
+		</div>
 		<div class="home-indicator" aria-hidden="true"></div>
 	</div>
 
+	<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
 	<script> 
 	(function () {
 		'use strict';
 
 		var API_BASE = 'https://test.ailien.shop/alienStore';
+
+		/**
+		 * 微信 JSSDK — 与 shareIndex.html 一致
+		 * POST {API_BASE}/wx/getWxConfig,body 传 url(当前页完整地址,不含 #)
+		 */
+		var WECHAT_MP_APP_ID = 'wx412792c77f47babd';
+		var WECHAT_OPEN_APP_ID = 'wxf5f1efe3a9f5012e';
+		var WECHAT_GET_WX_CONFIG_PATH = '/wx/getWxConfig';
+		var H5_PAGE_BASE_FALLBACK = 'https://test.ailien.shop/h5/HBuilderProjects/';
+		var WX_GET_CONFIG_SIGN_URL = H5_PAGE_BASE_FALLBACK + 'shareDynamic.html';
+		var WECHAT_JS_SAFE_HOSTS = ['uat.ailien.shop', 'test.ailien.shop'];
+		var weChatJssdkConfigured = false;
+		var wxConfigSignRetriedBaseUrl = false;
+		var wxInitLastError = '';
+		var wxJssdkInitPromise = null;
+
 		/**
 		 * 暂无承载数据时更多推荐:POST …/ai/multimodal-services/api/v1/search/global/store-recommend
 		 * 与 shareIndex.html / shareCheckInUndefined.html 一致。
@@ -941,6 +1049,476 @@
 			return compactShoproDeepLinkIfTooLong(raw, 7200);
 		}
 
+		/** 动态分享唤起 App 落地页(关店时 login,否则 newdetails) */
+		function getAppUniPathForDynamicOpen() {
+			if (isClosedMerchantForAppOpen()) {
+				return 'pages/index/login';
+			}
+			var explicit = (getMergedParam('appPath') || getMergedParam('appPage') || '')
+				.trim()
+				.replace(/^\//, '');
+			var fromHash = extractUniPagePathFromHash();
+			var defaultPath = String(APP_UNI_STORE_PATH || 'pages/newdetails/index').replace(/^\//, '');
+			var path = explicit;
+			if (!path && fromHash && /newdetails/i.test(fromHash)) {
+				path = fromHash.replace(/^\//, '');
+			}
+			if (!path) {
+				path = defaultPath;
+			}
+			return String(path || defaultPath).replace(/^\//, '');
+		}
+
+		/** 从 item JSON 或 query 解析动态 id,供微信 extinfo(仅传 id,避免 1024 超限) */
+		function resolveDynamicIdForAppLaunch() {
+			var item = parseShareDynamicItemBlob();
+			if (!item) {
+				item = parseOptionsItem();
+			}
+			if (item && item.id != null && String(item.id).trim() !== '') {
+				return String(item.id).trim();
+			}
+			var id =
+				getMergedParam('dynamicId') ||
+				getMergedParam('sourceId') ||
+				getMergedParam('id') ||
+				q('dynamicId') ||
+				q('id');
+			return id ? String(id).trim() : '';
+		}
+
+		/** Uni 路由串(无 shopro://),供 wx-open-launch-app extinfo */
+		function buildAppUniPageLaunchUrl() {
+			var path = getAppUniPathForDynamicOpen().replace(/^\//, '');
+			if (isClosedMerchantForAppOpen()) {
+				var sClosed = buildAppOpenQueryStringMerged().replace(/^\?/, '');
+				return sClosed ? path + '?' + sClosed : path;
+			}
+			var dynId = resolveDynamicIdForAppLaunch();
+			var mini = new URLSearchParams();
+			if (dynId) {
+				mini.set('id', dynId);
+			}
+			mini.set('fromShareDynamic', '1');
+			mini.set('needShowMore', 'true');
+			return path + '?' + mini.toString();
+		}
+
+		/**
+		 * wx-open-launch-app extinfo:动态详情 pages/newdetails/index?id=…&fromShareDynamic=1
+		 * 微信 extinfo 上限 1024,不传超大 item,App 端按 id 拉详情。
+		 */
+		function buildWeChatLaunchExtinfo() {
+			var uniPage = buildAppUniPageLaunchUrl();
+			if (uniPage.length <= 1024) {
+				return uniPage;
+			}
+			var path = getAppUniPathForDynamicOpen().replace(/^\//, '');
+			var dynId = resolveDynamicIdForAppLaunch();
+			var mini = new URLSearchParams();
+			if (dynId) {
+				mini.set('id', dynId);
+			}
+			mini.set('fromShareDynamic', '1');
+			var shortPage = path + '?' + mini.toString();
+			return shortPage.length <= 1024 ? shortPage : shortPage.slice(0, 1024);
+		}
+
+		function readQueryParam(name) {
+			return q(name);
+		}
+
+		function isWxDebugOn() {
+			return readQueryParam('wxDebug') === '1';
+		}
+
+		function isWxForceDebug() {
+			return readQueryParam('wxForce') === '1';
+		}
+
+		function isWxConfigOnClickDebug() {
+			return readQueryParam('wxConfigOnClick') === '1';
+		}
+
+		function isWxPcAutoDebugHost() {
+			var h = (location.hostname || '').toLowerCase();
+			if (h === 'localhost' || h === '127.0.0.1') return true;
+			for (var i = 0; i < WECHAT_JS_SAFE_HOSTS.length; i++) {
+				if (WECHAT_JS_SAFE_HOSTS[i] === h) return true;
+			}
+			return false;
+		}
+
+		function isWxPcBrowser() {
+			return !isWeChatInAppBrowser();
+		}
+
+		function shouldInitWeChatJssdkOnLoad() {
+			if (isWeChatInAppBrowser()) return true;
+			return isWxForceDebug() || isWxPcAutoDebugHost();
+		}
+
+		function shouldFetchWxConfig(fromUserClick) {
+			if (isWeChatInAppBrowser()) return true;
+			if (fromUserClick) return true;
+			return isWxForceDebug() || isWxPcAutoDebugHost();
+		}
+
+		function getWxHtmlUrl() {
+			var forced = String(q('wxSignUrl') || '').trim();
+			if (forced) return forced.split('#')[0];
+			return String(location.href || '').split('#')[0];
+		}
+
+		function getWxSignPageUrlForApi() {
+			var htmlUrl = getWxHtmlUrl();
+			if (htmlUrl && /^https?:\/\//i.test(htmlUrl)) return htmlUrl;
+			return WX_GET_CONFIG_SIGN_URL;
+		}
+
+		function getWxHtmlUrlBase() {
+			var htmlUrl = getWxSignPageUrlForApi();
+			try {
+				var u = new URL(htmlUrl);
+				return u.origin + u.pathname;
+			} catch (eU) {
+				return WX_GET_CONFIG_SIGN_URL;
+			}
+		}
+
+		function getWxConfigSignUrl() {
+			if (String(q('wxSignBaseOnly') || '') === '1') return getWxHtmlUrlBase();
+			return getWxSignPageUrlForApi();
+		}
+
+		function getWxGetConfigApiUrl() {
+			return API_BASE.replace(/\/$/, '') + WECHAT_GET_WX_CONFIG_PATH;
+		}
+
+		function buildWxGetConfigRequestBody(htmlUrl) {
+			return {
+				url: String(htmlUrl || '').split('#')[0].trim()
+			};
+		}
+
+		function resolveWxConfigAppIdFromSignData(d) {
+			if (!d || typeof d !== 'object') return '';
+			var mp =
+				d.mpAppId ||
+				d.mpAppid ||
+				d.officialAppId ||
+				d.gzhAppId ||
+				d.serviceAppId;
+			if (mp != null && String(mp).trim() !== '') return String(mp).trim();
+			var fromQuery = String(q('wxMpAppId') || WECHAT_MP_APP_ID || '').trim();
+			if (fromQuery) return fromQuery;
+			var raw = d.appId || d.appid || d.wxAppId;
+			return raw != null && String(raw).trim() !== '' ? String(raw).trim() : '';
+		}
+
+		function normalizeWxJssdkSignPayload(res, signUrlUsed) {
+			if (!res || typeof res !== 'object') return null;
+			var d = res.data != null && typeof res.data === 'object' ? res.data : res;
+			if (!d || typeof d !== 'object') return null;
+			var appId = resolveWxConfigAppIdFromSignData(d);
+			var timestamp = d.timestamp != null ? d.timestamp : d.timeStamp;
+			var nonceStr =
+				d.nonceStr != null && String(d.nonceStr) !== ''
+					? d.nonceStr
+					: d.noncestr != null && String(d.noncestr) !== ''
+						? d.noncestr
+						: d.nonce;
+			var signature = d.signature || d.sign;
+			if (!appId || timestamp == null || nonceStr == null || nonceStr === '' || !signature) {
+				return null;
+			}
+			return {
+				appId: String(appId),
+				timestamp: Number(timestamp),
+				nonceStr: String(nonceStr),
+				signature: String(signature),
+				signUrl: String(signUrlUsed || '')
+					.split('#')[0]
+					.trim()
+			};
+		}
+
+		function getWxErrMsg(err) {
+			if (!err) return '';
+			if (err.errMsg) return String(err.errMsg);
+			if (typeof err === 'string') return err;
+			try {
+				return JSON.stringify(err);
+			} catch (e) {
+				return String(err);
+			}
+		}
+
+		function formatWxConfigErrorTip(err, signPageUrl) {
+			var errMsg = getWxErrMsg(err);
+			var tip = '微信 JSSDK 配置失败';
+			if (/invalid signature/i.test(errMsg)) {
+				return (
+					tip +
+					':签名无效。请核对:①后端用与前端相同的 url 签名;②url=' +
+					(signPageUrl || getWxHtmlUrl()) +
+					';③nonceStr/timestamp 与接口返回一致;④appId=' +
+					WECHAT_MP_APP_ID
+				);
+			}
+			if (/require\s*subscribe/i.test(errMsg)) {
+				return tip + ':' + errMsg + '(服务号需用户已关注)';
+			}
+			return errMsg ? tip + ':' + errMsg : tip;
+		}
+
+		function requestWeChatJssdkSignAndConfig(htmlUrlOptional) {
+			var htmlUrl = String(
+				htmlUrlOptional != null ? htmlUrlOptional : getWxConfigSignUrl()
+			)
+				.split('#')[0]
+				.trim();
+			if (!htmlUrl || !/^https?:\/\//i.test(htmlUrl)) {
+				htmlUrl = WX_GET_CONFIG_SIGN_URL;
+			}
+
+			if (isWxDebugOn()) {
+				try {
+					window.alert('htmlUrl(签名用,应与地址栏一致):\n' + htmlUrl);
+				} catch (eDbg) {}
+			}
+
+			var requestUrl = getWxGetConfigApiUrl();
+			var requestBody = buildWxGetConfigRequestBody(htmlUrl);
+
+			return fetch(requestUrl, {
+				method: 'POST',
+				mode: 'cors',
+				credentials: 'omit',
+				headers: {
+					Accept: 'application/json',
+					'Content-Type': 'application/json;charset=UTF-8'
+				},
+				body: JSON.stringify(requestBody)
+			})
+				.then(function (r) {
+					if (r.ok) return r.json();
+					return r
+						.text()
+						.catch(function () {
+							return '';
+						})
+						.then(function (text) {
+							var hint = '';
+							try {
+								var j = JSON.parse(text);
+								hint = j.msg || j.message || '';
+							} catch (eP) {
+								if (text) hint = text.slice(0, 120);
+							}
+							throw new Error('getWxConfig HTTP ' + r.status + (hint ? ':' + hint : ''));
+						});
+				})
+				.then(function (res) {
+					if (res && res.code != null) {
+						var c = Number(res.code);
+						if (c !== 200 && c !== 0 && res.success !== true) {
+							throw new Error(res.msg || res.message || 'getWxConfig code ' + c);
+						}
+					}
+					var sign = normalizeWxJssdkSignPayload(res, htmlUrl);
+					if (!sign) {
+						throw new Error(
+							'getWxConfig 缺少 appId/timestamp/nonceStr/signature(见控制台)'
+						);
+					}
+					if (typeof wx === 'undefined') {
+						if (isWxPcBrowser()) {
+							console.log('[wx] PC getWxConfig 成功(无 jweixin)', sign);
+							return true;
+						}
+						setWxInitError('jweixin.js 未加载');
+						return false;
+					}
+					return applyWxConfigFromSign(sign, htmlUrl);
+				});
+		}
+
+		function applyWxConfigFromSign(sign, htmlUrl) {
+			var wxConfigParams = {
+				debug: isWxDebugOn(),
+				appId: String(sign.appId),
+				timestamp: sign.timestamp,
+				nonceStr: String(sign.nonceStr),
+				signature: String(sign.signature),
+				jsApiList: [],
+				openTagList: ['wx-open-launch-app']
+			};
+			return new Promise(function (resolve) {
+				wx.config(wxConfigParams);
+				wx.ready(function () {
+					weChatJssdkConfigured = true;
+					document.body.classList.add('wx-jssdk-ready');
+					refreshWxLaunchTagAttrs();
+					console.log('[wx.config] ready, htmlUrl=', htmlUrl);
+					resolve(true);
+				});
+				wx.error(function (err) {
+					weChatJssdkConfigured = false;
+					document.body.classList.remove('wx-jssdk-ready');
+					wxJssdkInitPromise = null;
+					var errMsg = getWxErrMsg(err);
+					setWxInitError(formatWxConfigErrorTip(err, htmlUrl));
+					if (isWxDebugOn()) window.alert(wxInitLastError);
+					console.warn('[wx.config]', errMsg, 'htmlUrl=', htmlUrl);
+					var baseUrl = getWxHtmlUrlBase();
+					var fullUrl = getWxSignPageUrlForApi();
+					if (
+						!/invalid signature/i.test(errMsg) ||
+						wxConfigSignRetriedBaseUrl ||
+						baseUrl === fullUrl ||
+						htmlUrl === baseUrl
+					) {
+						resolve(false);
+						return;
+					}
+					wxConfigSignRetriedBaseUrl = true;
+					requestWeChatJssdkSignAndConfig(baseUrl).then(resolve);
+				});
+			});
+		}
+
+		function refreshWxLaunchTagAttrs() {
+			var tag = document.getElementById('launch-btn');
+			if (!tag) return;
+			try {
+				tag.setAttribute('appid', WECHAT_OPEN_APP_ID);
+				tag.setAttribute('extinfo', buildWeChatLaunchExtinfo());
+			} catch (eA) {}
+		}
+
+		function bindWeChatLaunchTagEvents() {
+			var tag = document.getElementById('launch-btn');
+			if (!tag || tag._wxLaunchBound) return;
+			tag._wxLaunchBound = true;
+			refreshWxLaunchTagAttrs();
+			tag.addEventListener('launch', function () {
+				console.log('[wx-open-launch-app] launch ok');
+				showFabToast('正在打开 U店在哪…');
+			});
+			tag.addEventListener('error', function (e) {
+				var detail = e && e.detail;
+				var errMsg =
+					detail && detail.errMsg
+						? String(detail.errMsg)
+						: detail && detail.errmsg
+							? String(detail.errmsg)
+							: '';
+				console.warn('[wx-open-launch-app]', detail);
+				showAppOpenFailTip(
+					errMsg
+						? '未能唤起 App:' + errMsg
+						: '未能唤起 App,请确认已安装 U店在哪,且开放平台已绑定服务号与移动应用。'
+				);
+			});
+		}
+
+		function setWxInitError(msg) {
+			wxInitLastError = String(msg || '').trim();
+			if (wxInitLastError) console.warn('[wx]', wxInitLastError);
+		}
+
+		function initWeChatOpenLaunchApp(fromUserClick) {
+			if (!shouldFetchWxConfig(!!fromUserClick)) {
+				return Promise.resolve(false);
+			}
+			if (wxJssdkInitPromise && !fromUserClick) return wxJssdkInitPromise;
+
+			wxConfigSignRetriedBaseUrl = false;
+			wxInitLastError = '';
+			var htmlUrl = getWxConfigSignUrl();
+
+			bindWeChatLaunchTagEvents();
+			wxJssdkInitPromise = requestWeChatJssdkSignAndConfig(htmlUrl)
+				.then(function (ok) {
+					if (ok === true) return true;
+					if (!wxInitLastError) {
+						setWxInitError('wx.config 失败,可加 ?wxDebug=1 查看 htmlUrl');
+					}
+					return false;
+				})
+				.catch(function (e) {
+					var msg = e && e.message ? e.message : 'getWxConfig 请求失败';
+					setWxInitError(msg);
+					console.warn('[wx] requestWeChatJssdkSignAndConfig failed', msg, 'htmlUrl=', htmlUrl);
+					if (isWeChatInAppBrowser() && isWxDebugOn()) window.alert(msg);
+					return false;
+				})
+				.finally(function () {
+					if (!weChatJssdkConfigured) wxJssdkInitPromise = null;
+				});
+
+			return wxJssdkInitPromise;
+		}
+
+		function scheduleWeChatJssdkBootstrap() {
+			if (!shouldInitWeChatJssdkOnLoad()) return;
+			var attempts = 0;
+			function tick() {
+				attempts += 1;
+				if (weChatJssdkConfigured) return;
+				initWeChatOpenLaunchApp();
+				if (!weChatJssdkConfigured && attempts < 8 && typeof wx === 'undefined') {
+					setTimeout(tick, 400);
+				}
+			}
+			tick();
+		}
+
+		function showFabToast(msg, ms) {
+			var tip = String(msg || '').trim();
+			if (!tip) return;
+			var el = document.getElementById('openAppToast');
+			if (el) {
+				el.textContent = tip;
+				el.style.display = 'block';
+				if (showFabToast._t) clearTimeout(showFabToast._t);
+				showFabToast._t = setTimeout(function () {
+					el.style.display = 'none';
+				}, ms || 2800);
+			}
+			console.log('[openApp]', tip);
+		}
+
+		function showAppOpenFailTip(msg) {
+			var tip = msg || '未能打开 App,请确认已安装最新版「U店在哪」。';
+			if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
+				uni.showToast({ title: tip, icon: 'none', duration: 2800 });
+			} else if (isWeChatInAppBrowser()) {
+				window.alert(tip);
+			} else {
+				console.warn('[openApp]', tip);
+			}
+		}
+
+		function tryFetchWxConfigOnPcClick() {
+			if (!isWxPcBrowser()) return Promise.resolve(false);
+			showFabToast('正在请求 getWxConfig…');
+			wxJssdkInitPromise = null;
+			return initWeChatOpenLaunchApp(true).then(function (ok) {
+				if (ok) {
+					showFabToast(
+						weChatJssdkConfigured
+							? 'getWxConfig 成功,wx.config 已就绪'
+							: 'getWxConfig 成功'
+					);
+				} else {
+					showFabToast(wxInitLastError || 'getWxConfig 失败');
+				}
+				return ok;
+			});
+		}
+
 		function isWeChatInAppBrowser() {
 			return /MicroMessenger/i.test(navigator.userAgent || '');
 		}
@@ -976,7 +1554,25 @@
 		}
 
 		function tryOpenHBuilderApp() {
+			/* 微信内须直接点击 wx-open-launch-app,scheme 会被拦截 */
+			if (isWeChatInAppBrowser()) return;
+
+			tryFetchWxConfigOnPcClick().then(function () {
+				if (isWxConfigOnClickDebug() && !isWxForceDebug() && !isWxPcAutoDebugHost()) {
+					return;
+				}
+				var pf = prefetchShareVideoBeforeAppOpen();
+				if (pf && typeof pf.then === 'function') {
+					pf.then(tryOpenHBuilderAppViaScheme).catch(tryOpenHBuilderAppViaScheme);
+				} else {
+					tryOpenHBuilderAppViaScheme();
+				}
+			});
+		}
+
+		function tryOpenHBuilderAppViaScheme() {
 			var runOpen = function () {
+				showFabToast('正在打开 U店在哪…');
 				var deepLink = buildAppDeepLink();
 
 				if (typeof plus !== 'undefined' && plus.runtime) {
@@ -991,12 +1587,8 @@
 					} catch (e) {
 						console.warn(e);
 					}
-					/**
-					 * 不在「未安装」时直接弹下载:部分 ROM 对 isApplicationExist 误判为 false,
-					 * 仍应尝试 openURL,避免一点按钮就「请到应用商店下载」。
-					 */
 					try {
-						plus.runtime.openURL(deepLink); 
+						plus.runtime.openURL(deepLink);
 					} catch (e2) {
 						console.warn(e2);
 						if (installed === false) {
@@ -1022,10 +1614,6 @@
 				document.addEventListener('visibilitychange', onVis);
 				window.addEventListener('pagehide', onHide);
 
-				if (isWeChatInAppBrowser()) {
-					window.alert('若点击后无法打开 App:请先点右上角「···」,选择「在浏览器中打开」,再点「APP内打开」。');
-				}
-
 				try {
 					launchAppDeepLink(deepLink);
 				} catch (e3) {
@@ -1034,23 +1622,11 @@
 					return;
 				}
 
-				/**
-				 * 不在超时后弹「去应用商店」:App 已打开时页面常仍 visible,易误报;
-				 * 若未安装,用户无反应可自行去商店,避免打断操作。
-				 */
 				window.setTimeout(function () {
 					finish();
 				}, 3200);
 			};
-
-			var pf = prefetchShareVideoBeforeAppOpen();
-			if (pf && typeof pf.then === 'function') {
-				pf.then(runOpen).catch(function () {
-					runOpen();
-				});
-			} else {
-				runOpen();
-			}
+			runOpen();
 		}
 
 		function qs() {
@@ -2518,27 +3094,46 @@
 		}
 
 		function boot() {
+			var launchTag = document.getElementById('launch-btn');
+			if (launchTag) launchTag.setAttribute('appid', WECHAT_OPEN_APP_ID);
+			bindWeChatLaunchTagEvents();
+			if (shouldInitWeChatJssdkOnLoad()) {
+				if (isWeChatInAppBrowser()) document.body.classList.add('is-wechat');
+				if (isWxPcBrowser() && (isWxForceDebug() || isWxPcAutoDebugHost())) {
+					document.body.classList.add('wx-pc-debug');
+				}
+				scheduleWeChatJssdkBootstrap();
+			}
+
 			fetchGetDeleteFlagByIdIfId().then(function (res) {
 				if (isGetOneBusinessStatus99(res)) {
 					applyShareDynamicClosedMerchantUi(true);
+					refreshWxLaunchTagAttrs();
 					return;
 				}
-				// if (shouldRedirectToShareCheckInUndefined(res)) {
-				// 	window.location.replace(buildShareCheckInUndefinedHref(res));
-				// 	return;
-				// }
 				if (isNoCarryingDataDeleteFlagMsg(res)) {
 					showDynNoCarryingDataState();
+					refreshWxLaunchTagAttrs();
 					return;
 				}
 				applyQueryContent();
 				loadComments();
 			});
-			var openBtn = document.getElementById('openApp');
-			if (openBtn) {
-				openBtn.addEventListener('click', function () {
-					tryOpenHBuilderApp();
-				});
+
+			if (isWeChatInAppBrowser()) {
+				var openBtnWx = document.getElementById('openApp');
+				if (openBtnWx) {
+					openBtnWx.addEventListener('click', function () {
+						if (!weChatJssdkConfigured) {
+							showFabToast(
+								wxInitLastError || '微信 SDK 初始化中,请稍候再点底部按钮'
+							);
+						}
+					});
+				}
+			} else {
+				var openBtn = document.getElementById('openApp');
+				if (openBtn) openBtn.addEventListener('click', tryOpenHBuilderApp);
 			}
 		}