|
@@ -711,6 +711,50 @@
|
|
|
return { sessionId: sessionId, userId: userId, type: type };
|
|
return { sessionId: sessionId, userId: userId, type: type };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /** type=1 U宝;type=0 AI客服;其它(如 2)律师咨询 / 法律U宝 */
|
|
|
|
|
+ function getSharePageType() {
|
|
|
|
|
+ return String(q("type") || "").trim() || "1";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function getShareBrandByType(type) {
|
|
|
|
|
+ var t = String(type || "").trim() || "1";
|
|
|
|
|
+ if (t === "0") {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ogTitle: "和AI客服的对话",
|
|
|
|
|
+ ogDescription: "点击查看对话内容",
|
|
|
|
|
+ appPath: "pages/aiKfChat/index",
|
|
|
|
|
+ pageType: "",
|
|
|
|
|
+ fabLabel: "和AI客服继续聊",
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ if (t !== "1") {
|
|
|
|
|
+ return {
|
|
|
|
|
+ ogTitle: "和法律U宝的对话",
|
|
|
|
|
+ ogDescription: "点击查看对话内容",
|
|
|
|
|
+ appPath: "pages/aiSearchResult/index",
|
|
|
|
|
+ pageType: "laywer",
|
|
|
|
|
+ fabLabel: "和法律U宝继续聊",
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+ return {
|
|
|
|
|
+ ogTitle: "和U宝的对话",
|
|
|
|
|
+ ogDescription: "点击查看对话内容",
|
|
|
|
|
+ appPath: "pages/aiSearchResult/index",
|
|
|
|
|
+ pageType: "home",
|
|
|
|
|
+ fabLabel: "和U宝继续聊",
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function updateFabLabels(label) {
|
|
|
|
|
+ var text = String(label || "和U宝继续聊").trim() || "和U宝继续聊";
|
|
|
|
|
+ var openApp = document.getElementById("openApp");
|
|
|
|
|
+ if (openApp) {
|
|
|
|
|
+ openApp.setAttribute("aria-label", text);
|
|
|
|
|
+ var img = openApp.querySelector(".fab__brand-img");
|
|
|
|
|
+ if (img) img.setAttribute("alt", text);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function parseMessageIdsFromQuery() {
|
|
function parseMessageIdsFromQuery() {
|
|
|
var raw = String(q("message_ids") || q("messageIds") || "").trim();
|
|
var raw = String(q("message_ids") || q("messageIds") || "").trim();
|
|
|
if (!raw) return null;
|
|
if (!raw) return null;
|
|
@@ -1151,6 +1195,7 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var filterIds = parseMessageIdsFromQuery();
|
|
var filterIds = parseMessageIdsFromQuery();
|
|
|
|
|
+ updateFabLabels(getShareBrandByType(getSharePageType()).fabLabel);
|
|
|
main.innerHTML = '<div class="empty">对话内容加载中…</div>';
|
|
main.innerHTML = '<div class="empty">对话内容加载中…</div>';
|
|
|
fetchConversationHistory(params.sessionId, params.userId, params.type)
|
|
fetchConversationHistory(params.sessionId, params.userId, params.type)
|
|
|
.then(function (data) {
|
|
.then(function (data) {
|
|
@@ -1167,6 +1212,7 @@
|
|
|
var tip = e && e.message ? e.message : "对话加载失败,请稍后重试";
|
|
var tip = e && e.message ? e.message : "对话加载失败,请稍后重试";
|
|
|
console.warn("[conversation-api]", tip, e);
|
|
console.warn("[conversation-api]", tip, e);
|
|
|
main.innerHTML = '<div class="empty">' + escHtml(tip) + "</div>";
|
|
main.innerHTML = '<div class="empty">' + escHtml(tip) + "</div>";
|
|
|
|
|
+ updateFabLabels(getShareBrandByType(getSharePageType()).fabLabel);
|
|
|
refreshWxLaunchTagAttrs();
|
|
refreshWxLaunchTagAttrs();
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -1258,6 +1304,7 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function applyWeixinShareMeta() {
|
|
function applyWeixinShareMeta() {
|
|
|
|
|
+ var brand = getShareBrandByType(getSharePageType());
|
|
|
var siteName = "U店在哪";
|
|
var siteName = "U店在哪";
|
|
|
var iconUrl =
|
|
var iconUrl =
|
|
|
"https://alien-volume.oss-cn-beijing.aliyuncs.com/icon/ubao.png";
|
|
"https://alien-volume.oss-cn-beijing.aliyuncs.com/icon/ubao.png";
|
|
@@ -1278,8 +1325,8 @@
|
|
|
};
|
|
};
|
|
|
setMeta("og:site_name", siteName);
|
|
setMeta("og:site_name", siteName);
|
|
|
setMeta("application-name", siteName);
|
|
setMeta("application-name", siteName);
|
|
|
- setMeta("og:title", "和U宝的对话");
|
|
|
|
|
- setMeta("og:description", "点击查看对话内容");
|
|
|
|
|
|
|
+ setMeta("og:title", brand.ogTitle);
|
|
|
|
|
+ setMeta("og:description", brand.ogDescription);
|
|
|
var links = document.querySelectorAll('link[rel="icon"], link[rel="apple-touch-icon"]');
|
|
var links = document.querySelectorAll('link[rel="icon"], link[rel="apple-touch-icon"]');
|
|
|
for (var i = 0; i < links.length; i++) {
|
|
for (var i = 0; i < links.length; i++) {
|
|
|
links[i].setAttribute("href", iconUrl);
|
|
links[i].setAttribute("href", iconUrl);
|
|
@@ -1364,7 +1411,9 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function render(data) {
|
|
function render(data) {
|
|
|
|
|
+ var brand = getShareBrandByType(getSharePageType());
|
|
|
applyWeixinShareMeta();
|
|
applyWeixinShareMeta();
|
|
|
|
|
+ updateFabLabels(brand.fabLabel);
|
|
|
sharePayloadCache = data || null;
|
|
sharePayloadCache = data || null;
|
|
|
var main = document.getElementById("main");
|
|
var main = document.getElementById("main");
|
|
|
if (!data) {
|
|
if (!data) {
|
|
@@ -1413,26 +1462,43 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function buildAiConsultOpenParams() {
|
|
function buildAiConsultOpenParams() {
|
|
|
|
|
+ var brand = getShareBrandByType(getSharePageType());
|
|
|
var params = new URLSearchParams();
|
|
var params = new URLSearchParams();
|
|
|
- params.set("pageType", "home");
|
|
|
|
|
|
|
+ if (brand.pageType) params.set("pageType", brand.pageType);
|
|
|
params.set("fromShareAiConsult", "1");
|
|
params.set("fromShareAiConsult", "1");
|
|
|
|
|
+ var conv = getConversationQueryParams();
|
|
|
|
|
+ if (conv) {
|
|
|
|
|
+ if (conv.sessionId) params.set("session_id", conv.sessionId);
|
|
|
|
|
+ if (conv.userId) params.set("user_id", conv.userId);
|
|
|
|
|
+ if (conv.type) params.set("type", conv.type);
|
|
|
|
|
+ }
|
|
|
return params;
|
|
return params;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function buildWeChatLaunchExtinfoFallback(path, brand) {
|
|
|
|
|
+ var b = brand || getShareBrandByType(getSharePageType());
|
|
|
|
|
+ if (b.pageType) {
|
|
|
|
|
+ return path + "?pageType=" + encodeURIComponent(b.pageType) + "&fromShareAiConsult=1";
|
|
|
|
|
+ }
|
|
|
|
|
+ return path + "?fromShareAiConsult=1";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
function buildAppDeepLink() {
|
|
function buildAppDeepLink() {
|
|
|
- var path = APP_UNI_AI_PATH;
|
|
|
|
|
|
|
+ var brand = getShareBrandByType(getSharePageType());
|
|
|
|
|
+ var path = brand.appPath || APP_UNI_AI_PATH;
|
|
|
var qs = buildAiConsultOpenParams().toString();
|
|
var qs = buildAiConsultOpenParams().toString();
|
|
|
var root = APP_IOS_URL_SCHEME.replace(/\/$/, "");
|
|
var root = APP_IOS_URL_SCHEME.replace(/\/$/, "");
|
|
|
return root + "/" + path + (qs ? "?" + qs : "");
|
|
return root + "/" + path + (qs ? "?" + qs : "");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function buildWeChatLaunchExtinfo(useBarePathOnly) {
|
|
function buildWeChatLaunchExtinfo(useBarePathOnly) {
|
|
|
- var path = APP_UNI_AI_PATH.replace(/^\//, "");
|
|
|
|
|
|
|
+ var brand = getShareBrandByType(getSharePageType());
|
|
|
|
|
+ var path = (brand.appPath || APP_UNI_AI_PATH).replace(/^\//, "");
|
|
|
if (useBarePathOnly) return path;
|
|
if (useBarePathOnly) return path;
|
|
|
var qs = buildAiConsultOpenParams().toString();
|
|
var qs = buildAiConsultOpenParams().toString();
|
|
|
var uniPage = qs ? path + "?" + qs : path;
|
|
var uniPage = qs ? path + "?" + qs : path;
|
|
|
if (uniPage.length <= 1024) return uniPage;
|
|
if (uniPage.length <= 1024) return uniPage;
|
|
|
- return path + "?pageType=home&fromShareAiConsult=1";
|
|
|
|
|
|
|
+ return buildWeChatLaunchExtinfoFallback(path, brand);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function isWeChatInAppBrowser() {
|
|
function isWeChatInAppBrowser() {
|