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.

1801 lines
43 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. const ch = responseText.charAt(index);
  622. const current = messages.value[botIndex];
  623. // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
  624. messages.value.splice(botIndex, 1, {
  625. ...current,
  626. content: current.content + ch,
  627. isTyping: true,
  628. });
  629. index++;
  630. scrollToBottom();
  631. // 字符间延迟,模拟打字效果
  632. const baseDelay = 5; // 普通字符基础延迟(毫秒)
  633. const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
  634. const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
  635. const delay = slowPunct.test(ch)
  636. ? 220
  637. : midPunct.test(ch)
  638. ? 120
  639. : baseDelay;
  640. setTimeout(typeWriter, delay);
  641. } else {
  642. // 打字完成,更新状态
  643. const current = messages.value[botIndex];
  644. messages.value.splice(botIndex, 1, { ...current, isTyping: false });
  645. isSending.value = false;
  646. nextTick(() => {
  647. scrollToBottom();
  648. });
  649. }
  650. };
  651. // 启动打字机效果
  652. setTimeout(typeWriter, 300);
  653. return;
  654. }
  655. console.log("通过意图识别");
  656. messages.value[messages.value.length - 1].isFirst = true;
  657. // 获取意图识别结果
  658. const recordId = res.data.recordId;
  659. const parentId = res.data.parentId;
  660. const stockId = res.data.stockId;
  661. // 获取股票信息
  662. const StockInfo = await postStock({
  663. language: "cn",
  664. token:
  665. "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
  666. recordId: Number(recordId),
  667. parentId: Number(parentId),
  668. stockId: Number(stockId),
  669. });
  670. console.log("postStock payload", {
  671. language: "cn",
  672. token: "790750702588f1ea79f24dc56ccd5d8a",
  673. recordId,
  674. parentId,
  675. stockId,
  676. });
  677. console.log("StockInfo", StockInfo);
  678. const cftl = StockInfo?.cftl || {};
  679. const date = StockInfo?.date || "";
  680. if (StockInfo && StockInfo.code !== 200) {
  681. const errMsg = `postStock失败(${StockInfo.code}): ${
  682. StockInfo.message || "未知错误"
  683. }`;
  684. console.warn(errMsg, StockInfo);
  685. messages.value[messages.value.length - 1].isThinking = false;
  686. messages.value[messages.value.length - 1].isTyping = false;
  687. messages.value[messages.value.length - 1].content = errMsg;
  688. isSending.value = false;
  689. return;
  690. }
  691. const markdown = StockInfo?.data?.markdown || "抱歉,未找到该股票";
  692. console.log("StockInfo", StockInfo);
  693. // 添加请求延迟
  694. // const toDataInfo = await getData();
  695. // console.log(toDataInfo);
  696. // dataInfo.value = toDataInfo.data;
  697. // console.log(dataInfo.value);
  698. messages.value[messages.value.length - 1].isSecond = true;
  699. setTimeout(() => {
  700. messages.value[messages.value.length - 1].isThinking = false;
  701. }, 500);
  702. // 滚动到底部
  703. nextTick(() => {
  704. scrollToBottom();
  705. });
  706. // 模拟流式响应
  707. let responseText = `我已经收到您的消息: "${userMessage}"。"${markdown}" `;
  708. let index = 0;
  709. const botIndex = messages.value.length - 1;
  710. const baseDelay = 5; // 普通字符基础延迟(毫秒)
  711. const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
  712. const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
  713. const typeWriter = () => {
  714. if (index < responseText.length) {
  715. const ch = responseText.charAt(index);
  716. const current = messages.value[botIndex];
  717. // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
  718. messages.value.splice(botIndex, 1, {
  719. ...current,
  720. content: current.content + ch,
  721. isTyping: true,
  722. });
  723. index++;
  724. scrollToBottom();
  725. const delay = slowPunct.test(ch)
  726. ? 220
  727. : midPunct.test(ch)
  728. ? 120
  729. : baseDelay;
  730. setTimeout(typeWriter, delay);
  731. } else {
  732. const current = messages.value[botIndex];
  733. messages.value.splice(botIndex, 1, { ...current, isTyping: false });
  734. isSending.value = false;
  735. nextTick(() => {
  736. scrollToBottom();
  737. });
  738. }
  739. };
  740. // 启动前稍作停顿,避免过快开始
  741. setTimeout(typeWriter, 500);
  742. console.log("messages", messages);
  743. };
  744. // 当消息出现或变化时,测量容器并滚到底部
  745. watch(messages, (arr) => {
  746. if (arr.length > 0) {
  747. nextTick(() => {
  748. measureChatContainer();
  749. scrollToBottom();
  750. });
  751. }
  752. });
  753. // 滚动到底部(仅聊天区域滚动)
  754. const scrollToBottom = () => {
  755. if (!shouldAutoScroll.value) return;
  756. const query = uni.createSelectorQuery();
  757. query.select("#messageList").boundingClientRect();
  758. query.exec((res) => {
  759. if (res[0]) {
  760. latestContentHeight.value = res[0].height;
  761. chatScrollTop.value = res[0].height; // scroll-view 会自动夹紧到最大位置
  762. }
  763. });
  764. };
  765. const scrollToTop = () => {
  766. chatScrollTop.value = 0;
  767. };
  768. // 自动滚动控制:用户向上滚动时暂停自动滚到底部
  769. const shouldAutoScroll = ref(true);
  770. const latestContentHeight = ref(0);
  771. const lastScrollTop = ref(0);
  772. const windowHeight = uni.getSystemInfoSync().windowHeight;
  773. const AUTO_SCROLL_REENABLE_THRESHOLD = 40000; // px,接近底部时恢复自动滚动
  774. const onChatScroll = (e) => {
  775. const st = e.detail?.scrollTop || 0;
  776. const delta = st - lastScrollTop.value;
  777. lastScrollTop.value = st;
  778. if (delta < 0) {
  779. shouldAutoScroll.value = false;
  780. return;
  781. }
  782. const distanceToBottom =
  783. latestContentHeight.value - st - chatContainerHeight.value;
  784. if (distanceToBottom <= AUTO_SCROLL_REENABLE_THRESHOLD) {
  785. shouldAutoScroll.value = true;
  786. }
  787. };
  788. // 回到顶部图标拖拽状态
  789. const backTopX = ref(0);
  790. const backTopY = ref(0);
  791. const backTopDragging = ref(false);
  792. const backTopDragOffset = ref({ x: 0, y: 0 });
  793. const backTopTargetX = ref(0);
  794. const backTopTargetY = ref(0);
  795. let backTopRAF = 0;
  796. const backTopSmoothing = 0.15; // 越大越跟手,越小越顺滑
  797. const backTopEpsilon = 0.5; // 收敛阈值
  798. const raf =
  799. typeof requestAnimationFrame === "function"
  800. ? requestAnimationFrame
  801. : (fn) => setTimeout(fn, 16);
  802. const caf =
  803. typeof cancelAnimationFrame === "function"
  804. ? cancelAnimationFrame
  805. : (id) => clearTimeout(id);
  806. function stepBackTop() {
  807. const dx = backTopTargetX.value - backTopX.value;
  808. const dy = backTopTargetY.value - backTopY.value;
  809. // 插值缓动,避免每帧重排
  810. backTopX.value += dx * backTopSmoothing;
  811. backTopY.value += dy * backTopSmoothing;
  812. if (Math.abs(dx) > backTopEpsilon || Math.abs(dy) > backTopEpsilon) {
  813. backTopRAF = raf(stepBackTop);
  814. } else {
  815. backTopX.value = backTopTargetX.value;
  816. backTopY.value = backTopTargetY.value;
  817. backTopRAF = 0;
  818. }
  819. }
  820. function ensureBackTopRAF() {
  821. if (!backTopRAF) {
  822. backTopRAF = raf(stepBackTop);
  823. }
  824. }
  825. const clamp = (val, min, max) => Math.max(min, Math.min(val, max));
  826. const onBackTopTouchStart = (e) => {
  827. const t = e.touches && e.touches[0];
  828. if (!t) return;
  829. backTopDragging.value = false;
  830. backTopDragOffset.value = {
  831. x: t.pageX - backTopX.value,
  832. y: t.pageY - backTopY.value,
  833. };
  834. };
  835. const onBackTopTouchMove = (e) => {
  836. const t = e.touches && e.touches[0];
  837. if (!t) return;
  838. const sys = uni.getSystemInfoSync();
  839. const iconSize = uni.upx2px(100);
  840. const reserveBottom = uni.upx2px(260);
  841. const nx = t.pageX - backTopDragOffset.value.x;
  842. const ny = t.pageY - backTopDragOffset.value.y;
  843. const clampedX = clamp(nx, 0, sys.windowWidth - iconSize);
  844. const clampedY = clamp(ny, 0, sys.windowHeight - reserveBottom - iconSize);
  845. if (
  846. Math.abs(clampedX - backTopX.value) + Math.abs(clampedY - backTopY.value) >
  847. 3
  848. ) {
  849. backTopDragging.value = true;
  850. }
  851. backTopTargetX.value = clampedX;
  852. backTopTargetY.value = clampedY;
  853. ensureBackTopRAF();
  854. };
  855. const onBackTopTouchEnd = () => {
  856. // 结束拖拽即可
  857. };
  858. const onBackTopClick = () => {
  859. if (backTopDragging.value) return; // 拖拽时不触发点击回到顶部
  860. scrollToTop();
  861. };
  862. // 历史记录国家图像
  863. function stockImage(Market) {
  864. switch (Market) {
  865. case "usa":
  866. return "../../static/marketSituation-image/country-flag/us.png";
  867. case "can":
  868. return "../../static/marketSituation-image/country-flag/can.png";
  869. case "vi":
  870. return "../../static/marketSituation-image/country-flag/vi.png";
  871. case "th":
  872. return "../../static/marketSituation-image/country-flag/th.png";
  873. case "my":
  874. return "../../static/marketSituation-image/country-flag/my.png";
  875. case "sg":
  876. return "../../static/marketSituation-image/country-flag/sg.png";
  877. case "hk":
  878. return "../../static/marketSituation-image/country-flag/hk.png";
  879. case "cn":
  880. return "../../static/marketSituation-image/country-flag/cn.png";
  881. }
  882. }
  883. // 历史记录详情
  884. async function itemClick(item) {
  885. const res = await postHistoryDetail({
  886. recordId: item.id,
  887. parentId: item.parentId,
  888. model: 5,
  889. });
  890. if (res.code == 200) {
  891. const message = res.data.wokeFlowData.One.markdown;
  892. messages.value = [];
  893. const botMsg = {
  894. content: message,
  895. isUser: false,
  896. isTyping: false,
  897. isThinking: false,
  898. };
  899. onDrawerBackClick();
  900. messages.value.push(botMsg);
  901. }
  902. }
  903. </script>
  904. <style scoped>
  905. .deepMate-page {
  906. display: flex;
  907. flex-direction: column;
  908. position: fixed;
  909. /* 充满视口,彻底禁用页面滚动 */
  910. top: 0;
  911. left: 0;
  912. right: 0;
  913. bottom: 0;
  914. height: 100vh;
  915. overflow: hidden;
  916. /* 锁定页面滚动 */
  917. background-color: #ffffff;
  918. padding: 20rpx 0rpx;
  919. }
  920. .header {
  921. display: flex;
  922. justify-content: space-between;
  923. align-items: center;
  924. padding: 20rpx 30rpx;
  925. background-color: #ffffff;
  926. box-shadow: 0 2rpx rgba(0, 0, 0, 0.1);
  927. }
  928. .header-left,
  929. .header-right {
  930. display: flex;
  931. align-items: center;
  932. }
  933. .header-left .icon,
  934. .header-right .icon {
  935. width: 40rpx;
  936. height: 40rpx;
  937. /* margin-right: 20rpx; */
  938. }
  939. .header-center .title {
  940. position: fixed;
  941. top: 10rpx;
  942. left: 50%;
  943. transform: translateX(-50%);
  944. font-size: 36rpx;
  945. font-weight: bold;
  946. color: #333333;
  947. }
  948. .new-chat-button {
  949. background-color: #ff6600;
  950. border: none;
  951. border-radius: 8rpx;
  952. padding: 10rpx 20rpx;
  953. }
  954. .new-chat-text {
  955. color: white;
  956. font-size: 24rpx;
  957. }
  958. .main-content {
  959. background-color: #fff;
  960. flex: 1;
  961. display: flex;
  962. flex-direction: column;
  963. overflow: hidden;
  964. /* 内部滚动交给聊天容器 */
  965. padding: 20rpx;
  966. margin-top: 1rpx;
  967. margin-bottom: 280rpx;
  968. }
  969. /* 聊天顶部粘性欢迎块样式 */
  970. .chat-header {
  971. position: sticky;
  972. top: 0;
  973. /* 在页面滚动时始终贴顶 */
  974. z-index: 50;
  975. background-color: #ffffff;
  976. padding: 3rpx 20rpx;
  977. }
  978. .robot-container {
  979. display: flex;
  980. align-items: center;
  981. margin-top: 30rpx;
  982. }
  983. .robot-avatar {
  984. width: 130rpx;
  985. height: 130rpx;
  986. border-radius: 50%;
  987. margin-left: 20rpx;
  988. }
  989. .welcome-message {
  990. flex: 1;
  991. }
  992. .greeting {
  993. font-size: 32rpx;
  994. margin-left: 50rpx;
  995. top: 40rpx;
  996. font-weight: bold;
  997. color: #333333;
  998. line-height: 48rpx;
  999. }
  1000. .description {
  1001. display: block;
  1002. font-size: 24rpx;
  1003. color: #666666;
  1004. line-height: 36rpx;
  1005. margin-top: 10rpx;
  1006. margin-left: 45rpx;
  1007. }
  1008. .function-tabs {
  1009. display: block;
  1010. overflow: hidden;
  1011. margin-bottom: 30rpx;
  1012. }
  1013. .tabs-track {
  1014. display: inline-flex;
  1015. white-space: nowrap;
  1016. will-change: transform;
  1017. }
  1018. .tab-item {
  1019. padding: 5rpx 20rpx;
  1020. border-radius: 20rpx;
  1021. font-size: 20rpx;
  1022. font-weight: 700;
  1023. color: #666666;
  1024. background-color: #fffefe;
  1025. margin-right: 20rpx;
  1026. transition: all 0.3s;
  1027. }
  1028. .tab-item.active {
  1029. color: #ff6600;
  1030. background-color: #fff;
  1031. border: 1rpx solid #ff6600;
  1032. }
  1033. .recommend-card {
  1034. background: url("https://d31zlh4on95l9h.cloudfront.net/images/4da1d629a55c307c3605ca15bf15189a.svg");
  1035. background-repeat: no-repeat;
  1036. background-position: center bottom;
  1037. background-size: contain;
  1038. /* min-height: 20rpx; */
  1039. /* border-radius: 20rpx; */
  1040. padding: 40rpx;
  1041. margin-top: 20rpx;
  1042. margin-bottom: 10rpx;
  1043. /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); */
  1044. }
  1045. .welcome-section {
  1046. /* 灰色卡片(recommend-card)之后展示背景图 */
  1047. margin-top: 10rpx;
  1048. display: flex;
  1049. align-items: center;
  1050. justify-content: center;
  1051. background: url("https://d31zlh4on95l9h.cloudfront.net/images/eca84d9fb54712cb3bc6c6174773b83b.svg");
  1052. background-repeat: no-repeat;
  1053. background-position: center top;
  1054. /* 放在容器顶部,正好在灰色卡片下方 */
  1055. background-size: 80% auto;
  1056. /* 缩放以适配宽度 */
  1057. height: 460rpx;
  1058. /* 提供可视高度,让背景图可见 */
  1059. }
  1060. .card-content {
  1061. display: flex;
  1062. align-items: center;
  1063. justify-content: space-between;
  1064. margin-left: 40rpx;
  1065. }
  1066. .logo {
  1067. width: 80rpx;
  1068. height: 80rpx;
  1069. background-color: #ff0000;
  1070. border-radius: 10rpx;
  1071. display: flex;
  1072. align-items: center;
  1073. justify-content: center;
  1074. margin-right: 20rpx;
  1075. }
  1076. .card-text {
  1077. flex: 1;
  1078. margin-left: 20rpx;
  1079. }
  1080. .main-question {
  1081. font-size: 32rpx;
  1082. color: #333333;
  1083. line-height: 48rpx;
  1084. }
  1085. .stock-code {
  1086. display: block;
  1087. font-size: 24rpx;
  1088. color: #ff3b30;
  1089. background-color: #ffffff;
  1090. padding: 2rpx 15rpx;
  1091. border-radius: 12rpx;
  1092. margin-top: 8rpx;
  1093. width: fit-content;
  1094. border: 1rpx solid #ff3b30;
  1095. }
  1096. .arrow-icon {
  1097. background: url("https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg");
  1098. background-repeat: no-repeat;
  1099. left: 0.5rem;
  1100. top: 1.8rem;
  1101. background-size: 100% 100%;
  1102. width: 60rpx;
  1103. height: 60rpx;
  1104. }
  1105. .interest-section {
  1106. margin-bottom: 30rpx;
  1107. }
  1108. .section-title {
  1109. display: block;
  1110. text-align: left;
  1111. font-size: 26rpx;
  1112. color: #666666;
  1113. margin-bottom: 20rpx;
  1114. }
  1115. .topics-list {
  1116. display: flex;
  1117. flex-direction: column;
  1118. gap: 15rpx;
  1119. }
  1120. .topic-item {
  1121. display: flex;
  1122. align-items: center;
  1123. padding: 15rpx 20rpx;
  1124. background-color: #f0f0f0;
  1125. border-radius: 15rpx;
  1126. width: fit-content;
  1127. }
  1128. .tag-icon {
  1129. width: 24rpx;
  1130. height: 24rpx;
  1131. margin-right: 10rpx;
  1132. }
  1133. .topic-text {
  1134. font-size: 28rpx;
  1135. color: #333333;
  1136. flex: 1;
  1137. }
  1138. /* 聊天区域样式 */
  1139. .chat-container {
  1140. margin-top: 30rpx;
  1141. border-radius: 10rpx;
  1142. height: calc(100vh - 50rpx);
  1143. /* 缩短滚动区域,避免被输入框覆盖 */
  1144. overflow-y: auto;
  1145. -webkit-overflow-scrolling: touch;
  1146. }
  1147. .message-list {
  1148. background-color: #fff;
  1149. margin-bottom: 400rpx;
  1150. /* padding: 20rpx; */
  1151. }
  1152. .message {
  1153. display: flex;
  1154. align-items: flex-start;
  1155. margin-bottom: 30rpx;
  1156. }
  1157. .user-message {
  1158. flex-direction: row-reverse;
  1159. justify-content: flex-start;
  1160. }
  1161. .message-icon {
  1162. font-size: 24rpx;
  1163. margin: 0 10rpx;
  1164. /* padding: 10rpx; */
  1165. border-radius: 50%;
  1166. background-color: #ddd;
  1167. width: 60rpx;
  1168. height: 60rpx;
  1169. display: flex;
  1170. align-items: center;
  1171. justify-content: center;
  1172. }
  1173. .user-message .message-icon {
  1174. /* background-color: #007aff; */
  1175. border-radius: 50%;
  1176. color: #fff;
  1177. /* box-shadow: 0 0 12rpx rgba(0, 122, 255, 0.4); */
  1178. }
  1179. .bot-message .message-icon {
  1180. /* background: url("/static/images/robot (1).svg"); */
  1181. color: white;
  1182. }
  1183. .message-content {
  1184. max-width: 70%;
  1185. position: relative;
  1186. word-wrap: break-word;
  1187. word-break: break-all;
  1188. overflow-wrap: break-word;
  1189. }
  1190. .user-message .message-content {
  1191. /* background-color: #007aff; */
  1192. border: 2rpx solid #f3908f;
  1193. border-radius: 20rpx;
  1194. padding: 10rpx;
  1195. }
  1196. .bot-message .message-content {
  1197. background-color: #f0f0f0;
  1198. border-radius: 10rpx;
  1199. padding: 15rpx;
  1200. }
  1201. .message-text {
  1202. font-size: 28rpx;
  1203. line-height: 40rpx;
  1204. }
  1205. .user-message .message-text {
  1206. color: black;
  1207. }
  1208. .bot-message .message-text {
  1209. color: #333;
  1210. }
  1211. .loading-dots {
  1212. display: flex;
  1213. align-items: center;
  1214. /* padding-top: 10rpx; */
  1215. }
  1216. .dot {
  1217. width: 10rpx;
  1218. height: 10rpx;
  1219. background-color: #666;
  1220. border-radius: 50%;
  1221. margin: 0 4rpx;
  1222. animation: loading 1.4s infinite ease-in-out both;
  1223. }
  1224. .user-message .dot {
  1225. background-color: white;
  1226. }
  1227. .dot:nth-child(1) {
  1228. animation-delay: -0.32s;
  1229. }
  1230. .dot:nth-child(2) {
  1231. animation-delay: -0.16s;
  1232. }
  1233. @keyframes loading {
  1234. 0%,
  1235. 80%,
  1236. 100% {
  1237. transform: scale(0);
  1238. }
  1239. 40% {
  1240. transform: scale(1);
  1241. }
  1242. }
  1243. .input-area {
  1244. position: fixed;
  1245. margin-top: 20rpx;
  1246. bottom: 70rpx;
  1247. left: 0;
  1248. right: 0;
  1249. padding: 0 40rpx 80rpx 40rpx;
  1250. background-color: #ffffff;
  1251. }
  1252. .input-wrapper {
  1253. position: relative;
  1254. display: flex;
  1255. align-items: center;
  1256. padding: 15rpx 20rpx;
  1257. background-color: rgb(220, 31, 29);
  1258. border-radius: 100rpx;
  1259. display: flex;
  1260. align-items: center;
  1261. justify-content: center;
  1262. height: 50rpx;
  1263. }
  1264. .mic-icon {
  1265. width: 36rpx;
  1266. height: 36rpx;
  1267. margin-right: 20rpx;
  1268. }
  1269. .input-field {
  1270. flex: 1;
  1271. font-size: 28rpx;
  1272. color: #fff;
  1273. display: flex;
  1274. align-items: center;
  1275. justify-content: center;
  1276. margin-left: 60rpx;
  1277. background: none;
  1278. border: none;
  1279. outline: none;
  1280. }
  1281. .input-field::placeholder {
  1282. color: #ffffff !important;
  1283. opacity: 1;
  1284. }
  1285. /* .uni-scroll-view{
  1286. height: 92%;
  1287. } */
  1288. .send-button {
  1289. background: url("https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg");
  1290. background-repeat: no-repeat;
  1291. background-size: 100% 100%;
  1292. height: 50rpx;
  1293. width: 50rpx;
  1294. padding: 0;
  1295. border: 1rpx solid transparent;
  1296. margin-left: 20rpx;
  1297. }
  1298. .send-icon {
  1299. width: 36rpx;
  1300. height: 36rpx;
  1301. }
  1302. .disclaimer {
  1303. font-size: 15rpx;
  1304. color: #4d4c4c;
  1305. display: flex;
  1306. align-items: center;
  1307. justify-content: center;
  1308. margin-top: 15rpx;
  1309. }
  1310. .banner-panel {
  1311. position: relative;
  1312. height: 480rpx;
  1313. /* 拉长容器,灰色背景跟随变高 */
  1314. overflow: hidden;
  1315. /* 让圆角和内部层剪裁一致 */
  1316. border-radius: 15rpx;
  1317. }
  1318. .panelShow {
  1319. height: 12%;
  1320. }
  1321. .pray-banner {
  1322. position: absolute;
  1323. /* background-size: 100% 100%; */
  1324. inset: 0;
  1325. /* 顶部、底部、左、右都贴合容器 */
  1326. width: 100%;
  1327. height: 81%;
  1328. border-radius: 15rpx;
  1329. z-index: 1;
  1330. /* 在灰底之上、内容之下 */
  1331. }
  1332. .contain {
  1333. margin: 0 20rpx;
  1334. gap: 5rpx;
  1335. }
  1336. .banner-panel .robot-container,
  1337. .banner-panel .function-tabs,
  1338. .banner-panel .recommend-card {
  1339. position: relative;
  1340. z-index: 2;
  1341. }
  1342. .back-to-top {
  1343. position: fixed;
  1344. left: 0;
  1345. top: 0;
  1346. width: 100rpx;
  1347. height: 100rpx;
  1348. z-index: 1000;
  1349. }
  1350. .back-to-top:active {
  1351. transform: scale(0.96);
  1352. }
  1353. .static-footer {
  1354. position: fixed;
  1355. bottom: 0;
  1356. }
  1357. /* 搜索历史侧拉框样式 */
  1358. .drawer-overlay {
  1359. position: fixed;
  1360. left: 0;
  1361. top: 0;
  1362. right: 0;
  1363. bottom: 0;
  1364. background-color: rgba(0, 0, 0, 0.35);
  1365. z-index: 900;
  1366. }
  1367. .drawer-panel {
  1368. position: fixed;
  1369. left: 0;
  1370. right: 0;
  1371. bottom: 0;
  1372. height: 75vh;
  1373. max-height: 80vh;
  1374. width: 100%;
  1375. background: #ffffff;
  1376. box-shadow: 0 -8rpx 20rpx rgba(0, 0, 0, 0.06);
  1377. z-index: 1000;
  1378. display: flex;
  1379. flex-direction: column;
  1380. border-top-left-radius: 20rpx;
  1381. border-top-right-radius: 20rpx;
  1382. transition: transform 0.22s ease;
  1383. }
  1384. .drawer-back {
  1385. position: absolute;
  1386. left: 50%;
  1387. top: -14px;
  1388. transform: translateX(-50%);
  1389. width: 28px;
  1390. height: 48px;
  1391. border-radius: 12px;
  1392. background: #fff;
  1393. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  1394. display: flex;
  1395. align-items: center;
  1396. justify-content: center;
  1397. }
  1398. .drawer-back-icon {
  1399. font-size: 16px;
  1400. color: #8a8a8a;
  1401. }
  1402. .drawer-actions {
  1403. display: flex;
  1404. align-items: center;
  1405. gap: 40rpx;
  1406. }
  1407. .delete-all-container {
  1408. display: flex;
  1409. align-items: center;
  1410. gap: 14rpx;
  1411. }
  1412. .delete-icon {
  1413. width: 45rpx;
  1414. height: 40rpx;
  1415. }
  1416. .delete-all {
  1417. font-size: 28rpx;
  1418. }
  1419. .drawer-close {
  1420. background: url("/static/icons/close-two.svg");
  1421. width: 48rpx;
  1422. height: 48rpx;
  1423. border-radius: 24rpx;
  1424. /* background: #f5f5f5; */
  1425. /* box-shadow: 0 2px 8px rgba(0,0,0,0.08); */
  1426. display: flex;
  1427. align-items: center;
  1428. justify-content: center;
  1429. }
  1430. .drawer-close-icon {
  1431. font-size: 24rpx;
  1432. color: #8a8a8a;
  1433. }
  1434. .drawer-header {
  1435. display: flex;
  1436. align-items: center;
  1437. justify-content: space-between;
  1438. padding: 52rpx 28rpx 0rpx 28rpx;
  1439. /* border-bottom: 2rpx solid #f0f0f0; */
  1440. }
  1441. .drawer-title {
  1442. font-size: 32rpx;
  1443. font-weight: 600;
  1444. color: #333333;
  1445. }
  1446. /* .drawer-close {
  1447. font-size: 42rpx;
  1448. color: #999999;
  1449. } */
  1450. .drawer-content {
  1451. flex: 1;
  1452. min-height: 0;
  1453. /* 让 flex 子元素可在容器内收缩以启用滚动 */
  1454. height: 100%;
  1455. overscroll-behavior-y: contain;
  1456. /* 防止滚动串联到页面 */
  1457. -webkit-overflow-scrolling: touch;
  1458. /* iOS 惯性滚动 */
  1459. touch-action: pan-y;
  1460. /* 优化触控滚动,仅垂直 */
  1461. }
  1462. .drawer-inner {
  1463. padding: 20rpx 24rpx 20rpx 24rpx;
  1464. }
  1465. .history-section {
  1466. margin-bottom: 20rpx;
  1467. /* margin: 0 24rpx; */
  1468. }
  1469. .section-title {
  1470. font-size: 26rpx;
  1471. color: #888;
  1472. margin: 10rpx 6rpx 16rpx;
  1473. }
  1474. .history-item {
  1475. display: flex;
  1476. align-items: center;
  1477. padding: 19rpx 18rpx;
  1478. background-color: #f6f7f9;
  1479. border-radius: 12rpx;
  1480. margin-bottom: 12rpx;
  1481. }
  1482. .history-left {
  1483. margin-right: 12rpx;
  1484. }
  1485. .icon-stock {
  1486. width: 36rpx;
  1487. height: 36rpx;
  1488. }
  1489. .flag-circle {
  1490. width: 36rpx;
  1491. height: 36rpx;
  1492. border-radius: 50%;
  1493. background: #fff;
  1494. border: 2rpx solid #eee;
  1495. display: flex;
  1496. align-items: center;
  1497. justify-content: center;
  1498. }
  1499. .flag-emoji {
  1500. font-size: 24rpx;
  1501. }
  1502. .history-main {
  1503. flex: 1;
  1504. }
  1505. .history-query {
  1506. font-size: 28rpx;
  1507. color: #333;
  1508. }
  1509. .history-time {
  1510. font-size: 22rpx;
  1511. color: #999;
  1512. }
  1513. .history-card {
  1514. background-color: #fff;
  1515. border: 2rpx solid #f2f2f2;
  1516. border-left: 8rpx solid rgb(220, 31, 29);
  1517. border-radius: 12rpx;
  1518. padding: 18rpx 20rpx;
  1519. margin-bottom: 16rpx;
  1520. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.03);
  1521. }
  1522. .history-query {
  1523. font-size: 28rpx;
  1524. color: #333333;
  1525. font-weight: 500;
  1526. }
  1527. .history-time {
  1528. margin-top: 8rpx;
  1529. font-size: 22rpx;
  1530. color: #888888;
  1531. }
  1532. .empty-history {
  1533. padding: 40rpx;
  1534. color: #999999;
  1535. text-align: center;
  1536. }
  1537. .thinking-process {
  1538. margin: 10rpx 0;
  1539. border: 2rpx solid #e5e5e5;
  1540. border-radius: 20rpx;
  1541. background-color: #f9f9f9;
  1542. }
  1543. .thinking-header {
  1544. display: flex;
  1545. align-items: center;
  1546. padding: 20rpx 30rpx;
  1547. cursor: pointer;
  1548. background-color: #fff;
  1549. border-radius: 20rpx;
  1550. border-bottom: 2rpx solid #e5e5e5;
  1551. }
  1552. .thinking-icon {
  1553. font-size: 32rpx;
  1554. margin-right: 16rpx;
  1555. color: #d47c45;
  1556. }
  1557. .thinking-title {
  1558. font-size: 28rpx;
  1559. font-weight: 500;
  1560. color: #d47c45;
  1561. margin-right: 16rpx;
  1562. }
  1563. .thinking-count {
  1564. font-size: 24rpx;
  1565. color: #666;
  1566. margin-right: 16rpx;
  1567. }
  1568. .thinking-toggle {
  1569. font-size: 24rpx;
  1570. color: #999;
  1571. }
  1572. .thinking-content {
  1573. padding: 20rpx 30rpx;
  1574. }
  1575. .thinking-item {
  1576. display: flex;
  1577. align-items: center;
  1578. margin-bottom: 16rpx;
  1579. padding: 8rpx 0;
  1580. }
  1581. .item-status {
  1582. width: 32rpx;
  1583. height: 32rpx;
  1584. border-radius: 50%;
  1585. background-color: #f0f0f0;
  1586. display: flex;
  1587. justify-content: center;
  1588. align-items: center;
  1589. margin-right: 16rpx;
  1590. }
  1591. .checkmark {
  1592. font-size: 20rpx;
  1593. color: #ff0000;
  1594. }
  1595. .item-text {
  1596. font-size: 24rpx;
  1597. color: #333;
  1598. }
  1599. </style>