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.

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