|
@@ -195,11 +195,8 @@
|
|
|
|
|
|
|
|
#launch-btn {
|
|
#launch-btn {
|
|
|
display: none;
|
|
display: none;
|
|
|
- position: absolute;
|
|
|
|
|
- left: 0;
|
|
|
|
|
- top: 0;
|
|
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
- height: 100%;
|
|
|
|
|
|
|
+ height: 48px;
|
|
|
min-height: 48px;
|
|
min-height: 48px;
|
|
|
border-radius: 999px;
|
|
border-radius: 999px;
|
|
|
overflow: hidden;
|
|
overflow: hidden;
|
|
@@ -207,11 +204,11 @@
|
|
|
|
|
|
|
|
body.is-wechat.wx-jssdk-ready #launch-btn {
|
|
body.is-wechat.wx-jssdk-ready #launch-btn {
|
|
|
display: block;
|
|
display: block;
|
|
|
|
|
+ pointer-events: auto;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
body.is-wechat.wx-jssdk-ready #btnContinue {
|
|
body.is-wechat.wx-jssdk-ready #btnContinue {
|
|
|
- visibility: hidden;
|
|
|
|
|
- pointer-events: none;
|
|
|
|
|
|
|
+ display: none !important;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#openAppToast {
|
|
#openAppToast {
|
|
@@ -341,6 +338,16 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ 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) {
|
|
function getFirstUserQuestion(messages) {
|
|
|
var list = Array.isArray(messages) ? messages : [];
|
|
var list = Array.isArray(messages) ? messages : [];
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
for (var i = 0; i < list.length; i++) {
|
|
@@ -467,24 +474,14 @@
|
|
|
refreshWxLaunchTagAttrs();
|
|
refreshWxLaunchTagAttrs();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function buildAiConsultOpenParams() {
|
|
|
|
|
- var params = new URLSearchParams();
|
|
|
|
|
- params.set("pageType", "home");
|
|
|
|
|
- params.set("fromShareAiConsult", "1");
|
|
|
|
|
- return params;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
function buildAppDeepLink() {
|
|
function buildAppDeepLink() {
|
|
|
- var path = APP_UNI_AI_PATH;
|
|
|
|
|
- var qs = buildAiConsultOpenParams().toString();
|
|
|
|
|
|
|
+ var path = String(APP_UNI_AI_PATH || "pages/aiSearchResult/index").replace(/^\//, "");
|
|
|
var root = APP_IOS_URL_SCHEME.replace(/\/$/, "");
|
|
var root = APP_IOS_URL_SCHEME.replace(/\/$/, "");
|
|
|
- return root + "/" + path + (qs ? "?" + qs : "");
|
|
|
|
|
|
|
+ return root + "/" + path;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function buildWeChatLaunchExtinfo() {
|
|
function buildWeChatLaunchExtinfo() {
|
|
|
- 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";
|
|
|
|
|
|
|
+ return String(APP_UNI_AI_PATH || "pages/aiSearchResult/index").replace(/^\//, "");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function isWeChatInAppBrowser() {
|
|
function isWeChatInAppBrowser() {
|
|
@@ -551,8 +548,7 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getWxConfigSignUrl() {
|
|
function getWxConfigSignUrl() {
|
|
|
- if (String(q("wxSignBaseOnly") || "") === "1") return getWxHtmlUrlBase();
|
|
|
|
|
- return getWxSignPageUrlForApi();
|
|
|
|
|
|
|
+ return getWxHtmlUrlBase();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getWxGetConfigApiUrl() {
|
|
function getWxGetConfigApiUrl() {
|
|
@@ -778,7 +774,11 @@
|
|
|
: detail && detail.errmsg
|
|
: detail && detail.errmsg
|
|
|
? String(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/i.test(errMsg)) {
|
|
|
|
|
+ showAppOpenFailTip("未能打开 App,请确认已安装最新版「U店在哪」");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
showAppOpenFailTip(
|
|
showAppOpenFailTip(
|
|
|
errMsg
|
|
errMsg
|
|
|
? "未能打开 App:" + errMsg
|
|
? "未能打开 App:" + errMsg
|
|
@@ -865,11 +865,9 @@
|
|
|
function showAppOpenFailTip(msg) {
|
|
function showAppOpenFailTip(msg) {
|
|
|
var tip = msg || "未能打开 App,请确认已安装最新版「U店在哪」。";
|
|
var tip = msg || "未能打开 App,请确认已安装最新版「U店在哪」。";
|
|
|
if (typeof uni !== "undefined" && typeof uni.showToast === "function") {
|
|
if (typeof uni !== "undefined" && typeof uni.showToast === "function") {
|
|
|
- uni.showToast({ title: msg, icon: "none", duration: 2800 });
|
|
|
|
|
- } else if (isWeChatInAppBrowser()) {
|
|
|
|
|
- window.alert(tip);
|
|
|
|
|
|
|
+ uni.showToast({ title: tip, icon: "none", duration: 2800 });
|
|
|
} else {
|
|
} else {
|
|
|
- showFabToast(tip);
|
|
|
|
|
|
|
+ showFabToast(tip, 3200);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -945,6 +943,7 @@
|
|
|
function tryOpenApp() {
|
|
function tryOpenApp() {
|
|
|
if (isWeChatInAppBrowser()) {
|
|
if (isWeChatInAppBrowser()) {
|
|
|
if (!weChatJssdkConfigured) {
|
|
if (!weChatJssdkConfigured) {
|
|
|
|
|
+ showFabToast("微信 SDK 初始化中,请稍候再点");
|
|
|
initWeChatOpenLaunchApp(true).then(function (ok) {
|
|
initWeChatOpenLaunchApp(true).then(function (ok) {
|
|
|
if (!ok) {
|
|
if (!ok) {
|
|
|
showAppOpenFailTip(wxInitLastError || "微信唤起 App 初始化失败");
|
|
showAppOpenFailTip(wxInitLastError || "微信唤起 App 初始化失败");
|
|
@@ -960,10 +959,22 @@
|
|
|
document.body.classList.add("is-wechat");
|
|
document.body.classList.add("is-wechat");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ document.addEventListener("WeixinOpenTagsError", function (e) {
|
|
|
|
|
+ console.warn("[WeixinOpenTagsError]", e && e.detail);
|
|
|
|
|
+ document.body.classList.remove("wx-jssdk-ready");
|
|
|
|
|
+ showFabToast("微信开放标签加载失败,请稍候再试");
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ var sharePayload = parsePayload();
|
|
|
|
|
+ stripPayloadQueryFromUrl();
|
|
|
|
|
+
|
|
|
|
|
+ var launchTagBoot = document.getElementById("launch-btn");
|
|
|
|
|
+ if (launchTagBoot) launchTagBoot.setAttribute("appid", WECHAT_OPEN_APP_ID);
|
|
|
|
|
+
|
|
|
bindWeChatLaunchTagEvents();
|
|
bindWeChatLaunchTagEvents();
|
|
|
- scheduleWeChatJssdkBootstrap();
|
|
|
|
|
document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
|
|
document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
|
|
|
- render(parsePayload());
|
|
|
|
|
|
|
+ render(sharePayload);
|
|
|
|
|
+ scheduleWeChatJssdkBootstrap();
|
|
|
})();
|
|
})();
|
|
|
</script>
|
|
</script>
|
|
|
</body>
|
|
</body>
|