Bladeren bron

律师登录跳转正确页面

lxr 7 uur geleden
bovenliggende
commit
5458c546b8
1 gewijzigde bestanden met toevoegingen van 81 en 6 verwijderingen
  1. 81 6
      HBuilderProjects/shareAiConsult.html

+ 81 - 6
HBuilderProjects/shareAiConsult.html

@@ -722,6 +722,56 @@
         return { sessionId: sessionId, userId: userId, type: type };
       }
 
+      /**
+       * 与 getConversationApiBase 一致:type=1 U宝;type=0 AI客服;缺省或其它走律师咨询
+       */
+      function getSharePageType() {
+        var type = String(q("type") || "").trim();
+        if (type === "0") return "0";
+        if (type === "1") return "1";
+        if (type) return type;
+        return "2";
+      }
+
+      function getShareBrandByType(type) {
+        var t = String(type || "").trim() || "2";
+        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: "home",
+            fabLabel: "和U宝继续聊",
+          };
+        }
+        return {
+          ogTitle: "和法律U宝的对话",
+          ogDescription: "点击查看对话内容",
+          appPath: "pages/aiSearchResult/index",
+          pageType: "laywer",
+          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() {
         var raw = String(q("message_ids") || q("messageIds") || "").trim();
         if (!raw) return null;
@@ -1162,6 +1212,7 @@
         }
 
         var filterIds = parseMessageIdsFromQuery();
+        updateFabLabels(getShareBrandByType(getSharePageType()).fabLabel);
         main.innerHTML = '<div class="empty">对话内容加载中…</div>';
         fetchConversationHistory(params.sessionId, params.userId, params.type)
           .then(function (data) {
@@ -1178,6 +1229,7 @@
             var tip = e && e.message ? e.message : "对话加载失败,请稍后重试";
             console.warn("[conversation-api]", tip, e);
             main.innerHTML = '<div class="empty">' + escHtml(tip) + "</div>";
+            updateFabLabels(getShareBrandByType(getSharePageType()).fabLabel);
             refreshWxLaunchTagAttrs();
           });
       }
@@ -1273,6 +1325,7 @@
       }
 
       function applyWeixinShareMeta() {
+        var brand = getShareBrandByType(getSharePageType());
         var siteName = "U店在哪";
         var iconUrl =
           "https://alien-volume.oss-cn-beijing.aliyuncs.com/icon/ubao.png";
@@ -1293,8 +1346,8 @@
         };
         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);
@@ -1380,7 +1433,9 @@
       }
 
       function render(data) {
+        var brand = getShareBrandByType(getSharePageType());
         applyWeixinShareMeta();
+        updateFabLabels(brand.fabLabel);
         sharePayloadCache = data || null;
         var main = document.getElementById("main");
         if (!data) {
@@ -1429,26 +1484,46 @@
       }
 
       function buildAiConsultOpenParams() {
+        var brand = getShareBrandByType(getSharePageType());
+        var shareType = getSharePageType();
         var params = new URLSearchParams();
-        params.set("pageType", "home");
+        if (brand.pageType) params.set("pageType", brand.pageType);
         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);
+          params.set("type", conv.type || shareType);
+        } else if (shareType) {
+          params.set("type", shareType);
+        }
         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() {
-        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";
+        return buildWeChatLaunchExtinfoFallback(path, brand);
       }
 
       function isWeChatInAppBrowser() {