You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1846 lines
44 KiB

4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
  1. <template>
  2. <view class="deepMate-page">
  3. <!-- 顶部导航栏 -->
  4. <view class="header" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
  5. <view class="header-left">
  6. <image
  7. src="https://d31zlh4on95l9h.cloudfront.net/images/f91e09b5987802185e7679055dafd272.svg"
  8. class="icon"
  9. @click="goToCustomerService"
  10. >
  11. </image>
  12. </view>
  13. <view class="header-center">
  14. <text class="title" :style="{ paddingTop: safeAreaInsets?.top + 'px' }"
  15. >DeepMate</text
  16. >
  17. </view>
  18. <view class="header-right">
  19. <image
  20. src="https://d31zlh4on95l9h.cloudfront.net/images/d7c4e74201213a25dd9574e908233928.svg"
  21. class="icon"
  22. @click="goToNotice"
  23. @tap="goToNotice"
  24. >
  25. </image>
  26. <image
  27. style="margin-left: 10px"
  28. src="https://d31zlh4on95l9h.cloudfront.net/images/099903c4aabf5713488b5cb60815e3f7.svg"
  29. class="icon"
  30. @click="openHistoryDrawer"
  31. ></image>
  32. <!-- 新增新会话按钮
  33. <button class="new-chat-button" @click="newChat">
  34. <text class="new-chat-text">新会话</text>
  35. </button> -->
  36. </view>
  37. </view>
  38. <!-- 主要内容区域 -->
  39. <view class="main-content">
  40. <view class="banner-panel" v-if="messages.length === 0">
  41. <image
  42. src="https://d31zlh4on95l9h.cloudfront.net/images/42e18bd7fe97d4f4f37aa70439a0990b.svg"
  43. class="pray-banner"
  44. ></image>
  45. <view class="contain">
  46. <!-- 机器人头像和欢迎语 -->
  47. <view class="robot-container" v-if="messages.length === 0">
  48. <image src="/static/icons/robot.svg" class="robot-avatar"></image>
  49. <view class="welcome-message">
  50. <text class="greeting">Hi, 我是您的股市随身顾问~</text>
  51. <text class="description"
  52. >个股诊断市场情绪解读都可以找我</text
  53. >
  54. </view>
  55. </view>
  56. <!-- 功能标签栏 -->
  57. <!-- <view class="function-tabs" v-if="messages.length === 0">
  58. <view ref="tabsTrack" class="tabs-track" :style="{ transform: 'translate3d(-' + marqueeOffset + 'px,0,0)' }">
  59. <view class="tab-item" v-for="(tab, idx) in marqueeList" :key="idx">{{ tab }}</view>
  60. </view>
  61. </view> -->
  62. <!-- 特斯拉推荐卡片 -->
  63. <view
  64. class="recommend-card"
  65. v-if="messages.length === 0"
  66. @click="goinstitutionalTrendsBriefing"
  67. >
  68. <view class="arrow" v-if="messages.length === 0"></view>
  69. <view class="card-content">
  70. <image
  71. src="../../static/images/tesla-logo.png"
  72. class="logo"
  73. ></image>
  74. <view class="card-text">
  75. <text class="main-question">当前特斯拉该如何布局</text>
  76. <text class="stock-code">TSLA</text>
  77. </view>
  78. <image
  79. src="https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg"
  80. class="arrow-icon"
  81. @click="goinstitutionalTrendsBriefing"
  82. ></image>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 可能感兴趣的话题 -->
  88. <!-- <view v-if="messages.length === 0" class="interest-section">
  89. <text class="section-title">- 您可能感兴趣 -</text>
  90. <view class="topics-list">
  91. <view class="topic-item" v-for="topic in hotTopics" :key="topic.id">
  92. <image :src="topic.icon" class="tag-icon"></image>
  93. <text class="topic-text" @click="sendMessageList(topic.text)">{{
  94. topic.text
  95. }}</text>
  96. </view>
  97. </view>
  98. </view> -->
  99. <view v-if="messages.length === 0" class="welcome-section"> </view>
  100. <!-- 聊天区域 -->
  101. <!-- 顶部粘性欢迎块始终保留在聊天上方 -->
  102. <view class="chat-header" v-if="messages.length > 0">
  103. <view class="robot-container">
  104. <image src="/static/icons/robot.svg" class="robot-avatar"></image>
  105. <view class="welcome-message">
  106. <text class="greeting">Hi, 我是您的股市随身顾问~</text>
  107. </view>
  108. </view>
  109. </view>
  110. <scroll-view
  111. class="chat-container"
  112. scroll-y="true"
  113. :scroll-top="chatScrollTop"
  114. :scroll-with-animation="!isSending"
  115. @scroll="onChatScroll"
  116. v-if="messages.length > 0"
  117. >
  118. <view class="message-list" id="messageList">
  119. <view
  120. v-for="(message, index) in messages"
  121. :key="index"
  122. :class="
  123. message.isUser ? 'message user-message' : 'message bot-message'
  124. "
  125. >
  126. <!-- 会话图标 -->
  127. <!-- <text
  128. :class="
  129. message.isUser
  130. ? 'fa-solid fa-user message-icon'
  131. : 'fa-solid fa-robot message-icon'
  132. "
  133. ></text> -->
  134. <image
  135. v-if="message.isUser"
  136. class="message-icon"
  137. :src="userAvatar"
  138. mode="scaleToFill"
  139. /><image
  140. v-else
  141. class="message-icon"
  142. src="/static/icons/robot.svg"
  143. mode="scaleToFill"
  144. />
  145. <!-- 会话内容 -->
  146. <view class="message-content">
  147. <!-- <text class="message-text">{{ message.content }}</text> -->
  148. <!-- loading -->
  149. <view
  150. class="loading-dots"
  151. v-if="message.isThinking || !message.isUser"
  152. >
  153. <view class="thinking-process">
  154. <view class="thinking-header">
  155. <view class="thinking-icon"></view>
  156. <view class="thinking-title">{{
  157. message.isTyping ? "正在思考" : "思考完成"
  158. }}</view>
  159. <view class="thinking-count"> </view>
  160. <view
  161. class="thinking-toggle"
  162. @click="message.isThinking = !message.isThinking"
  163. >
  164. <span v-if="message.isThinking"></span>
  165. <span v-else></span>
  166. </view>
  167. </view>
  168. <view v-show="message.isThinking" class="thinking-content">
  169. <view class="thinking-item">
  170. <view class="item-status">
  171. <span v-if="message.isFirst" class="checkmark"></span>
  172. </view>
  173. <view class="item-text">问题分析完成</view>
  174. </view>
  175. <view class="thinking-item">
  176. <view class="item-status">
  177. <span v-if="message.isSecond" class="checkmark"></span>
  178. </view>
  179. <view class="item-text">收集相关信息</view>
  180. </view>
  181. </view>
  182. </view>
  183. </view>
  184. <!-- 使用 rich-text 渲染 Markdown 内容 -->
  185. <rich-text
  186. v-if="!message.isUser"
  187. class="message-text"
  188. :nodes="renderMarkdown(message.content)"
  189. ></rich-text>
  190. <text v-else class="message-text">{{ message.content }}</text>
  191. </view>
  192. </view>
  193. </view>
  194. </scroll-view>
  195. </view>
  196. <!-- 输入框区域 -->
  197. <view class="input-area">
  198. <view class="input-wrapper">
  199. <input
  200. type="text"
  201. placeholder="请输入股票代码/名称,获取AI洞察"
  202. placeholder-style="color:#fff;opacity:1"
  203. class="input-field"
  204. v-model="inputMessage"
  205. @confirm="sendMessage"
  206. />
  207. <image class="send-button" @click="sendMessage" :disabled="isSending">
  208. <!-- <image
  209. src="https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg"
  210. class="send-icon"
  211. ></image> -->
  212. </image>
  213. </view>
  214. <text class="disclaimer"
  215. >以上数据由AI生成不作为最终投资建议决策需独立</text
  216. >
  217. </view>
  218. <image
  219. class="back-to-top"
  220. src="https://d31zlh4on95l9h.cloudfront.net/images/ba357635d2bb480241952bb1cabacd73.svg"
  221. :style="{
  222. transform: 'translate3d(' + backTopX + 'px,' + backTopY + 'px,0)',
  223. }"
  224. @touchstart="onBackTopTouchStart"
  225. @touchmove="onBackTopTouchMove"
  226. @touchend="onBackTopTouchEnd"
  227. @click="onBackTopClick"
  228. ></image>
  229. <!-- 搜索历史侧拉框 -->
  230. <view class="drawer-overlay" v-show="showHistoryDrawer"></view>
  231. <view
  232. class="drawer-panel"
  233. v-show="showHistoryDrawer"
  234. @click.stop
  235. @touchmove.stop.prevent
  236. :style="{ transform: 'translateY(' + drawerOffsetY + 'px)' }"
  237. >
  238. <view class="drawer-header">
  239. <text class="drawer-title">历史对话</text>
  240. <view class="drawer-actions">
  241. <view class="delete-all-container">
  242. <image
  243. class="delete-icon"
  244. src="/static/icons/Group_48095481.svg"
  245. ></image>
  246. <text class="delete-all" @click="clearAllHistory">删除全部</text>
  247. </view>
  248. <view class="drawer-close" @click="onDrawerBackClick"
  249. ><text class="drawer-close-icon"></text
  250. ></view>
  251. </view>
  252. </view>
  253. <scroll-view scroll-y="true" class="drawer-content">
  254. <view class="drawer-inner">
  255. <view v-if="groupedHistory.length === 0" class="empty-history">
  256. <text>暂无历史记录</text>
  257. </view>
  258. <view
  259. v-for="(section, sIdx) in groupedHistory"
  260. :key="sIdx"
  261. class="history-section"
  262. >
  263. <text class="section-title">{{ section.title }}</text>
  264. <view
  265. v-for="(item, idx) in section.items"
  266. :key="idx"
  267. class="history-item"
  268. >
  269. <view class="history-left">
  270. <view class="flag-circle"
  271. ><image
  272. class="icon-stock"
  273. :src="stockImage(item.stockMarket)"
  274. mode="scaleToFill"
  275. /></view>
  276. </view>
  277. <view class="history-main" @click="itemClick(item)">
  278. <text class="history-query">{{ item.stockName }}</text>
  279. <text class="history-query">{{ item.stockCode }}</text>
  280. </view>
  281. <text class="history-time">{{
  282. formatTimeForHistory(item.createdTime)
  283. }}</text>
  284. </view>
  285. </view>
  286. </view>
  287. </scroll-view>
  288. </view>
  289. <footerBar class="static-footer" :type="type"></footerBar>
  290. </view>
  291. <LoginPrompt ref="loginPrompt"></LoginPrompt>
  292. </template>
  293. <script setup>
  294. const { safeAreaInsets } = uni.getSystemInfoSync();
  295. import { ref, computed, onMounted, onUnmounted, watch, nextTick } from "vue";
  296. import footerBar from "../../components/footerBar";
  297. import marked from "marked"; // 引入 marked 库
  298. import { onPageScroll, onLoad } from "@dcloudio/uni-app";
  299. import {
  300. postStock,
  301. postIntent,
  302. postHistory,
  303. postHistoryDetail,
  304. } from "../../api/deepMate/deepMate";
  305. import { useUserStore } from "../../stores/modules/userInfo";
  306. const renderer = new marked.Renderer();
  307. renderer.heading = function (text, level) {
  308. return `<p>${text}</p>`;
  309. };
  310. // 设置 marked 选项
  311. marked.setOptions({
  312. renderer: new marked.Renderer(),
  313. highlight: null, // 如果需要代码高亮,可以设置适当的函数
  314. langPrefix: "language-",
  315. pedantic: false,
  316. gfm: true,
  317. breaks: false,
  318. sanitize: false,
  319. smartLists: true,
  320. smartypants: false,
  321. xhtml: false,
  322. });
  323. // 创建一个用于渲染 Markdown 的函数
  324. const renderMarkdown = (content) => {
  325. if (!content) return "";
  326. return marked.parse(content);
  327. };
  328. const type = ref("deepMate");
  329. const inputMessage = ref("");
  330. const showThinking = ref(true);
  331. const isSending = ref(false);
  332. const chatScrollTop = ref(0);
  333. const chatContainerHeight = ref(0);
  334. const uuid = ref("");
  335. const messages = ref([]);
  336. const showHistoryDrawer = ref(false);
  337. const drawerOffsetY = ref(0);
  338. const searchHistory = ref([]);
  339. const historyList = ref([]);
  340. // 处理页面加载时的路由参数
  341. onLoad((options) => {
  342. console.log("deepMate页面接收到参数:", options);
  343. // 如果有query参数,自动发送消息
  344. if (options.query) {
  345. const decodedQuery = decodeURIComponent(options.query);
  346. console.log("解码后的查询内容:", decodedQuery);
  347. // 设置输入框内容并自动发送
  348. inputMessage.value = decodedQuery;
  349. // 延迟一下再发送,确保页面已经完全加载
  350. setTimeout(() => {
  351. sendMessage();
  352. }, 500);
  353. }
  354. });
  355. // 初始化
  356. onMounted(() => {
  357. const sys = uni.getSystemInfoSync();
  358. const iconSize = uni.upx2px(100); // 和样式保持一致
  359. const reserveBottom = uni.upx2px(260); // 预留底部输入区域空间
  360. const initX = Math.max(0, sys.windowWidth - iconSize - uni.upx2px(30));
  361. const initY = Math.max(0, Math.floor(sys.windowHeight * 0.65) - iconSize);
  362. backTopTargetX.value = initX;
  363. backTopTargetY.value = initY;
  364. backTopX.value = initX;
  365. backTopY.value = initY;
  366. initUUID();
  367. if (messages.value.length === 0) {
  368. // nextTick(startTabsMarquee);
  369. }
  370. if (messages.value.length > 0) {
  371. nextTick(() => {
  372. measureChatContainer();
  373. scrollToBottom();
  374. });
  375. }
  376. // 载入历史
  377. // const hist = uni.getStorageSync("search_history") || [];
  378. // searchHistory.value = Array.isArray(hist) ? hist : [];
  379. // 缓存今天日期(YYYY-MM-DD)
  380. const todayStr = new Date().toISOString().slice(0, 10);
  381. uni.setStorageSync("today_date", todayStr);
  382. });
  383. // 初始化 UUID
  384. const initUUID = () => {
  385. let storedUUID = uni.getStorageSync("user_uuid");
  386. if (!storedUUID) {
  387. storedUUID = generateUUID();
  388. uni.setStorageSync("user_uuid", storedUUID);
  389. }
  390. uuid.value = storedUUID;
  391. };
  392. // 生成简单UUID
  393. const generateUUID = () => {
  394. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
  395. var r = (Math.random() * 16) | 0,
  396. v = c == "x" ? r : (r & 0x3) | 0x8;
  397. return v.toString(16);
  398. });
  399. };
  400. // 计算聊天容器可视高度
  401. const measureChatContainer = () => {
  402. const q = uni.createSelectorQuery();
  403. q.select(".chat-container").boundingClientRect();
  404. q.exec((res) => {
  405. chatContainerHeight.value = res[0]?.height || 0;
  406. });
  407. };
  408. // 新会话
  409. const newChat = () => {
  410. messages.value = [];
  411. uni.removeStorageSync("user_uuid");
  412. initUUID();
  413. };
  414. // 跳转到空白页
  415. const goinstitutionalTrendsBriefing = () => {
  416. uni.navigateTo({
  417. url: "/pages/blank/institutionalTrendsBriefing",
  418. });
  419. };
  420. // 跳转到客户服务平台首页
  421. const goToCustomerService = () => {
  422. uni.navigateTo({
  423. url: "/pages/customerServicePlatform/csPlatformIndex",
  424. });
  425. };
  426. // 跳转到通知页
  427. function goToNotice() {
  428. try {
  429. console.log("goToNotice: navigating to /pages/blank/notice");
  430. uni.navigateTo({ url: "/pages/blank/notice" });
  431. } catch (e) {
  432. console.error("goToNotice navigateTo failed, fallback to redirect:", e);
  433. uni.redirectTo({ url: "/pages/blank/notice" });
  434. }
  435. }
  436. // 历史记录
  437. const openHistoryDrawer = async () => {
  438. const res = await postHistory({
  439. model: 5,
  440. });
  441. if (res.code === 200) {
  442. historyList.value = res.data;
  443. }
  444. console.log("historyList.value", historyList.value);
  445. const hideDistance = uni.upx2px(900);
  446. drawerOffsetY.value = hideDistance;
  447. showHistoryDrawer.value = true;
  448. setTimeout(() => {
  449. drawerOffsetY.value = 0;
  450. }, 10);
  451. };
  452. const closeHistoryDrawer = () => {
  453. showHistoryDrawer.value = false;
  454. };
  455. const onDrawerBackClick = () => {
  456. const hideDistance = uni.upx2px(900);
  457. drawerOffsetY.value = hideDistance;
  458. setTimeout(() => {
  459. closeHistoryDrawer();
  460. drawerOffsetY.value = 0;
  461. }, 180);
  462. };
  463. // 时间格式化:YYYY-MM-DD HH:mm
  464. const pad2 = (n) => (n < 10 ? "0" + n : "" + n);
  465. const formatTime = (t) => {
  466. const d = new Date(t);
  467. const y = d.getFullYear();
  468. const m = pad2(d.getMonth() + 1);
  469. const day = pad2(d.getDate());
  470. const hh = pad2(d.getHours());
  471. const mm = pad2(d.getMinutes());
  472. return `${y}-${m}-${day} ${hh}:${mm}`;
  473. };
  474. // 为历史记录格式化时间:YYYY-MM-DD HH:mm
  475. const formatTimeForHistory = (timeString) => {
  476. // 假设 timeString 格式为 "YYYY-MM-DD HH:mm:ss"
  477. const parts = timeString.split(" ");
  478. if (parts.length >= 2) {
  479. const datePart = parts[0];
  480. const timePart = parts[1];
  481. const timeParts = timePart.split(":");
  482. if (timeParts.length >= 2) {
  483. return `${datePart} ${timeParts[0]}:${timeParts[1]}`;
  484. }
  485. }
  486. return timeString;
  487. };
  488. const userStore = useUserStore();
  489. // 用户头像
  490. const userAvatar = computed(() => {
  491. return userStore.userInfo.avatar;
  492. });
  493. // 历史分组(今天/昨天/近一周/按月)
  494. const groupedHistory = computed(() => {
  495. const sections = [];
  496. // 从缓存获取今天日期,如果没有则使用当前日期
  497. const now = new Date();
  498. const startOfDay = (d) =>
  499. new Date(d.getFullYear(), d.getMonth(), d.getDate());
  500. const isSameDay = (a, b) =>
  501. startOfDay(a).getTime() === startOfDay(b).getTime();
  502. const isYesterday = (d) => {
  503. const y = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
  504. return isSameDay(d, y);
  505. };
  506. const isToday = (d) => isSameDay(d, now);
  507. const withinLast7Days = (d) => {
  508. const seven = new Date(
  509. now.getFullYear(),
  510. now.getMonth(),
  511. now.getDate() - 7
  512. );
  513. return d >= seven && !isToday(d) && !isYesterday(d);
  514. };
  515. const monthLabel = (d) => `${d.getMonth() + 1}`;
  516. const today = [];
  517. const yesterday = [];
  518. const last7 = [];
  519. const byMonth = new Map();
  520. // 使用 historyList.value 替代 searchHistory.value
  521. historyList.value.forEach((item) => {
  522. // 根据你的数据结构,使用 createdTime 字段
  523. const dt = new Date(item.createdTime);
  524. if (isToday(dt)) {
  525. today.push(item);
  526. } else if (isYesterday(dt)) {
  527. yesterday.push(item);
  528. } else if (withinLast7Days(dt)) {
  529. last7.push(item);
  530. } else {
  531. const year = dt.getFullYear();
  532. const month = dt.getMonth() + 1;
  533. const key = `${year}-${month}`;
  534. if (!byMonth.has(key))
  535. byMonth.set(key, {
  536. title: `${year}${month}`,
  537. year,
  538. month,
  539. items: [],
  540. });
  541. byMonth.get(key).items.push(item);
  542. }
  543. });
  544. if (today.length) sections.push({ title: "今天", items: today });
  545. if (yesterday.length) sections.push({ title: "昨天", items: yesterday });
  546. if (last7.length) sections.push({ title: "近一周", items: last7 });
  547. const monthSections = Array.from(byMonth.values()).sort((a, b) => {
  548. if (a.year !== b.year) return b.year - a.year;
  549. return b.month - a.month; // 月份倒序,如 10月 在 9月 之前
  550. });
  551. sections.push(...monthSections);
  552. return sections;
  553. });
  554. const clearAllHistory = () => {
  555. searchHistory.value = [];
  556. // uni.setStorageSync("search_history", []);
  557. };
  558. // 发送消息
  559. const sendMessage = () => {
  560. if (inputMessage.value.trim() === "" || isSending.value) return;
  561. const userMessage = {
  562. content: inputMessage.value,
  563. isUser: true,
  564. isThinking: false,
  565. isTyping: false,
  566. };
  567. messages.value.push(userMessage);
  568. inputMessage.value = "";
  569. // 记录搜索历史
  570. // const entry = { query: userMessage.content, time: Date.now() };
  571. // searchHistory.value.unshift(entry);
  572. // uni.setStorageSync("search_history", searchHistory.value);
  573. // 发送后强制恢复并滚到底部
  574. shouldAutoScroll.value = true;
  575. nextTick(() => {
  576. scrollToBottom();
  577. });
  578. // 模拟机器人回复
  579. simulateBotResponse(userMessage.content);
  580. };
  581. // 模拟机器人回复
  582. const simulateBotResponse = async (userMessage) => {
  583. // 添加机器人加载消息
  584. const botMsg = {
  585. content: "",
  586. isUser: false,
  587. isTyping: true,
  588. isThinking: true,
  589. isFirst: false,
  590. isSecond: false,
  591. };
  592. messages.value.push(botMsg);
  593. isSending.value = true;
  594. // 首先进行意图识别
  595. let res;
  596. try {
  597. res = await postIntent({
  598. content: userMessage,
  599. language: "cn",
  600. marketList: "hk,cn,usa,my,sg,vi,in,gb",
  601. token:
  602. "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
  603. });
  604. } catch (error) {
  605. isSending.value = false;
  606. } finally {
  607. }
  608. console.log("res" + res);
  609. // 意图识别不通过
  610. if (res.code !== 200) {
  611. console.log("未通过意图识别");
  612. messages.value[messages.value.length - 1].isThinking = false;
  613. // 更新机器人的消息内容
  614. const errorMessage = res.message || "请求失败,请稍后重试";
  615. let responseText = `我已经收到您的消息: "${userMessage}"。错误信息: "${errorMessage}"`;
  616. // 开始打字机效果显示错误信息
  617. let index = 0;
  618. const botIndex = messages.value.length - 1;
  619. const typeWriter = () => {
  620. if (index < responseText.length) {
  621. let ch = responseText.charAt(index);
  622. let charsToAdd = ch;
  623. let newIndex = index + 1;
  624. // 检查是否遇到HTML标签开始
  625. if (ch === '<') {
  626. // 寻找标签结束位置
  627. let tagEndIndex = responseText.indexOf('>', index);
  628. if (tagEndIndex !== -1) {
  629. // 完整获取标签内容
  630. charsToAdd = responseText.substring(index, tagEndIndex + 1);
  631. newIndex = tagEndIndex + 1;
  632. }
  633. }
  634. const current = messages.value[botIndex];
  635. // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
  636. messages.value.splice(botIndex, 1, {
  637. ...current,
  638. content: current.content + charsToAdd,
  639. isTyping: true,
  640. });
  641. index = newIndex;
  642. scrollToBottom();
  643. // 字符间延迟,模拟打字效果
  644. const baseDelay = 5; // 普通字符基础延迟(毫秒)
  645. const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
  646. const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
  647. // 如果是标签,使用更短的延迟或者立即显示
  648. let delay;
  649. if (charsToAdd.startsWith('<')) {
  650. delay = 1; // 标签快速显示
  651. } else {
  652. delay = slowPunct.test(ch)
  653. ? 220
  654. : midPunct.test(ch)
  655. ? 120
  656. : baseDelay;
  657. }
  658. setTimeout(typeWriter, delay);
  659. } else {
  660. // 打字完成,更新状态
  661. const current = messages.value[botIndex];
  662. messages.value.splice(botIndex, 1, { ...current, isTyping: false });
  663. isSending.value = false;
  664. nextTick(() => {
  665. scrollToBottom();
  666. });
  667. }
  668. };
  669. // 启动打字机效果
  670. setTimeout(typeWriter, 300);
  671. return;
  672. }
  673. console.log("通过意图识别");
  674. messages.value[messages.value.length - 1].isFirst = true;
  675. // 获取意图识别结果
  676. const recordId = res.data.recordId;
  677. const parentId = res.data.parentId;
  678. const stockId = res.data.stockId;
  679. // 获取股票信息
  680. const StockInfo = await postStock({
  681. language: "cn",
  682. token:
  683. "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
  684. recordId: Number(recordId),
  685. parentId: Number(parentId),
  686. stockId: Number(stockId),
  687. });
  688. console.log("postStock payload", {
  689. language: "cn",
  690. token: "790750702588f1ea79f24dc56ccd5d8a",
  691. recordId,
  692. parentId,
  693. stockId,
  694. });
  695. console.log("StockInfo", StockInfo);
  696. const cftl = StockInfo?.cftl || {};
  697. const date = StockInfo?.date || "";
  698. if (StockInfo && StockInfo.code !== 200) {
  699. const errMsg = `postStock失败(${StockInfo.code}): ${
  700. StockInfo.message || "未知错误"
  701. }`;
  702. console.warn(errMsg, StockInfo);
  703. messages.value[messages.value.length - 1].isThinking = false;
  704. messages.value[messages.value.length - 1].isTyping = false;
  705. messages.value[messages.value.length - 1].content = errMsg;
  706. isSending.value = false;
  707. return;
  708. }
  709. const markdown = StockInfo?.data?.markdown || "抱歉,未找到该股票";
  710. console.log("StockInfo", StockInfo);
  711. // 添加请求延迟
  712. // const toDataInfo = await getData();
  713. // console.log(toDataInfo);
  714. // dataInfo.value = toDataInfo.data;
  715. // console.log(dataInfo.value);
  716. messages.value[messages.value.length - 1].isSecond = true;
  717. setTimeout(() => {
  718. messages.value[messages.value.length - 1].isThinking = false;
  719. }, 500);
  720. // 滚动到底部
  721. nextTick(() => {
  722. scrollToBottom();
  723. });
  724. // 模拟流式响应
  725. let responseText = `我已经收到您的消息: "${userMessage}"。"${markdown}" `;
  726. let index = 0;
  727. const botIndex = messages.value.length - 1;
  728. const baseDelay = 5; // 普通字符基础延迟(毫秒)
  729. const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
  730. const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
  731. const typeWriter = () => {
  732. if (index < responseText.length) {
  733. let ch = responseText.charAt(index);
  734. let charsToAdd = ch;
  735. let newIndex = index + 1;
  736. let delay = baseDelay;
  737. // 检查是否遇到HTML标签开始
  738. if (ch === '<') {
  739. // 寻找标签结束位置
  740. let tagEndIndex = responseText.indexOf('>', index);
  741. if (tagEndIndex !== -1) {
  742. // 完整获取标签内容
  743. charsToAdd = responseText.substring(index, tagEndIndex + 1);
  744. newIndex = tagEndIndex + 1;
  745. delay = 1; // 标签快速显示
  746. }
  747. }
  748. const current = messages.value[botIndex];
  749. // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
  750. messages.value.splice(botIndex, 1, {
  751. ...current,
  752. content: current.content + charsToAdd,
  753. isTyping: true,
  754. });
  755. index = newIndex;
  756. scrollToBottom();
  757. setTimeout(typeWriter, delay);
  758. } else {
  759. const current = messages.value[botIndex];
  760. messages.value.splice(botIndex, 1, { ...current, isTyping: false });
  761. isSending.value = false;
  762. nextTick(() => {
  763. scrollToBottom();
  764. });
  765. }
  766. };
  767. // 启动前稍作停顿,避免过快开始
  768. setTimeout(typeWriter, 500);
  769. console.log("messages", messages);
  770. };
  771. // 当消息出现或变化时,测量容器并滚到底部
  772. watch(messages, (arr) => {
  773. if (arr.length > 0) {
  774. nextTick(() => {
  775. measureChatContainer();
  776. scrollToBottom();
  777. });
  778. }
  779. });
  780. // 滚动到底部(仅聊天区域滚动)
  781. const scrollToBottom = () => {
  782. if (!shouldAutoScroll.value) return;
  783. const query = uni.createSelectorQuery();
  784. query.select("#messageList").boundingClientRect();
  785. query.exec((res) => {
  786. if (res[0]) {
  787. latestContentHeight.value = res[0].height;
  788. chatScrollTop.value = res[0].height; // scroll-view 会自动夹紧到最大位置
  789. }
  790. });
  791. };
  792. const scrollToTop = () => {
  793. chatScrollTop.value = 0;
  794. };
  795. // 自动滚动控制:用户向上滚动时暂停自动滚到底部
  796. const shouldAutoScroll = ref(true);
  797. const latestContentHeight = ref(0);
  798. const lastScrollTop = ref(0);
  799. const windowHeight = uni.getSystemInfoSync().windowHeight;
  800. const AUTO_SCROLL_REENABLE_THRESHOLD = 40000; // px,接近底部时恢复自动滚动
  801. const onChatScroll = (e) => {
  802. const st = e.detail?.scrollTop || 0;
  803. const delta = st - lastScrollTop.value;
  804. lastScrollTop.value = st;
  805. if (delta < 0) {
  806. shouldAutoScroll.value = false;
  807. return;
  808. }
  809. const distanceToBottom =
  810. latestContentHeight.value - st - chatContainerHeight.value;
  811. if (distanceToBottom <= AUTO_SCROLL_REENABLE_THRESHOLD) {
  812. shouldAutoScroll.value = true;
  813. }
  814. };
  815. // 回到顶部图标拖拽状态
  816. const backTopX = ref(0);
  817. const backTopY = ref(0);
  818. const backTopDragging = ref(false);
  819. const backTopDragOffset = ref({ x: 0, y: 0 });
  820. const backTopTargetX = ref(0);
  821. const backTopTargetY = ref(0);
  822. let backTopRAF = 0;
  823. const backTopSmoothing = 0.15; // 越大越跟手,越小越顺滑
  824. const backTopEpsilon = 0.5; // 收敛阈值
  825. const raf =
  826. typeof requestAnimationFrame === "function"
  827. ? requestAnimationFrame
  828. : (fn) => setTimeout(fn, 16);
  829. const caf =
  830. typeof cancelAnimationFrame === "function"
  831. ? cancelAnimationFrame
  832. : (id) => clearTimeout(id);
  833. function stepBackTop() {
  834. const dx = backTopTargetX.value - backTopX.value;
  835. const dy = backTopTargetY.value - backTopY.value;
  836. // 插值缓动,避免每帧重排
  837. backTopX.value += dx * backTopSmoothing;
  838. backTopY.value += dy * backTopSmoothing;
  839. if (Math.abs(dx) > backTopEpsilon || Math.abs(dy) > backTopEpsilon) {
  840. backTopRAF = raf(stepBackTop);
  841. } else {
  842. backTopX.value = backTopTargetX.value;
  843. backTopY.value = backTopTargetY.value;
  844. backTopRAF = 0;
  845. }
  846. }
  847. function ensureBackTopRAF() {
  848. if (!backTopRAF) {
  849. backTopRAF = raf(stepBackTop);
  850. }
  851. }
  852. const clamp = (val, min, max) => Math.max(min, Math.min(val, max));
  853. const onBackTopTouchStart = (e) => {
  854. const t = e.touches && e.touches[0];
  855. if (!t) return;
  856. backTopDragging.value = false;
  857. backTopDragOffset.value = {
  858. x: t.pageX - backTopX.value,
  859. y: t.pageY - backTopY.value,
  860. };
  861. };
  862. const onBackTopTouchMove = (e) => {
  863. const t = e.touches && e.touches[0];
  864. if (!t) return;
  865. const sys = uni.getSystemInfoSync();
  866. const iconSize = uni.upx2px(100);
  867. const reserveBottom = uni.upx2px(260);
  868. const nx = t.pageX - backTopDragOffset.value.x;
  869. const ny = t.pageY - backTopDragOffset.value.y;
  870. const clampedX = clamp(nx, 0, sys.windowWidth - iconSize);
  871. const clampedY = clamp(ny, 0, sys.windowHeight - reserveBottom - iconSize);
  872. if (
  873. Math.abs(clampedX - backTopX.value) + Math.abs(clampedY - backTopY.value) >
  874. 3
  875. ) {
  876. backTopDragging.value = true;
  877. }
  878. backTopTargetX.value = clampedX;
  879. backTopTargetY.value = clampedY;
  880. ensureBackTopRAF();
  881. };
  882. const onBackTopTouchEnd = () => {
  883. // 结束拖拽即可
  884. };
  885. const onBackTopClick = () => {
  886. if (backTopDragging.value) return; // 拖拽时不触发点击回到顶部
  887. scrollToTop();
  888. };
  889. // 历史记录国家图像
  890. function stockImage(Market) {
  891. switch (Market) {
  892. case "usa":
  893. return "../../static/marketSituation-image/country-flag/us.png";
  894. case "can":
  895. return "../../static/marketSituation-image/country-flag/can.png";
  896. case "vi":
  897. return "../../static/marketSituation-image/country-flag/vi.png";
  898. case "th":
  899. return "../../static/marketSituation-image/country-flag/th.png";
  900. case "my":
  901. return "../../static/marketSituation-image/country-flag/my.png";
  902. case "sg":
  903. return "../../static/marketSituation-image/country-flag/sg.png";
  904. case "hk":
  905. return "../../static/marketSituation-image/country-flag/hk.png";
  906. case "cn":
  907. return "../../static/marketSituation-image/country-flag/cn.png";
  908. }
  909. }
  910. // 历史记录详情
  911. async function itemClick(item) {
  912. const res = await postHistoryDetail({
  913. recordId: item.id,
  914. parentId: item.parentId,
  915. model: 5,
  916. });
  917. if (res.code == 200) {
  918. const message = res.data.wokeFlowData.One.markdown;
  919. messages.value = [];
  920. const botMsg = {
  921. content: message,
  922. isUser: false,
  923. isTyping: false,
  924. isThinking: false,
  925. };
  926. onDrawerBackClick();
  927. messages.value.push(botMsg);
  928. }
  929. }
  930. </script>
  931. <style scoped>
  932. .deepMate-page {
  933. display: flex;
  934. flex-direction: column;
  935. position: fixed;
  936. /* 充满视口,彻底禁用页面滚动 */
  937. top: 0;
  938. left: 0;
  939. right: 0;
  940. bottom: 0;
  941. height: 100vh;
  942. overflow: hidden;
  943. /* 锁定页面滚动 */
  944. background-color: #ffffff;
  945. padding: 20rpx 0rpx;
  946. }
  947. .header {
  948. display: flex;
  949. justify-content: space-between;
  950. align-items: center;
  951. padding: 20rpx 30rpx;
  952. background-color: #ffffff;
  953. box-shadow: 0 2rpx rgba(0, 0, 0, 0.1);
  954. }
  955. .header-left,
  956. .header-right {
  957. display: flex;
  958. align-items: center;
  959. }
  960. .header-left .icon,
  961. .header-right .icon {
  962. width: 40rpx;
  963. height: 40rpx;
  964. /* margin-right: 20rpx; */
  965. }
  966. .header-center .title {
  967. position: fixed;
  968. top: 10rpx;
  969. left: 50%;
  970. transform: translateX(-50%);
  971. font-size: 36rpx;
  972. font-weight: bold;
  973. color: #333333;
  974. }
  975. .new-chat-button {
  976. background-color: #ff6600;
  977. border: none;
  978. border-radius: 8rpx;
  979. padding: 10rpx 20rpx;
  980. }
  981. .new-chat-text {
  982. color: white;
  983. font-size: 24rpx;
  984. }
  985. .main-content {
  986. background-color: #fff;
  987. flex: 1;
  988. display: flex;
  989. flex-direction: column;
  990. overflow: hidden;
  991. /* 内部滚动交给聊天容器 */
  992. padding: 20rpx;
  993. margin-top: 1rpx;
  994. margin-bottom: 280rpx;
  995. }
  996. /* 聊天顶部粘性欢迎块样式 */
  997. .chat-header {
  998. position: sticky;
  999. top: 0;
  1000. /* 在页面滚动时始终贴顶 */
  1001. z-index: 50;
  1002. background-color: #ffffff;
  1003. padding: 3rpx 20rpx;
  1004. }
  1005. .robot-container {
  1006. display: flex;
  1007. align-items: center;
  1008. margin-top: 30rpx;
  1009. }
  1010. .robot-avatar {
  1011. width: 130rpx;
  1012. height: 130rpx;
  1013. border-radius: 50%;
  1014. margin-left: 20rpx;
  1015. }
  1016. .welcome-message {
  1017. flex: 1;
  1018. }
  1019. .greeting {
  1020. font-size: 32rpx;
  1021. margin-left: 50rpx;
  1022. top: 40rpx;
  1023. font-weight: bold;
  1024. color: #333333;
  1025. line-height: 48rpx;
  1026. }
  1027. .description {
  1028. display: block;
  1029. font-size: 24rpx;
  1030. color: #666666;
  1031. line-height: 36rpx;
  1032. margin-top: 10rpx;
  1033. margin-left: 45rpx;
  1034. }
  1035. .function-tabs {
  1036. display: block;
  1037. overflow: hidden;
  1038. margin-bottom: 30rpx;
  1039. }
  1040. .tabs-track {
  1041. display: inline-flex;
  1042. white-space: nowrap;
  1043. will-change: transform;
  1044. }
  1045. .tab-item {
  1046. padding: 5rpx 20rpx;
  1047. border-radius: 20rpx;
  1048. font-size: 20rpx;
  1049. font-weight: 700;
  1050. color: #666666;
  1051. background-color: #fffefe;
  1052. margin-right: 20rpx;
  1053. transition: all 0.3s;
  1054. }
  1055. .tab-item.active {
  1056. color: #ff6600;
  1057. background-color: #fff;
  1058. border: 1rpx solid #ff6600;
  1059. }
  1060. .recommend-card {
  1061. background: url("https://d31zlh4on95l9h.cloudfront.net/images/4da1d629a55c307c3605ca15bf15189a.svg");
  1062. background-repeat: no-repeat;
  1063. background-position: center bottom;
  1064. background-size: contain;
  1065. /* min-height: 20rpx; */
  1066. /* border-radius: 20rpx; */
  1067. padding: 40rpx;
  1068. margin-top: 20rpx;
  1069. margin-bottom: 10rpx;
  1070. /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); */
  1071. }
  1072. .welcome-section {
  1073. /* 灰色卡片(recommend-card)之后展示背景图 */
  1074. margin-top: 10rpx;
  1075. display: flex;
  1076. align-items: center;
  1077. justify-content: center;
  1078. background: url("https://d31zlh4on95l9h.cloudfront.net/images/eca84d9fb54712cb3bc6c6174773b83b.svg");
  1079. background-repeat: no-repeat;
  1080. background-position: center top;
  1081. /* 放在容器顶部,正好在灰色卡片下方 */
  1082. background-size: 80% auto;
  1083. /* 缩放以适配宽度 */
  1084. height: 460rpx;
  1085. /* 提供可视高度,让背景图可见 */
  1086. }
  1087. .card-content {
  1088. display: flex;
  1089. align-items: center;
  1090. justify-content: space-between;
  1091. margin-left: 40rpx;
  1092. }
  1093. .logo {
  1094. width: 80rpx;
  1095. height: 80rpx;
  1096. background-color: #ff0000;
  1097. border-radius: 10rpx;
  1098. display: flex;
  1099. align-items: center;
  1100. justify-content: center;
  1101. margin-right: 20rpx;
  1102. }
  1103. .card-text {
  1104. flex: 1;
  1105. margin-left: 20rpx;
  1106. }
  1107. .main-question {
  1108. font-size: 32rpx;
  1109. color: #333333;
  1110. line-height: 48rpx;
  1111. }
  1112. .stock-code {
  1113. display: block;
  1114. font-size: 24rpx;
  1115. color: #ff3b30;
  1116. background-color: #ffffff;
  1117. padding: 2rpx 15rpx;
  1118. border-radius: 12rpx;
  1119. margin-top: 8rpx;
  1120. width: fit-content;
  1121. border: 1rpx solid #ff3b30;
  1122. }
  1123. .arrow-icon {
  1124. background: url("https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg");
  1125. background-repeat: no-repeat;
  1126. left: 0.5rem;
  1127. top: 1.8rem;
  1128. background-size: 100% 100%;
  1129. width: 60rpx;
  1130. height: 60rpx;
  1131. }
  1132. .interest-section {
  1133. margin-bottom: 30rpx;
  1134. }
  1135. .section-title {
  1136. display: block;
  1137. text-align: left;
  1138. font-size: 26rpx;
  1139. color: #666666;
  1140. margin-bottom: 20rpx;
  1141. }
  1142. .topics-list {
  1143. display: flex;
  1144. flex-direction: column;
  1145. gap: 15rpx;
  1146. }
  1147. .topic-item {
  1148. display: flex;
  1149. align-items: center;
  1150. padding: 15rpx 20rpx;
  1151. background-color: #f0f0f0;
  1152. border-radius: 15rpx;
  1153. width: fit-content;
  1154. }
  1155. .tag-icon {
  1156. width: 24rpx;
  1157. height: 24rpx;
  1158. margin-right: 10rpx;
  1159. }
  1160. .topic-text {
  1161. font-size: 28rpx;
  1162. color: #333333;
  1163. flex: 1;
  1164. }
  1165. /* 聊天区域样式 */
  1166. .chat-container {
  1167. margin-top: 30rpx;
  1168. border-radius: 10rpx;
  1169. height: calc(100vh - 50rpx);
  1170. /* 缩短滚动区域,避免被输入框覆盖 */
  1171. overflow-y: auto;
  1172. -webkit-overflow-scrolling: touch;
  1173. }
  1174. .message-list {
  1175. background-color: #fff;
  1176. margin-bottom: 400rpx;
  1177. /* padding: 20rpx; */
  1178. }
  1179. .message {
  1180. display: flex;
  1181. align-items: flex-start;
  1182. margin-bottom: 30rpx;
  1183. }
  1184. .user-message {
  1185. flex-direction: row-reverse;
  1186. justify-content: flex-start;
  1187. }
  1188. .message-icon {
  1189. font-size: 24rpx;
  1190. margin: 0 10rpx;
  1191. /* padding: 10rpx; */
  1192. border-radius: 50%;
  1193. background-color: #ddd;
  1194. width: 60rpx;
  1195. height: 60rpx;
  1196. display: flex;
  1197. align-items: center;
  1198. justify-content: center;
  1199. }
  1200. .user-message .message-icon {
  1201. /* background-color: #007aff; */
  1202. border-radius: 50%;
  1203. color: #fff;
  1204. /* box-shadow: 0 0 12rpx rgba(0, 122, 255, 0.4); */
  1205. }
  1206. .bot-message .message-icon {
  1207. /* background: url("/static/images/robot (1).svg"); */
  1208. color: white;
  1209. }
  1210. .message-content {
  1211. max-width: 70%;
  1212. position: relative;
  1213. word-wrap: break-word;
  1214. word-break: break-all;
  1215. overflow-wrap: break-word;
  1216. }
  1217. .user-message .message-content {
  1218. /* background-color: #007aff; */
  1219. border: 2rpx solid #f3908f;
  1220. border-radius: 20rpx;
  1221. padding: 10rpx;
  1222. }
  1223. .bot-message .message-content {
  1224. background-color: #f0f0f0;
  1225. border-radius: 10rpx;
  1226. padding: 15rpx;
  1227. }
  1228. .message-text {
  1229. font-size: 28rpx;
  1230. line-height: 40rpx;
  1231. }
  1232. .user-message .message-text {
  1233. color: black;
  1234. }
  1235. .bot-message .message-text {
  1236. color: #333;
  1237. }
  1238. .loading-dots {
  1239. display: flex;
  1240. align-items: center;
  1241. /* padding-top: 10rpx; */
  1242. }
  1243. .dot {
  1244. width: 10rpx;
  1245. height: 10rpx;
  1246. background-color: #666;
  1247. border-radius: 50%;
  1248. margin: 0 4rpx;
  1249. animation: loading 1.4s infinite ease-in-out both;
  1250. }
  1251. .user-message .dot {
  1252. background-color: white;
  1253. }
  1254. .dot:nth-child(1) {
  1255. animation-delay: -0.32s;
  1256. }
  1257. .dot:nth-child(2) {
  1258. animation-delay: -0.16s;
  1259. }
  1260. @keyframes loading {
  1261. 0%,
  1262. 80%,
  1263. 100% {
  1264. transform: scale(0);
  1265. }
  1266. 40% {
  1267. transform: scale(1);
  1268. }
  1269. }
  1270. .input-area {
  1271. position: fixed;
  1272. margin-top: 20rpx;
  1273. bottom: 70rpx;
  1274. left: 0;
  1275. right: 0;
  1276. padding: 0 40rpx 80rpx 40rpx;
  1277. background-color: #ffffff;
  1278. }
  1279. .input-wrapper {
  1280. position: relative;
  1281. display: flex;
  1282. align-items: center;
  1283. padding: 15rpx 20rpx;
  1284. background-color: rgb(220, 31, 29);
  1285. border-radius: 100rpx;
  1286. display: flex;
  1287. align-items: center;
  1288. justify-content: center;
  1289. height: 50rpx;
  1290. }
  1291. .mic-icon {
  1292. width: 36rpx;
  1293. height: 36rpx;
  1294. margin-right: 20rpx;
  1295. }
  1296. .input-field {
  1297. flex: 1;
  1298. font-size: 28rpx;
  1299. color: #fff;
  1300. display: flex;
  1301. align-items: center;
  1302. justify-content: center;
  1303. margin-left: 60rpx;
  1304. background: none;
  1305. border: none;
  1306. outline: none;
  1307. }
  1308. .input-field::placeholder {
  1309. color: #ffffff !important;
  1310. opacity: 1;
  1311. }
  1312. /* .uni-scroll-view{
  1313. height: 92%;
  1314. } */
  1315. .send-button {
  1316. background: url("https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg");
  1317. background-repeat: no-repeat;
  1318. background-size: 100% 100%;
  1319. height: 50rpx;
  1320. width: 50rpx;
  1321. padding: 0;
  1322. border: 1rpx solid transparent;
  1323. margin-left: 20rpx;
  1324. }
  1325. .send-icon {
  1326. width: 36rpx;
  1327. height: 36rpx;
  1328. }
  1329. .disclaimer {
  1330. font-size: 15rpx;
  1331. color: #4d4c4c;
  1332. display: flex;
  1333. align-items: center;
  1334. justify-content: center;
  1335. margin-top: 15rpx;
  1336. }
  1337. .banner-panel {
  1338. position: relative;
  1339. height: 480rpx;
  1340. /* 拉长容器,灰色背景跟随变高 */
  1341. overflow: hidden;
  1342. /* 让圆角和内部层剪裁一致 */
  1343. border-radius: 15rpx;
  1344. }
  1345. .panelShow {
  1346. height: 12%;
  1347. }
  1348. .pray-banner {
  1349. position: absolute;
  1350. /* background-size: 100% 100%; */
  1351. inset: 0;
  1352. /* 顶部、底部、左、右都贴合容器 */
  1353. width: 100%;
  1354. height: 81%;
  1355. border-radius: 15rpx;
  1356. z-index: 1;
  1357. /* 在灰底之上、内容之下 */
  1358. }
  1359. .contain {
  1360. margin: 0 20rpx;
  1361. gap: 5rpx;
  1362. }
  1363. .banner-panel .robot-container,
  1364. .banner-panel .function-tabs,
  1365. .banner-panel .recommend-card {
  1366. position: relative;
  1367. z-index: 2;
  1368. }
  1369. .back-to-top {
  1370. position: fixed;
  1371. left: 0;
  1372. top: 0;
  1373. width: 100rpx;
  1374. height: 100rpx;
  1375. z-index: 1000;
  1376. }
  1377. .back-to-top:active {
  1378. transform: scale(0.96);
  1379. }
  1380. .static-footer {
  1381. position: fixed;
  1382. bottom: 0;
  1383. }
  1384. /* 搜索历史侧拉框样式 */
  1385. .drawer-overlay {
  1386. position: fixed;
  1387. left: 0;
  1388. top: 0;
  1389. right: 0;
  1390. bottom: 0;
  1391. background-color: rgba(0, 0, 0, 0.35);
  1392. z-index: 900;
  1393. }
  1394. .drawer-panel {
  1395. position: fixed;
  1396. left: 0;
  1397. right: 0;
  1398. bottom: 0;
  1399. height: 75vh;
  1400. max-height: 80vh;
  1401. width: 100%;
  1402. background: #ffffff;
  1403. box-shadow: 0 -8rpx 20rpx rgba(0, 0, 0, 0.06);
  1404. z-index: 1000;
  1405. display: flex;
  1406. flex-direction: column;
  1407. border-top-left-radius: 20rpx;
  1408. border-top-right-radius: 20rpx;
  1409. transition: transform 0.22s ease;
  1410. }
  1411. .drawer-back {
  1412. position: absolute;
  1413. left: 50%;
  1414. top: -14px;
  1415. transform: translateX(-50%);
  1416. width: 28px;
  1417. height: 48px;
  1418. border-radius: 12px;
  1419. background: #fff;
  1420. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  1421. display: flex;
  1422. align-items: center;
  1423. justify-content: center;
  1424. }
  1425. .drawer-back-icon {
  1426. font-size: 16px;
  1427. color: #8a8a8a;
  1428. }
  1429. .drawer-actions {
  1430. display: flex;
  1431. align-items: center;
  1432. gap: 40rpx;
  1433. }
  1434. .delete-all-container {
  1435. display: flex;
  1436. align-items: center;
  1437. gap: 14rpx;
  1438. }
  1439. .delete-icon {
  1440. width: 45rpx;
  1441. height: 40rpx;
  1442. }
  1443. .delete-all {
  1444. font-size: 28rpx;
  1445. }
  1446. .drawer-close {
  1447. background: url("/static/icons/close-two.svg");
  1448. width: 48rpx;
  1449. height: 48rpx;
  1450. border-radius: 24rpx;
  1451. /* background: #f5f5f5; */
  1452. /* box-shadow: 0 2px 8px rgba(0,0,0,0.08); */
  1453. display: flex;
  1454. align-items: center;
  1455. justify-content: center;
  1456. }
  1457. .drawer-close-icon {
  1458. font-size: 24rpx;
  1459. color: #8a8a8a;
  1460. }
  1461. .drawer-header {
  1462. display: flex;
  1463. align-items: center;
  1464. justify-content: space-between;
  1465. padding: 52rpx 28rpx 0rpx 28rpx;
  1466. /* border-bottom: 2rpx solid #f0f0f0; */
  1467. }
  1468. .drawer-title {
  1469. font-size: 32rpx;
  1470. font-weight: 600;
  1471. color: #333333;
  1472. }
  1473. /* .drawer-close {
  1474. font-size: 42rpx;
  1475. color: #999999;
  1476. } */
  1477. .drawer-content {
  1478. flex: 1;
  1479. min-height: 0;
  1480. /* 让 flex 子元素可在容器内收缩以启用滚动 */
  1481. height: 100%;
  1482. overscroll-behavior-y: contain;
  1483. /* 防止滚动串联到页面 */
  1484. -webkit-overflow-scrolling: touch;
  1485. /* iOS 惯性滚动 */
  1486. touch-action: pan-y;
  1487. /* 优化触控滚动,仅垂直 */
  1488. }
  1489. .drawer-inner {
  1490. padding: 20rpx 24rpx 20rpx 24rpx;
  1491. }
  1492. .history-section {
  1493. margin-bottom: 20rpx;
  1494. /* margin: 0 24rpx; */
  1495. }
  1496. .section-title {
  1497. font-size: 26rpx;
  1498. color: #888;
  1499. margin: 10rpx 6rpx 16rpx;
  1500. }
  1501. .history-item {
  1502. display: flex;
  1503. align-items: center;
  1504. padding: 19rpx 18rpx;
  1505. background-color: #f6f7f9;
  1506. border-radius: 12rpx;
  1507. margin-bottom: 12rpx;
  1508. }
  1509. .history-left {
  1510. margin-right: 12rpx;
  1511. }
  1512. .icon-stock {
  1513. width: 36rpx;
  1514. height: 36rpx;
  1515. }
  1516. .flag-circle {
  1517. width: 36rpx;
  1518. height: 36rpx;
  1519. border-radius: 50%;
  1520. background: #fff;
  1521. border: 2rpx solid #eee;
  1522. display: flex;
  1523. align-items: center;
  1524. justify-content: center;
  1525. }
  1526. .flag-emoji {
  1527. font-size: 24rpx;
  1528. }
  1529. .history-main {
  1530. flex: 1;
  1531. }
  1532. .history-query {
  1533. font-size: 28rpx;
  1534. color: #333;
  1535. }
  1536. .history-time {
  1537. font-size: 22rpx;
  1538. color: #999;
  1539. }
  1540. .history-card {
  1541. background-color: #fff;
  1542. border: 2rpx solid #f2f2f2;
  1543. border-left: 8rpx solid rgb(220, 31, 29);
  1544. border-radius: 12rpx;
  1545. padding: 18rpx 20rpx;
  1546. margin-bottom: 16rpx;
  1547. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.03);
  1548. }
  1549. .history-query {
  1550. font-size: 28rpx;
  1551. color: #333333;
  1552. font-weight: 500;
  1553. }
  1554. .history-time {
  1555. margin-top: 8rpx;
  1556. font-size: 22rpx;
  1557. color: #888888;
  1558. }
  1559. .empty-history {
  1560. padding: 40rpx;
  1561. color: #999999;
  1562. text-align: center;
  1563. }
  1564. .thinking-process {
  1565. margin: 10rpx 0;
  1566. border: 2rpx solid #e5e5e5;
  1567. border-radius: 20rpx;
  1568. background-color: #f9f9f9;
  1569. }
  1570. .thinking-header {
  1571. display: flex;
  1572. align-items: center;
  1573. padding: 20rpx 30rpx;
  1574. cursor: pointer;
  1575. background-color: #fff;
  1576. border-radius: 20rpx;
  1577. border-bottom: 2rpx solid #e5e5e5;
  1578. }
  1579. .thinking-icon {
  1580. font-size: 32rpx;
  1581. margin-right: 16rpx;
  1582. color: #d47c45;
  1583. }
  1584. .thinking-title {
  1585. font-size: 28rpx;
  1586. font-weight: 500;
  1587. color: #d47c45;
  1588. margin-right: 16rpx;
  1589. }
  1590. .thinking-count {
  1591. font-size: 24rpx;
  1592. color: #666;
  1593. margin-right: 16rpx;
  1594. }
  1595. .thinking-toggle {
  1596. font-size: 24rpx;
  1597. color: #999;
  1598. }
  1599. .thinking-content {
  1600. transition: transform 1s ease; /* 添加过渡效果 */
  1601. transform-origin: top center; /* 设置变换原点 */
  1602. padding: 20rpx 30rpx;
  1603. }
  1604. @keyframes transform {
  1605. from {
  1606. transform: scaleY(0);
  1607. }
  1608. to {
  1609. transform: scaleY(1);
  1610. }
  1611. }
  1612. .thinking-item {
  1613. display: flex;
  1614. align-items: center;
  1615. margin-bottom: 16rpx;
  1616. padding: 8rpx 0;
  1617. }
  1618. .item-status {
  1619. width: 32rpx;
  1620. height: 32rpx;
  1621. border-radius: 50%;
  1622. background-color: #f0f0f0;
  1623. display: flex;
  1624. justify-content: center;
  1625. align-items: center;
  1626. margin-right: 16rpx;
  1627. }
  1628. .checkmark {
  1629. font-size: 20rpx;
  1630. color: #ff0000;
  1631. }
  1632. .item-text {
  1633. font-size: 24rpx;
  1634. color: #333;
  1635. }
  1636. </style>