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.

1360 lines
32 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
  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. >
  10. </image>
  11. </view>
  12. <view class="header-center">
  13. <text class="title" :style="{ paddingTop: safeAreaInsets?.top + 'px' }"
  14. >DeepMate</text
  15. >
  16. </view>
  17. <view class="header-right">
  18. <image
  19. src="https://d31zlh4on95l9h.cloudfront.net/images/d7c4e74201213a25dd9574e908233928.svg"
  20. class="icon"
  21. >
  22. </image>
  23. <image
  24. style="margin-left: 10px"
  25. src="https://d31zlh4on95l9h.cloudfront.net/images/099903c4aabf5713488b5cb60815e3f7.svg"
  26. class="icon"
  27. @click="openHistoryDrawer"
  28. ></image>
  29. <!-- 新增新会话按钮
  30. <button class="new-chat-button" @click="newChat">
  31. <text class="new-chat-text">新会话</text>
  32. </button> -->
  33. </view>
  34. </view>
  35. <!-- 主要内容区域 -->
  36. <view class="main-content">
  37. <view class="banner-panel" v-if="messages.length === 0">
  38. <image
  39. src="https://d31zlh4on95l9h.cloudfront.net/images/42e18bd7fe97d4f4f37aa70439a0990b.svg"
  40. class="pray-banner"
  41. ></image>
  42. <view class="contain">
  43. <!-- 机器人头像和欢迎语 -->
  44. <view class="robot-container" v-if="messages.length === 0">
  45. <image
  46. src="https://d31zlh4on95l9h.cloudfront.net/images/61fa384381c88ad80be28f41827fe0e5.svg"
  47. class="robot-avatar"
  48. ></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 class="recommend-card" v-if="messages.length === 0">
  64. <view class="arrow" v-if="messages.length === 0"></view>
  65. <view class="card-content">
  66. <image
  67. src="../../static/images/tesla-logo.png"
  68. class="logo"
  69. ></image>
  70. <view class="card-text">
  71. <text class="main-question">当前特斯拉该如何布局</text>
  72. <text class="stock-code">TSLA</text>
  73. </view>
  74. <image
  75. src="https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg"
  76. class="arrow-icon"
  77. @click="goBlank"
  78. ></image>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <!-- 可能感兴趣的话题 -->
  84. <!-- <view v-if="messages.length === 0" class="interest-section">
  85. <text class="section-title">- 您可能感兴趣 -</text>
  86. <view class="topics-list">
  87. <view class="topic-item" v-for="topic in hotTopics" :key="topic.id">
  88. <image :src="topic.icon" class="tag-icon"></image>
  89. <text class="topic-text" @click="sendMessageList(topic.text)">{{
  90. topic.text
  91. }}</text>
  92. </view>
  93. </view>
  94. </view> -->
  95. <!-- 聊天区域 -->
  96. <!-- 顶部粘性欢迎块始终保留在聊天上方 -->
  97. <view class="chat-header" v-if="messages.length > 0">
  98. <view class="robot-container">
  99. <image
  100. src="https://d31zlh4on95l9h.cloudfront.net/images/61fa384381c88ad80be28f41827fe0e5.svg"
  101. class="robot-avatar"
  102. ></image>
  103. <view class="welcome-message">
  104. <text class="greeting">Hi, 我是您的股市随身顾问~</text>
  105. <text class="description"
  106. >个股诊断市场情绪解读都可以找我</text
  107. >
  108. </view>
  109. </view>
  110. </view>
  111. <scroll-view
  112. class="chat-container"
  113. scroll-y="true"
  114. :scroll-top="chatScrollTop"
  115. :scroll-with-animation="!isSending"
  116. @scroll="onChatScroll"
  117. v-if="messages.length > 0"
  118. >
  119. <view class="message-list" id="messageList">
  120. <view
  121. v-for="(message, index) in messages"
  122. :key="index"
  123. :class="
  124. message.isUser ? 'message user-message' : 'message bot-message'
  125. "
  126. >
  127. <!-- 会话图标 -->
  128. <text
  129. :class="
  130. message.isUser
  131. ? 'fa-solid fa-user message-icon'
  132. : 'fa-solid fa-robot message-icon'
  133. "
  134. ></text>
  135. <!-- 会话内容 -->
  136. <view class="message-content">
  137. <!-- <text class="message-text">{{ message.content }}</text> -->
  138. <!-- loading -->
  139. <view
  140. class="loading-dots"
  141. v-if="message.isThinking || !message.isUser"
  142. >
  143. <view class="thinking-process">
  144. <view class="thinking-header">
  145. <view class="thinking-icon"></view>
  146. <view class="thinking-title">{{
  147. message.isTyping ? "正在思考" : "思考完成"
  148. }}</view>
  149. <view class="thinking-count"> </view>
  150. <view
  151. class="thinking-toggle"
  152. @click="message.isThinking = !message.isThinking"
  153. >
  154. <span v-if="message.isThinking"></span>
  155. <span v-else></span>
  156. </view>
  157. </view>
  158. <view v-show="message.isThinking" class="thinking-content">
  159. <view class="thinking-item">
  160. <view class="item-status">
  161. <span class="checkmark"></span>
  162. </view>
  163. <view class="item-text">问题分析完成</view>
  164. </view>
  165. <view class="thinking-item">
  166. <view class="item-status">
  167. <span class="checkmark"></span>
  168. </view>
  169. <view class="item-text">收集相关信息</view>
  170. </view>
  171. </view>
  172. </view>
  173. </view>
  174. <!-- 使用 rich-text 渲染 Markdown 内容 -->
  175. <rich-text
  176. v-if="!message.isUser"
  177. class="message-text"
  178. :nodes="renderMarkdown(message.content)"
  179. ></rich-text>
  180. <text v-else class="message-text">{{ message.content }}</text>
  181. </view>
  182. </view>
  183. </view>
  184. </scroll-view>
  185. </view>
  186. <!-- 输入框区域 -->
  187. <view class="input-area">
  188. <view class="input-wrapper">
  189. <input
  190. type="text"
  191. placeholder="请输入股票代码/名称,获取AI洞察"
  192. placeholder-style="color:#fff;opacity:1"
  193. class="input-field"
  194. v-model="inputMessage"
  195. @confirm="sendMessage"
  196. />
  197. <image class="send-button" @click="sendMessage" :disabled="isSending">
  198. <!-- <image
  199. src="https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg"
  200. class="send-icon"
  201. ></image> -->
  202. </image>
  203. </view>
  204. <text class="disclaimer"
  205. >以上数据由AI生成不作为最终投资建议决策需独立</text
  206. >
  207. </view>
  208. <image
  209. class="back-to-top"
  210. src="https://d31zlh4on95l9h.cloudfront.net/images/ba357635d2bb480241952bb1cabacd73.svg"
  211. :style="{
  212. transform: 'translate3d(' + backTopX + 'px,' + backTopY + 'px,0)',
  213. }"
  214. @touchstart="onBackTopTouchStart"
  215. @touchmove="onBackTopTouchMove"
  216. @touchend="onBackTopTouchEnd"
  217. @click="onBackTopClick"
  218. ></image>
  219. <!-- 搜索历史侧拉框 -->
  220. <view class="drawer-overlay" v-show="showHistoryDrawer"></view>
  221. <view
  222. class="drawer-panel"
  223. v-show="showHistoryDrawer"
  224. @click.stop
  225. :style="{ transform: 'translateX(' + drawerOffsetX + 'px)' }"
  226. >
  227. <view class="drawer-back" @click="onDrawerBackClick"
  228. ><text class="drawer-back-icon">></text></view
  229. >
  230. <view class="drawer-header">
  231. <text class="drawer-title">搜索历史</text>
  232. <!-- <text class="drawer-close" @click="closeHistoryDrawer">×</text> -->
  233. </view>
  234. <scroll-view scroll-y="true" class="drawer-content">
  235. <view v-if="searchHistory.length === 0" class="empty-history">
  236. <text>暂无搜索历史</text>
  237. </view>
  238. <view
  239. v-for="(item, idx) in searchHistory"
  240. :key="idx"
  241. class="history-card"
  242. >
  243. <text class="history-query">{{ item.query }}</text>
  244. <text class="history-time">{{ formatTime(item.time) }}</text>
  245. </view>
  246. </scroll-view>
  247. </view>
  248. <footerBar class="static-footer" :type="type"></footerBar>
  249. </view>
  250. </template>
  251. <script setup>
  252. const { safeAreaInsets } = uni.getSystemInfoSync();
  253. import { ref, computed, onMounted, onUnmounted, watch, nextTick } from "vue";
  254. import footerBar from "../../components/footerBar-cn";
  255. import marked from "marked"; // 引入 marked 库
  256. import { onPageScroll } from "@dcloudio/uni-app";
  257. import { postStock, postIntent } from "../../api/deepMate/deepMate";
  258. // 设置 marked 选项
  259. marked.setOptions({
  260. renderer: new marked.Renderer(),
  261. highlight: null, // 如果需要代码高亮,可以设置适当的函数
  262. langPrefix: "language-",
  263. pedantic: false,
  264. gfm: true,
  265. breaks: false,
  266. sanitize: false,
  267. smartLists: true,
  268. smartypants: false,
  269. xhtml: false,
  270. });
  271. // 创建一个用于渲染 Markdown 的函数
  272. const renderMarkdown = (content) => {
  273. if (!content) return "";
  274. return marked.parse(content);
  275. };
  276. const type = ref("member");
  277. const inputMessage = ref("");
  278. const showThinking = ref(true);
  279. const isSending = ref(false);
  280. const chatScrollTop = ref(0);
  281. const chatContainerHeight = ref(0);
  282. const uuid = ref("");
  283. const messages = ref([]);
  284. const showHistoryDrawer = ref(false);
  285. const drawerOffsetX = ref(0);
  286. const searchHistory = ref([]);
  287. const hotTopics = ref([
  288. {
  289. id: 1,
  290. text: "英伟达(NVDA)股票情绪温度?",
  291. icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
  292. },
  293. {
  294. id: 2,
  295. text: "博通(AVGO)明天还能涨吗?",
  296. icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
  297. },
  298. {
  299. id: 3,
  300. text: "为什么Fluence Energy(FLNC)会暴涨?",
  301. icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
  302. },
  303. {
  304. id: 4,
  305. text: "为什么Fluence Energy(FLNC)会暴涨?",
  306. icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
  307. },
  308. ]);
  309. // 初始化
  310. onMounted(() => {
  311. const sys = uni.getSystemInfoSync();
  312. const iconSize = uni.upx2px(100); // 和样式保持一致
  313. const reserveBottom = uni.upx2px(260); // 预留底部输入区域空间
  314. const initX = Math.max(0, sys.windowWidth - iconSize - uni.upx2px(30));
  315. const initY = Math.max(0, Math.floor(sys.windowHeight * 0.65) - iconSize);
  316. backTopTargetX.value = initX;
  317. backTopTargetY.value = initY;
  318. backTopX.value = initX;
  319. backTopY.value = initY;
  320. initUUID();
  321. if (messages.value.length === 0) {
  322. // nextTick(startTabsMarquee);
  323. }
  324. if (messages.value.length > 0) {
  325. nextTick(() => {
  326. measureChatContainer();
  327. scrollToBottom();
  328. });
  329. }
  330. // 载入历史
  331. const hist = uni.getStorageSync("search_history") || [];
  332. searchHistory.value = Array.isArray(hist) ? hist : [];
  333. });
  334. // 初始化 UUID
  335. const initUUID = () => {
  336. let storedUUID = uni.getStorageSync("user_uuid");
  337. if (!storedUUID) {
  338. storedUUID = generateUUID();
  339. uni.setStorageSync("user_uuid", storedUUID);
  340. }
  341. uuid.value = storedUUID;
  342. };
  343. // 生成简单UUID
  344. const generateUUID = () => {
  345. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
  346. var r = (Math.random() * 16) | 0,
  347. v = c == "x" ? r : (r & 0x3) | 0x8;
  348. return v.toString(16);
  349. });
  350. };
  351. // 计算聊天容器可视高度
  352. const measureChatContainer = () => {
  353. const q = uni.createSelectorQuery();
  354. q.select(".chat-container").boundingClientRect();
  355. q.exec((res) => {
  356. chatContainerHeight.value = res[0]?.height || 0;
  357. });
  358. };
  359. // 新会话
  360. const newChat = () => {
  361. messages.value = [];
  362. uni.removeStorageSync("user_uuid");
  363. initUUID();
  364. };
  365. // 跳转到空白页
  366. const goBlank = () => {
  367. uni.navigateTo({
  368. url: "/pages/blank/blank",
  369. });
  370. };
  371. // 历史抽屉控制
  372. const openHistoryDrawer = () => {
  373. showHistoryDrawer.value = true;
  374. };
  375. const closeHistoryDrawer = () => {
  376. showHistoryDrawer.value = false;
  377. };
  378. const onDrawerBackClick = () => {
  379. drawerOffsetX.value = 500;
  380. setTimeout(() => {
  381. closeHistoryDrawer();
  382. drawerOffsetX.value = 0;
  383. }, 180);
  384. };
  385. // 时间格式化:YYYY-MM-DD HH:mm
  386. const pad2 = (n) => (n < 10 ? "0" + n : "" + n);
  387. const formatTime = (t) => {
  388. const d = new Date(t);
  389. const y = d.getFullYear();
  390. const m = pad2(d.getMonth() + 1);
  391. const day = pad2(d.getDate());
  392. const hh = pad2(d.getHours());
  393. const mm = pad2(d.getMinutes());
  394. return `${y}-${m}-${day} ${hh}:${mm}`;
  395. };
  396. // 发送消息
  397. const sendMessage = () => {
  398. if (inputMessage.value.trim() === "" || isSending.value) return;
  399. const userMessage = {
  400. content: inputMessage.value,
  401. isUser: true,
  402. isThinking: false,
  403. isTyping: false,
  404. };
  405. messages.value.push(userMessage);
  406. inputMessage.value = "";
  407. // 记录搜索历史
  408. const entry = { query: userMessage.content, time: Date.now() };
  409. searchHistory.value.unshift(entry);
  410. uni.setStorageSync("search_history", searchHistory.value);
  411. // 发送后强制恢复并滚到底部
  412. shouldAutoScroll.value = true;
  413. nextTick(() => {
  414. scrollToBottom();
  415. });
  416. // 模拟机器人回复
  417. simulateBotResponse(userMessage.content);
  418. };
  419. // 模拟机器人回复
  420. const simulateBotResponse = async (userMessage) => {
  421. // 添加机器人加载消息
  422. const botMsg = {
  423. content: "",
  424. isUser: false,
  425. isTyping: true,
  426. isThinking: true,
  427. };
  428. messages.value.push(botMsg);
  429. await new Promise((resolve) => setTimeout(resolve, 2000));
  430. isSending.value = true;
  431. // 首先进行意图识别
  432. const res = await postIntent({
  433. content: "森那美",
  434. language: "cn",
  435. marketlist: "hk,cn,usa,my,sg,vi,in,gb",
  436. token:
  437. "9ior41AF0xTIbIG2pRnnbZi0+fEeMx8pywnilrmTwo5FbqJ91WrSWOxp9MkpKiNtedtUafqvzIwpFKrwuMs",
  438. model: "1",
  439. });
  440. console.log("res" + res);
  441. // 意图识别不通过
  442. if (res.code !== 200) {
  443. return;
  444. }
  445. // 获取意图识别结果
  446. const recordId = res.data.recordId;
  447. const parentId = res.data.parentId;
  448. const stockId = res.data.stockId;
  449. await new Promise((resolve) => setTimeout(resolve, 2000));
  450. // 获取股票信息
  451. const StockInfo = await postStock({
  452. recordId,
  453. parentId,
  454. stockId,
  455. token:
  456. "9ior41AF0xTIbIG2pRnnbZi0+fEeMx8pywnilrmTwo5FbqJ91WrSWOxp9MkpKiNtedtUafqvzIwpFKrwuMs",
  457. language: "cn",
  458. });
  459. console.log("StockInfo", StockInfo);
  460. // if (StockInfo.code !== 200) {
  461. // return ;
  462. // }
  463. const markdown = StockInfo.markdown;
  464. console.log("StockInfo", StockInfo);
  465. // 添加请求延迟
  466. // const toDataInfo = await getData();
  467. // console.log(toDataInfo);
  468. // dataInfo.value = toDataInfo.data;
  469. // console.log(dataInfo.value);
  470. messages.value[messages.value.length - 1].isThinking = false;
  471. // 滚动到底部
  472. nextTick(() => {
  473. scrollToBottom();
  474. });
  475. // 模拟流式响应
  476. let responseText = `我已经收到您的消息: "${userMessage}"。+"${markdown}" `;
  477. let index = 0;
  478. const botIndex = messages.value.length - 1;
  479. const baseDelay = 5; // 普通字符基础延迟(毫秒)
  480. const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
  481. const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
  482. const typeWriter = () => {
  483. if (index < responseText.length) {
  484. const ch = responseText.charAt(index);
  485. const current = messages.value[botIndex];
  486. // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
  487. messages.value.splice(botIndex, 1, {
  488. ...current,
  489. content: current.content + ch,
  490. isTyping: true,
  491. });
  492. index++;
  493. scrollToBottom();
  494. const delay = slowPunct.test(ch)
  495. ? 220
  496. : midPunct.test(ch)
  497. ? 120
  498. : baseDelay;
  499. setTimeout(typeWriter, delay);
  500. } else {
  501. const current = messages.value[botIndex];
  502. messages.value.splice(botIndex, 1, { ...current, isTyping: false });
  503. isSending.value = false;
  504. nextTick(() => {
  505. scrollToBottom();
  506. });
  507. }
  508. };
  509. // 启动前稍作停顿,避免过快开始
  510. setTimeout(typeWriter, 500);
  511. console.log("messages", messages);
  512. };
  513. // 当消息出现或变化时,测量容器并滚到底部
  514. watch(messages, (arr) => {
  515. if (arr.length > 0) {
  516. nextTick(() => {
  517. measureChatContainer();
  518. scrollToBottom();
  519. });
  520. }
  521. });
  522. // 滚动到底部(仅聊天区域滚动)
  523. const scrollToBottom = () => {
  524. if (!shouldAutoScroll.value) return;
  525. const query = uni.createSelectorQuery();
  526. query.select("#messageList").boundingClientRect();
  527. query.exec((res) => {
  528. if (res[0]) {
  529. latestContentHeight.value = res[0].height;
  530. chatScrollTop.value = res[0].height; // scroll-view 会自动夹紧到最大位置
  531. }
  532. });
  533. };
  534. const scrollToTop = () => {
  535. chatScrollTop.value = 0;
  536. };
  537. // 自动滚动控制:用户向上滚动时暂停自动滚到底部
  538. const shouldAutoScroll = ref(true);
  539. const latestContentHeight = ref(0);
  540. const lastScrollTop = ref(0);
  541. const windowHeight = uni.getSystemInfoSync().windowHeight;
  542. const AUTO_SCROLL_REENABLE_THRESHOLD = 40000; // px,接近底部时恢复自动滚动
  543. const onChatScroll = (e) => {
  544. const st = e.detail?.scrollTop || 0;
  545. const delta = st - lastScrollTop.value;
  546. lastScrollTop.value = st;
  547. if (delta < 0) {
  548. shouldAutoScroll.value = false;
  549. return;
  550. }
  551. const distanceToBottom =
  552. latestContentHeight.value - st - chatContainerHeight.value;
  553. if (distanceToBottom <= AUTO_SCROLL_REENABLE_THRESHOLD) {
  554. shouldAutoScroll.value = true;
  555. }
  556. };
  557. // 回到顶部图标拖拽状态
  558. const backTopX = ref(0);
  559. const backTopY = ref(0);
  560. const backTopDragging = ref(false);
  561. const backTopDragOffset = ref({ x: 0, y: 0 });
  562. const backTopTargetX = ref(0);
  563. const backTopTargetY = ref(0);
  564. let backTopRAF = 0;
  565. const backTopSmoothing = 0.15; // 越大越跟手,越小越顺滑
  566. const backTopEpsilon = 0.5; // 收敛阈值
  567. const raf =
  568. typeof requestAnimationFrame === "function"
  569. ? requestAnimationFrame
  570. : (fn) => setTimeout(fn, 16);
  571. const caf =
  572. typeof cancelAnimationFrame === "function"
  573. ? cancelAnimationFrame
  574. : (id) => clearTimeout(id);
  575. function stepBackTop() {
  576. const dx = backTopTargetX.value - backTopX.value;
  577. const dy = backTopTargetY.value - backTopY.value;
  578. // 插值缓动,避免每帧重排
  579. backTopX.value += dx * backTopSmoothing;
  580. backTopY.value += dy * backTopSmoothing;
  581. if (Math.abs(dx) > backTopEpsilon || Math.abs(dy) > backTopEpsilon) {
  582. backTopRAF = raf(stepBackTop);
  583. } else {
  584. backTopX.value = backTopTargetX.value;
  585. backTopY.value = backTopTargetY.value;
  586. backTopRAF = 0;
  587. }
  588. }
  589. function ensureBackTopRAF() {
  590. if (!backTopRAF) {
  591. backTopRAF = raf(stepBackTop);
  592. }
  593. }
  594. const clamp = (val, min, max) => Math.max(min, Math.min(val, max));
  595. const onBackTopTouchStart = (e) => {
  596. const t = e.touches && e.touches[0];
  597. if (!t) return;
  598. backTopDragging.value = false;
  599. backTopDragOffset.value = {
  600. x: t.pageX - backTopX.value,
  601. y: t.pageY - backTopY.value,
  602. };
  603. };
  604. const onBackTopTouchMove = (e) => {
  605. const t = e.touches && e.touches[0];
  606. if (!t) return;
  607. const sys = uni.getSystemInfoSync();
  608. const iconSize = uni.upx2px(100);
  609. const reserveBottom = uni.upx2px(260);
  610. const nx = t.pageX - backTopDragOffset.value.x;
  611. const ny = t.pageY - backTopDragOffset.value.y;
  612. const clampedX = clamp(nx, 0, sys.windowWidth - iconSize);
  613. const clampedY = clamp(ny, 0, sys.windowHeight - reserveBottom - iconSize);
  614. if (
  615. Math.abs(clampedX - backTopX.value) + Math.abs(clampedY - backTopY.value) >
  616. 3
  617. ) {
  618. backTopDragging.value = true;
  619. }
  620. backTopTargetX.value = clampedX;
  621. backTopTargetY.value = clampedY;
  622. ensureBackTopRAF();
  623. };
  624. const onBackTopTouchEnd = () => {
  625. // 结束拖拽即可
  626. };
  627. const onBackTopClick = () => {
  628. if (backTopDragging.value) return; // 拖拽时不触发点击回到顶部
  629. scrollToTop();
  630. };
  631. </script>
  632. <style scoped>
  633. .deepMate-page {
  634. display: flex;
  635. flex-direction: column;
  636. position: fixed;
  637. /* 充满视口,彻底禁用页面滚动 */
  638. top: 0;
  639. left: 0;
  640. right: 0;
  641. bottom: 0;
  642. height: 100vh;
  643. overflow: hidden;
  644. /* 锁定页面滚动 */
  645. background-color: #ffffff;
  646. padding: 20rpx 0rpx;
  647. }
  648. .header {
  649. display: flex;
  650. justify-content: space-between;
  651. align-items: center;
  652. padding: 20rpx 30rpx;
  653. background-color: #ffffff;
  654. box-shadow: 0 2rpx rgba(0, 0, 0, 0.1);
  655. }
  656. .header-left,
  657. .header-right {
  658. display: flex;
  659. align-items: center;
  660. }
  661. .header-left .icon,
  662. .header-right .icon {
  663. width: 40rpx;
  664. height: 40rpx;
  665. /* margin-right: 20rpx; */
  666. }
  667. .header-center .title {
  668. position: fixed;
  669. top: 10rpx;
  670. left: 50%;
  671. transform: translateX(-50%);
  672. font-size: 36rpx;
  673. font-weight: bold;
  674. color: #333333;
  675. }
  676. .new-chat-button {
  677. background-color: #ff6600;
  678. border: none;
  679. border-radius: 8rpx;
  680. padding: 10rpx 20rpx;
  681. }
  682. .new-chat-text {
  683. color: white;
  684. font-size: 24rpx;
  685. }
  686. .main-content {
  687. background-color: #fff;
  688. flex: 1;
  689. display: flex;
  690. flex-direction: column;
  691. overflow: hidden;
  692. /* 内部滚动交给聊天容器 */
  693. padding: 20rpx;
  694. margin-top: 1rpx;
  695. margin-bottom: 280rpx;
  696. }
  697. /* 聊天顶部粘性欢迎块样式 */
  698. .chat-header {
  699. position: sticky;
  700. top: 0;
  701. /* 在页面滚动时始终贴顶 */
  702. z-index: 50;
  703. background-color: #ffffff;
  704. padding: 3rpx 20rpx;
  705. }
  706. .robot-container {
  707. display: flex;
  708. align-items: center;
  709. margin-top: 30rpx;
  710. }
  711. .robot-avatar {
  712. width: 130rpx;
  713. height: 130rpx;
  714. border-radius: 50%;
  715. margin-left: 20rpx;
  716. }
  717. .welcome-message {
  718. flex: 1;
  719. }
  720. .greeting {
  721. font-size: 32rpx;
  722. margin-left: 50rpx;
  723. top: 40rpx;
  724. font-weight: bold;
  725. color: #333333;
  726. line-height: 48rpx;
  727. }
  728. .description {
  729. display: block;
  730. font-size: 24rpx;
  731. color: #666666;
  732. line-height: 36rpx;
  733. margin-top: 10rpx;
  734. margin-left: 45rpx;
  735. }
  736. .function-tabs {
  737. display: block;
  738. overflow: hidden;
  739. margin-bottom: 30rpx;
  740. }
  741. .tabs-track {
  742. display: inline-flex;
  743. white-space: nowrap;
  744. will-change: transform;
  745. }
  746. .tab-item {
  747. padding: 5rpx 20rpx;
  748. border-radius: 20rpx;
  749. font-size: 20rpx;
  750. font-weight: 700;
  751. color: #666666;
  752. background-color: #fffefe;
  753. margin-right: 20rpx;
  754. transition: all 0.3s;
  755. }
  756. .tab-item.active {
  757. color: #ff6600;
  758. background-color: #fff;
  759. border: 1rpx solid #ff6600;
  760. }
  761. .recommend-card {
  762. background: url("https://d31zlh4on95l9h.cloudfront.net/images/4da1d629a55c307c3605ca15bf15189a.svg");
  763. background-repeat: no-repeat;
  764. background-position: center bottom;
  765. background-size: contain;
  766. /* min-height: 20rpx; */
  767. /* border-radius: 20rpx; */
  768. padding: 40rpx;
  769. margin-top: 20rpx;
  770. margin-bottom: 10rpx;
  771. /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); */
  772. }
  773. .card-content {
  774. display: flex;
  775. align-items: center;
  776. justify-content: space-between;
  777. margin-left: 40rpx;
  778. }
  779. .logo {
  780. width: 80rpx;
  781. height: 80rpx;
  782. background-color: #ff0000;
  783. border-radius: 10rpx;
  784. display: flex;
  785. align-items: center;
  786. justify-content: center;
  787. margin-right: 20rpx;
  788. }
  789. .card-text {
  790. flex: 1;
  791. margin-left: 20rpx;
  792. }
  793. .main-question {
  794. font-size: 32rpx;
  795. color: #333333;
  796. line-height: 48rpx;
  797. }
  798. .stock-code {
  799. display: block;
  800. font-size: 24rpx;
  801. color: #ff3b30;
  802. background-color: #ffffff;
  803. padding: 2rpx 15rpx;
  804. border-radius: 12rpx;
  805. margin-top: 8rpx;
  806. width: fit-content;
  807. border: 1rpx solid #ff3b30;
  808. }
  809. .arrow-icon {
  810. background: url("https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg");
  811. background-repeat: no-repeat;
  812. left: 0.5rem;
  813. top: 1.8rem;
  814. background-size: 100% 100%;
  815. width: 60rpx;
  816. height: 60rpx;
  817. }
  818. .interest-section {
  819. margin-bottom: 30rpx;
  820. }
  821. .section-title {
  822. display: block;
  823. text-align: center;
  824. font-size: 26rpx;
  825. color: #666666;
  826. margin-bottom: 20rpx;
  827. }
  828. .topics-list {
  829. display: flex;
  830. flex-direction: column;
  831. gap: 15rpx;
  832. }
  833. .topic-item {
  834. display: flex;
  835. align-items: center;
  836. padding: 15rpx 20rpx;
  837. background-color: #f0f0f0;
  838. border-radius: 15rpx;
  839. width: fit-content;
  840. }
  841. .tag-icon {
  842. width: 24rpx;
  843. height: 24rpx;
  844. margin-right: 10rpx;
  845. }
  846. .topic-text {
  847. font-size: 28rpx;
  848. color: #333333;
  849. flex: 1;
  850. }
  851. /* 聊天区域样式 */
  852. .chat-container {
  853. margin-top: 30rpx;
  854. border-radius: 10rpx;
  855. height: calc(100vh - 50rpx);
  856. /* 缩短滚动区域,避免被输入框覆盖 */
  857. overflow-y: auto;
  858. -webkit-overflow-scrolling: touch;
  859. }
  860. .message-list {
  861. background-color: #fff;
  862. margin-bottom: 400rpx;
  863. /* padding: 20rpx; */
  864. }
  865. .message {
  866. display: flex;
  867. align-items: flex-start;
  868. margin-bottom: 30rpx;
  869. }
  870. /* .user-message {
  871. flex-direction: row-reverse;
  872. } */
  873. .message-icon {
  874. font-size: 24rpx;
  875. margin: 0 10rpx;
  876. padding: 10rpx;
  877. border-radius: 50%;
  878. background-color: #ddd;
  879. width: 40rpx;
  880. height: 40rpx;
  881. display: flex;
  882. align-items: center;
  883. justify-content: center;
  884. }
  885. .user-message .message-icon {
  886. background-color: transparent;
  887. border-radius: 40rpx;
  888. /* padding: 0;
  889. width: auto;
  890. height: auto; */
  891. color: #333;
  892. }
  893. .bot-message .message-icon {
  894. background: url("https://d31zlh4on95l9h.cloudfront.net/images/61fa384381c88ad80be28f41827fe0e5.svg");
  895. color: white;
  896. }
  897. .message-content {
  898. max-width: 70%;
  899. position: relative;
  900. }
  901. .user-message .message-content {
  902. background-color: #007aff;
  903. border-radius: 10rpx;
  904. padding: 15rpx;
  905. }
  906. .bot-message .message-content {
  907. background-color: #f0f0f0;
  908. border-radius: 10rpx;
  909. padding: 15rpx;
  910. }
  911. .message-text {
  912. font-size: 28rpx;
  913. line-height: 40rpx;
  914. }
  915. .user-message .message-text {
  916. color: white;
  917. }
  918. .bot-message .message-text {
  919. color: #333;
  920. }
  921. .loading-dots {
  922. display: flex;
  923. align-items: center;
  924. /* padding-top: 10rpx; */
  925. }
  926. .dot {
  927. width: 10rpx;
  928. height: 10rpx;
  929. background-color: #666;
  930. border-radius: 50%;
  931. margin: 0 4rpx;
  932. animation: loading 1.4s infinite ease-in-out both;
  933. }
  934. .user-message .dot {
  935. background-color: white;
  936. }
  937. .dot:nth-child(1) {
  938. animation-delay: -0.32s;
  939. }
  940. .dot:nth-child(2) {
  941. animation-delay: -0.16s;
  942. }
  943. @keyframes loading {
  944. 0%,
  945. 80%,
  946. 100% {
  947. transform: scale(0);
  948. }
  949. 40% {
  950. transform: scale(1);
  951. }
  952. }
  953. .input-area {
  954. position: fixed;
  955. margin-top: 20rpx;
  956. bottom: 70rpx;
  957. left: 0;
  958. right: 0;
  959. padding: 0 40rpx 80rpx 40rpx;
  960. background-color: #ffffff;
  961. }
  962. .input-wrapper {
  963. position: relative;
  964. display: flex;
  965. align-items: center;
  966. padding: 15rpx 20rpx;
  967. background-color: rgb(220, 31, 29);
  968. border-radius: 100rpx;
  969. display: flex;
  970. align-items: center;
  971. justify-content: center;
  972. height: 50rpx;
  973. }
  974. .mic-icon {
  975. width: 36rpx;
  976. height: 36rpx;
  977. margin-right: 20rpx;
  978. }
  979. .input-field {
  980. flex: 1;
  981. font-size: 28rpx;
  982. color: #fff;
  983. display: flex;
  984. align-items: center;
  985. justify-content: center;
  986. margin-left: 60rpx;
  987. background: none;
  988. border: none;
  989. outline: none;
  990. }
  991. .input-field::placeholder {
  992. color: #ffffff !important;
  993. opacity: 1;
  994. }
  995. /* .uni-scroll-view{
  996. height: 92%;
  997. } */
  998. .send-button {
  999. background: url("https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg");
  1000. background-repeat: no-repeat;
  1001. background-size: 100% 100%;
  1002. height: 50rpx;
  1003. width: 50rpx;
  1004. padding: 0;
  1005. border: 1rpx solid transparent;
  1006. margin-left: 20rpx;
  1007. }
  1008. .send-icon {
  1009. width: 36rpx;
  1010. height: 36rpx;
  1011. }
  1012. .disclaimer {
  1013. font-size: 15rpx;
  1014. color: #4d4c4c;
  1015. display: flex;
  1016. align-items: center;
  1017. justify-content: center;
  1018. margin-top: 15rpx;
  1019. }
  1020. .banner-panel {
  1021. position: relative;
  1022. height: 480rpx;
  1023. /* 拉长容器,灰色背景跟随变高 */
  1024. overflow: hidden;
  1025. /* 让圆角和内部层剪裁一致 */
  1026. border-radius: 15rpx;
  1027. }
  1028. .panelShow {
  1029. height: 12%;
  1030. }
  1031. .pray-banner {
  1032. position: absolute;
  1033. /* background-size: 100% 100%; */
  1034. inset: 0;
  1035. /* 顶部、底部、左、右都贴合容器 */
  1036. width: 100%;
  1037. height: 81%;
  1038. border-radius: 15rpx;
  1039. z-index: 1;
  1040. /* 在灰底之上、内容之下 */
  1041. }
  1042. .contain {
  1043. margin: 0 20rpx;
  1044. gap: 5rpx;
  1045. }
  1046. .banner-panel .robot-container,
  1047. .banner-panel .function-tabs,
  1048. .banner-panel .recommend-card {
  1049. position: relative;
  1050. z-index: 2;
  1051. }
  1052. .back-to-top {
  1053. position: fixed;
  1054. left: 0;
  1055. top: 0;
  1056. width: 100rpx;
  1057. height: 100rpx;
  1058. z-index: 1000;
  1059. }
  1060. .back-to-top:active {
  1061. transform: scale(0.96);
  1062. }
  1063. .static-footer {
  1064. position: fixed;
  1065. bottom: 0;
  1066. }
  1067. /* 搜索历史侧拉框样式 */
  1068. .drawer-overlay {
  1069. position: fixed;
  1070. left: 0;
  1071. top: 0;
  1072. right: 0;
  1073. bottom: 0;
  1074. background-color: rgba(0, 0, 0, 0.35);
  1075. z-index: 900;
  1076. }
  1077. .drawer-panel {
  1078. position: fixed;
  1079. top: 0;
  1080. right: 0;
  1081. bottom: 0;
  1082. width: 600rpx;
  1083. max-width: 75%;
  1084. background: #ffffff;
  1085. box-shadow: -8rpx 0 20rpx rgba(0, 0, 0, 0.08);
  1086. z-index: 901;
  1087. display: flex;
  1088. flex-direction: column;
  1089. transition: transform 0.2s ease;
  1090. }
  1091. .drawer-back {
  1092. position: absolute;
  1093. left: -14px;
  1094. top: 50%;
  1095. transform: translateY(-50%);
  1096. width: 28px;
  1097. height: 28px;
  1098. border-radius: 14px;
  1099. background: #fff;
  1100. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  1101. border: 1px solid #eee;
  1102. display: flex;
  1103. align-items: center;
  1104. justify-content: center;
  1105. }
  1106. .drawer-back-icon {
  1107. font-size: 16px;
  1108. color: #666;
  1109. }
  1110. .drawer-header {
  1111. display: flex;
  1112. align-items: center;
  1113. justify-content: space-between;
  1114. padding: 24rpx 28rpx;
  1115. border-bottom: 2rpx solid #f0f0f0;
  1116. }
  1117. .drawer-title {
  1118. font-size: 32rpx;
  1119. font-weight: 600;
  1120. color: #333333;
  1121. }
  1122. /* .drawer-close {
  1123. font-size: 42rpx;
  1124. color: #999999;
  1125. } */
  1126. .drawer-content {
  1127. flex: 1;
  1128. padding: 20rpx 24rpx;
  1129. }
  1130. .history-card {
  1131. background-color: #fff;
  1132. border: 2rpx solid #f2f2f2;
  1133. border-left: 8rpx solid rgb(220, 31, 29);
  1134. border-radius: 12rpx;
  1135. padding: 18rpx 20rpx;
  1136. margin-bottom: 16rpx;
  1137. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.03);
  1138. }
  1139. .history-query {
  1140. font-size: 28rpx;
  1141. color: #333333;
  1142. font-weight: 500;
  1143. }
  1144. .history-time {
  1145. margin-top: 8rpx;
  1146. font-size: 22rpx;
  1147. color: #888888;
  1148. }
  1149. .empty-history {
  1150. padding: 40rpx;
  1151. color: #999999;
  1152. text-align: center;
  1153. }
  1154. .thinking-process {
  1155. margin: 10rpx 0;
  1156. border: 2rpx solid #e5e5e5;
  1157. border-radius: 20rpx;
  1158. background-color: #f9f9f9;
  1159. }
  1160. .thinking-header {
  1161. display: flex;
  1162. align-items: center;
  1163. padding: 20rpx 30rpx;
  1164. cursor: pointer;
  1165. background-color: #fff;
  1166. border-radius: 20rpx;
  1167. border-bottom: 2rpx solid #e5e5e5;
  1168. }
  1169. .thinking-icon {
  1170. font-size: 32rpx;
  1171. margin-right: 16rpx;
  1172. color: #d47c45;
  1173. }
  1174. .thinking-title {
  1175. font-size: 28rpx;
  1176. font-weight: 500;
  1177. color: #d47c45;
  1178. margin-right: 16rpx;
  1179. }
  1180. .thinking-count {
  1181. font-size: 24rpx;
  1182. color: #666;
  1183. margin-right: 16rpx;
  1184. }
  1185. .thinking-toggle {
  1186. font-size: 24rpx;
  1187. color: #999;
  1188. }
  1189. .thinking-content {
  1190. padding: 20rpx 30rpx;
  1191. }
  1192. .thinking-item {
  1193. display: flex;
  1194. align-items: center;
  1195. margin-bottom: 16rpx;
  1196. padding: 8rpx 0;
  1197. }
  1198. .item-status {
  1199. width: 32rpx;
  1200. height: 32rpx;
  1201. border-radius: 50%;
  1202. background-color: #f0f0f0;
  1203. display: flex;
  1204. justify-content: center;
  1205. align-items: center;
  1206. margin-right: 16rpx;
  1207. }
  1208. .checkmark {
  1209. font-size: 20rpx;
  1210. color: #ff0000;
  1211. }
  1212. .item-text {
  1213. font-size: 24rpx;
  1214. color: #333;
  1215. }
  1216. </style>