|
@@ -35,7 +35,7 @@
|
|
|
background: var(--bg);
|
|
background: var(--bg);
|
|
|
color: var(--text);
|
|
color: var(--text);
|
|
|
min-height: 100vh;
|
|
min-height: 100vh;
|
|
|
- padding-bottom: calc(92px + var(--safe-bottom));
|
|
|
|
|
|
|
+ padding-bottom: calc(88px + var(--safe-bottom));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.hero {
|
|
.hero {
|
|
@@ -134,62 +134,44 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.footer__dock {
|
|
.footer__dock {
|
|
|
- display: flex;
|
|
|
|
|
- justify-content: center;
|
|
|
|
|
|
|
+ position: relative;
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
pointer-events: auto;
|
|
pointer-events: auto;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- .footer__btn-slot {
|
|
|
|
|
- position: relative;
|
|
|
|
|
- width: 50%;
|
|
|
|
|
- height: 48px;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
.continue-btn {
|
|
.continue-btn {
|
|
|
- display: flex;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- justify-content: center;
|
|
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
- height: 48px;
|
|
|
|
|
- margin: 0;
|
|
|
|
|
- padding: 0;
|
|
|
|
|
|
|
+ height: 44px;
|
|
|
border: none;
|
|
border: none;
|
|
|
border-radius: 999px;
|
|
border-radius: 999px;
|
|
|
- background: linear-gradient(90deg, #ffb84c 0%, #ff6b3e 100%);
|
|
|
|
|
- box-shadow: 0 4px 16px rgba(255, 107, 62, 0.32);
|
|
|
|
|
|
|
+ background: linear-gradient(90deg, #ffb347 0%, #f47d1f 55%, #ff7849 100%);
|
|
|
|
|
+ box-shadow: 0 4px 12px rgba(244, 125, 31, 0.28);
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ font-weight: 600;
|
|
|
touch-action: manipulation;
|
|
touch-action: manipulation;
|
|
|
- -webkit-tap-highlight-color: transparent;
|
|
|
|
|
- position: relative;
|
|
|
|
|
- z-index: 1;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- .continue-btn__label {
|
|
|
|
|
- display: block;
|
|
|
|
|
- height: 20px;
|
|
|
|
|
- width: auto;
|
|
|
|
|
- max-width: 90%;
|
|
|
|
|
- pointer-events: none;
|
|
|
|
|
- -webkit-user-drag: none;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#launch-btn {
|
|
#launch-btn {
|
|
|
display: none;
|
|
display: none;
|
|
|
position: absolute;
|
|
position: absolute;
|
|
|
left: 0;
|
|
left: 0;
|
|
|
|
|
+ right: 0;
|
|
|
top: 0;
|
|
top: 0;
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
- height: 100%;
|
|
|
|
|
- min-height: 48px;
|
|
|
|
|
|
|
+ height: 44px;
|
|
|
|
|
+ min-height: 44px;
|
|
|
border-radius: 999px;
|
|
border-radius: 999px;
|
|
|
overflow: hidden;
|
|
overflow: hidden;
|
|
|
- z-index: 2;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /* 微信 SDK 就绪:开放标签叠在 continue 按钮之上,底层按钮始终可见作兜底 */
|
|
|
|
|
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 {
|
|
|
|
|
+ visibility: hidden;
|
|
|
|
|
+ pointer-events: none;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#openAppToast {
|
|
#openAppToast {
|
|
@@ -220,43 +202,32 @@
|
|
|
|
|
|
|
|
<footer class="footer">
|
|
<footer class="footer">
|
|
|
<div class="footer__dock">
|
|
<div class="footer__dock">
|
|
|
- <div class="footer__btn-slot">
|
|
|
|
|
- <button type="button" class="continue-btn" id="btnContinue" aria-label="和U宝继续聊">
|
|
|
|
|
- <img class="continue-btn__label" src="images/uCharts.png" alt="和U宝继续聊" decoding="async">
|
|
|
|
|
- </button>
|
|
|
|
|
- <wx-open-launch-app id="launch-btn" appid="wxf5f1efe3a9f5012e" extinfo="">
|
|
|
|
|
- <script type="text/wxtag-template">
|
|
|
|
|
- <style>
|
|
|
|
|
- .wx-open-app-btn {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- align-items: center;
|
|
|
|
|
- justify-content: center;
|
|
|
|
|
- width: 100%;
|
|
|
|
|
- height: 48px;
|
|
|
|
|
- margin: 0;
|
|
|
|
|
- padding: 0;
|
|
|
|
|
- border: none;
|
|
|
|
|
- border-radius: 999px;
|
|
|
|
|
- background: linear-gradient(90deg, #ffb84c 0%, #ff6b3e 100%);
|
|
|
|
|
- box-shadow: 0 4px 16px rgba(255, 107, 62, 0.32);
|
|
|
|
|
- cursor: pointer;
|
|
|
|
|
- -webkit-tap-highlight-color: transparent;
|
|
|
|
|
- box-sizing: border-box;
|
|
|
|
|
- }
|
|
|
|
|
- .wx-open-app-btn__label {
|
|
|
|
|
- display: block;
|
|
|
|
|
- height: 20px;
|
|
|
|
|
- width: auto;
|
|
|
|
|
- max-width: 90%;
|
|
|
|
|
- pointer-events: none;
|
|
|
|
|
- }
|
|
|
|
|
- </style>
|
|
|
|
|
- <button class="wx-open-app-btn" aria-label="和U宝继续聊">
|
|
|
|
|
- <img class="wx-open-app-btn__label" src="https://test.ailien.shop/h5/HBuilderProjects/images/uCharts.png" alt="和U宝继续聊" decoding="async">
|
|
|
|
|
- </button>
|
|
|
|
|
- </script>
|
|
|
|
|
- </wx-open-launch-app>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <button type="button" class="continue-btn" id="btnContinue">和U宝继续聊 →</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: 44px;
|
|
|
|
|
+ margin: 0;
|
|
|
|
|
+ padding: 0;
|
|
|
|
|
+ border: none;
|
|
|
|
|
+ border-radius: 999px;
|
|
|
|
|
+ background: linear-gradient(90deg, #ffb347 0%, #f47d1f 55%, #ff7849 100%);
|
|
|
|
|
+ box-shadow: 0 4px 12px rgba(244, 125, 31, 0.28);
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ font-weight: 600;
|
|
|
|
|
+ line-height: 44px;
|
|
|
|
|
+ text-align: center;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ -webkit-tap-highlight-color: transparent;
|
|
|
|
|
+ }
|
|
|
|
|
+ </style>
|
|
|
|
|
+ <button class="wx-open-app-btn">和U宝继续聊 →</button>
|
|
|
|
|
+ </script>
|
|
|
|
|
+ </wx-open-launch-app>
|
|
|
</div>
|
|
</div>
|
|
|
</footer>
|
|
</footer>
|
|
|
|
|
|
|
@@ -319,52 +290,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 formatNavTitle(question) {
|
|
|
|
|
- var titled = formatDiscussionTitle(question);
|
|
|
|
|
- var maxLen = 14;
|
|
|
|
|
- var short = titled.length > maxLen ? titled.slice(0, maxLen) + "..." : titled;
|
|
|
|
|
- return short + "-U宝";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function parseContentToMessages(content) {
|
|
|
|
|
- var text = String(content || "").trim();
|
|
|
|
|
- if (!text) return [];
|
|
|
|
|
- var messages = [];
|
|
|
|
|
- var blocks = text.split(/\n\n+/);
|
|
|
|
|
- for (var i = 0; i < blocks.length; i++) {
|
|
|
|
|
- var block = String(blocks[i] || "").trim();
|
|
|
|
|
- if (!block) continue;
|
|
|
|
|
- var userMatch = block.match(/^我[::]\s*([\s\S]*)$/);
|
|
|
|
|
- if (userMatch) {
|
|
|
|
|
- var userText = String(userMatch[1] || "").trim();
|
|
|
|
|
- if (userText) messages.push({ role: "user", content: userText });
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- var aiMatch = block.match(/^UBAO[::]\s*([\s\S]*)$/i);
|
|
|
|
|
- if (aiMatch) {
|
|
|
|
|
- var aiText = String(aiMatch[1] || "").trim();
|
|
|
|
|
- if (aiText) messages.push({ role: "ai", content: aiText });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return messages;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- function resolveShareMessages(data) {
|
|
|
|
|
- var messages = Array.isArray(data && data.messages) ? data.messages : [];
|
|
|
|
|
- if (messages.length) return messages;
|
|
|
|
|
- return parseContentToMessages(data && data.content);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
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++) {
|
|
@@ -456,19 +381,13 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var messages = resolveShareMessages(data);
|
|
|
|
|
|
|
+ var messages = data.messages || [];
|
|
|
var firstQuestion =
|
|
var firstQuestion =
|
|
|
- String(data.firstQuestion || "").trim() ||
|
|
|
|
|
- getFirstUserQuestion(messages) ||
|
|
|
|
|
- (function () {
|
|
|
|
|
- var text = String(data.content || "").trim();
|
|
|
|
|
- var m = text.match(/^我[::]([\s\S]+?)(?:\n\n|$)/);
|
|
|
|
|
- return m ? String(m[1] || "").trim() : "";
|
|
|
|
|
- })();
|
|
|
|
|
|
|
+ String(data.firstQuestion || "").trim() || getFirstUserQuestion(messages);
|
|
|
var pageTitle = formatDiscussionTitle(firstQuestion);
|
|
var pageTitle = formatDiscussionTitle(firstQuestion);
|
|
|
var dateText = formatDate(data.shareTime);
|
|
var dateText = formatDate(data.shareTime);
|
|
|
|
|
|
|
|
- document.title = formatNavTitle(firstQuestion);
|
|
|
|
|
|
|
+ document.title = pageTitle;
|
|
|
|
|
|
|
|
var bodyHtml =
|
|
var bodyHtml =
|
|
|
'<section class="hero">' +
|
|
'<section class="hero">' +
|
|
@@ -484,6 +403,11 @@
|
|
|
var convHtml = renderMessages(messages);
|
|
var convHtml = renderMessages(messages);
|
|
|
if (convHtml) {
|
|
if (convHtml) {
|
|
|
bodyHtml += '<section class="conversation">' + convHtml + "</section>";
|
|
bodyHtml += '<section class="conversation">' + convHtml + "</section>";
|
|
|
|
|
+ } else if (data.content) {
|
|
|
|
|
+ bodyHtml +=
|
|
|
|
|
+ '<section class="fallback-card"><div class="ai-card__text">' +
|
|
|
|
|
+ escHtml(data.content) +
|
|
|
|
|
+ "</div></section>";
|
|
|
} else {
|
|
} else {
|
|
|
bodyHtml += '<div class="empty">暂无对话内容</div>';
|
|
bodyHtml += '<div class="empty">暂无对话内容</div>';
|
|
|
}
|
|
}
|
|
@@ -492,14 +416,24 @@
|
|
|
refreshWxLaunchTagAttrs();
|
|
refreshWxLaunchTagAttrs();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function buildAiConsultOpenParams() {
|
|
|
|
|
+ var params = new URLSearchParams();
|
|
|
|
|
+ params.set("pageType", "home");
|
|
|
|
|
+ params.set("fromShareAiConsult", "1");
|
|
|
|
|
+ return params;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function buildAppDeepLink() {
|
|
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(/\/$/, "");
|
|
var root = APP_IOS_URL_SCHEME.replace(/\/$/, "");
|
|
|
- return root + "/" + path;
|
|
|
|
|
|
|
+ return root + "/" + path + (qs ? "?" + qs : "");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function buildWeChatLaunchExtinfo() {
|
|
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() {
|
|
function isWeChatInAppBrowser() {
|
|
@@ -566,7 +500,8 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getWxConfigSignUrl() {
|
|
function getWxConfigSignUrl() {
|
|
|
- return getWxHtmlUrlBase();
|
|
|
|
|
|
|
+ if (String(q("wxSignBaseOnly") || "") === "1") return getWxHtmlUrlBase();
|
|
|
|
|
+ return getWxSignPageUrlForApi();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getWxGetConfigApiUrl() {
|
|
function getWxGetConfigApiUrl() {
|
|
@@ -776,10 +711,6 @@
|
|
|
} catch (eA) {}
|
|
} catch (eA) {}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function hideWxLaunchOverlay() {
|
|
|
|
|
- document.body.classList.remove("wx-jssdk-ready");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
function bindWeChatLaunchTagEvents() {
|
|
function bindWeChatLaunchTagEvents() {
|
|
|
var tag = document.getElementById("launch-btn");
|
|
var tag = document.getElementById("launch-btn");
|
|
|
if (!tag || tag._wxLaunchBound) return;
|
|
if (!tag || tag._wxLaunchBound) return;
|
|
@@ -796,13 +727,7 @@
|
|
|
: detail && detail.errmsg
|
|
: detail && detail.errmsg
|
|
|
? String(detail.errmsg)
|
|
? String(detail.errmsg)
|
|
|
: "";
|
|
: "";
|
|
|
- console.warn("[wx-open-launch-app]", detail, "extinfo=", tag.getAttribute("extinfo"));
|
|
|
|
|
- if (/launch:fail/i.test(errMsg)) {
|
|
|
|
|
- showAppOpenFailTip(
|
|
|
|
|
- "未能打开 App,请确认已安装最新版「U店在哪」"
|
|
|
|
|
- );
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ console.warn("[wx-open-launch-app]", detail);
|
|
|
showAppOpenFailTip(
|
|
showAppOpenFailTip(
|
|
|
errMsg
|
|
errMsg
|
|
|
? "未能打开 App:" + errMsg
|
|
? "未能打开 App:" + errMsg
|
|
@@ -889,9 +814,11 @@
|
|
|
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: tip, icon: "none", duration: 2800 });
|
|
|
|
|
|
|
+ uni.showToast({ title: msg, icon: "none", duration: 2800 });
|
|
|
|
|
+ } else if (isWeChatInAppBrowser()) {
|
|
|
|
|
+ window.alert(tip);
|
|
|
} else {
|
|
} else {
|
|
|
- showFabToast(tip, 3200);
|
|
|
|
|
|
|
+ showFabToast(tip);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -967,7 +894,6 @@
|
|
|
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 初始化失败");
|
|
@@ -983,19 +909,10 @@
|
|
|
document.body.classList.add("is-wechat");
|
|
document.body.classList.add("is-wechat");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- document.addEventListener("WeixinOpenTagsError", function (e) {
|
|
|
|
|
- console.warn("[WeixinOpenTagsError]", e && e.detail);
|
|
|
|
|
- hideWxLaunchOverlay();
|
|
|
|
|
- showFabToast("微信开放标签加载失败,请稍候再试");
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- var sharePayload = parsePayload();
|
|
|
|
|
- stripPayloadQueryFromUrl();
|
|
|
|
|
-
|
|
|
|
|
bindWeChatLaunchTagEvents();
|
|
bindWeChatLaunchTagEvents();
|
|
|
- document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
|
|
|
|
|
- render(sharePayload);
|
|
|
|
|
scheduleWeChatJssdkBootstrap();
|
|
scheduleWeChatJssdkBootstrap();
|
|
|
|
|
+ document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
|
|
|
|
|
+ render(parsePayload());
|
|
|
})();
|
|
})();
|
|
|
</script>
|
|
</script>
|
|
|
</body>
|
|
</body>
|