|
|
@@ -392,6 +392,8 @@
|
|
|
"https://prod.ailien.shop/ai/life-manager/api/v1/legal-consultation/history/conversation";
|
|
|
var AI_UBAO_CONVERSATION_API =
|
|
|
"https://prod.ailien.shop/ai/life-manager/api/v1/ubao-conversation/history/conversation";
|
|
|
+ var AI_CS_CONVERSATION_API =
|
|
|
+ "https://prod.ailien.shop/ai/life-manager/api/v1/udian-cs-conversation/history/conversation";
|
|
|
|
|
|
var sharePayloadCache = null;
|
|
|
var weChatJssdkConfigured = false;
|
|
|
@@ -563,16 +565,54 @@
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ function getSharePageType() {
|
|
|
+ return String(q("type") || "").trim();
|
|
|
+ }
|
|
|
+
|
|
|
+ /** type=1 U宝;type=0 AI客服;其它(如 2)法律U宝 */
|
|
|
+ function getShareBrandByType(type) {
|
|
|
+ var t = String(type || "").trim();
|
|
|
+ if (t === "0") {
|
|
|
+ return {
|
|
|
+ ogTitle: "和AI客服的对话",
|
|
|
+ ogDescription: "点击查看对话内容",
|
|
|
+ appPath: "pages/aiKfChat/index",
|
|
|
+ pageType: "",
|
|
|
+ fabLabel: "和AI客服继续聊",
|
|
|
+ };
|
|
|
+ }
|
|
|
+ if (t === "2") {
|
|
|
+ return {
|
|
|
+ ogTitle: "和法律U宝的对话",
|
|
|
+ ogDescription: "点击查看对话内容",
|
|
|
+ appPath: "pages/lawyer/index",
|
|
|
+ pageType: "",
|
|
|
+ fabLabel: "和法律U宝继续聊",
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ ogTitle: "和U宝的对话",
|
|
|
+ ogDescription: "点击查看对话内容",
|
|
|
+ appPath: "pages/aiSearchResult/index",
|
|
|
+ pageType: "home",
|
|
|
+ fabLabel: "和U宝继续聊",
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
function getConversationApiBase(type) {
|
|
|
- return String(type || "").trim() === "1"
|
|
|
- ? AI_UBAO_CONVERSATION_API
|
|
|
- : AI_LEGAL_CONVERSATION_API;
|
|
|
+ var t = String(type || "").trim();
|
|
|
+ if (t === "1") return AI_UBAO_CONVERSATION_API;
|
|
|
+ if (t === "0") return AI_CS_CONVERSATION_API;
|
|
|
+ return AI_LEGAL_CONVERSATION_API;
|
|
|
}
|
|
|
|
|
|
function buildConversationApiUrl(sessionId, userId, type) {
|
|
|
var params = new URLSearchParams();
|
|
|
params.set("session_id", sessionId);
|
|
|
params.set("user_id", userId);
|
|
|
+ if (String(type || "").trim() === "0") {
|
|
|
+ params.set("client_type", "0");
|
|
|
+ }
|
|
|
return getConversationApiBase(type) + "?" + params.toString();
|
|
|
}
|
|
|
|
|
|
@@ -751,6 +791,7 @@
|
|
|
}
|
|
|
|
|
|
var filterIds = parseMessageIdsFromQuery();
|
|
|
+ updateFabLabels(getShareBrandByType(params.type).fabLabel);
|
|
|
main.innerHTML = '<div class="empty">对话内容加载中…</div>';
|
|
|
fetchConversationHistory(params.sessionId, params.userId, params.type)
|
|
|
.then(function (data) {
|
|
|
@@ -857,6 +898,7 @@
|
|
|
}
|
|
|
|
|
|
function applyWeixinShareMeta() {
|
|
|
+ var brand = getShareBrandByType(getSharePageType());
|
|
|
var siteName = "U店在哪";
|
|
|
var iconUrl =
|
|
|
"https://alien-volume.oss-cn-beijing.aliyuncs.com/icon/ubao.png";
|
|
|
@@ -877,14 +919,24 @@
|
|
|
};
|
|
|
setMeta("og:site_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"]');
|
|
|
for (var i = 0; i < links.length; i++) {
|
|
|
links[i].setAttribute("href", iconUrl);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ 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 countDisplayableMessages(messages) {
|
|
|
var list = Array.isArray(messages) ? messages : [];
|
|
|
var count = 0;
|
|
|
@@ -963,7 +1015,9 @@
|
|
|
}
|
|
|
|
|
|
function render(data) {
|
|
|
+ var brand = getShareBrandByType(getSharePageType());
|
|
|
applyWeixinShareMeta();
|
|
|
+ updateFabLabels(brand.fabLabel);
|
|
|
sharePayloadCache = data || null;
|
|
|
var main = document.getElementById("main");
|
|
|
if (!data) {
|
|
|
@@ -1012,26 +1066,32 @@
|
|
|
}
|
|
|
|
|
|
function buildAiConsultOpenParams() {
|
|
|
+ var brand = getShareBrandByType(getSharePageType());
|
|
|
var params = new URLSearchParams();
|
|
|
- params.set("pageType", "home");
|
|
|
+ if (brand.pageType) params.set("pageType", brand.pageType);
|
|
|
params.set("fromShareAiConsult", "1");
|
|
|
return params;
|
|
|
}
|
|
|
|
|
|
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 root = APP_IOS_URL_SCHEME.replace(/\/$/, "");
|
|
|
return root + "/" + path + (qs ? "?" + qs : "");
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
var qs = buildAiConsultOpenParams().toString();
|
|
|
var uniPage = qs ? path + "?" + qs : path;
|
|
|
if (uniPage.length <= 1024) return uniPage;
|
|
|
- return path + "?pageType=home&fromShareAiConsult=1";
|
|
|
+ if (brand.pageType) {
|
|
|
+ return path + "?pageType=" + encodeURIComponent(brand.pageType) + "&fromShareAiConsult=1";
|
|
|
+ }
|
|
|
+ return path + "?fromShareAiConsult=1";
|
|
|
}
|
|
|
|
|
|
function isWeChatInAppBrowser() {
|