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.

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