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.

1221 lines
30 KiB

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