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

+ 575 - 26
HBuilderProjects/shareDynamic.html

@@ -486,10 +486,66 @@
 			pointer-events: none;
 		}
 
+		.fab-dock__slot {
+			width: 100%;
+			max-width: 320px;
+			height: 48px;
+			margin: 0 auto;
+			pointer-events: auto;
+		}
+
 		.fab-wrap .fab {
 			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 {
 			display: flex;
 			align-items: center;
@@ -588,13 +644,49 @@
 	</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';
@@ -638,6 +730,18 @@
 		var APP_IOS_URL_SCHEME = 'shopro://';
 		var APP_UNI_STORE_PATH = 'pages/newdetails/index';
 
+		/** 微信 JSSDK — 与 shareIndex.html 一致 */
+		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;
+
 		function showDownloadTip() {
 			var msg = '请到应用商店下载';
 			if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
@@ -912,29 +1016,59 @@
 			return out.length <= maxLen ? out : fullUrl;
 		}
 
-		function buildAppDeepLink() {
+		function getAppUniPathForShareDynamic() {
 			if (isClosedMerchantForAppOpen()) {
-				var sClosed = buildAppOpenQueryStringMerged();
-				var rootClosed = APP_IOS_URL_SCHEME.replace(/\/$/, '');
-				var pathClosed = 'pages/index/login'.replace(/^\//, '');
-				var rawClosed = !sClosed ? rootClosed + '/' + pathClosed : rootClosed + '/' + pathClosed + sClosed;
-				return compactShoproDeepLinkIfTooLong(rawClosed, 7200);
+				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(/^\//, '');
-			/**
-			 * 不要用「任意 pages/ 的 hash」当 App 路径:分享页常在 #/pages/shareDynamic?…,
-			 * 会误唤起成该页而不是 newdetails。仅当 hash 明确含 newdetails 时才采用 hash 路径。
-			 */
+			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;
+			if (!path) path = defaultPath;
+			return String(path || defaultPath).replace(/^\//, '');
+		}
+
+		function buildAppUniPageLaunchUrl() {
+			var path = getAppUniPathForShareDynamic();
+			var qs = buildAppOpenQueryStringMerged().replace(/^\?/, '');
+			return qs ? path + '?' + qs : path;
+		}
+
+		/**
+		 * wx-open-launch-app extinfo:App 解析 Uni 路径,默认 pages/newdetails/index?…&fromShareDynamic=1
+		 */
+		function buildWeChatLaunchExtinfo() {
+			var uniPage = buildAppUniPageLaunchUrl();
+			if (uniPage.length <= 1024) return uniPage;
+			var params = mergeSearchAndHashParams();
+			var mini = new URLSearchParams();
+			var did = params.get('dynamicId') || params.get('sourceId') || params.get('id') || '';
+			if (did) {
+				mini.set('dynamicId', did);
+				mini.set('sourceId', did);
+			}
+			var st = params.get('sourceType');
+			if (st) mini.set('sourceType', st);
+			mini.set('fromShareDynamic', '1');
+			var path = getAppUniPathForShareDynamic();
+			var shortPage = path + '?' + mini.toString();
+			if (shortPage.length <= 1024) return shortPage;
+			var deep = buildAppDeepLink();
+			return deep.length <= 1024 ? deep : shortPage.slice(0, 1024);
+		}
+
+		function buildAppDeepLink() {
+			if (isClosedMerchantForAppOpen()) {
+				var sClosed = buildAppOpenQueryStringMerged();
+				var rootClosed = APP_IOS_URL_SCHEME.replace(/\/$/, '');
+				var pathClosed = 'pages/index/login'.replace(/^\//, '');
+				var rawClosed = !sClosed ? rootClosed + '/' + pathClosed : rootClosed + '/' + pathClosed + sClosed;
+				return compactShoproDeepLinkIfTooLong(rawClosed, 7200);
 			}
-			path = String(path || defaultPath).replace(/^\//, '');
+			var path = getAppUniPathForShareDynamic();
 			var s = buildAppOpenQueryStringMerged();
 			var root = APP_IOS_URL_SCHEME.replace(/\/$/, '');
 			var raw = !s ? root + '/' + path : root + '/' + path + s;
@@ -945,6 +1079,386 @@
 			return /MicroMessenger/i.test(navigator.userAgent || '');
 		}
 
+		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 buildWxGetConfigRequestUrl(htmlUrl) {
+			return (
+				API_BASE.replace(/\/$/, '') +
+				WECHAT_GET_WX_CONFIG_PATH +
+				'?url=' +
+				encodeURIComponent(htmlUrl || getWxConfigSignUrl())
+			);
+		}
+
+		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 || d.noncestr || d.nonce;
+			var signature = d.signature || d.sign;
+			if (!appId || timestamp == null || !nonceStr || !signature) return null;
+			return {
+				appId: String(appId),
+				timestamp: Number(timestamp),
+				nonceStr: String(nonceStr),
+				signature: String(signature)
+			};
+		}
+
+		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=' +
+					(signPageUrl || getWxHtmlUrl()) +
+					';appId=' +
+					WECHAT_MP_APP_ID
+				);
+			}
+			if (/require\s*subscribe/i.test(errMsg)) {
+				return tip + ':' + errMsg + '(服务号需用户已关注)';
+			}
+			return errMsg ? tip + ':' + errMsg : tip;
+		}
+
+		function setWxInitError(msg) {
+			wxInitLastError = String(msg || '').trim();
+			if (wxInitLastError) console.warn('[wx]', wxInitLastError);
+		}
+
+		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 = buildWxGetConfigRequestUrl(htmlUrl);
+			console.log('[wx] htmlUrl=', htmlUrl);
+			console.log('[wx] GET getWxConfig →', requestUrl);
+			return fetch(requestUrl, {
+				method: 'GET',
+				mode: 'cors',
+				credentials: 'omit',
+				headers: { Accept: 'application/json' }
+			})
+				.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 (sign.appId !== WECHAT_MP_APP_ID) {
+						console.warn(
+							'[wx] 后端 appId=' + sign.appId + ',期望服务号 ' + WECHAT_MP_APP_ID
+						);
+					}
+					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 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');
+					}
+					return false;
+				})
+				.catch(function (e) {
+					var msg = e && e.message ? e.message : 'getWxConfig 请求失败';
+					setWxInitError(msg);
+					console.warn('[wx] init 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;
+			});
+		}
+
 		/** 微信内置浏览器、iOS:OSS 截图/封面易因 Referer 被拒;video 首帧不可靠 */
 		function preferStaticStillOverVideo() {
 			return isIOSVideoEnv() || isWeChatInAppBrowser();
@@ -976,6 +1490,17 @@
 		}
 
 		function tryOpenHBuilderApp() {
+			if (isWeChatInAppBrowser()) return;
+
+			tryFetchWxConfigOnPcClick().then(function () {
+				if (isWxConfigOnClickDebug() && !isWxForceDebug() && !isWxPcAutoDebugHost()) {
+					return;
+				}
+				tryOpenHBuilderAppViaScheme();
+			});
+		}
+
+		function tryOpenHBuilderAppViaScheme() {
 			var runOpen = function () {
 				var deepLink = buildAppDeepLink();
 
@@ -1022,10 +1547,6 @@
 				document.addEventListener('visibilitychange', onVis);
 				window.addEventListener('pagehide', onHide);
 
-				if (isWeChatInAppBrowser()) {
-					window.alert('若点击后无法打开 App:请先点右上角「···」,选择「在浏览器中打开」,再点「APP内打开」。');
-				}
-
 				try {
 					launchAppDeepLink(deepLink);
 				} catch (e3) {
@@ -1581,6 +2102,9 @@
 		function applyShareDynamicClosedMerchantUi(closed) {
 			var wasClosed = closedMerchantFlag;
 			closedMerchantFlag = closed;
+			if (wasClosed !== closed && weChatJssdkConfigured) {
+				refreshWxLaunchTagAttrs();
+			}
 			if (closed) {
 				setShareDynamicClosedSurfaceDom(true);
 				if (!wasClosed) {
@@ -2518,6 +3042,17 @@
 		}
 
 		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);
@@ -2533,12 +3068,26 @@
 				}
 				applyQueryContent();
 				loadComments();
+				if (weChatJssdkConfigured) refreshWxLaunchTagAttrs();
 			});
-			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', function () {
+						tryOpenHBuilderApp();
+					});
+				}
 			}
 		}