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.

1310 lines
33 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. await new Promise((resolve) => setTimeout(resolve, 2000));
  389. // 首先进行意图识别
  390. const res = await postIntent({
  391. content:"森那美",
  392. language: "cn",
  393. marketlist: "hk,cn,usa,my,sg,vi,in,gb",
  394. token: "9ior41AF0xTIbIG2pRnnbZi0+fEeMx8pywnilrmTwo5FbqJ91WrSWOxp9MkpKiNtedtUafqvzIwpFKrwuMs",
  395. model: "1",
  396. });
  397. console.log("res"+res);
  398. // 意图识别不通过
  399. if (res.code !== 200) {
  400. return ;
  401. }
  402. // 获取意图识别结果
  403. const recordId = res.data.recordId;
  404. const parentId = res.data.parentId;
  405. const stockId = res.data.stockId;
  406. await new Promise((resolve) => setTimeout(resolve, 2000));
  407. // 获取股票信息
  408. const StockInfo = await postStock({
  409. recordId,
  410. parentId,
  411. stockId,
  412. token: "9ior41AF0xTIbIG2pRnnbZi0+fEeMx8pywnilrmTwo5FbqJ91WrSWOxp9MkpKiNtedtUafqvzIwpFKrwuMs",
  413. language:'cn'
  414. });
  415. console.log("StockInfo", StockInfo);
  416. // if (StockInfo.code !== 200) {
  417. // return ;
  418. // }
  419. const markdown = StockInfo.markdown;
  420. console.log("StockInfo", StockInfo);
  421. // 添加请求延迟
  422. // const toDataInfo = await getData();
  423. // console.log(toDataInfo);
  424. // dataInfo.value = toDataInfo.data;
  425. // console.log(dataInfo.value);
  426. messages.value[messages.value.length - 1].isThinking = false;
  427. // 滚动到底部
  428. nextTick(() => {
  429. scrollToBottom();
  430. });
  431. // 模拟流式响应
  432. let responseText = `我已经收到您的消息: "${userMessage}"。+"${markdown}" `;
  433. let index = 0;
  434. const botIndex = messages.value.length - 1;
  435. const baseDelay = 165; // 普通字符基础延迟(毫秒)
  436. const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
  437. const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
  438. const typeWriter = () => {
  439. if (index < responseText.length) {
  440. const ch = responseText.charAt(index);
  441. const current = messages.value[botIndex];
  442. // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
  443. messages.value.splice(
  444. botIndex,
  445. 1,
  446. { ...current, content: current.content + ch, isTyping: true }
  447. );
  448. index++;
  449. scrollToBottom();
  450. const delay = slowPunct.test(ch) ? 220 : midPunct.test(ch) ? 120 : baseDelay;
  451. setTimeout(typeWriter, delay);
  452. } else {
  453. const current = messages.value[botIndex];
  454. messages.value.splice(
  455. botIndex,
  456. 1,
  457. { ...current, isTyping: false }
  458. );
  459. isSending.value = false;
  460. nextTick(() => { scrollToBottom(); });
  461. }
  462. };
  463. // 启动前稍作停顿,避免过快开始
  464. setTimeout(typeWriter, 500);
  465. };
  466. // 当消息出现或变化时,测量容器并滚到底部
  467. watch(messages, (arr) => {
  468. if (arr.length > 0) {
  469. nextTick(() => {
  470. measureChatContainer();
  471. scrollToBottom();
  472. });
  473. }
  474. });
  475. // 滚动到底部(仅聊天区域滚动)
  476. const scrollToBottom = () => {
  477. if (!shouldAutoScroll.value) return;
  478. const query = uni.createSelectorQuery();
  479. query.select('#messageList').boundingClientRect();
  480. query.exec((res) => {
  481. if (res[0]) {
  482. latestContentHeight.value = res[0].height;
  483. chatScrollTop.value = res[0].height; // scroll-view 会自动夹紧到最大位置
  484. }
  485. });
  486. };
  487. const scrollToTop = () => {
  488. chatScrollTop.value = 0;
  489. };
  490. // 自动滚动控制:用户向上滚动时暂停自动滚到底部
  491. const shouldAutoScroll = ref(true);
  492. const latestContentHeight = ref(0);
  493. const lastScrollTop = ref(0);
  494. const windowHeight = uni.getSystemInfoSync().windowHeight;
  495. const AUTO_SCROLL_REENABLE_THRESHOLD = 40000; // px,接近底部时恢复自动滚动
  496. const onChatScroll = (e) => {
  497. const st = e.detail?.scrollTop || 0;
  498. const delta = st - lastScrollTop.value;
  499. lastScrollTop.value = st;
  500. if (delta < 0) {
  501. shouldAutoScroll.value = false;
  502. return;
  503. }
  504. const distanceToBottom = latestContentHeight.value - st - chatContainerHeight.value;
  505. if (distanceToBottom <= AUTO_SCROLL_REENABLE_THRESHOLD) {
  506. shouldAutoScroll.value = true;
  507. }
  508. };
  509. // 回到顶部图标拖拽状态
  510. const backTopX = ref(0);
  511. const backTopY = ref(0);
  512. const backTopDragging = ref(false);
  513. const backTopDragOffset = ref({ x: 0, y: 0 });
  514. const backTopTargetX = ref(0);
  515. const backTopTargetY = ref(0);
  516. let backTopRAF = 0;
  517. const backTopSmoothing = 0.15; // 越大越跟手,越小越顺滑
  518. const backTopEpsilon = 0.5; // 收敛阈值
  519. const raf = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : (fn) => setTimeout(fn, 16);
  520. const caf = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : (id) => clearTimeout(id);
  521. function stepBackTop() {
  522. const dx = backTopTargetX.value - backTopX.value;
  523. const dy = backTopTargetY.value - backTopY.value;
  524. // 插值缓动,避免每帧重排
  525. backTopX.value += dx * backTopSmoothing;
  526. backTopY.value += dy * backTopSmoothing;
  527. if (Math.abs(dx) > backTopEpsilon || Math.abs(dy) > backTopEpsilon) {
  528. backTopRAF = raf(stepBackTop);
  529. } else {
  530. backTopX.value = backTopTargetX.value;
  531. backTopY.value = backTopTargetY.value;
  532. backTopRAF = 0;
  533. }
  534. }
  535. function ensureBackTopRAF() {
  536. if (!backTopRAF) {
  537. backTopRAF = raf(stepBackTop);
  538. }
  539. }
  540. const clamp = (val, min, max) => Math.max(min, Math.min(val, max));
  541. const onBackTopTouchStart = (e) => {
  542. const t = e.touches && e.touches[0];
  543. if (!t) return;
  544. backTopDragging.value = false;
  545. backTopDragOffset.value = {
  546. x: t.pageX - backTopX.value,
  547. y: t.pageY - backTopY.value,
  548. };
  549. };
  550. const onBackTopTouchMove = (e) => {
  551. const t = e.touches && e.touches[0];
  552. if (!t) return;
  553. const sys = uni.getSystemInfoSync();
  554. const iconSize = uni.upx2px(100);
  555. const reserveBottom = uni.upx2px(260);
  556. const nx = t.pageX - backTopDragOffset.value.x;
  557. const ny = t.pageY - backTopDragOffset.value.y;
  558. const clampedX = clamp(nx, 0, sys.windowWidth - iconSize);
  559. const clampedY = clamp(ny, 0, sys.windowHeight - reserveBottom - iconSize);
  560. if (Math.abs(clampedX - backTopX.value) + Math.abs(clampedY - backTopY.value) > 3) {
  561. backTopDragging.value = true;
  562. }
  563. backTopTargetX.value = clampedX;
  564. backTopTargetY.value = clampedY;
  565. ensureBackTopRAF();
  566. };
  567. const onBackTopTouchEnd = () => {
  568. // 结束拖拽即可
  569. };
  570. const onBackTopClick = () => {
  571. if (backTopDragging.value) return; // 拖拽时不触发点击回到顶部
  572. scrollToTop();
  573. };
  574. </script>
  575. <style scoped>
  576. .deepMate-page {
  577. display: flex;
  578. flex-direction: column;
  579. position: fixed;
  580. /* 充满视口,彻底禁用页面滚动 */
  581. top: 0;
  582. left: 0;
  583. right: 0;
  584. bottom: 0;
  585. height: 100vh;
  586. overflow: hidden;
  587. /* 锁定页面滚动 */
  588. background-color: #ffffff;
  589. padding: 20rpx 0rpx;
  590. }
  591. .header {
  592. display: flex;
  593. justify-content: space-between;
  594. align-items: center;
  595. padding: 20rpx 30rpx;
  596. background-color: #ffffff;
  597. box-shadow: 0 2rpx rgba(0, 0, 0, 0.1);
  598. }
  599. .header-left,
  600. .header-right {
  601. display: flex;
  602. align-items: center;
  603. }
  604. .header-left .icon,
  605. .header-right .icon {
  606. width: 40rpx;
  607. height: 40rpx;
  608. /* margin-right: 20rpx; */
  609. }
  610. .header-center .title {
  611. position: fixed;
  612. top: 10rpx;
  613. left: 50%;
  614. transform: translateX(-50%);
  615. font-size: 36rpx;
  616. font-weight: bold;
  617. color: #333333;
  618. }
  619. .new-chat-button {
  620. background-color: #ff6600;
  621. border: none;
  622. border-radius: 8rpx;
  623. padding: 10rpx 20rpx;
  624. }
  625. .new-chat-text {
  626. color: white;
  627. font-size: 24rpx;
  628. }
  629. .main-content {
  630. background-color: #fff;
  631. flex: 1;
  632. display: flex;
  633. flex-direction: column;
  634. overflow: hidden;
  635. /* 内部滚动交给聊天容器 */
  636. padding: 20rpx;
  637. margin-top: 1rpx;
  638. margin-bottom: 280rpx;
  639. }
  640. /* 聊天顶部粘性欢迎块样式 */
  641. .chat-header {
  642. position: sticky;
  643. top: 0;
  644. /* 在页面滚动时始终贴顶 */
  645. z-index: 50;
  646. background-color: #ffffff;
  647. padding: 3rpx 20rpx;
  648. }
  649. .robot-container {
  650. display: flex;
  651. align-items: center;
  652. margin-top: 30rpx;
  653. }
  654. .robot-avatar {
  655. width: 130rpx;
  656. height: 130rpx;
  657. border-radius: 50%;
  658. margin-left: 20rpx;
  659. }
  660. .welcome-message {
  661. flex: 1;
  662. }
  663. .greeting {
  664. font-size: 32rpx;
  665. margin-left: 50rpx;
  666. top: 40rpx;
  667. font-weight: bold;
  668. color: #333333;
  669. line-height: 48rpx;
  670. }
  671. .description {
  672. display: block;
  673. font-size: 24rpx;
  674. color: #666666;
  675. line-height: 36rpx;
  676. margin-top: 10rpx;
  677. margin-left: 45rpx;
  678. }
  679. .function-tabs {
  680. display: block;
  681. overflow: hidden;
  682. margin-bottom: 30rpx;
  683. }
  684. .tabs-track {
  685. display: inline-flex;
  686. white-space: nowrap;
  687. will-change: transform;
  688. }
  689. .tab-item {
  690. padding: 5rpx 20rpx;
  691. border-radius: 20rpx;
  692. font-size: 20rpx;
  693. font-weight: 700;
  694. color: #666666;
  695. background-color: #fffefe;
  696. margin-right: 20rpx;
  697. transition: all 0.3s;
  698. }
  699. .tab-item.active {
  700. color: #ff6600;
  701. background-color: #fff;
  702. border: 1rpx solid #ff6600;
  703. }
  704. .recommend-card {
  705. background: url("https://d31zlh4on95l9h.cloudfront.net/images/4da1d629a55c307c3605ca15bf15189a.svg");
  706. background-repeat: no-repeat;
  707. background-position: center bottom;
  708. background-size: contain;
  709. /* min-height: 20rpx; */
  710. /* border-radius: 20rpx; */
  711. padding: 40rpx;
  712. margin-top: 20rpx;
  713. margin-bottom: 10rpx;
  714. /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); */
  715. }
  716. .card-content {
  717. display: flex;
  718. align-items: center;
  719. justify-content: space-between;
  720. margin-left: 40rpx;
  721. }
  722. .logo {
  723. width: 80rpx;
  724. height: 80rpx;
  725. background-color: #ff0000;
  726. border-radius: 10rpx;
  727. display: flex;
  728. align-items: center;
  729. justify-content: center;
  730. margin-right: 20rpx;
  731. }
  732. .card-text {
  733. flex: 1;
  734. margin-left: 20rpx;
  735. }
  736. .main-question {
  737. font-size: 32rpx;
  738. color: #333333;
  739. line-height: 48rpx;
  740. }
  741. .stock-code {
  742. display: block;
  743. font-size: 24rpx;
  744. color: #ff3b30;
  745. background-color: #ffffff;
  746. padding: 2rpx 15rpx;
  747. border-radius: 12rpx;
  748. margin-top: 8rpx;
  749. width: fit-content;
  750. border: 1rpx solid #ff3b30;
  751. }
  752. .arrow-icon {
  753. background: url("https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg");
  754. background-repeat: no-repeat;
  755. left: 0.5rem;
  756. top: 1.8rem;
  757. background-size: 100% 100%;
  758. width: 60rpx;
  759. height: 60rpx;
  760. }
  761. .interest-section {
  762. margin-bottom: 30rpx;
  763. }
  764. .section-title {
  765. display: block;
  766. text-align: center;
  767. font-size: 26rpx;
  768. color: #666666;
  769. margin-bottom: 20rpx;
  770. }
  771. .topics-list {
  772. display: flex;
  773. flex-direction: column;
  774. gap: 15rpx;
  775. }
  776. .topic-item {
  777. display: flex;
  778. align-items: center;
  779. padding: 15rpx 20rpx;
  780. background-color: #f0f0f0;
  781. border-radius: 15rpx;
  782. width: fit-content;
  783. }
  784. .tag-icon {
  785. width: 24rpx;
  786. height: 24rpx;
  787. margin-right: 10rpx;
  788. }
  789. .topic-text {
  790. font-size: 28rpx;
  791. color: #333333;
  792. flex: 1;
  793. }
  794. /* 聊天区域样式 */
  795. .chat-container {
  796. margin-top: 30rpx;
  797. border-radius: 10rpx;
  798. height: calc(100vh - 50rpx);
  799. /* 缩短滚动区域,避免被输入框覆盖 */
  800. overflow-y: auto;
  801. -webkit-overflow-scrolling: touch;
  802. }
  803. .message-list {
  804. background-color: #fff;
  805. margin-bottom: 400rpx;
  806. /* padding: 20rpx; */
  807. }
  808. .message {
  809. display: flex;
  810. align-items: flex-start;
  811. margin-bottom: 30rpx;
  812. }
  813. /* .user-message {
  814. flex-direction: row-reverse;
  815. } */
  816. .message-icon {
  817. font-size: 24rpx;
  818. margin: 0 10rpx;
  819. padding: 10rpx;
  820. border-radius: 50%;
  821. background-color: #ddd;
  822. width: 40rpx;
  823. height: 40rpx;
  824. display: flex;
  825. align-items: center;
  826. justify-content: center;
  827. }
  828. .user-message .message-icon {
  829. background-color: transparent;
  830. border-radius: 0;
  831. /* padding: 0;
  832. width: auto;
  833. height: auto; */
  834. color: #333;
  835. }
  836. .bot-message .message-icon {
  837. background: url('https://d31zlh4on95l9h.cloudfront.net/images/61fa384381c88ad80be28f41827fe0e5.svg');
  838. color: white;
  839. }
  840. .message-content {
  841. max-width: 70%;
  842. position: relative;
  843. }
  844. .user-message .message-content {
  845. background-color: #007aff;
  846. border-radius: 10rpx;
  847. padding: 15rpx;
  848. }
  849. .bot-message .message-content {
  850. background-color: #f0f0f0;
  851. border-radius: 10rpx;
  852. padding: 15rpx;
  853. }
  854. .message-text {
  855. font-size: 28rpx;
  856. line-height: 40rpx;
  857. }
  858. .user-message .message-text {
  859. color: white;
  860. }
  861. .bot-message .message-text {
  862. color: #333;
  863. }
  864. .loading-dots {
  865. display: flex;
  866. align-items: center;
  867. /* padding-top: 10rpx; */
  868. }
  869. .dot {
  870. width: 10rpx;
  871. height: 10rpx;
  872. background-color: #666;
  873. border-radius: 50%;
  874. margin: 0 4rpx;
  875. animation: loading 1.4s infinite ease-in-out both;
  876. }
  877. .user-message .dot {
  878. background-color: white;
  879. }
  880. .dot:nth-child(1) {
  881. animation-delay: -0.32s;
  882. }
  883. .dot:nth-child(2) {
  884. animation-delay: -0.16s;
  885. }
  886. @keyframes loading {
  887. 0%,
  888. 80%,
  889. 100% {
  890. transform: scale(0);
  891. }
  892. 40% {
  893. transform: scale(1);
  894. }
  895. }
  896. .input-area {
  897. position: fixed;
  898. margin-top: 20rpx;
  899. bottom: 70rpx;
  900. left: 0;
  901. right: 0;
  902. padding: 0 40rpx 80rpx 40rpx;
  903. background-color: #ffffff;
  904. }
  905. .input-wrapper {
  906. position: relative;
  907. display: flex;
  908. align-items: center;
  909. padding: 15rpx 20rpx;
  910. background-color: rgb(220, 31, 29);
  911. border-radius: 100rpx;
  912. display: flex;
  913. align-items: center;
  914. justify-content: center;
  915. height: 50rpx;
  916. }
  917. .mic-icon {
  918. width: 36rpx;
  919. height: 36rpx;
  920. margin-right: 20rpx;
  921. }
  922. .input-field {
  923. flex: 1;
  924. font-size: 28rpx;
  925. color: #fff;
  926. display: flex;
  927. align-items: center;
  928. justify-content: center;
  929. margin-left: 60rpx;
  930. background: none;
  931. border: none;
  932. outline: none;
  933. }
  934. .input-field::placeholder {
  935. color: #ffffff !important;
  936. opacity: 1;
  937. }
  938. /* .uni-scroll-view{
  939. height: 92%;
  940. } */
  941. .send-button {
  942. background: url("https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg");
  943. background-repeat: no-repeat;
  944. background-size: 100% 100%;
  945. height: 50rpx;
  946. width: 50rpx;
  947. padding: 0;
  948. border: 1rpx solid transparent;
  949. margin-left: 20rpx;
  950. }
  951. .send-icon {
  952. width: 36rpx;
  953. height: 36rpx;
  954. }
  955. .disclaimer {
  956. font-size: 15rpx;
  957. color: #4d4c4c;
  958. display: flex;
  959. align-items: center;
  960. justify-content: center;
  961. margin-top: 15rpx;
  962. }
  963. .banner-panel {
  964. position: relative;
  965. height: 480rpx;
  966. /* 拉长容器,灰色背景跟随变高 */
  967. overflow: hidden;
  968. /* 让圆角和内部层剪裁一致 */
  969. border-radius: 15rpx;
  970. }
  971. .panelShow {
  972. height: 12%;
  973. }
  974. .pray-banner {
  975. position: absolute;
  976. /* background-size: 100% 100%; */
  977. inset: 0;
  978. /* 顶部、底部、左、右都贴合容器 */
  979. width: 100%;
  980. height: 81%;
  981. border-radius: 15rpx;
  982. z-index: 1;
  983. /* 在灰底之上、内容之下 */
  984. }
  985. .contain {
  986. margin: 0 20rpx;
  987. gap: 5rpx;
  988. }
  989. .banner-panel .robot-container,
  990. .banner-panel .function-tabs,
  991. .banner-panel .recommend-card {
  992. position: relative;
  993. z-index: 2;
  994. }
  995. .back-to-top {
  996. position: fixed;
  997. left: 0;
  998. top: 0;
  999. width: 100rpx;
  1000. height: 100rpx;
  1001. z-index: 1000;
  1002. }
  1003. .back-to-top:active {
  1004. transform: scale(0.96);
  1005. }
  1006. .static-footer {
  1007. position: fixed;
  1008. bottom: 0;
  1009. }
  1010. /* 搜索历史侧拉框样式 */
  1011. .drawer-overlay {
  1012. position: fixed;
  1013. left: 0;
  1014. top: 0;
  1015. right: 0;
  1016. bottom: 0;
  1017. background-color: rgba(0, 0, 0, 0.35);
  1018. z-index: 900;
  1019. }
  1020. .drawer-panel {
  1021. position: fixed;
  1022. top: 0;
  1023. right: 0;
  1024. bottom: 0;
  1025. width: 600rpx;
  1026. max-width: 75%;
  1027. background: #ffffff;
  1028. box-shadow: -8rpx 0 20rpx rgba(0, 0, 0, 0.08);
  1029. z-index: 901;
  1030. display: flex;
  1031. flex-direction: column;
  1032. transition: transform 0.2s ease;
  1033. }
  1034. .drawer-back {
  1035. position: absolute;
  1036. left: -14px;
  1037. top: 50%;
  1038. transform: translateY(-50%);
  1039. width: 28px;
  1040. height: 28px;
  1041. border-radius: 14px;
  1042. background: #fff;
  1043. box-shadow: 0 2px 8px rgba(0,0,0,.15);
  1044. border: 1px solid #eee;
  1045. display: flex;
  1046. align-items: center;
  1047. justify-content: center;
  1048. }
  1049. .drawer-back-icon {
  1050. font-size: 16px;
  1051. color: #666;
  1052. }
  1053. .drawer-header {
  1054. display: flex;
  1055. align-items: center;
  1056. justify-content: space-between;
  1057. padding: 24rpx 28rpx;
  1058. border-bottom: 2rpx solid #f0f0f0;
  1059. }
  1060. .drawer-title {
  1061. font-size: 32rpx;
  1062. font-weight: 600;
  1063. color: #333333;
  1064. }
  1065. /* .drawer-close {
  1066. font-size: 42rpx;
  1067. color: #999999;
  1068. } */
  1069. .drawer-content {
  1070. flex: 1;
  1071. padding: 20rpx 24rpx;
  1072. }
  1073. .history-card {
  1074. background-color: #fff;
  1075. border: 2rpx solid #f2f2f2;
  1076. border-left: 8rpx solid rgb(220, 31, 29);
  1077. border-radius: 12rpx;
  1078. padding: 18rpx 20rpx;
  1079. margin-bottom: 16rpx;
  1080. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.03);
  1081. }
  1082. .history-query {
  1083. font-size: 28rpx;
  1084. color: #333333;
  1085. font-weight: 500; }
  1086. .history-time { margin-top: 8rpx; font-size: 22rpx; color: #888888; }
  1087. .empty-history { padding: 40rpx; color: #999999; text-align: center; }
  1088. .thinking-process {
  1089. margin: 10rpx 0;
  1090. border: 2rpx solid #e5e5e5;
  1091. border-radius: 20rpx;
  1092. background-color: #f9f9f9;
  1093. }
  1094. .thinking-header {
  1095. display: flex;
  1096. align-items: center;
  1097. padding: 20rpx 30rpx;
  1098. cursor: pointer;
  1099. background-color: #fff;
  1100. border-radius: 20rpx;
  1101. border-bottom: 2rpx solid #e5e5e5;
  1102. }
  1103. .thinking-icon {
  1104. font-size: 32rpx;
  1105. margin-right: 16rpx;
  1106. color: #d47c45;
  1107. }
  1108. .thinking-title {
  1109. font-size: 28rpx;
  1110. font-weight: 500;
  1111. color: #d47c45;
  1112. margin-right: 16rpx;
  1113. }
  1114. .thinking-count {
  1115. font-size: 24rpx;
  1116. color: #666;
  1117. margin-right: 16rpx;
  1118. }
  1119. .thinking-toggle {
  1120. font-size: 24rpx;
  1121. color: #999;
  1122. }
  1123. .thinking-content {
  1124. padding: 20rpx 30rpx;
  1125. }
  1126. .thinking-item {
  1127. display: flex;
  1128. align-items: center;
  1129. margin-bottom: 16rpx;
  1130. padding: 8rpx 0;
  1131. }
  1132. .item-status {
  1133. width: 32rpx;
  1134. height: 32rpx;
  1135. border-radius: 50%;
  1136. background-color: #f0f0f0;
  1137. display: flex;
  1138. justify-content: center;
  1139. align-items: center;
  1140. margin-right: 16rpx;
  1141. }
  1142. .checkmark {
  1143. font-size: 20rpx;
  1144. color: #ff0000;
  1145. }
  1146. .item-text {
  1147. font-size: 24rpx;
  1148. color: #333;
  1149. }
  1150. </style>