zhuli vor 1 Woche
Ursprung
Commit
2f5655725f
2 geänderte Dateien mit 1187 neuen und 45 gelöschten Zeilen
  1. 602 26
      HBuilderProjects/secondShareGoods.html
  2. 585 19
      HBuilderProjects/shareCheckIn.html

+ 602 - 26
HBuilderProjects/secondShareGoods.html

@@ -47,10 +47,66 @@
 			pointer-events: none;
 			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;
+		}
+
 		.fab-wrap .fab {
 		.fab-wrap .fab {
 			pointer-events: auto;
 			pointer-events: auto;
 		}
 		}
 
 
+		#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 {
 		.fab {
 			display: flex;
 			display: flex;
 			align-items: center;
 			align-items: center;
@@ -564,13 +620,49 @@
 		</section>
 		</section>
 	</div>
 	</div>
 
 
+	<div id="openAppToast" role="status" aria-live="polite"></div>
 	<div class="fab-wrap">
 	<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 class="home-indicator" aria-hidden="true"></div>
 	</div>
 	</div>
 
 
+	<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
 	<script>
 	<script>
 	(function () {
 	(function () {
 		'use strict';
 		'use strict';
@@ -588,6 +680,23 @@
 		var APP_IOS_URL_SCHEME = 'shopro://';
 		var APP_IOS_URL_SCHEME = 'shopro://';
 		var APP_UNI_STORE_PATH = 'pages/secondHandTransactions/pages/detail/index';
 		var APP_UNI_STORE_PATH = 'pages/secondHandTransactions/pages/detail/index';
 
 
+		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 + 'secondShareGoods.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() {
 		function showDownloadTip() {
 			var msg = '请到应用商店下载';
 			var msg = '请到应用商店下载';
 			if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
 			if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
@@ -599,24 +708,36 @@
 
 
 		function mergeSearchAndHashParams() {
 		function mergeSearchAndHashParams() {
 			var params = new URLSearchParams();
 			var params = new URLSearchParams();
-			function ingest(querySlice) {
+			function ingestAppend(querySlice) {
 				if (!querySlice) return;
 				if (!querySlice) return;
 				var p = new URLSearchParams(querySlice);
 				var p = new URLSearchParams(querySlice);
 				p.forEach(function (val, key) {
 				p.forEach(function (val, key) {
 					params.append(key, val);
 					params.append(key, val);
 				});
 				});
 			}
 			}
+			function ingestSet(querySlice) {
+				if (!querySlice) return;
+				var p = new URLSearchParams(querySlice);
+				p.forEach(function (val, key) {
+					params.set(key, val);
+				});
+			}
 			if (location.search && location.search.length > 1) {
 			if (location.search && location.search.length > 1) {
-				ingest(location.search.slice(1));
+				ingestAppend(location.search.slice(1));
 			}
 			}
 			var hash = location.hash || '';
 			var hash = location.hash || '';
 			var qi = hash.indexOf('?');
 			var qi = hash.indexOf('?');
 			if (qi >= 0) {
 			if (qi >= 0) {
-				ingest(hash.slice(qi + 1));
+				ingestSet(hash.slice(qi + 1));
 			}
 			}
 			return params;
 			return params;
 		}
 		}
 
 
+		function q(name) {
+			var v = mergeSearchAndHashParams().get(name);
+			return v == null ? '' : String(v);
+		}
+
 		function buildAppOpenQueryStringMerged() {
 		function buildAppOpenQueryStringMerged() {
 			var params = mergeSearchAndHashParams();
 			var params = mergeSearchAndHashParams();
 			var gid = params.get('goodsId') || params.get('id') || '';
 			var gid = params.get('goodsId') || params.get('id') || '';
@@ -631,8 +752,15 @@
 			return qsOut ? ('?' + qsOut) : '';
 			return qsOut ? ('?' + qsOut) : '';
 		}
 		}
 
 
+		function getSecondGoodsAppUniPath() {
+			return String(APP_UNI_STORE_PATH || 'pages/secondHandTransactions/pages/detail/index').replace(
+				/^\//,
+				''
+			);
+		}
+
 		function buildAppDeepLink() {
 		function buildAppDeepLink() {
-			var path = String(APP_UNI_STORE_PATH || 'pages/secondHandTransactions/pages/detail/index').replace(/^\//, '');
+			var path = getSecondGoodsAppUniPath();
 			var s = buildAppOpenQueryStringMerged();
 			var s = buildAppOpenQueryStringMerged();
 			var root = APP_IOS_URL_SCHEME.replace(/\/$/, '');
 			var root = APP_IOS_URL_SCHEME.replace(/\/$/, '');
 			if (!s) {
 			if (!s) {
@@ -641,10 +769,430 @@
 			return root + '/' + path + s;
 			return root + '/' + path + s;
 		}
 		}
 
 
+		/** Uni 路由串(无 shopro://),供 wx-open-launch-app extinfo */
+		function buildAppUniPageLaunchUrl() {
+			var path = getSecondGoodsAppUniPath();
+			var qs = buildAppOpenQueryStringMerged().replace(/^\?/, '');
+			return qs ? path + '?' + qs : path;
+		}
+
+		/**
+		 * wx-open-launch-app extinfo:pages/secondHandTransactions/pages/detail/index?goodsId=…
+		 */
+		function buildWeChatLaunchExtinfo() {
+			var uniPage = buildAppUniPageLaunchUrl();
+			if (uniPage.length <= 1024) return uniPage;
+			var params = mergeSearchAndHashParams();
+			var mini = new URLSearchParams();
+			var goodsId = params.get('goodsId') || params.get('id') || '';
+			if (goodsId) mini.set('goodsId', goodsId);
+			var path = getSecondGoodsAppUniPath();
+			var shortPage = path + '?' + mini.toString();
+			if (shortPage.length <= 1024) return shortPage;
+			return shortPage.slice(0, 1024);
+		}
+
 		function isWeChatInAppBrowser() {
 		function isWeChatInAppBrowser() {
 			return /MicroMessenger/i.test(navigator.userAgent || '');
 			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 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=' +
+					(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 = getWxGetConfigApiUrl();
+			var requestBody = buildWxGetConfigRequestBody(htmlUrl);
+			console.log('[wx] htmlUrl=', htmlUrl);
+			console.log('[wx] POST getWxConfig →', requestUrl, requestBody);
+			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) {
+						console.warn('[wx] getWxConfig 响应字段不全', res, 'htmlUrl=', htmlUrl);
+						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;
+			});
+		}
+
 		function launchAppDeepLink(deepLink) {
 		function launchAppDeepLink(deepLink) {
 			try {
 			try {
 				var a = document.createElement('a');
 				var a = document.createElement('a');
@@ -660,6 +1208,17 @@
 		}
 		}
 
 
 		function tryOpenHBuilderApp() {
 		function tryOpenHBuilderApp() {
+			if (isWeChatInAppBrowser()) return;
+			tryFetchWxConfigOnPcClick().then(function () {
+				if (isWxConfigOnClickDebug() && !isWxForceDebug() && !isWxPcAutoDebugHost()) {
+					return;
+				}
+				tryOpenHBuilderAppViaScheme();
+			});
+		}
+
+		function tryOpenHBuilderAppViaScheme() {
+			showFabToast('正在打开 U店在哪…');
 			var deepLink = buildAppDeepLink();
 			var deepLink = buildAppDeepLink();
 
 
 			if (typeof plus !== 'undefined' && plus.runtime) {
 			if (typeof plus !== 'undefined' && plus.runtime) {
@@ -704,10 +1263,6 @@
 			document.addEventListener('visibilitychange', onVis);
 			document.addEventListener('visibilitychange', onVis);
 			window.addEventListener('pagehide', onHide);
 			window.addEventListener('pagehide', onHide);
 
 
-			if (isWeChatInAppBrowser()) {
-				window.alert('若点击后无法打开 App:请先点右上角「···」,选择「在浏览器中打开」,再点「APP内打开」。');
-			}
-
 			try {
 			try {
 				launchAppDeepLink(deepLink);
 				launchAppDeepLink(deepLink);
 			} catch (e3) {
 			} catch (e3) {
@@ -717,18 +1272,10 @@
 			}
 			}
 
 
 			window.setTimeout(function () {
 			window.setTimeout(function () {
-				if (done) return;
-				if (document.visibilityState === 'visible' && Date.now() - t0 < 3500) {
-					showDownloadTip();
-				}
 				finish();
 				finish();
 			}, 2600);
 			}, 2600);
 		}
 		}
 
 
-		function q(name) {
-			var v = mergeSearchAndHashParams().get(name);
-			return v == null ? '' : String(v);
-		}
 		function tryDecode(s) {
 		function tryDecode(s) {
 			s = String(s || '');
 			s = String(s || '');
 			if (!s) return '';
 			if (!s) return '';
@@ -740,7 +1287,6 @@
 		}
 		}
 
 
 		var DEFAULT_HERO = '';
 		var DEFAULT_HERO = '';
-		var API_BASE = 'https://test.ailien.shop/alienStore';
 		/** 二手商品等业务接口前缀(与 alienStore 分离) */
 		/** 二手商品等业务接口前缀(与 alienStore 分离) */
 		var API_BASE_SECOND = 'https://test.ailien.shop/alienSecond';
 		var API_BASE_SECOND = 'https://test.ailien.shop/alienSecond';
 		/** 与接口调试「表单数据」一致;地址栏未带经纬度时使用 */
 		/** 与接口调试「表单数据」一致;地址栏未带经纬度时使用 */
@@ -1396,14 +1942,44 @@
 		var shareBtn = document.getElementById('goodsShareBtn');
 		var shareBtn = document.getElementById('goodsShareBtn');
 		if (shareBtn) shareBtn.addEventListener('click', sharePage);
 		if (shareBtn) shareBtn.addEventListener('click', sharePage);
 
 
-		var openAppBtn = document.getElementById('openApp');
-		if (openAppBtn) {
-			openAppBtn.addEventListener('click', function () {
-				tryOpenHBuilderApp();
-			});
+		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();
+			}
+
+			if (isWeChatInAppBrowser()) {
+				var openBtnWx = document.getElementById('openApp');
+				if (openBtnWx) {
+					openBtnWx.addEventListener('click', function () {
+						if (!weChatJssdkConfigured) {
+							showFabToast(
+								wxInitLastError || '微信 SDK 初始化中,请稍候再点底部按钮'
+							);
+						}
+					});
+				}
+			} else {
+				var openAppBtn = document.getElementById('openApp');
+				if (openAppBtn) {
+					openAppBtn.addEventListener('click', tryOpenHBuilderApp);
+				}
+			}
+
+			run();
 		}
 		}
 
 
-		run();
+		if (document.readyState === 'complete') {
+			boot();
+		} else {
+			window.onload = boot;
+		}
 	})();
 	})();
 	</script>
 	</script>
 </body>
 </body>

+ 585 - 19
HBuilderProjects/shareCheckIn.html

@@ -296,10 +296,66 @@
 			pointer-events: none;
 			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;
+		}
+
 		.fab-wrap .fab {
 		.fab-wrap .fab {
 			pointer-events: auto;
 			pointer-events: auto;
 		}
 		}
 
 
+		#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 {
 		.fab {
 			display: flex;
 			display: flex;
 			align-items: center;
 			align-items: center;
@@ -536,13 +592,49 @@
 	</div>
 	</div>
 	</div>
 	</div>
 
 
+	<div id="openAppToast" role="status" aria-live="polite"></div>
 	<div class="fab-wrap">
 	<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 class="home-indicator" aria-hidden="true"></div>
 	</div>
 	</div>
 
 
+	<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
 	<script>
 	<script>
 	(function () {
 	(function () {
 		'use strict';
 		'use strict';
@@ -558,6 +650,21 @@
 		/** 与 shareUndefined.html 一致 */
 		/** 与 shareUndefined.html 一致 */
 		var API_BASE = 'https://test.ailien.shop/alienStore';
 		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 + 'shareCheckIn.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() {
 		function showDownloadTip() {
 			var msg = '请到应用商店下载';
 			var msg = '请到应用商店下载';
 			if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
 			if (typeof uni !== 'undefined' && typeof uni.showToast === 'function') {
@@ -573,20 +680,27 @@
 		 */
 		 */
 		function mergeSearchAndHashParams() {
 		function mergeSearchAndHashParams() {
 			var params = new URLSearchParams();
 			var params = new URLSearchParams();
-			function ingest(querySlice) {
+			function ingestAppend(querySlice) {
 				if (!querySlice) return;
 				if (!querySlice) return;
 				var p = new URLSearchParams(querySlice);
 				var p = new URLSearchParams(querySlice);
 				p.forEach(function (val, key) {
 				p.forEach(function (val, key) {
 					params.append(key, val);
 					params.append(key, val);
 				});
 				});
 			}
 			}
+			function ingestSet(querySlice) {
+				if (!querySlice) return;
+				var p = new URLSearchParams(querySlice);
+				p.forEach(function (val, key) {
+					params.set(key, val);
+				});
+			}
 			if (location.search && location.search.length > 1) {
 			if (location.search && location.search.length > 1) {
-				ingest(location.search.slice(1));
+				ingestAppend(location.search.slice(1));
 			}
 			}
 			var hash = location.hash || '';
 			var hash = location.hash || '';
 			var qi = hash.indexOf('?');
 			var qi = hash.indexOf('?');
 			if (qi >= 0) {
 			if (qi >= 0) {
-				ingest(hash.slice(qi + 1));
+				ingestSet(hash.slice(qi + 1));
 			}
 			}
 			return params;
 			return params;
 		}
 		}
@@ -626,10 +740,435 @@
 			return root + '/' + path + s;
 			return root + '/' + path + s;
 		}
 		}
 
 
+		/** Uni 路由串(无 shopro://),供 wx-open-launch-app extinfo */
+		function buildAppUniPageLaunchUrl() {
+			var path = getCheckInAppUniPath().replace(/^\//, '');
+			var qs = buildAppOpenQueryStringMerged().replace(/^\?/, '');
+			return qs ? path + '?' + qs : path;
+		}
+
+		/**
+		 * wx-open-launch-app extinfo:pages/checkIn/index 或 pages/checkIn/details?…
+		 * isShareCheckInSquare 为真时进详情页(与 getCheckInAppUniPath 一致)
+		 */
+		function buildWeChatLaunchExtinfo() {
+			var uniPage = buildAppUniPageLaunchUrl();
+			if (uniPage.length <= 1024) return uniPage;
+			var params = mergeSearchAndHashParams();
+			var mini = new URLSearchParams();
+			var storeId = params.get('storeId') || params.get('id') || '';
+			if (storeId) mini.set('storeId', storeId);
+			var square = params.get('isShareCheckInSquare');
+			if (square != null && String(square).trim() !== '') {
+				mini.set('isShareCheckInSquare', String(square).trim());
+			}
+			var path = getCheckInAppUniPath().replace(/^\//, '');
+			var shortPage = path + '?' + mini.toString();
+			if (shortPage.length <= 1024) return shortPage;
+			return shortPage.slice(0, 1024);
+		}
+
 		function isWeChatInAppBrowser() {
 		function isWeChatInAppBrowser() {
 			return /MicroMessenger/i.test(navigator.userAgent || '');
 			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 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=' +
+					(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 = getWxGetConfigApiUrl();
+			var requestBody = buildWxGetConfigRequestBody(htmlUrl);
+			console.log('[wx] htmlUrl=', htmlUrl);
+			console.log('[wx] POST getWxConfig →', requestUrl, requestBody);
+			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) {
+						console.warn('[wx] getWxConfig 响应字段不全', res, 'htmlUrl=', htmlUrl);
+						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;
+			});
+		}
+
 		function launchAppDeepLink(deepLink) {
 		function launchAppDeepLink(deepLink) {
 			try {
 			try {
 				var a = document.createElement('a');
 				var a = document.createElement('a');
@@ -645,6 +1184,17 @@
 		}
 		}
 
 
 		function tryOpenHBuilderApp() {
 		function tryOpenHBuilderApp() {
+			if (isWeChatInAppBrowser()) return;
+			tryFetchWxConfigOnPcClick().then(function () {
+				if (isWxConfigOnClickDebug() && !isWxForceDebug() && !isWxPcAutoDebugHost()) {
+					return;
+				}
+				tryOpenHBuilderAppViaScheme();
+			});
+		}
+
+		function tryOpenHBuilderAppViaScheme() {
+			showFabToast('正在打开 U店在哪…');
 			var deepLink = buildAppDeepLink();
 			var deepLink = buildAppDeepLink();
 
 
 			if (typeof plus !== 'undefined' && plus.runtime) {
 			if (typeof plus !== 'undefined' && plus.runtime) {
@@ -689,10 +1239,6 @@
 			document.addEventListener('visibilitychange', onVis);
 			document.addEventListener('visibilitychange', onVis);
 			window.addEventListener('pagehide', onHide);
 			window.addEventListener('pagehide', onHide);
 
 
-			if (isWeChatInAppBrowser()) {
-				window.alert('若点击后无法打开 App:请先点右上角「···」,选择「在浏览器中打开」,再点「APP内打开」。');
-			}
-
 			try {
 			try {
 				launchAppDeepLink(deepLink);
 				launchAppDeepLink(deepLink);
 			} catch (e3) {
 			} catch (e3) {
@@ -702,10 +1248,6 @@
 			}
 			}
 
 
 			window.setTimeout(function () {
 			window.setTimeout(function () {
-				if (done) return;
-				if (document.visibilityState === 'visible' && Date.now() - t0 < 3500) {
-					showDownloadTip();
-				}
 				finish();
 				finish();
 			}, 2600);
 			}, 2600);
 		}
 		}
@@ -1639,6 +2181,17 @@
 		}
 		}
 
 
 		function boot() {
 		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) {
 			fetchGetDeleteFlagByIdIfId().then(function (res) {
 				if (isShareCheckInDeletedByDeleteFlag(res)) {
 				if (isShareCheckInDeletedByDeleteFlag(res)) {
 					applyCheckInDeletedByDeleteFlagUi();
 					applyCheckInDeletedByDeleteFlagUi();
@@ -1649,12 +2202,25 @@
 					return;
 					return;
 				}
 				}
 				applyPage();
 				applyPage();
+				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', tryOpenHBuilderApp);
+				}
 			}
 			}
 		}
 		}