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.

1888 lines
45 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
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
4 weeks ago
  1. <template>
  2. <view class="deepMate-page">
  3. <!-- 顶部导航栏 -->
  4. <view class="header" :style="{ paddingTop: safeAreaInsets?.top + 'px' }">
  5. <view class="header-left">
  6. <image
  7. src="https://d31zlh4on95l9h.cloudfront.net/images/f91e09b5987802185e7679055dafd272.svg"
  8. class="icon"
  9. @click="goToCustomerService"
  10. >
  11. </image>
  12. </view>
  13. <view class="header-center">
  14. <text class="title" :style="{ paddingTop: safeAreaInsets?.top + 'px' }"
  15. >DeepMate</text
  16. >
  17. </view>
  18. <view class="header-right">
  19. <image
  20. src="https://d31zlh4on95l9h.cloudfront.net/images/d7c4e74201213a25dd9574e908233928.svg"
  21. class="icon"
  22. @click="goToNotice"
  23. @tap="goToNotice"
  24. >
  25. </image>
  26. <image
  27. style="margin-left: 10px"
  28. src="https://d31zlh4on95l9h.cloudfront.net/images/099903c4aabf5713488b5cb60815e3f7.svg"
  29. class="icon"
  30. @click="openHistoryDrawer"
  31. ></image>
  32. <!-- 新增新会话按钮
  33. <button class="new-chat-button" @click="newChat">
  34. <text class="new-chat-text">新会话</text>
  35. </button> -->
  36. </view>
  37. </view>
  38. <!-- 主要内容区域 -->
  39. <view class="main-content">
  40. <view class="banner-panel" v-if="messages.length === 0">
  41. <image
  42. src="https://d31zlh4on95l9h.cloudfront.net/images/42e18bd7fe97d4f4f37aa70439a0990b.svg"
  43. class="pray-banner"
  44. ></image>
  45. <view class="contain">
  46. <!-- 机器人头像和欢迎语 -->
  47. <view class="robot-container" v-if="messages.length === 0">
  48. <image src="/static/icons/robot.svg" class="robot-avatar"></image>
  49. <view class="welcome-message">
  50. <text class="greeting">Hi, 我是您的股市随身顾问~</text>
  51. <text class="description"
  52. >个股诊断市场情绪解读都可以找我</text
  53. >
  54. </view>
  55. </view>
  56. <!-- 功能标签栏 -->
  57. <!-- <view class="function-tabs" v-if="messages.length === 0">
  58. <view ref="tabsTrack" class="tabs-track" :style="{ transform: 'translate3d(-' + marqueeOffset + 'px,0,0)' }">
  59. <view class="tab-item" v-for="(tab, idx) in marqueeList" :key="idx">{{ tab }}</view>
  60. </view>
  61. </view> -->
  62. <!-- 特斯拉推荐卡片 -->
  63. <view
  64. class="recommend-card"
  65. v-if="messages.length === 0"
  66. @click="goinstitutionalTrendsBriefing"
  67. >
  68. <view class="arrow" v-if="messages.length === 0"></view>
  69. <view class="card-content">
  70. <image
  71. src="../../static/images/tesla-logo.png"
  72. class="logo"
  73. ></image>
  74. <view class="card-text">
  75. <text class="main-question">当前特斯拉该如何布局</text>
  76. <text class="stock-code">TSLA</text>
  77. </view>
  78. <image
  79. src="https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg"
  80. class="arrow-icon"
  81. @click="goinstitutionalTrendsBriefing"
  82. ></image>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- 可能感兴趣的话题 -->
  88. <!-- <view v-if="messages.length === 0" class="interest-section">
  89. <text class="section-title">- 您可能感兴趣 -</text>
  90. <view class="topics-list">
  91. <view class="topic-item" v-for="topic in hotTopics" :key="topic.id">
  92. <image :src="topic.icon" class="tag-icon"></image>
  93. <text class="topic-text" @click="sendMessageList(topic.text)">{{
  94. topic.text
  95. }}</text>
  96. </view>
  97. </view>
  98. </view> -->
  99. <view v-if="messages.length === 0" class="welcome-section"> </view>
  100. <!-- 聊天区域 -->
  101. <!-- 顶部粘性欢迎块始终保留在聊天上方 -->
  102. <view class="chat-header" v-if="messages.length > 0">
  103. <view class="robot-container">
  104. <image src="/static/icons/robot.svg" class="robot-avatar"></image>
  105. <view class="welcome-message">
  106. <text class="greeting">Hi, 我是您的股市随身顾问~</text>
  107. </view>
  108. </view>
  109. </view>
  110. <scroll-view
  111. class="chat-container"
  112. scroll-y="true"
  113. :scroll-top="chatScrollTop"
  114. :scroll-with-animation="!isSending"
  115. @scroll="onChatScroll"
  116. v-if="messages.length > 0"
  117. >
  118. <view class="message-list" id="messageList">
  119. <view
  120. v-for="(message, index) in messages"
  121. :key="index"
  122. :class="
  123. message.isUser ? 'message user-message' : 'message bot-message'
  124. "
  125. >
  126. <!-- 会话图标 -->
  127. <!-- <text
  128. :class="
  129. message.isUser
  130. ? 'fa-solid fa-user message-icon'
  131. : 'fa-solid fa-robot message-icon'
  132. "
  133. ></text> -->
  134. <image
  135. v-if="message.isUser"
  136. class="message-icon"
  137. :src="userAvatar"
  138. mode="scaleToFill"
  139. /><image
  140. v-else
  141. class="message-icon"
  142. src="/static/icons/robot.svg"
  143. mode="scaleToFill"
  144. />
  145. <!-- 会话内容 -->
  146. <view class="message-content">
  147. <!-- <text class="message-text">{{ message.content }}</text> -->
  148. <!-- loading -->
  149. <view
  150. class="loading-dots"
  151. v-if="message.isThinking || !message.isUser"
  152. >
  153. <view class="thinking-process">
  154. <view class="thinking-header">
  155. <view class="thinking-icon"></view>
  156. <view class="thinking-title">{{
  157. message.isTyping ? "正在思考" : "思考完成"
  158. }}</view>
  159. <view class="thinking-count"> </view>
  160. <view
  161. class="thinking-toggle"
  162. @click="message.isThinking = !message.isThinking"
  163. >
  164. <span v-if="message.isThinking"></span>
  165. <span v-else></span>
  166. </view>
  167. </view>
  168. <view v-show="message.isThinking" class="thinking-content">
  169. <view class="thinking-item">
  170. <view class="item-status">
  171. <span v-if="message.isFirst" class="checkmark"></span>
  172. </view>
  173. <view class="item-text">问题分析完成</view>
  174. </view>
  175. <view class="thinking-item">
  176. <view class="item-status">
  177. <span v-if="message.isSecond" class="checkmark"></span>
  178. </view>
  179. <view class="item-text">收集相关信息</view>
  180. </view>
  181. </view>
  182. </view>
  183. </view>
  184. <!-- 使用 rich-text 渲染 Markdown 内容 -->
  185. <rich-text
  186. v-if="!message.isUser"
  187. class="message-text"
  188. :nodes="renderMarkdown(message.content)"
  189. ></rich-text>
  190. <text v-else class="message-text">{{ message.content }}</text>
  191. </view>
  192. </view>
  193. </view>
  194. </scroll-view>
  195. </view>
  196. <!-- 输入框区域 -->
  197. <view class="input-area">
  198. <view class="input-wrapper">
  199. <input
  200. type="text"
  201. placeholder="请输入股票代码/名称,获取AI洞察"
  202. placeholder-style="color:#fff;opacity:1"
  203. class="input-field"
  204. v-model="inputMessage"
  205. @confirm="sendMessage"
  206. />
  207. <image class="send-button" @click="sendMessage" :disabled="isSending">
  208. <!-- <image
  209. src="https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg"
  210. class="send-icon"
  211. ></image> -->
  212. </image>
  213. </view>
  214. <text class="disclaimer"
  215. >以上数据由AI生成不作为最终投资建议决策需独立</text
  216. >
  217. </view>
  218. <image
  219. class="back-to-top"
  220. src="https://d31zlh4on95l9h.cloudfront.net/images/ba357635d2bb480241952bb1cabacd73.svg"
  221. :style="{
  222. transform: 'translate3d(' + backTopX + 'px,' + backTopY + 'px,0)',
  223. }"
  224. @touchstart="onBackTopTouchStart"
  225. @touchmove="onBackTopTouchMove"
  226. @touchend="onBackTopTouchEnd"
  227. @click="onBackTopClick"
  228. v-if="messages.length > 0"
  229. ></image>
  230. <!-- 搜索历史侧拉框 -->
  231. <view class="drawer-overlay" v-show="showHistoryDrawer"></view>
  232. <view
  233. class="drawer-panel"
  234. v-show="showHistoryDrawer"
  235. @click.stop
  236. @touchmove.stop.prevent
  237. :style="{ transform: 'translateY(' + drawerOffsetY + 'px)' }"
  238. >
  239. <view class="drawer-header">
  240. <text class="drawer-title">历史对话</text>
  241. <view class="drawer-actions">
  242. <view class="delete-all-container">
  243. <image
  244. class="delete-icon"
  245. src="/static/icons/Group_48095481.svg"
  246. @click="clearAllHistory"
  247. ></image>
  248. <text class="delete-all" @click="clearAllHistory">删除全部</text>
  249. </view>
  250. <view class="drawer-close" @click="onDrawerBackClick"
  251. ><text class="drawer-close-icon"></text
  252. ></view>
  253. </view>
  254. </view>
  255. <scroll-view scroll-y="true" class="drawer-content">
  256. <view class="drawer-inner">
  257. <view v-if="groupedHistory.length === 0" class="empty-history">
  258. <text>暂无历史记录</text>
  259. </view>
  260. <view
  261. v-for="(section, sIdx) in groupedHistory"
  262. :key="sIdx"
  263. class="history-section"
  264. >
  265. <text class="section-title">{{ section.title }}</text>
  266. <view
  267. v-for="(item, idx) in section.items"
  268. :key="idx"
  269. class="history-item"
  270. >
  271. <view class="history-left">
  272. <view class="flag-circle"
  273. ><image
  274. class="icon-stock"
  275. :src="stockImage(item.stockMarket)"
  276. mode="scaleToFill"
  277. /></view>
  278. </view>
  279. <view class="history-main" @click="itemClick(item)">
  280. <text class="history-query">{{ item.stockName }}</text>
  281. <text class="history-query">{{ item.stockCode }}</text>
  282. </view>
  283. <text class="history-time">{{
  284. formatTimeForHistory(item.createdTime)
  285. }}</text>
  286. </view>
  287. </view>
  288. </view>
  289. </scroll-view>
  290. </view>
  291. <footerBar class="static-footer" :type="type"></footerBar>
  292. </view>
  293. <LoginPrompt ref="loginPrompt"></LoginPrompt>
  294. </template>
  295. <script setup>
  296. const { safeAreaInsets } = uni.getSystemInfoSync();
  297. import { ref, computed, onMounted, onUnmounted, watch, nextTick } from "vue";
  298. import footerBar from "../../components/footerBar";
  299. import marked from "marked"; // 引入 marked 库
  300. import { onPageScroll, onLoad } from "@dcloudio/uni-app";
  301. import {
  302. postStock,
  303. postIntent,
  304. postHistory,
  305. postHistoryDetail,
  306. postDeleteHistory,
  307. } from "../../api/deepMate/deepMate";
  308. import { useUserStore } from "../../stores/modules/userInfo";
  309. const renderer = new marked.Renderer();
  310. renderer.heading = function (text, level) {
  311. return `<p>${text}</p>`;
  312. };
  313. // 设置 marked 选项
  314. marked.setOptions({
  315. renderer: new marked.Renderer(),
  316. highlight: null, // 如果需要代码高亮,可以设置适当的函数
  317. langPrefix: "language-",
  318. pedantic: false,
  319. gfm: true,
  320. breaks: false,
  321. sanitize: false,
  322. smartLists: true,
  323. smartypants: false,
  324. xhtml: false,
  325. });
  326. // 创建一个用于渲染 Markdown 的函数
  327. const renderMarkdown = (content) => {
  328. if (!content) return "";
  329. return marked.parse(content);
  330. };
  331. const type = ref("deepMate");
  332. const inputMessage = ref("");
  333. const showThinking = ref(true);
  334. const isSending = ref(false);
  335. const chatScrollTop = ref(0);
  336. const chatContainerHeight = ref(0);
  337. const uuid = ref("");
  338. const messages = ref([]);
  339. const showHistoryDrawer = ref(false);
  340. const drawerOffsetY = ref(0);
  341. const searchHistory = ref([]);
  342. const historyList = ref([]);
  343. // 处理页面加载时的路由参数
  344. onLoad((options) => {
  345. console.log("deepMate页面接收到参数:", options);
  346. // 如果有query参数,自动发送消息
  347. if (options.query) {
  348. const decodedQuery = decodeURIComponent(options.query);
  349. console.log("解码后的查询内容:", decodedQuery);
  350. // 设置输入框内容并自动发送
  351. inputMessage.value = decodedQuery;
  352. // 延迟一下再发送,确保页面已经完全加载
  353. setTimeout(() => {
  354. sendMessage();
  355. }, 500);
  356. }
  357. });
  358. // 初始化
  359. onMounted(() => {
  360. const sys = uni.getSystemInfoSync();
  361. const iconSize = uni.upx2px(100); // 和样式保持一致
  362. const reserveBottom = uni.upx2px(260); // 预留底部输入区域空间
  363. const initX = Math.max(0, sys.windowWidth - iconSize - uni.upx2px(30));
  364. const initY = Math.max(0, Math.floor(sys.windowHeight * 0.65) - iconSize);
  365. backTopTargetX.value = initX;
  366. backTopTargetY.value = initY;
  367. backTopX.value = initX;
  368. backTopY.value = initY;
  369. initUUID();
  370. if (messages.value.length === 0) {
  371. // nextTick(startTabsMarquee);
  372. }
  373. if (messages.value.length > 0) {
  374. nextTick(() => {
  375. measureChatContainer();
  376. scrollToBottom();
  377. });
  378. }
  379. // 载入历史
  380. // const hist = uni.getStorageSync("search_history") || [];
  381. // searchHistory.value = Array.isArray(hist) ? hist : [];
  382. // 缓存今天日期(YYYY-MM-DD)
  383. const todayStr = new Date().toISOString().slice(0, 10);
  384. uni.setStorageSync("today_date", todayStr);
  385. });
  386. // 初始化 UUID
  387. const initUUID = () => {
  388. let storedUUID = uni.getStorageSync("user_uuid");
  389. if (!storedUUID) {
  390. storedUUID = generateUUID();
  391. uni.setStorageSync("user_uuid", storedUUID);
  392. }
  393. uuid.value = storedUUID;
  394. };
  395. // 生成简单UUID
  396. const generateUUID = () => {
  397. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
  398. var r = (Math.random() * 16) | 0,
  399. v = c == "x" ? r : (r & 0x3) | 0x8;
  400. return v.toString(16);
  401. });
  402. };
  403. // 计算聊天容器可视高度
  404. const measureChatContainer = () => {
  405. const q = uni.createSelectorQuery();
  406. q.select(".chat-container").boundingClientRect();
  407. q.exec((res) => {
  408. chatContainerHeight.value = res[0]?.height || 0;
  409. });
  410. };
  411. // 新会话
  412. const newChat = () => {
  413. messages.value = [];
  414. uni.removeStorageSync("user_uuid");
  415. initUUID();
  416. };
  417. // 跳转到空白页
  418. const goinstitutionalTrendsBriefing = () => {
  419. uni.navigateTo({
  420. url: "/pages/blank/institutionalTrendsBriefing",
  421. });
  422. };
  423. // 跳转到客户服务平台首页
  424. const goToCustomerService = () => {
  425. uni.navigateTo({
  426. url: "/pages/customerServicePlatform/csPlatformIndex",
  427. });
  428. };
  429. // 跳转到通知页
  430. function goToNotice() {
  431. try {
  432. console.log("goToNotice: navigating to /pages/blank/notice");
  433. uni.navigateTo({ url: "/pages/blank/notice" });
  434. } catch (e) {
  435. console.error("goToNotice navigateTo failed, fallback to redirect:", e);
  436. uni.redirectTo({ url: "/pages/blank/notice" });
  437. }
  438. }
  439. // 历史记录
  440. const openHistoryDrawer = async () => {
  441. const res = await postHistory({
  442. model: 5,
  443. });
  444. if (res.code === 200) {
  445. historyList.value = res.data;
  446. }
  447. console.log("historyList.value", historyList.value);
  448. const hideDistance = uni.upx2px(900);
  449. drawerOffsetY.value = hideDistance;
  450. showHistoryDrawer.value = true;
  451. setTimeout(() => {
  452. drawerOffsetY.value = 0;
  453. }, 10);
  454. };
  455. const closeHistoryDrawer = () => {
  456. showHistoryDrawer.value = false;
  457. };
  458. const onDrawerBackClick = () => {
  459. const hideDistance = uni.upx2px(900);
  460. drawerOffsetY.value = hideDistance;
  461. setTimeout(() => {
  462. closeHistoryDrawer();
  463. drawerOffsetY.value = 0;
  464. }, 180);
  465. };
  466. // 时间格式化:YYYY-MM-DD HH:mm
  467. const pad2 = (n) => (n < 10 ? "0" + n : "" + n);
  468. const formatTime = (t) => {
  469. const d = new Date(t);
  470. const y = d.getFullYear();
  471. const m = pad2(d.getMonth() + 1);
  472. const day = pad2(d.getDate());
  473. const hh = pad2(d.getHours());
  474. const mm = pad2(d.getMinutes());
  475. return `${y}-${m}-${day} ${hh}:${mm}`;
  476. };
  477. // 为历史记录格式化时间:YYYY-MM-DD HH:mm
  478. const formatTimeForHistory = (timeString) => {
  479. // 假设 timeString 格式为 "YYYY-MM-DD HH:mm:ss"
  480. const parts = timeString.split(" ");
  481. if (parts.length >= 2) {
  482. const datePart = parts[0];
  483. const timePart = parts[1];
  484. const timeParts = timePart.split(":");
  485. if (timeParts.length >= 2) {
  486. return `${datePart} ${timeParts[0]}:${timeParts[1]}`;
  487. }
  488. }
  489. return timeString;
  490. };
  491. const userStore = useUserStore();
  492. // 用户头像
  493. const userAvatar = computed(() => {
  494. return userStore.userInfo.avatar;
  495. });
  496. // 历史分组(今天/昨天/近一周/按月)
  497. const groupedHistory = computed(() => {
  498. const sections = [];
  499. // 从缓存获取今天日期,如果没有则使用当前日期
  500. const now = new Date();
  501. const startOfDay = (d) =>
  502. new Date(d.getFullYear(), d.getMonth(), d.getDate());
  503. const isSameDay = (a, b) =>
  504. startOfDay(a).getTime() === startOfDay(b).getTime();
  505. const isYesterday = (d) => {
  506. const y = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
  507. return isSameDay(d, y);
  508. };
  509. const isToday = (d) => isSameDay(d, now);
  510. const withinLast7Days = (d) => {
  511. const seven = new Date(
  512. now.getFullYear(),
  513. now.getMonth(),
  514. now.getDate() - 7
  515. );
  516. return d >= seven && !isToday(d) && !isYesterday(d);
  517. };
  518. const monthLabel = (d) => `${d.getMonth() + 1}`;
  519. const today = [];
  520. const yesterday = [];
  521. const last7 = [];
  522. const byMonth = new Map();
  523. // 使用 historyList.value 替代 searchHistory.value
  524. historyList.value.forEach((item) => {
  525. // 根据你的数据结构,使用 createdTime 字段
  526. const dt = new Date(item.createdTime);
  527. if (isToday(dt)) {
  528. today.push(item);
  529. } else if (isYesterday(dt)) {
  530. yesterday.push(item);
  531. } else if (withinLast7Days(dt)) {
  532. last7.push(item);
  533. } else {
  534. const year = dt.getFullYear();
  535. const month = dt.getMonth() + 1;
  536. const key = `${year}-${month}`;
  537. if (!byMonth.has(key))
  538. byMonth.set(key, {
  539. title: `${year}${month}`,
  540. year,
  541. month,
  542. items: [],
  543. });
  544. byMonth.get(key).items.push(item);
  545. }
  546. });
  547. if (today.length) sections.push({ title: "今天", items: today });
  548. if (yesterday.length) sections.push({ title: "昨天", items: yesterday });
  549. if (last7.length) sections.push({ title: "近一周", items: last7 });
  550. const monthSections = Array.from(byMonth.values()).sort((a, b) => {
  551. if (a.year !== b.year) return b.year - a.year;
  552. return b.month - a.month; // 月份倒序,如 10月 在 9月 之前
  553. });
  554. sections.push(...monthSections);
  555. return sections;
  556. });
  557. const clearAllHistory = () => {
  558. uni.showModal({
  559. title: "确认删除",
  560. content: "确定要删除全部历史记录吗?该操作不可撤销。",
  561. confirmText: "删除",
  562. cancelText: "取消",
  563. success: (res) => {
  564. if (res.confirm) {
  565. deleteHistory();
  566. }
  567. },
  568. });
  569. };
  570. // 删除历史记录
  571. async function deleteHistory(historyId) {
  572. // 当前历史面板依赖 historyList,而非 searchHistory
  573. // 同步清空本地旧缓存(如果曾使用)
  574. const res = await postDeleteHistory({
  575. model: 5,
  576. });
  577. if (res.code === 200) {
  578. historyList.value = [];
  579. // uni.setStorageSync("search_history", []);
  580. uni.showToast({ title: "历史已清空", icon: "none" });
  581. }
  582. else {
  583. uni.showToast({ title: res.message, icon: "none" });
  584. }
  585. }
  586. // 发送消息
  587. const sendMessage = () => {
  588. if (inputMessage.value.trim() === "" || isSending.value) return;
  589. const userMessage = {
  590. content: inputMessage.value,
  591. isUser: true,
  592. isThinking: false,
  593. isTyping: false,
  594. };
  595. messages.value.push(userMessage);
  596. inputMessage.value = "";
  597. // 记录搜索历史
  598. // const entry = { query: userMessage.content, time: Date.now() };
  599. // searchHistory.value.unshift(entry);
  600. // uni.setStorageSync("search_history", searchHistory.value);
  601. // 发送后强制恢复并滚到底部
  602. shouldAutoScroll.value = true;
  603. nextTick(() => {
  604. scrollToBottom();
  605. });
  606. // 模拟机器人回复
  607. simulateBotResponse(userMessage.content);
  608. };
  609. // 模拟机器人回复
  610. const simulateBotResponse = async (userMessage) => {
  611. // 添加机器人加载消息
  612. const botMsg = {
  613. content: "",
  614. isUser: false,
  615. isTyping: true,
  616. isThinking: true,
  617. isFirst: false,
  618. isSecond: false,
  619. };
  620. messages.value.push(botMsg);
  621. isSending.value = true;
  622. // 首先进行意图识别
  623. let res;
  624. try {
  625. res = await postIntent({
  626. content: userMessage,
  627. language: "cn",
  628. marketList: "hk,cn,usa,my,sg,vi,in,gb",
  629. token:
  630. "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
  631. });
  632. } catch (error) {
  633. isSending.value = false;
  634. } finally {
  635. }
  636. console.log("res" + res);
  637. // 意图识别不通过
  638. if (res.code !== 200) {
  639. console.log("未通过意图识别");
  640. messages.value[messages.value.length - 1].isThinking = false;
  641. // 更新机器人的消息内容
  642. const errorMessage = res.message || "请求失败,请稍后重试";
  643. let responseText = `我已经收到您的消息: "${userMessage}"。"${errorMessage}"`;
  644. // 开始打字机效果显示错误信息
  645. let index = 0;
  646. const botIndex = messages.value.length - 1;
  647. const typeWriter = () => {
  648. if (index < responseText.length) {
  649. let ch = responseText.charAt(index);
  650. let charsToAdd = ch;
  651. let newIndex = index + 1;
  652. // 检查是否遇到HTML标签开始
  653. if (ch === "<") {
  654. // 寻找标签结束位置
  655. let tagEndIndex = responseText.indexOf(">", index);
  656. if (tagEndIndex !== -1) {
  657. // 完整获取标签内容
  658. charsToAdd = responseText.substring(index, tagEndIndex + 1);
  659. newIndex = tagEndIndex + 1;
  660. }
  661. }
  662. const current = messages.value[botIndex];
  663. // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
  664. messages.value.splice(botIndex, 1, {
  665. ...current,
  666. content: current.content + charsToAdd,
  667. isTyping: true,
  668. });
  669. index = newIndex;
  670. scrollToBottom();
  671. // 字符间延迟,模拟打字效果
  672. const baseDelay = 5; // 普通字符基础延迟(毫秒)
  673. const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
  674. const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
  675. // 如果是标签,使用更短的延迟或者立即显示
  676. let delay;
  677. if (charsToAdd.startsWith("<")) {
  678. delay = 1; // 标签快速显示
  679. } else {
  680. delay = slowPunct.test(ch)
  681. ? 220
  682. : midPunct.test(ch)
  683. ? 120
  684. : baseDelay;
  685. }
  686. setTimeout(typeWriter, delay);
  687. } else {
  688. // 打字完成,更新状态
  689. const current = messages.value[botIndex];
  690. messages.value.splice(botIndex, 1, { ...current, isTyping: false });
  691. isSending.value = false;
  692. nextTick(() => {
  693. scrollToBottom();
  694. });
  695. }
  696. };
  697. // 启动打字机效果
  698. setTimeout(typeWriter, 300);
  699. return;
  700. }
  701. console.log("通过意图识别");
  702. messages.value[messages.value.length - 1].isFirst = true;
  703. // 获取意图识别结果
  704. const recordId = res.data.recordId;
  705. const parentId = res.data.parentId;
  706. const stockId = res.data.stockId;
  707. // 获取股票信息
  708. const StockInfo = await postStock({
  709. language: "cn",
  710. token:
  711. "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
  712. recordId: Number(recordId),
  713. parentId: Number(parentId),
  714. stockId: Number(stockId),
  715. });
  716. console.log("postStock payload", {
  717. language: "cn",
  718. token: "790750702588f1ea79f24dc56ccd5d8a",
  719. recordId,
  720. parentId,
  721. stockId,
  722. });
  723. console.log("StockInfo", StockInfo);
  724. const cftl = StockInfo?.cftl || {};
  725. const date = StockInfo?.date || "";
  726. if (StockInfo && StockInfo.code !== 200) {
  727. const errMsg = `postStock失败(${StockInfo.code}): ${
  728. StockInfo.message || "未知错误"
  729. }`;
  730. console.warn(errMsg, StockInfo);
  731. messages.value[messages.value.length - 1].isThinking = false;
  732. messages.value[messages.value.length - 1].isTyping = false;
  733. messages.value[messages.value.length - 1].content = errMsg;
  734. isSending.value = false;
  735. return;
  736. }
  737. const markdown = StockInfo?.data?.markdown || "抱歉,未找到该股票";
  738. console.log("StockInfo", StockInfo);
  739. // 添加请求延迟
  740. // const toDataInfo = await getData();
  741. // console.log(toDataInfo);
  742. // dataInfo.value = toDataInfo.data;
  743. // console.log(dataInfo.value);
  744. messages.value[messages.value.length - 1].isSecond = true;
  745. setTimeout(() => {
  746. messages.value[messages.value.length - 1].isThinking = false;
  747. }, 500);
  748. // 滚动到底部
  749. nextTick(() => {
  750. scrollToBottom();
  751. });
  752. // 模拟流式响应
  753. let responseText = `我已经收到您的消息: "${userMessage}"。"${markdown}" `;
  754. let index = 0;
  755. const botIndex = messages.value.length - 1;
  756. const baseDelay = 5; // 普通字符基础延迟(毫秒)
  757. const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿
  758. const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿
  759. const typeWriter = () => {
  760. if (index < responseText.length) {
  761. let ch = responseText.charAt(index);
  762. let charsToAdd = ch;
  763. let newIndex = index + 1;
  764. let delay = baseDelay;
  765. // 检查是否遇到HTML标签开始
  766. if (ch === "<") {
  767. // 寻找标签结束位置
  768. let tagEndIndex = responseText.indexOf(">", index);
  769. if (tagEndIndex !== -1) {
  770. // 完整获取标签内容
  771. charsToAdd = responseText.substring(index, tagEndIndex + 1);
  772. newIndex = tagEndIndex + 1;
  773. delay = 1; // 标签快速显示
  774. }
  775. }
  776. const current = messages.value[botIndex];
  777. // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应
  778. messages.value.splice(botIndex, 1, {
  779. ...current,
  780. content: current.content + charsToAdd,
  781. isTyping: true,
  782. });
  783. index = newIndex;
  784. scrollToBottom();
  785. setTimeout(typeWriter, delay);
  786. } else {
  787. const current = messages.value[botIndex];
  788. messages.value.splice(botIndex, 1, { ...current, isTyping: false });
  789. isSending.value = false;
  790. nextTick(() => {
  791. scrollToBottom();
  792. });
  793. }
  794. };
  795. // 启动前稍作停顿,避免过快开始
  796. setTimeout(typeWriter, 500);
  797. console.log("messages", messages);
  798. };
  799. // 当消息出现或变化时,测量容器并滚到底部
  800. watch(messages, (arr) => {
  801. if (arr.length > 0) {
  802. nextTick(() => {
  803. measureChatContainer();
  804. scrollToBottom();
  805. });
  806. }
  807. });
  808. // 滚动到底部(仅聊天区域滚动)
  809. const scrollToBottom = () => {
  810. if (!shouldAutoScroll.value) return;
  811. const query = uni.createSelectorQuery();
  812. query.select("#messageList").boundingClientRect();
  813. query.exec((res) => {
  814. if (res[0]) {
  815. latestContentHeight.value = res[0].height;
  816. chatScrollTop.value = res[0].height; // scroll-view 会自动夹紧到最大位置
  817. }
  818. });
  819. };
  820. const scrollToTop = () => {
  821. // 聊天区存在:控制 scroll-view 回到顶部
  822. if (messages.value.length > 0) {
  823. chatScrollTop.value = 0;
  824. return;
  825. }
  826. // 未发起对话:页面级滚动回到顶部
  827. try {
  828. uni.pageScrollTo({ scrollTop: 0, duration: 200 });
  829. } catch (e) {
  830. // 兜底,无需处理
  831. }
  832. };
  833. // 自动滚动控制:用户向上滚动时暂停自动滚到底部
  834. const shouldAutoScroll = ref(true);
  835. const latestContentHeight = ref(0);
  836. const lastScrollTop = ref(0);
  837. const windowHeight = uni.getSystemInfoSync().windowHeight;
  838. const AUTO_SCROLL_REENABLE_THRESHOLD = 40000; // px,接近底部时恢复自动滚动
  839. const onChatScroll = (e) => {
  840. const st = e.detail?.scrollTop || 0;
  841. const delta = st - lastScrollTop.value;
  842. lastScrollTop.value = st;
  843. // 同步当前滚动位置,确保点击回顶能产生数值变化
  844. chatScrollTop.value = st;
  845. if (delta < 0) {
  846. shouldAutoScroll.value = false;
  847. return;
  848. }
  849. const distanceToBottom =
  850. latestContentHeight.value - st - chatContainerHeight.value;
  851. if (distanceToBottom <= AUTO_SCROLL_REENABLE_THRESHOLD) {
  852. shouldAutoScroll.value = true;
  853. }
  854. };
  855. // 回到顶部图标拖拽状态
  856. const backTopX = ref(0);
  857. const backTopY = ref(0);
  858. const backTopDragging = ref(false);
  859. const backTopDragOffset = ref({ x: 0, y: 0 });
  860. const backTopTargetX = ref(0);
  861. const backTopTargetY = ref(0);
  862. let backTopRAF = 0;
  863. const backTopSmoothing = 0.15; // 越大越跟手,越小越顺滑
  864. const backTopEpsilon = 0.5; // 收敛阈值
  865. const raf =
  866. typeof requestAnimationFrame === "function"
  867. ? requestAnimationFrame
  868. : (fn) => setTimeout(fn, 16);
  869. const caf =
  870. typeof cancelAnimationFrame === "function"
  871. ? cancelAnimationFrame
  872. : (id) => clearTimeout(id);
  873. function stepBackTop() {
  874. const dx = backTopTargetX.value - backTopX.value;
  875. const dy = backTopTargetY.value - backTopY.value;
  876. // 插值缓动,避免每帧重排
  877. backTopX.value += dx * backTopSmoothing;
  878. backTopY.value += dy * backTopSmoothing;
  879. if (Math.abs(dx) > backTopEpsilon || Math.abs(dy) > backTopEpsilon) {
  880. backTopRAF = raf(stepBackTop);
  881. } else {
  882. backTopX.value = backTopTargetX.value;
  883. backTopY.value = backTopTargetY.value;
  884. backTopRAF = 0;
  885. }
  886. }
  887. function ensureBackTopRAF() {
  888. if (!backTopRAF) {
  889. backTopRAF = raf(stepBackTop);
  890. }
  891. }
  892. const clamp = (val, min, max) => Math.max(min, Math.min(val, max));
  893. const onBackTopTouchStart = (e) => {
  894. const t = e.touches && e.touches[0];
  895. if (!t) return;
  896. backTopDragging.value = false;
  897. backTopDragOffset.value = {
  898. x: t.pageX - backTopX.value,
  899. y: t.pageY - backTopY.value,
  900. };
  901. };
  902. const onBackTopTouchMove = (e) => {
  903. const t = e.touches && e.touches[0];
  904. if (!t) return;
  905. const sys = uni.getSystemInfoSync();
  906. const iconSize = uni.upx2px(100);
  907. const reserveBottom = uni.upx2px(260);
  908. const nx = t.pageX - backTopDragOffset.value.x;
  909. const ny = t.pageY - backTopDragOffset.value.y;
  910. const clampedX = clamp(nx, 0, sys.windowWidth - iconSize);
  911. const clampedY = clamp(ny, 0, sys.windowHeight - reserveBottom - iconSize);
  912. if (
  913. Math.abs(clampedX - backTopX.value) + Math.abs(clampedY - backTopY.value) >
  914. 3
  915. ) {
  916. backTopDragging.value = true;
  917. }
  918. backTopTargetX.value = clampedX;
  919. backTopTargetY.value = clampedY;
  920. ensureBackTopRAF();
  921. };
  922. const onBackTopTouchEnd = () => {
  923. // 结束拖拽即可
  924. };
  925. const onBackTopClick = () => {
  926. if (backTopDragging.value) return; // 拖拽时不触发点击回到顶部
  927. scrollToTop();
  928. };
  929. // 历史记录国家图像
  930. function stockImage(Market) {
  931. switch (Market) {
  932. case "usa":
  933. return "../../static/marketSituation-image/country-flag/us.png";
  934. case "can":
  935. return "../../static/marketSituation-image/country-flag/can.png";
  936. case "vi":
  937. return "../../static/marketSituation-image/country-flag/vi.png";
  938. case "th":
  939. return "../../static/marketSituation-image/country-flag/th.png";
  940. case "my":
  941. return "../../static/marketSituation-image/country-flag/my.png";
  942. case "sg":
  943. return "../../static/marketSituation-image/country-flag/sg.png";
  944. case "hk":
  945. return "../../static/marketSituation-image/country-flag/hk.png";
  946. case "cn":
  947. return "../../static/marketSituation-image/country-flag/cn.png";
  948. }
  949. }
  950. // 历史记录详情
  951. async function itemClick(item) {
  952. const res = await postHistoryDetail({
  953. recordId: item.id,
  954. parentId: item.parentId,
  955. model: 5,
  956. });
  957. if (res.code == 200) {
  958. const message = res.data.wokeFlowData.One.markdown;
  959. messages.value = [];
  960. const botMsg = {
  961. content: message,
  962. isUser: false,
  963. isTyping: false,
  964. isThinking: false,
  965. };
  966. onDrawerBackClick();
  967. messages.value.push(botMsg);
  968. }
  969. }
  970. </script>
  971. <style scoped>
  972. .deepMate-page {
  973. display: flex;
  974. flex-direction: column;
  975. position: fixed;
  976. /* 充满视口,彻底禁用页面滚动 */
  977. top: 0;
  978. left: 0;
  979. right: 0;
  980. bottom: 0;
  981. height: 100vh;
  982. overflow: hidden;
  983. /* 锁定页面滚动 */
  984. background-color: #ffffff;
  985. padding: 20rpx 0rpx;
  986. }
  987. .header {
  988. display: flex;
  989. justify-content: space-between;
  990. align-items: center;
  991. padding: 20rpx 30rpx;
  992. background-color: #ffffff;
  993. box-shadow: 0 2rpx rgba(0, 0, 0, 0.1);
  994. }
  995. .header-left,
  996. .header-right {
  997. display: flex;
  998. align-items: center;
  999. }
  1000. .header-left .icon,
  1001. .header-right .icon {
  1002. width: 40rpx;
  1003. height: 40rpx;
  1004. /* margin-right: 20rpx; */
  1005. }
  1006. .header-center .title {
  1007. position: fixed;
  1008. top: 10rpx;
  1009. left: 50%;
  1010. transform: translateX(-50%);
  1011. font-size: 36rpx;
  1012. font-weight: bold;
  1013. color: #333333;
  1014. }
  1015. .new-chat-button {
  1016. background-color: #ff6600;
  1017. border: none;
  1018. border-radius: 8rpx;
  1019. padding: 10rpx 20rpx;
  1020. }
  1021. .new-chat-text {
  1022. color: white;
  1023. font-size: 24rpx;
  1024. }
  1025. .main-content {
  1026. background-color: #fff;
  1027. flex: 1;
  1028. display: flex;
  1029. flex-direction: column;
  1030. overflow: hidden;
  1031. /* 内部滚动交给聊天容器 */
  1032. padding: 20rpx;
  1033. margin-top: 1rpx;
  1034. margin-bottom: 280rpx;
  1035. }
  1036. /* 聊天顶部粘性欢迎块样式 */
  1037. .chat-header {
  1038. position: sticky;
  1039. top: 0;
  1040. /* 在页面滚动时始终贴顶 */
  1041. z-index: 50;
  1042. background-color: #ffffff;
  1043. padding: 3rpx 20rpx;
  1044. }
  1045. .robot-container {
  1046. display: flex;
  1047. align-items: center;
  1048. margin-top: 30rpx;
  1049. }
  1050. .robot-avatar {
  1051. width: 130rpx;
  1052. height: 130rpx;
  1053. border-radius: 50%;
  1054. margin-left: 20rpx;
  1055. }
  1056. .welcome-message {
  1057. flex: 1;
  1058. }
  1059. .greeting {
  1060. font-size: 32rpx;
  1061. margin-left: 50rpx;
  1062. top: 40rpx;
  1063. font-weight: bold;
  1064. color: #333333;
  1065. line-height: 48rpx;
  1066. }
  1067. .description {
  1068. display: block;
  1069. font-size: 24rpx;
  1070. color: #666666;
  1071. line-height: 36rpx;
  1072. margin-top: 10rpx;
  1073. margin-left: 45rpx;
  1074. }
  1075. .function-tabs {
  1076. display: block;
  1077. overflow: hidden;
  1078. margin-bottom: 30rpx;
  1079. }
  1080. .tabs-track {
  1081. display: inline-flex;
  1082. white-space: nowrap;
  1083. will-change: transform;
  1084. }
  1085. .tab-item {
  1086. padding: 5rpx 20rpx;
  1087. border-radius: 20rpx;
  1088. font-size: 20rpx;
  1089. font-weight: 700;
  1090. color: #666666;
  1091. background-color: #fffefe;
  1092. margin-right: 20rpx;
  1093. transition: all 0.3s;
  1094. }
  1095. .tab-item.active {
  1096. color: #ff6600;
  1097. background-color: #fff;
  1098. border: 1rpx solid #ff6600;
  1099. }
  1100. .recommend-card {
  1101. background: url("https://d31zlh4on95l9h.cloudfront.net/images/4da1d629a55c307c3605ca15bf15189a.svg");
  1102. background-repeat: no-repeat;
  1103. background-position: center bottom;
  1104. background-size: contain;
  1105. /* min-height: 20rpx; */
  1106. /* border-radius: 20rpx; */
  1107. padding: 40rpx;
  1108. margin-top: 10rpx;
  1109. margin-bottom: 10rpx;
  1110. /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); */
  1111. }
  1112. .welcome-section {
  1113. /* 灰色卡片(recommend-card)之后展示背景图 */
  1114. margin-top: 40rpx;
  1115. display: flex;
  1116. align-items: center;
  1117. justify-content: center;
  1118. background: url("/static/images/welcomeRobot@2x.png");
  1119. background-repeat: no-repeat;
  1120. background-position: center center;
  1121. /* 居中显示,避免顶部被裁剪 */
  1122. background-size: contain;
  1123. /* 保证整张图片完整展示 */
  1124. height: 460rpx;
  1125. /* 提供可视高度,让背景图可见 */
  1126. }
  1127. .card-content {
  1128. display: flex;
  1129. align-items: center;
  1130. justify-content: space-between;
  1131. margin-left: 40rpx;
  1132. }
  1133. .logo {
  1134. width: 80rpx;
  1135. height: 80rpx;
  1136. background-color: #ff0000;
  1137. border-radius: 10rpx;
  1138. display: flex;
  1139. align-items: center;
  1140. justify-content: center;
  1141. margin-right: 20rpx;
  1142. }
  1143. .card-text {
  1144. flex: 1;
  1145. margin-left: 20rpx;
  1146. }
  1147. .main-question {
  1148. font-size: 32rpx;
  1149. color: #333333;
  1150. line-height: 48rpx;
  1151. }
  1152. .stock-code {
  1153. display: block;
  1154. font-size: 24rpx;
  1155. color: #ff3b30;
  1156. background-color: #ffffff;
  1157. padding: 2rpx 15rpx;
  1158. border-radius: 12rpx;
  1159. margin-top: 8rpx;
  1160. width: fit-content;
  1161. border: 1rpx solid #ff3b30;
  1162. }
  1163. .arrow-icon {
  1164. background: url("https://d31zlh4on95l9h.cloudfront.net/images/40d94054644f6e3f1c366751f07f0010.svg");
  1165. background-repeat: no-repeat;
  1166. left: 0.5rem;
  1167. top: 1.8rem;
  1168. background-size: 100% 100%;
  1169. width: 60rpx;
  1170. height: 60rpx;
  1171. }
  1172. .interest-section {
  1173. margin-bottom: 30rpx;
  1174. }
  1175. .section-title {
  1176. display: block;
  1177. text-align: left;
  1178. font-size: 26rpx;
  1179. color: #666666;
  1180. margin-bottom: 20rpx;
  1181. }
  1182. .topics-list {
  1183. display: flex;
  1184. flex-direction: column;
  1185. gap: 15rpx;
  1186. }
  1187. .topic-item {
  1188. display: flex;
  1189. align-items: center;
  1190. padding: 15rpx 20rpx;
  1191. background-color: #f0f0f0;
  1192. border-radius: 15rpx;
  1193. width: fit-content;
  1194. }
  1195. .tag-icon {
  1196. width: 24rpx;
  1197. height: 24rpx;
  1198. margin-right: 10rpx;
  1199. }
  1200. .topic-text {
  1201. font-size: 28rpx;
  1202. color: #333333;
  1203. flex: 1;
  1204. }
  1205. /* 聊天区域样式 */
  1206. .chat-container {
  1207. margin-top: 30rpx;
  1208. border-radius: 10rpx;
  1209. height: calc(100vh - 50rpx);
  1210. /* 缩短滚动区域,避免被输入框覆盖 */
  1211. overflow-y: auto;
  1212. -webkit-overflow-scrolling: touch;
  1213. }
  1214. .message-list {
  1215. background-color: #fff;
  1216. margin-bottom: 400rpx;
  1217. /* padding: 20rpx; */
  1218. }
  1219. .message {
  1220. display: flex;
  1221. align-items: flex-start;
  1222. margin-bottom: 30rpx;
  1223. }
  1224. .user-message {
  1225. flex-direction: row-reverse;
  1226. justify-content: flex-start;
  1227. }
  1228. .message-icon {
  1229. font-size: 24rpx;
  1230. margin: 0 10rpx;
  1231. /* padding: 10rpx; */
  1232. border-radius: 50%;
  1233. background-color: #ddd;
  1234. width: 60rpx;
  1235. height: 60rpx;
  1236. display: flex;
  1237. align-items: center;
  1238. justify-content: center;
  1239. }
  1240. .user-message .message-icon {
  1241. /* background-color: #007aff; */
  1242. border-radius: 50%;
  1243. color: #fff;
  1244. /* box-shadow: 0 0 12rpx rgba(0, 122, 255, 0.4); */
  1245. }
  1246. .bot-message .message-icon {
  1247. /* background: url("/static/images/robot (1).svg"); */
  1248. color: white;
  1249. }
  1250. .message-content {
  1251. max-width: 70%;
  1252. position: relative;
  1253. word-wrap: break-word;
  1254. word-break: break-all;
  1255. overflow-wrap: break-word;
  1256. }
  1257. .user-message .message-content {
  1258. /* background-color: #007aff; */
  1259. border: 2rpx solid #f3908f;
  1260. border-radius: 20rpx;
  1261. padding: 10rpx;
  1262. }
  1263. .bot-message .message-content {
  1264. background-color: #f0f0f0;
  1265. border-radius: 10rpx;
  1266. padding: 15rpx;
  1267. }
  1268. .message-text {
  1269. font-size: 28rpx;
  1270. line-height: 40rpx;
  1271. }
  1272. .user-message .message-text {
  1273. color: black;
  1274. }
  1275. .bot-message .message-text {
  1276. color: #333;
  1277. }
  1278. .loading-dots {
  1279. display: flex;
  1280. align-items: center;
  1281. /* padding-top: 10rpx; */
  1282. }
  1283. .dot {
  1284. width: 10rpx;
  1285. height: 10rpx;
  1286. background-color: #666;
  1287. border-radius: 50%;
  1288. margin: 0 4rpx;
  1289. animation: loading 1.4s infinite ease-in-out both;
  1290. }
  1291. .user-message .dot {
  1292. background-color: white;
  1293. }
  1294. .dot:nth-child(1) {
  1295. animation-delay: -0.32s;
  1296. }
  1297. .dot:nth-child(2) {
  1298. animation-delay: -0.16s;
  1299. }
  1300. @keyframes loading {
  1301. 0%,
  1302. 80%,
  1303. 100% {
  1304. transform: scale(0);
  1305. }
  1306. 40% {
  1307. transform: scale(1);
  1308. }
  1309. }
  1310. .input-area {
  1311. position: fixed;
  1312. margin-top: 20rpx;
  1313. bottom: 70rpx;
  1314. left: 0;
  1315. right: 0;
  1316. padding: 0 40rpx 80rpx 40rpx;
  1317. background-color: #ffffff;
  1318. }
  1319. .input-wrapper {
  1320. position: relative;
  1321. display: flex;
  1322. align-items: center;
  1323. padding: 15rpx 20rpx;
  1324. background-color: rgb(220, 31, 29);
  1325. border-radius: 100rpx;
  1326. display: flex;
  1327. align-items: center;
  1328. justify-content: center;
  1329. height: 50rpx;
  1330. }
  1331. .mic-icon {
  1332. width: 36rpx;
  1333. height: 36rpx;
  1334. margin-right: 20rpx;
  1335. }
  1336. .input-field {
  1337. flex: 1;
  1338. font-size: 28rpx;
  1339. color: #fff;
  1340. display: flex;
  1341. align-items: center;
  1342. justify-content: center;
  1343. margin-left: 60rpx;
  1344. background: none;
  1345. border: none;
  1346. outline: none;
  1347. }
  1348. .input-field::placeholder {
  1349. color: #ffffff !important;
  1350. opacity: 1;
  1351. }
  1352. /* .uni-scroll-view{
  1353. height: 92%;
  1354. } */
  1355. .send-button {
  1356. background: url("https://d31zlh4on95l9h.cloudfront.net/images/95f1ea2262e9157db13c93c0dc1c5d96.svg");
  1357. background-repeat: no-repeat;
  1358. background-size: 100% 100%;
  1359. height: 50rpx;
  1360. width: 50rpx;
  1361. padding: 0;
  1362. border: 1rpx solid transparent;
  1363. margin-left: 20rpx;
  1364. }
  1365. .send-icon {
  1366. width: 36rpx;
  1367. height: 36rpx;
  1368. }
  1369. .disclaimer {
  1370. font-size: 15rpx;
  1371. color: #4d4c4c;
  1372. display: flex;
  1373. align-items: center;
  1374. justify-content: center;
  1375. margin-top: 15rpx;
  1376. }
  1377. .banner-panel {
  1378. position: relative;
  1379. height: 480rpx;
  1380. /* 拉长容器,灰色背景跟随变高 */
  1381. overflow: hidden;
  1382. /* 让圆角和内部层剪裁一致 */
  1383. border-radius: 15rpx;
  1384. }
  1385. .panelShow {
  1386. height: 12%;
  1387. }
  1388. .pray-banner {
  1389. position: absolute;
  1390. /* background-size: 100% 100%; */
  1391. inset: 0;
  1392. /* 顶部、底部、左、右都贴合容器 */
  1393. width: 100%;
  1394. height: 83%;
  1395. border-radius: 15rpx;
  1396. z-index: 1;
  1397. /* 在灰底之上、内容之下 */
  1398. }
  1399. .contain {
  1400. margin: 0 20rpx;
  1401. gap: 5rpx;
  1402. }
  1403. .banner-panel .robot-container,
  1404. .banner-panel .function-tabs,
  1405. .banner-panel .recommend-card {
  1406. position: relative;
  1407. z-index: 2;
  1408. }
  1409. .back-to-top {
  1410. position: fixed;
  1411. left: 0;
  1412. top: 0;
  1413. width: 100rpx;
  1414. height: 100rpx;
  1415. z-index: 1000;
  1416. }
  1417. .back-to-top:active {
  1418. transform: scale(0.96);
  1419. }
  1420. .static-footer {
  1421. position: fixed;
  1422. bottom: 0;
  1423. }
  1424. /* 搜索历史侧拉框样式 */
  1425. .drawer-overlay {
  1426. position: fixed;
  1427. left: 0;
  1428. top: 0;
  1429. right: 0;
  1430. bottom: 0;
  1431. background-color: rgba(0, 0, 0, 0.35);
  1432. z-index: 900;
  1433. }
  1434. .drawer-panel {
  1435. position: fixed;
  1436. left: 0;
  1437. right: 0;
  1438. bottom: 0;
  1439. height: 75vh;
  1440. max-height: 80vh;
  1441. width: 100%;
  1442. background: #ffffff;
  1443. box-shadow: 0 -8rpx 20rpx rgba(0, 0, 0, 0.06);
  1444. z-index: 1000;
  1445. display: flex;
  1446. flex-direction: column;
  1447. border-top-left-radius: 20rpx;
  1448. border-top-right-radius: 20rpx;
  1449. transition: transform 0.22s ease;
  1450. }
  1451. .drawer-back {
  1452. position: absolute;
  1453. left: 50%;
  1454. top: -14px;
  1455. transform: translateX(-50%);
  1456. width: 28px;
  1457. height: 48px;
  1458. border-radius: 12px;
  1459. background: #fff;
  1460. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  1461. display: flex;
  1462. align-items: center;
  1463. justify-content: center;
  1464. }
  1465. .drawer-back-icon {
  1466. font-size: 16px;
  1467. color: #8a8a8a;
  1468. }
  1469. .drawer-actions {
  1470. display: flex;
  1471. align-items: center;
  1472. gap: 40rpx;
  1473. }
  1474. .delete-all-container {
  1475. display: flex;
  1476. align-items: center;
  1477. gap: 14rpx;
  1478. }
  1479. .delete-icon {
  1480. width: 45rpx;
  1481. height: 40rpx;
  1482. }
  1483. .delete-all {
  1484. font-size: 28rpx;
  1485. }
  1486. .drawer-close {
  1487. background: url("/static/icons/close-two.svg");
  1488. width: 48rpx;
  1489. height: 48rpx;
  1490. border-radius: 24rpx;
  1491. /* background: #f5f5f5; */
  1492. /* box-shadow: 0 2px 8px rgba(0,0,0,0.08); */
  1493. display: flex;
  1494. align-items: center;
  1495. justify-content: center;
  1496. }
  1497. .drawer-close-icon {
  1498. font-size: 24rpx;
  1499. color: #8a8a8a;
  1500. }
  1501. .drawer-header {
  1502. display: flex;
  1503. align-items: center;
  1504. justify-content: space-between;
  1505. padding: 52rpx 28rpx 0rpx 28rpx;
  1506. /* border-bottom: 2rpx solid #f0f0f0; */
  1507. }
  1508. .drawer-title {
  1509. font-size: 32rpx;
  1510. font-weight: 600;
  1511. color: #333333;
  1512. }
  1513. /* .drawer-close {
  1514. font-size: 42rpx;
  1515. color: #999999;
  1516. } */
  1517. .drawer-content {
  1518. flex: 1;
  1519. min-height: 0;
  1520. /* 让 flex 子元素可在容器内收缩以启用滚动 */
  1521. height: 100%;
  1522. overscroll-behavior-y: contain;
  1523. /* 防止滚动串联到页面 */
  1524. -webkit-overflow-scrolling: touch;
  1525. /* iOS 惯性滚动 */
  1526. touch-action: pan-y;
  1527. /* 优化触控滚动,仅垂直 */
  1528. }
  1529. .drawer-inner {
  1530. padding: 20rpx 24rpx 20rpx 24rpx;
  1531. }
  1532. .history-section {
  1533. margin-bottom: 20rpx;
  1534. /* margin: 0 24rpx; */
  1535. }
  1536. .section-title {
  1537. font-size: 26rpx;
  1538. color: #888;
  1539. margin: 10rpx 6rpx 16rpx;
  1540. }
  1541. .history-item {
  1542. display: flex;
  1543. align-items: center;
  1544. padding: 19rpx 18rpx;
  1545. background-color: #f6f7f9;
  1546. border-radius: 12rpx;
  1547. margin-bottom: 12rpx;
  1548. }
  1549. .history-left {
  1550. margin-right: 12rpx;
  1551. }
  1552. .icon-stock {
  1553. width: 36rpx;
  1554. height: 36rpx;
  1555. }
  1556. .flag-circle {
  1557. width: 36rpx;
  1558. height: 36rpx;
  1559. border-radius: 50%;
  1560. background: #fff;
  1561. border: 2rpx solid #eee;
  1562. display: flex;
  1563. align-items: center;
  1564. justify-content: center;
  1565. }
  1566. .flag-emoji {
  1567. font-size: 24rpx;
  1568. }
  1569. .history-main {
  1570. flex: 1;
  1571. }
  1572. .history-query {
  1573. font-size: 28rpx;
  1574. color: #333;
  1575. }
  1576. .history-time {
  1577. font-size: 22rpx;
  1578. color: #999;
  1579. }
  1580. .history-card {
  1581. background-color: #fff;
  1582. border: 2rpx solid #f2f2f2;
  1583. border-left: 8rpx solid rgb(220, 31, 29);
  1584. border-radius: 12rpx;
  1585. padding: 18rpx 20rpx;
  1586. margin-bottom: 16rpx;
  1587. box-shadow: 0 4rpx 10rpx rgba(0, 0, 0, 0.03);
  1588. }
  1589. .history-query {
  1590. font-size: 28rpx;
  1591. color: #333333;
  1592. font-weight: 500;
  1593. }
  1594. .history-time {
  1595. margin-top: 8rpx;
  1596. font-size: 22rpx;
  1597. color: #888888;
  1598. }
  1599. .empty-history {
  1600. padding: 40rpx;
  1601. color: #999999;
  1602. text-align: center;
  1603. }
  1604. .thinking-process {
  1605. margin: 10rpx 0;
  1606. border: 2rpx solid #e5e5e5;
  1607. border-radius: 20rpx;
  1608. background-color: #f9f9f9;
  1609. }
  1610. .thinking-header {
  1611. display: flex;
  1612. align-items: center;
  1613. padding: 20rpx 30rpx;
  1614. cursor: pointer;
  1615. background-color: #fff;
  1616. border-radius: 20rpx;
  1617. border-bottom: 2rpx solid #e5e5e5;
  1618. }
  1619. .thinking-icon {
  1620. font-size: 32rpx;
  1621. margin-right: 16rpx;
  1622. color: #d47c45;
  1623. }
  1624. .thinking-title {
  1625. font-size: 28rpx;
  1626. font-weight: 500;
  1627. color: #d47c45;
  1628. margin-right: 16rpx;
  1629. }
  1630. .thinking-count {
  1631. font-size: 24rpx;
  1632. color: #666;
  1633. margin-right: 16rpx;
  1634. }
  1635. .thinking-toggle {
  1636. font-size: 24rpx;
  1637. color: #999;
  1638. }
  1639. .thinking-content {
  1640. transition: transform 1s ease; /* 添加过渡效果 */
  1641. transform-origin: top center; /* 设置变换原点 */
  1642. padding: 20rpx 30rpx;
  1643. }
  1644. @keyframes transform {
  1645. from {
  1646. transform: scaleY(0);
  1647. }
  1648. to {
  1649. transform: scaleY(1);
  1650. }
  1651. }
  1652. .thinking-item {
  1653. display: flex;
  1654. align-items: center;
  1655. margin-bottom: 16rpx;
  1656. padding: 8rpx 0;
  1657. }
  1658. .item-status {
  1659. width: 32rpx;
  1660. height: 32rpx;
  1661. border-radius: 50%;
  1662. background-color: #f0f0f0;
  1663. display: flex;
  1664. justify-content: center;
  1665. align-items: center;
  1666. margin-right: 16rpx;
  1667. }
  1668. .checkmark {
  1669. font-size: 20rpx;
  1670. color: #ff0000;
  1671. }
  1672. .item-text {
  1673. font-size: 24rpx;
  1674. color: #333;
  1675. }
  1676. </style>