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.

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