shareAiConsult.html 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
  6. <meta name="format-detection" content="telephone=no">
  7. <title>与U宝对话</title>
  8. <meta property="og:title" content="和U宝的对话">
  9. <meta property="og:description" content="点击查看对话内容">
  10. <meta property="og:site_name" content="U店在哪">
  11. <meta name="application-name" content="U店在哪">
  12. <link rel="icon" type="image/png" href="https://alien-volume.oss-cn-beijing.aliyuncs.com/icon/ubao.png">
  13. <link rel="apple-touch-icon" href="https://alien-volume.oss-cn-beijing.aliyuncs.com/icon/ubao.png">
  14. <style>
  15. :root {
  16. --bg: #f4f6fb;
  17. --text: #151515;
  18. --muted: #aaaaaa;
  19. --orange: #f47d1f;
  20. --safe-bottom: env(safe-area-inset-bottom, 0px);
  21. }
  22. * {
  23. margin: 0;
  24. padding: 0;
  25. box-sizing: border-box;
  26. }
  27. html {
  28. height: 100%;
  29. -webkit-tap-highlight-color: transparent;
  30. overflow: hidden;
  31. }
  32. body {
  33. font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  34. background: var(--bg);
  35. color: var(--text);
  36. height: 100vh;
  37. display: flex;
  38. flex-direction: column;
  39. overflow: hidden;
  40. }
  41. #main {
  42. flex: 1;
  43. min-height: 0;
  44. overflow-x: hidden;
  45. overflow-y: auto;
  46. -webkit-overflow-scrolling: touch;
  47. padding-bottom: calc(100px + var(--safe-bottom));
  48. }
  49. .hero {
  50. padding: 16px 15px 0;
  51. }
  52. .hero__title {
  53. font-size: 20px;
  54. font-weight: 700;
  55. line-height: 1.4;
  56. word-break: break-word;
  57. }
  58. .hero__meta {
  59. margin-top: 8px;
  60. font-size: 12px;
  61. color: var(--muted);
  62. line-height: 1.4;
  63. }
  64. .hero__divider {
  65. margin-top: 14px;
  66. height: 1px;
  67. background: rgba(170, 170, 170, 0.25);
  68. }
  69. .conversation {
  70. padding: 14px 15px 8px;
  71. }
  72. .scroll-spacer {
  73. height: calc(72px + var(--safe-bottom));
  74. flex-shrink: 0;
  75. }
  76. .conversation .row:last-child {
  77. margin-bottom: 0;
  78. }
  79. .row {
  80. display: flex;
  81. margin-bottom: 12px;
  82. }
  83. .row--user {
  84. justify-content: flex-end;
  85. }
  86. .row--ai {
  87. justify-content: flex-start;
  88. }
  89. .user-bubble {
  90. position: relative;
  91. max-width: 78%;
  92. padding: 10px 14px;
  93. background: var(--orange);
  94. border-radius: 8px 8px 2px 8px;
  95. color: #fff;
  96. font-size: 15px;
  97. font-weight: 500;
  98. line-height: 1.5;
  99. white-space: pre-wrap;
  100. word-break: break-word;
  101. }
  102. .user-bubble::after {
  103. content: "";
  104. position: absolute;
  105. right: -6px;
  106. bottom: 8px;
  107. width: 0;
  108. height: 0;
  109. border-style: solid;
  110. border-width: 6px 0 6px 7px;
  111. border-color: transparent transparent transparent var(--orange);
  112. }
  113. .ai-card {
  114. width: 100%;
  115. padding: 14px 13px;
  116. background: #fff;
  117. border-radius: 12px;
  118. box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
  119. }
  120. .ai-card__text {
  121. font-size: 14px;
  122. line-height: 1.65;
  123. white-space: pre-wrap;
  124. word-break: break-word;
  125. text-align: left;
  126. }
  127. .ai-card__image {
  128. display: block;
  129. max-width: 100%;
  130. height: auto;
  131. margin: 8px 0;
  132. border-radius: 6px;
  133. }
  134. .user-bubble__image {
  135. display: block;
  136. max-width: 180px;
  137. border-radius: 4px;
  138. }
  139. .fallback-card {
  140. margin: 14px 15px 0;
  141. padding: 14px 13px;
  142. background: #fff;
  143. border-radius: 8px;
  144. box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
  145. }
  146. .fallback-card .ai-card__text {
  147. font-size: 14px;
  148. line-height: 1.65;
  149. white-space: pre-wrap;
  150. word-break: break-word;
  151. text-align: left;
  152. }
  153. .empty {
  154. padding: 48px 20px;
  155. text-align: center;
  156. color: var(--muted);
  157. font-size: 14px;
  158. }
  159. .fab-wrap {
  160. position: fixed;
  161. left: 0;
  162. right: 0;
  163. bottom: 0;
  164. z-index: 200;
  165. padding: 12px 24px calc(12px + var(--safe-bottom));
  166. background: linear-gradient(to top, rgba(255, 255, 255, 0.98) 70%, transparent);
  167. pointer-events: none;
  168. }
  169. .fab-dock__slot {
  170. position: relative;
  171. width: 100%;
  172. max-width: 280px;
  173. height: 48px;
  174. margin: 0 auto;
  175. pointer-events: auto;
  176. }
  177. #openApp.fab {
  178. padding: 0 10px;
  179. -webkit-font-smoothing: antialiased;
  180. text-rendering: optimizeLegibility;
  181. }
  182. .fab__brand-clip {
  183. display: block;
  184. flex-shrink: 0;
  185. line-height: 0;
  186. }
  187. .fab__brand-img {
  188. display: block;
  189. height: 20px;
  190. width: auto;
  191. max-width: 90%;
  192. pointer-events: none;
  193. -webkit-user-drag: none;
  194. }
  195. .fab__label {
  196. font-size: 15px;
  197. line-height: 1;
  198. letter-spacing: 0.04em;
  199. white-space: nowrap;
  200. }
  201. #launch-btn {
  202. display: none;
  203. position: absolute;
  204. left: 0;
  205. top: 0;
  206. z-index: 2;
  207. width: 100%;
  208. height: 48px;
  209. min-height: 48px;
  210. border-radius: 999px;
  211. overflow: hidden;
  212. opacity: 1;
  213. }
  214. /* 与 secondShareGoods 一致:微信就绪后显示开放标签;openApp 保持可见作兜底 */
  215. body.is-wechat.wx-jssdk-ready #launch-btn {
  216. display: block;
  217. }
  218. .fab-wrap .fab {
  219. pointer-events: auto;
  220. }
  221. #openApp {
  222. touch-action: manipulation;
  223. }
  224. .fab {
  225. display: flex;
  226. align-items: center;
  227. justify-content: center;
  228. gap: 4px;
  229. width: 100%;
  230. max-width: 280px;
  231. margin: 0 auto;
  232. height: 48px;
  233. border: none;
  234. border-radius: 999px;
  235. background: linear-gradient(90deg, #ffb84c 0%, #ff6b3e 100%);
  236. color: #fff;
  237. font-size: 16px;
  238. font-weight: 600;
  239. box-shadow: 0 4px 16px rgba(255, 107, 62, 0.32);
  240. cursor: pointer;
  241. }
  242. .home-indicator {
  243. height: 5px;
  244. background: #000;
  245. border-radius: 3px;
  246. width: 134px;
  247. margin: 8px auto 4px;
  248. opacity: 0.2;
  249. }
  250. #openAppToast {
  251. display: none;
  252. position: fixed;
  253. left: 16px;
  254. right: 16px;
  255. bottom: calc(72px + var(--safe-bottom));
  256. z-index: 10001;
  257. padding: 10px 14px;
  258. font-size: 13px;
  259. line-height: 1.45;
  260. color: #fff;
  261. text-align: center;
  262. background: rgba(0, 0, 0, 0.78);
  263. border-radius: 8px;
  264. pointer-events: none;
  265. word-break: break-all;
  266. }
  267. </style>
  268. </head>
  269. <body>
  270. <main id="main">
  271. <div class="empty">对话内容加载中…</div>
  272. </main>
  273. <div id="openAppToast" role="status" aria-live="polite"></div>
  274. <div class="fab-wrap">
  275. <div class="fab-dock__slot">
  276. <!-- 与 secondShareGoods 相同顺序:openApp 在下,launch-btn 在上,避免挡住点击 -->
  277. <button type="button" class="fab" id="openApp" aria-label="和U宝继续聊">
  278. <span class="fab__brand-clip" aria-hidden="true">
  279. <img class="fab__brand-img" src="images/uCharts.png" alt="和U宝继续聊" decoding="async">
  280. </span>
  281. </button>
  282. <wx-open-launch-app id="launch-btn" appid="wxf5f1efe3a9f5012e" extinfo="">
  283. <script type="text/wxtag-template">
  284. <style>
  285. .wx-open-app-btn {
  286. display: flex;
  287. align-items: center;
  288. justify-content: center;
  289. width: 100%;
  290. height: 48px;
  291. margin: 0;
  292. padding: 0;
  293. border: none;
  294. border-radius: 999px;
  295. background: linear-gradient(90deg, #ffb84c 0%, #ff6b3e 100%);
  296. box-shadow: 0 4px 16px rgba(255, 107, 62, 0.32);
  297. cursor: pointer;
  298. overflow: hidden;
  299. -webkit-tap-highlight-color: transparent;
  300. box-sizing: border-box;
  301. }
  302. .wx-open-app-btn .fab__brand-clip {
  303. display: block;
  304. flex-shrink: 0;
  305. line-height: 0;
  306. }
  307. .wx-open-app-btn .fab__brand-img {
  308. display: block;
  309. height: 20px;
  310. width: auto;
  311. max-width: 90%;
  312. pointer-events: none;
  313. -webkit-user-drag: none;
  314. }
  315. </style>
  316. <button class="wx-open-app-btn" aria-label="和U宝继续聊">
  317. <span class="fab__brand-clip" aria-hidden="true">
  318. <img class="fab__brand-img" src="https://prod.ailien.shop/h5/HBuilderProjects/images/uCharts.png" alt="和U宝继续聊" decoding="async">
  319. </span>
  320. </button>
  321. </script>
  322. </wx-open-launch-app>
  323. </div>
  324. <div class="home-indicator" aria-hidden="true"></div>
  325. </div>
  326. <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
  327. <script>
  328. (function () {
  329. "use strict";
  330. var API_BASE = "https://prod.ailien.shop/alienStore";
  331. var WECHAT_MP_APP_ID = "wx412792c77f47babd";
  332. var WECHAT_OPEN_APP_ID = "wxf5f1efe3a9f5012e";
  333. var WECHAT_GET_WX_CONFIG_PATH = "/wx/getWxConfig";
  334. var H5_PAGE_BASE_FALLBACK = "https://prod.ailien.shop/h5/HBuilderProjects/";
  335. var WX_GET_CONFIG_SIGN_URL = H5_PAGE_BASE_FALLBACK + "shareAiConsult.html";
  336. var WECHAT_JS_SAFE_HOSTS = ["uat.ailien.shop", "prod.ailien.shop"];
  337. var APP_ANDROID_PACKAGE = "com.alien.Udianzaizhe";
  338. var APP_IOS_URL_SCHEME = "shopro://";
  339. var APP_UNI_AI_PATH = "pages/aiSearchResult/index";
  340. var sharePayloadCache = null;
  341. var weChatJssdkConfigured = false;
  342. var wxConfigSignRetriedBaseUrl = false;
  343. var wxInitLastError = "";
  344. var wxJssdkInitPromise = null;
  345. var wxOpenTagBroken = false;
  346. function escHtml(s) {
  347. return String(s || "")
  348. .replace(/&/g, "&amp;")
  349. .replace(/</g, "&lt;")
  350. .replace(/>/g, "&gt;")
  351. .replace(/"/g, "&quot;");
  352. }
  353. var IMAGE_EXT = "(?:jpe?g|png|gif|webp|bmp|avif)";
  354. var IMAGE_URL_PATTERN =
  355. "https?:\\/\\/[^\\s))\\]]+\\." + IMAGE_EXT + "(?:\\?[^\\s))\\]]*)?";
  356. function isInsideImageUrlSyntax(full, offset) {
  357. if (offset >= 2 && full.slice(offset - 2, offset) === "](") return true;
  358. if (offset >= 1 && full[offset - 1] === "(") return true;
  359. if (offset >= 6 && full.slice(offset - 6, offset) === "{{IMG|") return true;
  360. return false;
  361. }
  362. /** AI 回复常见:店名(https://...jpg) — 转为可渲染的图片占位 */
  363. function embedInlineImageUrls(text) {
  364. if (text == null) return "";
  365. var t = String(text);
  366. t = t.replace(
  367. new RegExp("([^\\n((]+?)\\((" + IMAGE_URL_PATTERN + ")\\)", "gi"),
  368. function (_, label, url) {
  369. var name = String(label).trim();
  370. if (!name) return "\n\n{{IMG|" + url + "|}}\n\n";
  371. var alt = name.length > 24 ? "图片" : name.replace(/[\[\]]/g, "");
  372. return name + "\n\n{{IMG|" + url + "|" + alt + "}}\n\n";
  373. }
  374. );
  375. t = t.replace(
  376. new RegExp("\\((" + IMAGE_URL_PATTERN + ")\\)", "gi"),
  377. function (_, url) {
  378. return "\n\n{{IMG|" + url + "|}}\n\n";
  379. }
  380. );
  381. t = t.replace(new RegExp(IMAGE_URL_PATTERN, "gi"), function (url, offset, full) {
  382. if (isInsideImageUrlSyntax(full, offset)) return url;
  383. return "\n\n{{IMG|" + url + "|}}\n\n";
  384. });
  385. return t.replace(/\n{3,}/g, "\n\n");
  386. }
  387. function formatTextBlockHtml(text) {
  388. return escHtml(text).replace(/\n/g, "<br>");
  389. }
  390. function buildAiImageTag(url, alt) {
  391. var safeUrl = escHtml(url);
  392. var safeAlt = escHtml(alt || "图片");
  393. return (
  394. '<img class="ai-card__image" src="' +
  395. safeUrl +
  396. '" alt="' +
  397. safeAlt +
  398. '" loading="lazy" decoding="async" />'
  399. );
  400. }
  401. function renderAiContentHtml(text) {
  402. var t = embedInlineImageUrls(text);
  403. var html = "";
  404. var tokenRe = /\{\{IMG\|([^|]+)\|([^}]*)\}\}/g;
  405. var lastIndex = 0;
  406. var match;
  407. while ((match = tokenRe.exec(t)) !== null) {
  408. if (match.index > lastIndex) {
  409. html += formatTextBlockHtml(t.slice(lastIndex, match.index));
  410. }
  411. html += buildAiImageTag(match[1], match[2]);
  412. lastIndex = tokenRe.lastIndex;
  413. }
  414. if (lastIndex < t.length) {
  415. html += formatTextBlockHtml(t.slice(lastIndex));
  416. }
  417. return html;
  418. }
  419. function q(name) {
  420. try {
  421. var v = new URLSearchParams(location.search || "").get(name);
  422. return v == null ? "" : String(v);
  423. } catch (e) {
  424. return "";
  425. }
  426. }
  427. function getQueryParam(name) {
  428. var m = new RegExp("[?&]" + name + "=([^&]*)").exec(window.location.search);
  429. if (!m) return "";
  430. try {
  431. return decodeURIComponent(m[1].replace(/\+/g, " "));
  432. } catch (e) {
  433. return "";
  434. }
  435. }
  436. function parsePayload() {
  437. var raw = getQueryParam("payload");
  438. if (!raw) return null;
  439. try {
  440. return JSON.parse(raw);
  441. } catch (e) {
  442. return null;
  443. }
  444. }
  445. function getFirstUserQuestion(messages) {
  446. var list = Array.isArray(messages) ? messages : [];
  447. for (var i = 0; i < list.length; i++) {
  448. var m = list[i];
  449. if (!m || m.role !== "user") continue;
  450. if (m.isImage) return "[图片]";
  451. var t = String(m.content || "").trim();
  452. if (t) return t;
  453. }
  454. return "";
  455. }
  456. function formatDiscussionTitle(question) {
  457. var qText = String(question || "").trim();
  458. if (!qText) return "与AI助手对话";
  459. if (qText.slice(-3) === "的讨论") return qText;
  460. return qText + "的讨论";
  461. }
  462. function formatDate(ts) {
  463. var d = ts ? new Date(Number(ts)) : new Date();
  464. if (isNaN(d.getTime())) d = new Date();
  465. return d.getFullYear() + "年" + (d.getMonth() + 1) + "月" + d.getDate() + "日";
  466. }
  467. function renderMessages(messages) {
  468. var html = "";
  469. var list = Array.isArray(messages) ? messages : [];
  470. for (var i = 0; i < list.length; i++) {
  471. var msg = list[i];
  472. if (!msg) continue;
  473. if (msg.role === "user") {
  474. if (msg.isImage && msg.imageUrl) {
  475. html +=
  476. '<div class="row row--user"><div class="user-bubble"><img class="user-bubble__image" src="' +
  477. escHtml(msg.imageUrl) +
  478. '" alt="图片" loading="lazy" decoding="async" /></div></div>';
  479. continue;
  480. }
  481. var userText = String(msg.content || "").trim();
  482. if (!userText) continue;
  483. html +=
  484. '<div class="row row--user"><div class="user-bubble">' +
  485. escHtml(userText) +
  486. "</div></div>";
  487. continue;
  488. }
  489. if (msg.role === "ai" || msg.role === "assistant") {
  490. var aiText = String(msg.content || "").trim();
  491. if (!aiText) continue;
  492. html +=
  493. '<div class="row row--ai"><div class="ai-card"><div class="ai-card__text">' +
  494. renderAiContentHtml(aiText) +
  495. "</div></div></div>";
  496. }
  497. }
  498. return html;
  499. }
  500. function applyWeixinShareMeta() {
  501. var siteName = "U店在哪";
  502. var iconUrl =
  503. "https://alien-volume.oss-cn-beijing.aliyuncs.com/icon/ubao.png";
  504. var setMeta = function (key, content) {
  505. var el =
  506. document.querySelector('meta[property="' + key + '"]') ||
  507. document.querySelector('meta[name="' + key + '"]');
  508. if (!el) {
  509. el = document.createElement("meta");
  510. if (key.indexOf("og:") === 0) {
  511. el.setAttribute("property", key);
  512. } else {
  513. el.setAttribute("name", key);
  514. }
  515. document.head.appendChild(el);
  516. }
  517. el.setAttribute("content", content);
  518. };
  519. setMeta("og:site_name", siteName);
  520. setMeta("application-name", siteName);
  521. setMeta("og:title", "和U宝的对话");
  522. setMeta("og:description", "点击查看对话内容");
  523. var links = document.querySelectorAll('link[rel="icon"], link[rel="apple-touch-icon"]');
  524. for (var i = 0; i < links.length; i++) {
  525. links[i].setAttribute("href", iconUrl);
  526. }
  527. }
  528. function countDisplayableMessages(messages) {
  529. var list = Array.isArray(messages) ? messages : [];
  530. var count = 0;
  531. for (var i = 0; i < list.length; i++) {
  532. var msg = list[i];
  533. if (!msg) continue;
  534. if (msg.role === "user") {
  535. if (msg.isImage && msg.imageUrl) {
  536. count += 1;
  537. continue;
  538. }
  539. if (String(msg.content || "").trim()) count += 1;
  540. continue;
  541. }
  542. if (msg.role === "ai" || msg.role === "assistant") {
  543. if (String(msg.content || "").trim()) count += 1;
  544. }
  545. }
  546. return count;
  547. }
  548. function parseMessagesFromContent(text) {
  549. var raw = String(text || "").trim();
  550. if (!raw) return [];
  551. var list = [];
  552. var blocks = raw.split(/\n\n+/);
  553. for (var i = 0; i < blocks.length; i++) {
  554. var block = String(blocks[i] || "").trim();
  555. if (!block) continue;
  556. var userMatch = block.match(/^我[::]\s*([\s\S]*)$/);
  557. if (userMatch) {
  558. var userText = String(userMatch[1] || "").trim();
  559. if (userText) list.push({ role: "user", content: userText });
  560. continue;
  561. }
  562. var aiMatch = block.match(/^UBAO[::]\s*([\s\S]*)$/i);
  563. if (aiMatch) {
  564. var aiText = String(aiMatch[1] || "").trim();
  565. if (aiText) list.push({ role: "ai", content: aiText });
  566. }
  567. }
  568. if (list.length) return list;
  569. var current = null;
  570. var lines = raw.split(/\n/);
  571. for (var j = 0; j < lines.length; j++) {
  572. var line = String(lines[j] || "");
  573. var userLine = line.match(/^我[::]\s*(.*)$/);
  574. var aiLine = line.match(/^UBAO[::]\s*(.*)$/i);
  575. if (userLine) {
  576. if (current) list.push(current);
  577. current = { role: "user", content: String(userLine[1] || "").trim() };
  578. continue;
  579. }
  580. if (aiLine) {
  581. if (current) list.push(current);
  582. current = { role: "ai", content: String(aiLine[1] || "").trim() };
  583. continue;
  584. }
  585. if (current && line.trim()) {
  586. current.content = (current.content ? current.content + "\n" : "") + line.trim();
  587. }
  588. }
  589. if (current && String(current.content || "").trim()) list.push(current);
  590. return list;
  591. }
  592. function resolveShareMessagesForDisplay(data) {
  593. var fromArray = Array.isArray(data && data.messages) ? data.messages : [];
  594. var fromContent = parseMessagesFromContent((data && data.content) || "");
  595. var arrayCount = countDisplayableMessages(fromArray);
  596. var contentCount = countDisplayableMessages(fromContent);
  597. // 分享链接超长时 messages 会被截断,但 content 仍保留完整对话文本
  598. if (contentCount > arrayCount) return fromContent;
  599. if (arrayCount) return fromArray;
  600. return fromContent;
  601. }
  602. function render(data) {
  603. applyWeixinShareMeta();
  604. sharePayloadCache = data || null;
  605. var main = document.getElementById("main");
  606. if (!data) {
  607. main.innerHTML = '<div class="empty">对话内容不存在或链接已失效</div>';
  608. refreshWxLaunchTagAttrs();
  609. return;
  610. }
  611. var messages = resolveShareMessagesForDisplay(data);
  612. var firstQuestion =
  613. String(data.firstQuestion || "").trim() ||
  614. getFirstUserQuestion(messages) ||
  615. (function () {
  616. var text = String(data.content || "").trim();
  617. var m = text.match(/^我[::]([\s\S]+?)(?:\n\n|$)/);
  618. return m ? String(m[1] || "").trim() : "";
  619. })();
  620. var pageTitle = formatDiscussionTitle(firstQuestion);
  621. var dateText = formatDate(data.shareTime);
  622. document.title = pageTitle;
  623. var bodyHtml =
  624. '<section class="hero">' +
  625. '<h1 class="hero__title">' +
  626. escHtml(pageTitle) +
  627. "</h1>" +
  628. '<p class="hero__meta">' +
  629. escHtml(dateText) +
  630. " · 内容由AI生成,不能完全保障真实</p>" +
  631. '<div class="hero__divider"></div>' +
  632. "</section>";
  633. var convHtml = renderMessages(messages);
  634. if (convHtml) {
  635. bodyHtml +=
  636. '<section class="conversation">' +
  637. convHtml +
  638. '</section><div class="scroll-spacer" aria-hidden="true"></div>';
  639. } else {
  640. bodyHtml += '<div class="empty">暂无对话内容</div>';
  641. }
  642. main.innerHTML = bodyHtml;
  643. refreshWxLaunchTagAttrs();
  644. }
  645. function buildAiConsultOpenParams() {
  646. var params = new URLSearchParams();
  647. params.set("pageType", "home");
  648. params.set("fromShareAiConsult", "1");
  649. return params;
  650. }
  651. function buildAppDeepLink() {
  652. var path = APP_UNI_AI_PATH;
  653. var qs = buildAiConsultOpenParams().toString();
  654. var root = APP_IOS_URL_SCHEME.replace(/\/$/, "");
  655. return root + "/" + path + (qs ? "?" + qs : "");
  656. }
  657. function buildWeChatLaunchExtinfo(useBarePathOnly) {
  658. var path = APP_UNI_AI_PATH.replace(/^\//, "");
  659. if (useBarePathOnly) return path;
  660. var qs = buildAiConsultOpenParams().toString();
  661. var uniPage = qs ? path + "?" + qs : path;
  662. if (uniPage.length <= 1024) return uniPage;
  663. return path + "?pageType=home&fromShareAiConsult=1";
  664. }
  665. function isWeChatInAppBrowser() {
  666. return /MicroMessenger/i.test(navigator.userAgent || "");
  667. }
  668. function getWxShareEntryFrom() {
  669. var from = q("from");
  670. if (from) return String(from).trim().toLowerCase();
  671. try {
  672. var h = location.hash || "";
  673. var qi = h.indexOf("?");
  674. if (qi >= 0) {
  675. var hf = new URLSearchParams(h.slice(qi + 1)).get("from");
  676. if (hf) return String(hf).trim().toLowerCase();
  677. }
  678. } catch (eH) {}
  679. return "";
  680. }
  681. function logWxEntryDiagnostics() {
  682. if (!isWeChatInAppBrowser()) return;
  683. console.log("[wx-entry]", {
  684. entryFrom: getWxShareEntryFrom() || "(无)",
  685. wxJssdkReady: weChatJssdkConfigured,
  686. signUrl: getWxConfigSignUrl(),
  687. });
  688. }
  689. function isIOSWeChatBrowser() {
  690. var ua = navigator.userAgent || "";
  691. return /MicroMessenger/i.test(ua) && /iPhone|iPad|iPod/i.test(ua);
  692. }
  693. function isWxDebugOn() {
  694. return q("wxDebug") === "1";
  695. }
  696. function isWxForceDebug() {
  697. return q("wxForce") === "1";
  698. }
  699. function isWxConfigOnClickDebug() {
  700. return q("wxConfigOnClick") === "1";
  701. }
  702. function isWxPcAutoDebugHost() {
  703. var h = (location.hostname || "").toLowerCase();
  704. if (h === "localhost" || h === "127.0.0.1") return true;
  705. for (var i = 0; i < WECHAT_JS_SAFE_HOSTS.length; i++) {
  706. if (WECHAT_JS_SAFE_HOSTS[i] === h) return true;
  707. }
  708. return false;
  709. }
  710. function isWxPcBrowser() {
  711. return !isWeChatInAppBrowser();
  712. }
  713. function shouldInitWeChatJssdkOnLoad() {
  714. if (isWeChatInAppBrowser()) return true;
  715. return isWxForceDebug() || isWxPcAutoDebugHost();
  716. }
  717. function shouldFetchWxConfig(fromUserClick) {
  718. if (isWeChatInAppBrowser()) return true;
  719. if (fromUserClick) return true;
  720. return isWxForceDebug() || isWxPcAutoDebugHost();
  721. }
  722. function getWxHtmlUrl() {
  723. var forced = String(q("wxSignUrl") || "").trim();
  724. if (forced) return forced.split("#")[0];
  725. return String(location.href || "").split("#")[0];
  726. }
  727. function getWxSignPageUrlForApi() {
  728. var htmlUrl = getWxHtmlUrl();
  729. if (htmlUrl && /^https?:\/\//i.test(htmlUrl)) return htmlUrl;
  730. return WX_GET_CONFIG_SIGN_URL;
  731. }
  732. function getWxHtmlUrlBase() {
  733. var htmlUrl = getWxSignPageUrlForApi();
  734. try {
  735. var u = new URL(htmlUrl);
  736. return u.origin + u.pathname;
  737. } catch (eU) {
  738. return WX_GET_CONFIG_SIGN_URL;
  739. }
  740. }
  741. /** 默认 pathname 验签:AI 分享链常带超长 payload,与后端无参签名一致,避免开放标签 fail_check */
  742. function getWxConfigSignUrl() {
  743. if (String(q("wxSignFullUrl") || "") === "1") return getWxSignPageUrlForApi();
  744. if (String(q("wxSignBaseOnly") || "") === "1") return getWxHtmlUrlBase();
  745. if (isWeChatInAppBrowser()) return getWxHtmlUrlBase();
  746. return getWxSignPageUrlForApi();
  747. }
  748. function getWxGetConfigApiUrl() {
  749. return API_BASE.replace(/\/$/, "") + WECHAT_GET_WX_CONFIG_PATH;
  750. }
  751. function buildWxGetConfigRequestBody(htmlUrl) {
  752. return {
  753. url: String(htmlUrl || "").split("#")[0].trim(),
  754. };
  755. }
  756. function resolveWxConfigAppIdFromSignData(d) {
  757. if (!d || typeof d !== "object") return "";
  758. var mp =
  759. d.mpAppId ||
  760. d.mpAppid ||
  761. d.officialAppId ||
  762. d.gzhAppId ||
  763. d.serviceAppId;
  764. if (mp != null && String(mp).trim() !== "") return String(mp).trim();
  765. var fromQuery = String(q("wxMpAppId") || WECHAT_MP_APP_ID || "").trim();
  766. if (fromQuery) return fromQuery;
  767. var raw = d.appId || d.appid || d.wxAppId;
  768. return raw != null && String(raw).trim() !== "" ? String(raw).trim() : "";
  769. }
  770. function normalizeWxJssdkSignPayload(res, signUrlUsed) {
  771. if (!res || typeof res !== "object") return null;
  772. var d = res.data != null && typeof res.data === "object" ? res.data : res;
  773. if (!d || typeof d !== "object") return null;
  774. var appId = resolveWxConfigAppIdFromSignData(d);
  775. var timestamp = d.timestamp != null ? d.timestamp : d.timeStamp;
  776. var nonceStr =
  777. d.nonceStr != null && String(d.nonceStr) !== ""
  778. ? d.nonceStr
  779. : d.noncestr != null && String(d.noncestr) !== ""
  780. ? d.noncestr
  781. : d.nonce;
  782. var signature = d.signature || d.sign;
  783. if (!appId || timestamp == null || nonceStr == null || nonceStr === "" || !signature) {
  784. return null;
  785. }
  786. return {
  787. appId: String(appId),
  788. timestamp: Number(timestamp),
  789. nonceStr: String(nonceStr),
  790. signature: String(signature),
  791. signUrl: String(signUrlUsed || "")
  792. .split("#")[0]
  793. .trim(),
  794. };
  795. }
  796. function getWxErrMsg(err) {
  797. if (!err) return "";
  798. if (err.errMsg) return String(err.errMsg);
  799. if (typeof err === "string") return err;
  800. try {
  801. return JSON.stringify(err);
  802. } catch (e) {
  803. return String(err);
  804. }
  805. }
  806. function formatWxConfigErrorTip(err, signPageUrl) {
  807. var errMsg = getWxErrMsg(err);
  808. var tip = "微信 JSSDK 配置失败";
  809. if (/invalid signature/i.test(errMsg)) {
  810. return (
  811. tip +
  812. ":签名无效。请核对:①后端用与前端相同的 url 签名;②url=" +
  813. (signPageUrl || getWxHtmlUrl()) +
  814. ";③nonceStr/timestamp 与接口返回一致;④appId=" +
  815. WECHAT_MP_APP_ID
  816. );
  817. }
  818. if (/require\s*subscribe/i.test(errMsg)) {
  819. return tip + ":" + errMsg + "(服务号需用户已关注)";
  820. }
  821. return errMsg ? tip + ":" + errMsg : tip;
  822. }
  823. function setWxInitError(msg) {
  824. wxInitLastError = String(msg || "").trim();
  825. if (wxInitLastError) console.warn("[wx]", wxInitLastError);
  826. }
  827. function requestWeChatJssdkSignAndConfig(htmlUrlOptional) {
  828. var htmlUrl = String(htmlUrlOptional != null ? htmlUrlOptional : getWxConfigSignUrl())
  829. .split("#")[0]
  830. .trim();
  831. if (!htmlUrl || !/^https?:\/\//i.test(htmlUrl)) {
  832. htmlUrl = WX_GET_CONFIG_SIGN_URL;
  833. }
  834. if (isWxDebugOn()) {
  835. try {
  836. window.alert("htmlUrl(签名用,应与地址栏一致):\n" + htmlUrl);
  837. } catch (eDbg) {}
  838. }
  839. var requestUrl = getWxGetConfigApiUrl();
  840. var requestBody = buildWxGetConfigRequestBody(htmlUrl);
  841. return fetch(requestUrl, {
  842. method: "POST",
  843. mode: "cors",
  844. credentials: "omit",
  845. headers: {
  846. Accept: "application/json",
  847. "Content-Type": "application/json;charset=UTF-8",
  848. },
  849. body: JSON.stringify(requestBody),
  850. })
  851. .then(function (r) {
  852. if (r.ok) return r.json();
  853. return r
  854. .text()
  855. .catch(function () {
  856. return "";
  857. })
  858. .then(function (text) {
  859. var hint = "";
  860. try {
  861. var j = JSON.parse(text);
  862. hint = j.msg || j.message || "";
  863. } catch (eP) {
  864. if (text) hint = text.slice(0, 120);
  865. }
  866. throw new Error("getWxConfig HTTP " + r.status + (hint ? ":" + hint : ""));
  867. });
  868. })
  869. .then(function (res) {
  870. if (res && res.code != null) {
  871. var c = Number(res.code);
  872. if (c !== 200 && c !== 0 && res.success !== true) {
  873. throw new Error(res.msg || res.message || "getWxConfig code " + c);
  874. }
  875. }
  876. var sign = normalizeWxJssdkSignPayload(res, htmlUrl);
  877. if (!sign) {
  878. throw new Error("getWxConfig 缺少 appId/timestamp/nonceStr/signature(见控制台)");
  879. }
  880. if (typeof wx === "undefined") {
  881. if (isWxPcBrowser()) {
  882. console.log("[wx] PC getWxConfig 成功(无 jweixin)", sign);
  883. return true;
  884. }
  885. setWxInitError("jweixin.js 未加载");
  886. return false;
  887. }
  888. return applyWxConfigFromSign(sign, htmlUrl);
  889. });
  890. }
  891. function applyWxConfigFromSign(sign, htmlUrl) {
  892. var wxConfigParams = {
  893. debug: isWxDebugOn(),
  894. appId: String(sign.appId),
  895. timestamp: sign.timestamp,
  896. nonceStr: String(sign.nonceStr),
  897. signature: String(sign.signature),
  898. jsApiList: [],
  899. openTagList: ["wx-open-launch-app"],
  900. };
  901. return new Promise(function (resolve) {
  902. wx.config(wxConfigParams);
  903. wx.ready(function () {
  904. weChatJssdkConfigured = true;
  905. if (!wxOpenTagBroken) {
  906. document.body.classList.add("wx-jssdk-ready");
  907. }
  908. refreshWxLaunchTagAttrs();
  909. console.log("[wx.config] ready, htmlUrl=", htmlUrl);
  910. resolve(true);
  911. });
  912. wx.error(function (err) {
  913. weChatJssdkConfigured = false;
  914. document.body.classList.remove("wx-jssdk-ready");
  915. wxJssdkInitPromise = null;
  916. var errMsg = getWxErrMsg(err);
  917. setWxInitError(formatWxConfigErrorTip(err, htmlUrl));
  918. if (isWxDebugOn()) window.alert(wxInitLastError);
  919. console.warn("[wx.config]", errMsg, "htmlUrl=", htmlUrl);
  920. var baseUrl = getWxHtmlUrlBase();
  921. var fullUrl = getWxSignPageUrlForApi();
  922. if (
  923. !/invalid signature/i.test(errMsg) ||
  924. wxConfigSignRetriedBaseUrl ||
  925. baseUrl === fullUrl ||
  926. htmlUrl === baseUrl
  927. ) {
  928. resolve(false);
  929. return;
  930. }
  931. wxConfigSignRetriedBaseUrl = true;
  932. requestWeChatJssdkSignAndConfig(baseUrl).then(resolve);
  933. });
  934. });
  935. }
  936. function disableWxLaunchTagUi() {
  937. wxOpenTagBroken = true;
  938. document.body.classList.remove("wx-jssdk-ready");
  939. }
  940. function refreshWxLaunchTagAttrs(useBarePathOnly) {
  941. var tag = document.getElementById("launch-btn");
  942. if (!tag) return;
  943. try {
  944. tag.setAttribute("appid", WECHAT_OPEN_APP_ID);
  945. tag.setAttribute("extinfo", buildWeChatLaunchExtinfo(!!useBarePathOnly));
  946. console.log("[wx-open-launch-app] extinfo=", tag.getAttribute("extinfo"));
  947. } catch (eA) {}
  948. }
  949. function bindWeChatLaunchTagEvents() {
  950. var tag = document.getElementById("launch-btn");
  951. if (!tag || tag._wxLaunchBound) return;
  952. tag._wxLaunchBound = true;
  953. refreshWxLaunchTagAttrs();
  954. tag.addEventListener("launch", function () {
  955. console.log("[wx-open-launch-app] launch ok");
  956. });
  957. tag.addEventListener("error", function (e) {
  958. var detail = e && e.detail;
  959. var errMsg =
  960. detail && detail.errMsg
  961. ? String(detail.errMsg)
  962. : detail && detail.errmsg
  963. ? String(detail.errmsg)
  964. : "";
  965. console.warn("[wx-open-launch-app]", detail);
  966. if (/launch:fail/i.test(errMsg) && !getWxShareEntryFrom()) {
  967. showAppOpenFailTip("请前往应用商店下载U店在哪app");
  968. } else {
  969. showAppOpenFailTip(
  970. errMsg
  971. ? "未能打开 App:" + errMsg
  972. : "未能打开 App,请确认已安装最新版「U店在哪」"
  973. );
  974. }
  975. });
  976. }
  977. function initWeChatOpenLaunchApp(fromUserClick) {
  978. if (!shouldFetchWxConfig(!!fromUserClick)) {
  979. return Promise.resolve(false);
  980. }
  981. if (wxJssdkInitPromise && !fromUserClick) return wxJssdkInitPromise;
  982. wxConfigSignRetriedBaseUrl = false;
  983. wxInitLastError = "";
  984. var htmlUrl = getWxConfigSignUrl();
  985. bindWeChatLaunchTagEvents();
  986. wxJssdkInitPromise = requestWeChatJssdkSignAndConfig(htmlUrl)
  987. .then(function (ok) {
  988. if (ok === true) return true;
  989. if (!wxInitLastError) {
  990. setWxInitError("wx.config 失败,可加 ?wxDebug=1 查看 htmlUrl");
  991. }
  992. return false;
  993. })
  994. .catch(function (e) {
  995. var msg = e && e.message ? e.message : "getWxConfig 请求失败";
  996. setWxInitError(msg);
  997. console.warn("[wx] requestWeChatJssdkSignAndConfig failed", msg, "htmlUrl=", htmlUrl);
  998. if (isWeChatInAppBrowser() && isWxDebugOn()) window.alert(msg);
  999. return false;
  1000. })
  1001. .finally(function () {
  1002. if (!weChatJssdkConfigured) wxJssdkInitPromise = null;
  1003. });
  1004. return wxJssdkInitPromise;
  1005. }
  1006. function scheduleWeChatJssdkBootstrap() {
  1007. if (!shouldInitWeChatJssdkOnLoad()) return;
  1008. var attempts = 0;
  1009. function tick() {
  1010. attempts += 1;
  1011. if (weChatJssdkConfigured) return;
  1012. initWeChatOpenLaunchApp();
  1013. if (!weChatJssdkConfigured && attempts < 8 && typeof wx === "undefined") {
  1014. setTimeout(tick, 400);
  1015. }
  1016. }
  1017. if (isIOSWeChatBrowser()) {
  1018. setTimeout(tick, 350);
  1019. } else {
  1020. tick();
  1021. }
  1022. }
  1023. function showFabToast(msg, ms) {
  1024. var tip = String(msg || "").trim();
  1025. if (!tip) return;
  1026. var el = document.getElementById("openAppToast");
  1027. if (el) {
  1028. el.textContent = tip;
  1029. el.style.display = "block";
  1030. if (showFabToast._t) clearTimeout(showFabToast._t);
  1031. showFabToast._t = setTimeout(function () {
  1032. el.style.display = "none";
  1033. }, ms || 2800);
  1034. }
  1035. console.log("[openApp]", tip);
  1036. }
  1037. function showDownloadTip() {
  1038. var msg = "请到应用商店下载「U店在哪」";
  1039. if (typeof uni !== "undefined" && typeof uni.showToast === "function") {
  1040. uni.showToast({ title: msg, icon: "none", duration: 2500 });
  1041. } else {
  1042. window.alert(msg);
  1043. }
  1044. }
  1045. function showAppOpenFailTip(msg) {
  1046. var tip = msg || "未能打开 App,请确认已安装最新版「U店在哪」。";
  1047. if (typeof uni !== "undefined" && typeof uni.showToast === "function") {
  1048. uni.showToast({ title: msg, icon: "none", duration: 2800 });
  1049. } else if (isWeChatInAppBrowser()) {
  1050. window.alert(tip);
  1051. } else {
  1052. showFabToast(tip);
  1053. }
  1054. }
  1055. function launchAppDeepLink(deepLink) {
  1056. try {
  1057. var a = document.createElement("a");
  1058. a.href = deepLink;
  1059. a.setAttribute("target", "_self");
  1060. document.body.appendChild(a);
  1061. a.click();
  1062. document.body.removeChild(a);
  1063. } catch (e1) {}
  1064. try {
  1065. window.location.href = deepLink;
  1066. } catch (e2) {}
  1067. }
  1068. function tryOpenHBuilderAppViaScheme() {
  1069. var deepLink = buildAppDeepLink();
  1070. if (typeof plus !== "undefined" && plus.runtime) {
  1071. var installed = null;
  1072. try {
  1073. if (typeof plus.runtime.isApplicationExist === "function") {
  1074. installed = plus.runtime.isApplicationExist({
  1075. pname: APP_ANDROID_PACKAGE,
  1076. action: APP_IOS_URL_SCHEME,
  1077. });
  1078. }
  1079. } catch (e) {
  1080. console.warn(e);
  1081. }
  1082. if (installed === false) {
  1083. showDownloadTip();
  1084. return;
  1085. }
  1086. try {
  1087. plus.runtime.openURL(deepLink);
  1088. } catch (e2) {
  1089. console.warn(e2);
  1090. showDownloadTip();
  1091. }
  1092. return;
  1093. }
  1094. var done = false;
  1095. function finish() {
  1096. if (done) return;
  1097. done = true;
  1098. document.removeEventListener("visibilitychange", onVis);
  1099. window.removeEventListener("pagehide", onHide);
  1100. }
  1101. function onVis() {
  1102. if (document.visibilityState === "hidden") finish();
  1103. }
  1104. function onHide() {
  1105. finish();
  1106. }
  1107. document.addEventListener("visibilitychange", onVis);
  1108. window.addEventListener("pagehide", onHide);
  1109. try {
  1110. launchAppDeepLink(deepLink);
  1111. } catch (e3) {
  1112. finish();
  1113. showDownloadTip();
  1114. return;
  1115. }
  1116. window.setTimeout(function () {
  1117. finish();
  1118. }, 3200);
  1119. }
  1120. function tryFetchWxConfigOnPcClick() {
  1121. if (!isWxPcBrowser()) return Promise.resolve(false);
  1122. showFabToast("正在请求 getWxConfig…");
  1123. wxJssdkInitPromise = null;
  1124. return initWeChatOpenLaunchApp(true).then(function (ok) {
  1125. if (ok) {
  1126. showFabToast(
  1127. weChatJssdkConfigured
  1128. ? "getWxConfig 成功,wx.config 已就绪"
  1129. : "getWxConfig 成功"
  1130. );
  1131. } else {
  1132. showFabToast(wxInitLastError || "getWxConfig 失败");
  1133. }
  1134. return ok;
  1135. });
  1136. }
  1137. function tryOpenHBuilderApp() {
  1138. if (isWeChatInAppBrowser()) return;
  1139. tryFetchWxConfigOnPcClick().then(function () {
  1140. if (isWxConfigOnClickDebug() && !isWxForceDebug() && !isWxPcAutoDebugHost()) {
  1141. return;
  1142. }
  1143. tryOpenHBuilderAppViaScheme();
  1144. });
  1145. }
  1146. function boot() {
  1147. var launchTag = document.getElementById("launch-btn");
  1148. if (launchTag) launchTag.setAttribute("appid", WECHAT_OPEN_APP_ID);
  1149. bindWeChatLaunchTagEvents();
  1150. if (isWeChatInAppBrowser()) {
  1151. document.body.classList.add("is-wechat");
  1152. logWxEntryDiagnostics();
  1153. }
  1154. if (shouldInitWeChatJssdkOnLoad()) {
  1155. if (isWxPcBrowser() && (isWxForceDebug() || isWxPcAutoDebugHost())) {
  1156. document.body.classList.add("wx-pc-debug");
  1157. }
  1158. scheduleWeChatJssdkBootstrap();
  1159. }
  1160. document.addEventListener("WeixinOpenTagsError", function (e) {
  1161. disableWxLaunchTagUi();
  1162. console.warn("[WeixinOpenTagsError]", e && e.detail);
  1163. });
  1164. if (isWeChatInAppBrowser()) {
  1165. var openBtnWx = document.getElementById("openApp");
  1166. if (openBtnWx) {
  1167. openBtnWx.addEventListener("click", function () {
  1168. if (!weChatJssdkConfigured) {
  1169. showFabToast(
  1170. wxInitLastError || "微信 SDK 初始化中,请稍候再点底部按钮"
  1171. );
  1172. }
  1173. });
  1174. }
  1175. } else {
  1176. var openAppBtn = document.getElementById("openApp");
  1177. if (openAppBtn) {
  1178. openAppBtn.addEventListener("click", tryOpenHBuilderApp);
  1179. }
  1180. }
  1181. render(parsePayload());
  1182. }
  1183. if (document.readyState === "complete") {
  1184. boot();
  1185. } else {
  1186. window.addEventListener("load", boot);
  1187. }
  1188. })();
  1189. </script>
  1190. </body>
  1191. </html>