|
@@ -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(88px + var(--safe-bottom));
|
|
|
|
|
|
|
+ padding-bottom: calc(92px + var(--safe-bottom));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.hero {
|
|
.hero {
|
|
@@ -134,44 +134,58 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.footer__dock {
|
|
.footer__dock {
|
|
|
- position: relative;
|
|
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ justify-content: center;
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
pointer-events: auto;
|
|
pointer-events: auto;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ .footer__btn-slot {
|
|
|
|
|
+ width: 50%;
|
|
|
|
|
+ height: 48px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
.continue-btn {
|
|
.continue-btn {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
- height: 44px;
|
|
|
|
|
|
|
+ height: 48px;
|
|
|
|
|
+ margin: 0;
|
|
|
|
|
+ padding: 0;
|
|
|
border: none;
|
|
border: none;
|
|
|
border-radius: 999px;
|
|
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;
|
|
|
|
|
|
|
+ background: linear-gradient(90deg, #ffb84c 0%, #ff6b3e 100%);
|
|
|
|
|
+ box-shadow: 0 4px 16px rgba(255, 107, 62, 0.32);
|
|
|
touch-action: manipulation;
|
|
touch-action: manipulation;
|
|
|
|
|
+ -webkit-tap-highlight-color: transparent;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .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;
|
|
|
|
|
- left: 0;
|
|
|
|
|
- right: 0;
|
|
|
|
|
- top: 0;
|
|
|
|
|
width: 100%;
|
|
width: 100%;
|
|
|
- height: 44px;
|
|
|
|
|
- min-height: 44px;
|
|
|
|
|
|
|
+ height: 48px;
|
|
|
|
|
+ min-height: 48px;
|
|
|
border-radius: 999px;
|
|
border-radius: 999px;
|
|
|
overflow: hidden;
|
|
overflow: hidden;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
@@ -202,32 +216,43 @@
|
|
|
|
|
|
|
|
<footer class="footer">
|
|
<footer class="footer">
|
|
|
<div class="footer__dock">
|
|
<div class="footer__dock">
|
|
|
- <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 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>
|
|
|
</div>
|
|
</div>
|
|
|
</footer>
|
|
</footer>
|
|
|
|
|
|
|
@@ -290,6 +315,52 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ 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++) {
|
|
@@ -381,13 +452,19 @@
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var messages = data.messages || [];
|
|
|
|
|
|
|
+ var messages = resolveShareMessages(data);
|
|
|
var firstQuestion =
|
|
var firstQuestion =
|
|
|
- String(data.firstQuestion || "").trim() || getFirstUserQuestion(messages);
|
|
|
|
|
|
|
+ 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() : "";
|
|
|
|
|
+ })();
|
|
|
var pageTitle = formatDiscussionTitle(firstQuestion);
|
|
var pageTitle = formatDiscussionTitle(firstQuestion);
|
|
|
var dateText = formatDate(data.shareTime);
|
|
var dateText = formatDate(data.shareTime);
|
|
|
|
|
|
|
|
- document.title = pageTitle;
|
|
|
|
|
|
|
+ document.title = formatNavTitle(firstQuestion);
|
|
|
|
|
|
|
|
var bodyHtml =
|
|
var bodyHtml =
|
|
|
'<section class="hero">' +
|
|
'<section class="hero">' +
|
|
@@ -403,11 +480,6 @@
|
|
|
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>';
|
|
|
}
|
|
}
|
|
@@ -416,24 +488,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() {
|
|
@@ -500,8 +562,7 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getWxConfigSignUrl() {
|
|
function getWxConfigSignUrl() {
|
|
|
- if (String(q("wxSignBaseOnly") || "") === "1") return getWxHtmlUrlBase();
|
|
|
|
|
- return getWxSignPageUrlForApi();
|
|
|
|
|
|
|
+ return getWxHtmlUrlBase();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function getWxGetConfigApiUrl() {
|
|
function getWxGetConfigApiUrl() {
|
|
@@ -727,7 +788,13 @@
|
|
|
: 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
|
|
@@ -814,11 +881,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);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -894,6 +959,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 初始化失败");
|
|
@@ -909,10 +975,19 @@
|
|
|
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();
|
|
|
|
|
+
|
|
|
bindWeChatLaunchTagEvents();
|
|
bindWeChatLaunchTagEvents();
|
|
|
- scheduleWeChatJssdkBootstrap();
|
|
|
|
|
document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
|
|
document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
|
|
|
- render(parsePayload());
|
|
|
|
|
|
|
+ render(sharePayload);
|
|
|
|
|
+ scheduleWeChatJssdkBootstrap();
|
|
|
})();
|
|
})();
|
|
|
</script>
|
|
</script>
|
|
|
</body>
|
|
</body>
|