Explorar o código

Merge branch 'master' of http://8.152.195.41:3000/alien/h5

sunshibo hai 1 semana
pai
achega
6b68e1e819
Modificáronse 2 ficheiros con 191 adicións e 53 borrados
  1. BIN=BIN
      HBuilderProjects/images/uCharts.png
  2. 191 53
      HBuilderProjects/shareAiConsult.html

BIN=BIN
HBuilderProjects/images/uCharts.png


+ 191 - 53
HBuilderProjects/shareAiConsult.html

@@ -5,6 +5,12 @@
   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
   <meta name="format-detection" content="telephone=no">
   <title>与U宝对话</title>
+  <meta property="og:title" content="和U宝的对话">
+  <meta property="og:description" content="点击查看对话内容">
+  <meta property="og:site_name" content="U店在哪">
+  <meta name="application-name" content="U店在哪">
+  <link rel="icon" type="image/png" href="https://alien-volume.oss-cn-beijing.aliyuncs.com/icon/ubao.png">
+  <link rel="apple-touch-icon" href="https://alien-volume.oss-cn-beijing.aliyuncs.com/icon/ubao.png">
   <style>
     :root {
       --bg: #f4f6fb;
@@ -29,7 +35,7 @@
       background: var(--bg);
       color: var(--text);
       min-height: 100vh;
-      padding-bottom: calc(88px + var(--safe-bottom));
+      padding-bottom: calc(92px + var(--safe-bottom));
     }
 
     .hero {
@@ -57,7 +63,11 @@
     }
 
     .conversation {
-      padding: 14px 15px 0;
+      padding: 14px 15px 8px;
+    }
+
+    .conversation .row:last-child {
+      margin-bottom: 0;
     }
 
     .row {
@@ -74,10 +84,11 @@
     }
 
     .user-bubble {
+      position: relative;
       max-width: 78%;
-      padding: 10px 12px;
+      padding: 10px 14px;
       background: var(--orange);
-      border-radius: 6px;
+      border-radius: 8px 8px 2px 8px;
       color: #fff;
       font-size: 15px;
       font-weight: 500;
@@ -86,11 +97,23 @@
       word-break: break-word;
     }
 
+    .user-bubble::after {
+      content: "";
+      position: absolute;
+      right: -6px;
+      bottom: 8px;
+      width: 0;
+      height: 0;
+      border-style: solid;
+      border-width: 6px 0 6px 7px;
+      border-color: transparent transparent transparent var(--orange);
+    }
+
     .ai-card {
       width: 100%;
       padding: 14px 13px;
       background: #fff;
-      border-radius: 8px;
+      border-radius: 12px;
       box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
     }
 
@@ -107,6 +130,15 @@
       padding: 14px 13px;
       background: #fff;
       border-radius: 8px;
+      box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
+    }
+
+    .fallback-card .ai-card__text {
+      font-size: 14px;
+      line-height: 1.65;
+      white-space: pre-wrap;
+      word-break: break-word;
+      text-align: left;
     }
 
     .empty {
@@ -128,44 +160,61 @@
     }
 
     .footer__dock {
-      position: relative;
+      display: flex;
+      justify-content: center;
       width: 100%;
       pointer-events: auto;
     }
 
+    .footer__btn-slot {
+      position: relative;
+      width: 50%;
+      height: 48px;
+    }
+
     .continue-btn {
+      display: flex;
+      align-items: center;
+      justify-content: center;
       width: 100%;
-      height: 44px;
+      height: 48px;
+      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;
+      background: linear-gradient(90deg, #ffb84c 0%, #ff6b3e 100%);
+      box-shadow: 0 4px 16px rgba(255, 107, 62, 0.32);
       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 {
       display: none;
       position: absolute;
       left: 0;
-      right: 0;
       top: 0;
       width: 100%;
-      height: 44px;
-      min-height: 44px;
+      height: 100%;
+      min-height: 48px;
       border-radius: 999px;
       overflow: hidden;
+      z-index: 2;
     }
 
     body.is-wechat.wx-jssdk-ready #launch-btn {
       display: block;
-    }
-
-    body.is-wechat.wx-jssdk-ready #btnContinue {
-      visibility: hidden;
-      pointer-events: none;
+      pointer-events: auto;
     }
 
     #openAppToast {
@@ -196,32 +245,43 @@
 
   <footer class="footer">
     <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>
   </footer>
 
@@ -336,7 +396,84 @@
         return html;
       }
 
+      function applyWeixinShareMeta() {
+        var siteName = "U店在哪";
+        var iconUrl =
+          "https://alien-volume.oss-cn-beijing.aliyuncs.com/icon/ubao.png";
+        var setMeta = function (key, content) {
+          var el =
+            document.querySelector('meta[property="' + key + '"]') ||
+            document.querySelector('meta[name="' + key + '"]');
+          if (!el) {
+            el = document.createElement("meta");
+            if (key.indexOf("og:") === 0) {
+              el.setAttribute("property", key);
+            } else {
+              el.setAttribute("name", key);
+            }
+            document.head.appendChild(el);
+          }
+          el.setAttribute("content", content);
+        };
+        setMeta("og:site_name", siteName);
+        setMeta("application-name", siteName);
+        setMeta("og:title", "和U宝的对话");
+        setMeta("og:description", "点击查看对话内容");
+        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 resolveShareMessagesForDisplay(data) {
+        var messages = Array.isArray(data && data.messages) ? data.messages : [];
+        if (messages.length) return messages;
+        var text = String((data && data.content) || "").trim();
+        if (!text) return [];
+        var list = [];
+        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) list.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) list.push({ role: "ai", content: aiText });
+          }
+        }
+        if (list.length) return list;
+        var current = null;
+        var lines = text.split(/\n/);
+        for (var j = 0; j < lines.length; j++) {
+          var line = String(lines[j] || "");
+          var userLine = line.match(/^我[::]\s*(.*)$/);
+          var aiLine = line.match(/^UBAO[::]\s*(.*)$/i);
+          if (userLine) {
+            if (current) list.push(current);
+            current = { role: "user", content: String(userLine[1] || "").trim() };
+            continue;
+          }
+          if (aiLine) {
+            if (current) list.push(current);
+            current = { role: "ai", content: String(aiLine[1] || "").trim() };
+            continue;
+          }
+          if (current && line.trim()) {
+            current.content = (current.content ? current.content + "\n" : "") + line.trim();
+          }
+        }
+        if (current && String(current.content || "").trim()) list.push(current);
+        return list;
+      }
+
       function render(data) {
+        applyWeixinShareMeta();
         sharePayloadCache = data || null;
         var main = document.getElementById("main");
         if (!data) {
@@ -345,9 +482,15 @@
           return;
         }
 
-        var messages = data.messages || [];
+        var messages = resolveShareMessagesForDisplay(data);
         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 dateText = formatDate(data.shareTime);
 
@@ -367,11 +510,6 @@
         var convHtml = renderMessages(messages);
         if (convHtml) {
           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 {
           bodyHtml += '<div class="empty">暂无对话内容</div>';
         }