|
|
@@ -167,9 +167,10 @@
|
|
|
}
|
|
|
|
|
|
.footer__btn-slot {
|
|
|
- position: relative;
|
|
|
- width: 50%;
|
|
|
+ width: 100%;
|
|
|
+ max-width: 280px;
|
|
|
height: 48px;
|
|
|
+ margin: 0 auto;
|
|
|
}
|
|
|
|
|
|
.continue-btn {
|
|
|
@@ -186,8 +187,6 @@
|
|
|
box-shadow: 0 4px 16px rgba(255, 107, 62, 0.32);
|
|
|
touch-action: manipulation;
|
|
|
-webkit-tap-highlight-color: transparent;
|
|
|
- position: relative;
|
|
|
- z-index: 1;
|
|
|
}
|
|
|
|
|
|
.continue-btn__label {
|
|
|
@@ -201,20 +200,20 @@
|
|
|
|
|
|
#launch-btn {
|
|
|
display: none;
|
|
|
- position: absolute;
|
|
|
- left: 0;
|
|
|
- top: 0;
|
|
|
width: 100%;
|
|
|
- height: 100%;
|
|
|
+ height: 48px;
|
|
|
min-height: 48px;
|
|
|
border-radius: 999px;
|
|
|
overflow: hidden;
|
|
|
- z-index: 2;
|
|
|
+ opacity: 1;
|
|
|
}
|
|
|
|
|
|
body.is-wechat.wx-jssdk-ready #launch-btn {
|
|
|
display: block;
|
|
|
- pointer-events: auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ body.is-wechat.wx-jssdk-ready #btnContinue {
|
|
|
+ display: none !important;
|
|
|
}
|
|
|
|
|
|
#openAppToast {
|
|
|
@@ -532,16 +531,42 @@
|
|
|
return root + "/" + path + (qs ? "?" + qs : "");
|
|
|
}
|
|
|
|
|
|
- function buildWeChatLaunchExtinfo() {
|
|
|
+ function buildWeChatLaunchExtinfo(useBarePathOnly) {
|
|
|
+ var path = APP_UNI_AI_PATH.replace(/^\//, "");
|
|
|
+ if (useBarePathOnly) return path;
|
|
|
var qs = buildAiConsultOpenParams().toString();
|
|
|
- var uniPage = qs ? APP_UNI_AI_PATH + "?" + qs : APP_UNI_AI_PATH;
|
|
|
- return uniPage.length <= 1024 ? uniPage : APP_UNI_AI_PATH + "?pageType=home&fromShareAiConsult=1";
|
|
|
+ var uniPage = qs ? path + "?" + qs : path;
|
|
|
+ if (uniPage.length <= 1024) return uniPage;
|
|
|
+ return path + "?pageType=home&fromShareAiConsult=1";
|
|
|
}
|
|
|
|
|
|
function isWeChatInAppBrowser() {
|
|
|
return /MicroMessenger/i.test(navigator.userAgent || "");
|
|
|
}
|
|
|
|
|
|
+ function getWxShareEntryFrom() {
|
|
|
+ var from = q("from");
|
|
|
+ if (from) return String(from).trim().toLowerCase();
|
|
|
+ try {
|
|
|
+ var h = location.hash || "";
|
|
|
+ var qi = h.indexOf("?");
|
|
|
+ if (qi >= 0) {
|
|
|
+ var hf = new URLSearchParams(h.slice(qi + 1)).get("from");
|
|
|
+ if (hf) return String(hf).trim().toLowerCase();
|
|
|
+ }
|
|
|
+ } catch (eH) {}
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ function logWxEntryDiagnostics() {
|
|
|
+ if (!isWeChatInAppBrowser()) return;
|
|
|
+ console.log("[wx-entry]", {
|
|
|
+ entryFrom: getWxShareEntryFrom() || "(无)",
|
|
|
+ wxJssdkReady: weChatJssdkConfigured,
|
|
|
+ signUrl: getWxConfigSignUrl(),
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
function isIOSWeChatBrowser() {
|
|
|
var ua = navigator.userAgent || "";
|
|
|
return /MicroMessenger/i.test(ua) && /iPhone|iPad|iPod/i.test(ua);
|
|
|
@@ -601,8 +626,11 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /** 默认 pathname 验签:AI 分享链常带超长 payload,与后端无参签名一致,避免开放标签 fail_check */
|
|
|
function getWxConfigSignUrl() {
|
|
|
+ if (String(q("wxSignFullUrl") || "") === "1") return getWxSignPageUrlForApi();
|
|
|
if (String(q("wxSignBaseOnly") || "") === "1") return getWxHtmlUrlBase();
|
|
|
+ if (isWeChatInAppBrowser()) return getWxHtmlUrlBase();
|
|
|
return getWxSignPageUrlForApi();
|
|
|
}
|
|
|
|
|
|
@@ -804,12 +832,12 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- function refreshWxLaunchTagAttrs() {
|
|
|
+ function refreshWxLaunchTagAttrs(useBarePathOnly) {
|
|
|
var tag = document.getElementById("launch-btn");
|
|
|
if (!tag) return;
|
|
|
try {
|
|
|
tag.setAttribute("appid", WECHAT_OPEN_APP_ID);
|
|
|
- tag.setAttribute("extinfo", buildWeChatLaunchExtinfo());
|
|
|
+ tag.setAttribute("extinfo", buildWeChatLaunchExtinfo(!!useBarePathOnly));
|
|
|
} catch (eA) {}
|
|
|
}
|
|
|
|
|
|
@@ -829,7 +857,38 @@
|
|
|
: detail && detail.errmsg
|
|
|
? String(detail.errmsg)
|
|
|
: "";
|
|
|
- console.warn("[wx-open-launch-app]", detail);
|
|
|
+ console.warn(
|
|
|
+ "[wx-open-launch-app]",
|
|
|
+ detail,
|
|
|
+ "extinfo=",
|
|
|
+ tag.getAttribute("extinfo")
|
|
|
+ );
|
|
|
+
|
|
|
+ if (/launch:fail_check/i.test(errMsg)) {
|
|
|
+ showAppOpenFailTip(
|
|
|
+ "请用微信分享卡片进入,或确认已安装最新版「U店在哪」"
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (
|
|
|
+ /launch:fail/i.test(errMsg) &&
|
|
|
+ !tag._wxLaunchBareRetried &&
|
|
|
+ tag.getAttribute("extinfo") !== buildWeChatLaunchExtinfo(true)
|
|
|
+ ) {
|
|
|
+ tag._wxLaunchBareRetried = true;
|
|
|
+ refreshWxLaunchTagAttrs(true);
|
|
|
+ showFabToast("请再点一次「和U宝继续聊」");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (/launch:fail/i.test(errMsg) && !getWxShareEntryFrom()) {
|
|
|
+ showAppOpenFailTip(
|
|
|
+ "当前环境无法直接打开 App,请使用 App「分享到微信」后点分享卡片进入"
|
|
|
+ );
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
showAppOpenFailTip(
|
|
|
errMsg
|
|
|
? "未能打开 App:" + errMsg
|
|
|
@@ -994,27 +1053,52 @@
|
|
|
}
|
|
|
|
|
|
function tryOpenApp() {
|
|
|
+ if (isWeChatInAppBrowser()) return;
|
|
|
+ tryOpenHBuilderAppViaScheme();
|
|
|
+ }
|
|
|
+
|
|
|
+ function boot() {
|
|
|
+ var launchTag = document.getElementById("launch-btn");
|
|
|
+ if (launchTag) launchTag.setAttribute("appid", WECHAT_OPEN_APP_ID);
|
|
|
+ bindWeChatLaunchTagEvents();
|
|
|
+
|
|
|
if (isWeChatInAppBrowser()) {
|
|
|
- if (!weChatJssdkConfigured) {
|
|
|
- initWeChatOpenLaunchApp(true).then(function (ok) {
|
|
|
- if (!ok) {
|
|
|
- showAppOpenFailTip(wxInitLastError || "微信唤起 App 初始化失败");
|
|
|
+ document.body.classList.add("is-wechat");
|
|
|
+ logWxEntryDiagnostics();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (shouldInitWeChatJssdkOnLoad()) {
|
|
|
+ scheduleWeChatJssdkBootstrap();
|
|
|
+ }
|
|
|
+
|
|
|
+ document.addEventListener("WeixinOpenTagsError", function (e) {
|
|
|
+ console.warn("[WeixinOpenTagsError]", e && e.detail);
|
|
|
+ });
|
|
|
+
|
|
|
+ var btnContinue = document.getElementById("btnContinue");
|
|
|
+ if (btnContinue) {
|
|
|
+ if (isWeChatInAppBrowser()) {
|
|
|
+ btnContinue.addEventListener("click", function () {
|
|
|
+ if (!weChatJssdkConfigured) {
|
|
|
+ showFabToast(
|
|
|
+ wxInitLastError || "微信 SDK 初始化中,请稍候再点底部按钮"
|
|
|
+ );
|
|
|
+ initWeChatOpenLaunchApp(true);
|
|
|
}
|
|
|
});
|
|
|
+ } else {
|
|
|
+ btnContinue.addEventListener("click", tryOpenApp);
|
|
|
}
|
|
|
- return;
|
|
|
}
|
|
|
- tryOpenHBuilderAppViaScheme();
|
|
|
- }
|
|
|
|
|
|
- if (isWeChatInAppBrowser()) {
|
|
|
- document.body.classList.add("is-wechat");
|
|
|
+ render(parsePayload());
|
|
|
}
|
|
|
|
|
|
- bindWeChatLaunchTagEvents();
|
|
|
- scheduleWeChatJssdkBootstrap();
|
|
|
- document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
|
|
|
- render(parsePayload());
|
|
|
+ if (document.readyState === "complete") {
|
|
|
+ boot();
|
|
|
+ } else {
|
|
|
+ window.addEventListener("load", boot);
|
|
|
+ }
|
|
|
})();
|
|
|
</script>
|
|
|
</body>
|