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.

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