lxr 1 неделя назад
Родитель
Сommit
b68f351c3f
1 измененных файлов с 150 добавлено и 47 удалено
  1. 150 47
      HBuilderProjects/shareAiConsult.html

+ 150 - 47
HBuilderProjects/shareAiConsult.html

@@ -17,6 +17,7 @@
       --text: #151515;
       --text: #151515;
       --muted: #aaaaaa;
       --muted: #aaaaaa;
       --orange: #f47d1f;
       --orange: #f47d1f;
+      --safe-top: env(safe-area-inset-top, 0px);
       --safe-bottom: env(safe-area-inset-bottom, 0px);
       --safe-bottom: env(safe-area-inset-bottom, 0px);
     }
     }
 
 
@@ -35,7 +36,58 @@
       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));
+    }
+
+    .nav {
+      position: sticky;
+      top: 0;
+      z-index: 10;
+      display: flex;
+      align-items: center;
+      padding: 10px 12px;
+      padding-top: calc(10px + var(--safe-top));
+      background: #fff;
+    }
+
+    .nav__close {
+      width: 36px;
+      height: 36px;
+      border: none;
+      background: transparent;
+      font-size: 22px;
+      line-height: 36px;
+      color: #151515;
+      flex-shrink: 0;
+      cursor: pointer;
+      -webkit-tap-highlight-color: transparent;
+    }
+
+    .nav__center {
+      flex: 1;
+      min-width: 0;
+      text-align: center;
+      padding: 0 8px;
+    }
+
+    .nav__title {
+      font-size: 15px;
+      font-weight: 600;
+      color: #151515;
+      white-space: nowrap;
+      overflow: hidden;
+      text-overflow: ellipsis;
+    }
+
+    .nav__url {
+      margin-top: 2px;
+      font-size: 11px;
+      color: var(--muted);
+    }
+
+    .nav__side {
+      width: 36px;
+      flex-shrink: 0;
     }
     }
 
 
     .hero {
     .hero {
@@ -83,11 +135,11 @@
       max-width: 78%;
       max-width: 78%;
       padding: 10px 12px;
       padding: 10px 12px;
       background: var(--orange);
       background: var(--orange);
-      border-radius: 6px;
+      border-radius: 11px;
       color: #fff;
       color: #fff;
       font-size: 15px;
       font-size: 15px;
       font-weight: 500;
       font-weight: 500;
-      line-height: 1.5;
+      line-height: 1.47;
       white-space: pre-wrap;
       white-space: pre-wrap;
       word-break: break-word;
       word-break: break-word;
     }
     }
@@ -135,34 +187,46 @@
 
 
     .footer__dock {
     .footer__dock {
       position: relative;
       position: relative;
+      display: flex;
+      justify-content: center;
       width: 100%;
       width: 100%;
-      min-height: 44px;
       pointer-events: auto;
       pointer-events: auto;
     }
     }
 
 
     .continue-btn {
     .continue-btn {
-      width: 100%;
-      height: 44px;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      width: 50%;
+      height: 48px;
+      margin: 0 auto;
+      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;
       position: absolute;
-      left: 0;
-      right: 0;
+      left: 50%;
       top: 0;
       top: 0;
-      z-index: 2;
-      width: 100%;
-      height: 44px;
-      min-height: 44px;
+      width: 50%;
+      height: 48px;
+      min-height: 48px;
+      transform: translateX(-50%);
       border-radius: 999px;
       border-radius: 999px;
       overflow: hidden;
       overflow: hidden;
     }
     }
@@ -172,6 +236,7 @@
     }
     }
 
 
     body.is-wechat.wx-jssdk-ready #btnContinue {
     body.is-wechat.wx-jssdk-ready #btnContinue {
+      visibility: hidden;
       pointer-events: none;
       pointer-events: none;
     }
     }
 
 
@@ -195,6 +260,15 @@
   </style>
   </style>
 </head>
 </head>
 <body>
 <body>
