|
|
@@ -182,8 +182,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 {
|
|
|
@@ -205,13 +203,15 @@
|
|
|
min-height: 48px;
|
|
|
border-radius: 999px;
|
|
|
overflow: hidden;
|
|
|
- z-index: 2;
|
|
|
}
|
|
|
|
|
|
- /* 底层 continue 按钮始终可见;微信就绪后开放标签叠在上面接收点击 */
|
|
|
body.is-wechat.wx-jssdk-ready #launch-btn {
|
|
|
display: block;
|
|
|
- pointer-events: auto;
|
|
|
+ }
|
|
|
+
|
|
|
+ body.is-wechat.wx-jssdk-ready #btnContinue {
|
|
|
+ visibility: hidden;
|
|
|
+ pointer-events: none;
|
|
|
}
|
|
|
|
|
|
#openAppToast {
|
|
|
@@ -341,16 +341,6 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function stripPayloadQueryFromUrl() {
|
|
|
- try {
|
|
|
- if (!location.search || location.search.indexOf("payload=") < 0) return;
|
|
|
- var u = new URL(location.href);
|
|
|
- u.searchParams.delete("payload");
|
|
|
- var next = u.pathname + (u.search || "") + (u.hash || "");
|
|
|
- history.replaceState(null, document.title, next);
|
|
|
- } catch (eStrip) {}
|
|
|
- }
|
|
|
-
|
|
|
function getFirstUserQuestion(messages) {
|
|
|
var list = Array.isArray(messages) ? messages : [];
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
@@ -477,14 +467,24 @@
|
|
|
refreshWxLaunchTagAttrs();
|
|
|
}
|
|
|
|
|
|
+ function buildAiConsultOpenParams() {
|
|
|
+ var params = new URLSearchParams();
|
|
|
+ params.set("pageType", "home");
|
|
|
+ params.set("fromShareAiConsult", "1");
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+
|
|
|
function buildAppDeepLink() {
|
|
|
- var path = String(APP_UNI_AI_PATH || "pages/aiSearchResult/index").replace(/^\//, "");
|
|
|
+ var path = APP_UNI_AI_PATH;
|
|
|
+ var qs = buildAiConsultOpenParams().toString();
|
|
|
var root = APP_IOS_URL_SCHEME.replace(/\/$/, "");
|
|
|
- return root + "/" + path;
|
|
|
+ return root + "/" + path + (qs ? "?" + qs : "");
|
|
|
}
|
|
|
|
|
|
function buildWeChatLaunchExtinfo() {
|
|
|
- return String(APP_UNI_AI_PATH || "pages/aiSearchResult/index").replace(/^\//, "");
|
|
|
+ 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";
|
|
|
}
|
|
|
|
|
|
function isWeChatInAppBrowser() {
|
|
|
@@ -551,7 +551,8 @@
|
|
|
}
|
|
|
|
|
|
function getWxConfigSignUrl() {
|
|
|
- return getWxHtmlUrlBase();
|
|
|
+ if (String(q("wxSignBaseOnly") || "") === "1") return getWxHtmlUrlBase();
|
|
|
+ return getWxSignPageUrlForApi();
|
|
|
}
|
|
|
|
|
|
function getWxGetConfigApiUrl() {
|
|
|
@@ -752,10 +753,6 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- function hideWxLaunchOverlay() {
|
|
|
- document.body.classList.remove("wx-jssdk-ready");
|
|
|
- }
|
|
|
-
|
|
|
function refreshWxLaunchTagAttrs() {
|
|
|
var tag = document.getElementById("launch-btn");
|
|
|
if (!tag) return;
|
|
|
@@ -781,12 +778,7 @@
|
|
|
: detail && detail.errmsg
|
|
|
? String(detail.errmsg)
|
|
|
: "";
|
|
|
- console.warn("[wx-open-launch-app]", detail, "extinfo=", tag.getAttribute("extinfo"));
|
|
|
- if (/launch:fail/i.test(errMsg)) {
|
|
|
- hideWxLaunchOverlay();
|
|
|
- showAppOpenFailTip("未能打开 App,请确认已安装最新版「U店在哪」");
|
|
|
- return;
|
|
|
- }
|
|
|
+ console.warn("[wx-open-launch-app]", detail);
|
|
|
showAppOpenFailTip(
|
|
|
errMsg
|
|
|
? "未能打开 App:" + errMsg
|
|
|
@@ -873,9 +865,11 @@
|
|
|
function showAppOpenFailTip(msg) {
|
|
|
var tip = msg || "未能打开 App,请确认已安装最新版「U店在哪」。";
|
|
|
if (typeof uni !== "undefined" && typeof uni.showToast === "function") {
|
|
|
- uni.showToast({ title: tip, icon: "none", duration: 2800 });
|
|
|
+ uni.showToast({ title: msg, icon: "none", duration: 2800 });
|
|
|
+ } else if (isWeChatInAppBrowser()) {
|
|
|
+ window.alert(tip);
|
|
|
} else {
|
|
|
- showFabToast(tip, 3200);
|
|
|
+ showFabToast(tip);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -950,14 +944,7 @@
|
|
|
|
|
|
function tryOpenApp() {
|
|
|
if (isWeChatInAppBrowser()) {
|
|
|
- if (weChatJssdkConfigured && !document.body.classList.contains("wx-jssdk-ready")) {
|
|
|
- document.body.classList.add("wx-jssdk-ready");
|
|
|
- refreshWxLaunchTagAttrs();
|
|
|
- showFabToast("请再次点击底部按钮");
|
|
|
- return;
|
|
|
- }
|
|
|
if (!weChatJssdkConfigured) {
|
|
|
- showFabToast("微信 SDK 初始化中,请稍候再点");
|
|
|
initWeChatOpenLaunchApp(true).then(function (ok) {
|
|
|
if (!ok) {
|
|
|
showAppOpenFailTip(wxInitLastError || "微信唤起 App 初始化失败");
|
|
|
@@ -973,22 +960,10 @@
|
|
|
document.body.classList.add("is-wechat");
|
|
|
}
|
|
|
|
|
|
- document.addEventListener("WeixinOpenTagsError", function (e) {
|
|
|
- console.warn("[WeixinOpenTagsError]", e && e.detail);
|
|
|
- hideWxLaunchOverlay();
|
|
|
- showFabToast("微信开放标签加载失败,请稍候再试");
|
|
|
- });
|
|
|
-
|
|
|
- var sharePayload = parsePayload();
|
|
|
- stripPayloadQueryFromUrl();
|
|
|
-
|
|
|
- var launchTagBoot = document.getElementById("launch-btn");
|
|
|
- if (launchTagBoot) launchTagBoot.setAttribute("appid", WECHAT_OPEN_APP_ID);
|
|
|
-
|
|
|
bindWeChatLaunchTagEvents();
|
|
|
- document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
|
|
|
- render(sharePayload);
|
|
|
scheduleWeChatJssdkBootstrap();
|
|
|
+ document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
|
|
|
+ render(parsePayload());
|
|
|
})();
|
|
|
</script>
|
|
|
</body>
|