+  <header class="nav">
+    <button type="button" class="nav__close" id="btnClose" aria-label="关闭">×</button>
+    <div class="nav__center">
+      <div class="nav__title" id="navTitle">与AI助手-U宝</div>
+      <div class="nav__url">www.ailien.shop</div>
+    </div>
+    <div class="nav__side"></div>
+  </header>
+
   <main id="main">
   <main id="main">
     <div class="empty">对话内容加载中…</div>
     <div class="empty">对话内容加载中…</div>
   </main>
   </main>
@@ -203,28 +277,38 @@
 
 
   <footer class="footer">
   <footer class="footer">
     <div class="footer__dock">
     <div class="footer__dock">
-      <button type="button" class="continue-btn" id="btnContinue">和U宝继续聊 →</button>
+      <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="">
       <wx-open-launch-app id="launch-btn" appid="wxf5f1efe3a9f5012e" extinfo="">
         <script type="text/wxtag-template">
         <script type="text/wxtag-template">
           <style>
           <style>
             .wx-open-app-btn {
             .wx-open-app-btn {
-              display: block;
+              display: flex;
+              align-items: center;
+              justify-content: center;
               width: 100%;
               width: 100%;
-              height: 44px;
+              height: 48px;
               margin: 0;
               margin: 0;
               padding: 0;
               padding: 0;
               border: none;
               border: none;
               border-radius: 999px;
               border-radius: 999px;
-              background: transparent;
-              color: transparent;
-              font-size: 16px;
-              line-height: 44px;
-              text-align: center;
+              background: linear-gradient(90deg, #ffb84c 0%, #ff6b3e 100%);
+              box-shadow: 0 4px 16px rgba(255, 107, 62, 0.32);
               cursor: pointer;
               cursor: pointer;
               -webkit-tap-highlight-color: transparent;
               -webkit-tap-highlight-color: transparent;
             }
             }
+            .continue-btn__label {
+              display: block;
+              height: 20px;
+              width: auto;
+              max-width: 90%;
+              pointer-events: none;
+            }
           </style>
           </style>
-          <button class="wx-open-app-btn" aria-label="和U宝继续聊">打开 App</button>
+          <button class="wx-open-app-btn" aria-label="和U宝继续聊">
+            <img class="continue-btn__label" src="https://test.ailien.shop/h5/HBuilderProjects/images/uCharts.png" alt="和U宝继续聊" decoding="async">
+          </button>
         </script>
         </script>
       </wx-open-launch-app>
       </wx-open-launch-app>
     </div>
     </div>
@@ -281,15 +365,6 @@
 
 
       function parsePayload() {
       function parsePayload() {
         var raw = getQueryParam("payload");
         var raw = getQueryParam("payload");
-        if (!raw) {
-          try {
-            var hash = String(location.hash || "").replace(/^#/, "");
-            if (hash) {
-              var hp = new URLSearchParams(hash).get("payload");
-              if (hp != null && String(hp) !== "") raw = String(hp);
-            }
-          } catch (eHash) {}
-        }
         if (!raw) return null;
         if (!raw) return null;
         try {
         try {
           return JSON.parse(raw);
           return JSON.parse(raw);
@@ -317,6 +392,13 @@
         return qText + "的讨论";
         return qText + "的讨论";
       }
       }
 
 
+      function formatNavTitle(question) {
+        var titled = formatDiscussionTitle(question);
+        var maxLen = 14;
+        var short = titled.length > maxLen ? titled.slice(0, maxLen) + "..." : titled;
+        return short + "-U宝";
+      }
+
       function formatDate(ts) {
       function formatDate(ts) {
         var d = ts ? new Date(Number(ts)) : new Date();
         var d = ts ? new Date(Number(ts)) : new Date();
         if (isNaN(d.getTime())) d = new Date();
         if (isNaN(d.getTime())) d = new Date();
@@ -383,7 +465,9 @@
         applyWeixinShareMeta();
         applyWeixinShareMeta();
         sharePayloadCache = data || null;
         sharePayloadCache = data || null;
         var main = document.getElementById("main");
         var main = document.getElementById("main");
+        var navTitle = document.getElementById("navTitle");
         if (!data) {
         if (!data) {
+          if (navTitle) navTitle.textContent = "与AI助手-U宝";
           main.innerHTML = '<div class="empty">对话内容不存在或链接已失效</div>';
           main.innerHTML = '<div class="empty">对话内容不存在或链接已失效</div>';
           refreshWxLaunchTagAttrs();
           refreshWxLaunchTagAttrs();
           return;
           return;
@@ -395,6 +479,7 @@
         var pageTitle = formatDiscussionTitle(firstQuestion);
         var pageTitle = formatDiscussionTitle(firstQuestion);
         var dateText = formatDate(data.shareTime);
         var dateText = formatDate(data.shareTime);
 
 
+        if (navTitle) navTitle.textContent = formatNavTitle(firstQuestion);
         document.title = pageTitle;
         document.title = pageTitle;
 
 
         var bodyHtml =
         var bodyHtml =
@@ -424,15 +509,24 @@
         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 path = APP_UNI_AI_PATH;
+        var qs = buildAiConsultOpenParams().toString();
         var root = APP_IOS_URL_SCHEME.replace(/\/$/, "");
         var root = APP_IOS_URL_SCHEME.replace(/\/$/, "");
-        return root + "/" + path + "?pageType=home";
+        return root + "/" + path + (qs ? "?" + qs : "");
       }
       }
 
 
-      /** wx-open-launch-app extinfo:仅跳转 AI 首页,不传分享上下文 */
       function buildWeChatLaunchExtinfo() {
       function buildWeChatLaunchExtinfo() {
-        return APP_UNI_AI_PATH + "?pageType=home";
+        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";
       }
       }
 
 
       function isWeChatInAppBrowser() {
       function isWeChatInAppBrowser() {
@@ -498,10 +592,9 @@
         }
         }
       }
       }
 
 
-      /** 签名 url 不含 query/hash,避免 payload 过长导致 wx.config / 开放标签 launch:fail */
       function getWxConfigSignUrl() {
       function getWxConfigSignUrl() {
-        if (String(q("wxSignFullUrl") || "") === "1") return getWxSignPageUrlForApi();
-        return getWxHtmlUrlBase();
+        if (String(q("wxSignBaseOnly") || "") === "1") return getWxHtmlUrlBase();
+        return getWxSignPageUrlForApi();
       }
       }
 
 
       function getWxGetConfigApiUrl() {
       function getWxGetConfigApiUrl() {
@@ -893,12 +986,13 @@
 
 
       function tryOpenApp() {
       function tryOpenApp() {
         if (isWeChatInAppBrowser()) {
         if (isWeChatInAppBrowser()) {
-          if (weChatJssdkConfigured) return;
-          initWeChatOpenLaunchApp(true).then(function (ok) {
-            if (!ok) {
-              showAppOpenFailTip(wxInitLastError || "微信唤起 App 初始化失败");
-            }
-          });
+          if (!weChatJssdkConfigured) {
+            initWeChatOpenLaunchApp(true).then(function (ok) {
+              if (!ok) {
+                showAppOpenFailTip(wxInitLastError || "微信唤起 App 初始化失败");
+              }
+            });
+          }
           return;
           return;
         }
         }
         tryOpenHBuilderAppViaScheme();
         tryOpenHBuilderAppViaScheme();
@@ -911,6 +1005,15 @@
       bindWeChatLaunchTagEvents();
       bindWeChatLaunchTagEvents();
       scheduleWeChatJssdkBootstrap();
       scheduleWeChatJssdkBootstrap();
       document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
       document.getElementById("btnContinue").addEventListener("click", tryOpenApp);
+      document.getElementById("btnClose").addEventListener("click", function () {
+        if (window.history.length > 1) {
+          window.history.back();
+        } else if (typeof WeixinJSBridge !== "undefined") {
+          WeixinJSBridge.call("closeWindow");
+        } else {
+          window.close();
+        }
+      });
       render(parsePayload());
       render(parsePayload());
     })();
     })();
   </script>
   </script>