chat.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. <template>
  2. <view class="chat-container">
  3. <!-- 导航栏 -->
  4. <view class="chat-nav" :class="'mascot-' + mascotCode">
  5. <view class="nav-back" @click="goBack">
  6. <text class="nav-back-icon">‹</text>
  7. </view>
  8. <text class="nav-title">{{ isNutrition ? '精准营养助手' : 'AI 家庭助手' }}</text>
  9. <view class="nav-actions">
  10. <view class="mascot-badge" v-if="mascotCode && !isNutrition" @click="showConversations = !showConversations">
  11. <text class="mascot-badge-icon">{{ mascotIcon }}</text>
  12. <text class="mascot-badge-name">{{ mascotName }}</text>
  13. </view>
  14. <text class="nav-action" @click="showConversations = !showConversations" v-else>☰</text>
  15. </view>
  16. </view>
  17. <!-- 会话列表(侧拉) -->
  18. <view class="conv-overlay" v-if="showConversations" @click="showConversations = false"></view>
  19. <view class="conv-sidebar" :class="{ 'conv-sidebar-open': showConversations }">
  20. <view class="conv-header">
  21. <text class="conv-header-title">会话列表</text>
  22. <text class="conv-header-new" @click="newConversation">+ 新会话</text>
  23. </view>
  24. <scroll-view class="conv-list" scroll-y>
  25. <view class="conv-item" v-for="conv in conversations" :key="conv.id"
  26. :class="{ 'conv-item-active': conv.id === currentConversationId }"
  27. @click="switchConversation(conv.id)">
  28. <text class="conv-item-name">{{ conv.name || '新会话' }}</text>
  29. <text class="conv-item-time">{{ formatTime(conv.updated_at) }}</text>
  30. </view>
  31. <BaseEmpty v-if="conversations.length === 0" text="暂无会话" icon="💬" />
  32. </scroll-view>
  33. </view>
  34. <!-- 消息列表 -->
  35. <scroll-view class="message-list" scroll-y :scroll-into-view="scrollToId" scroll-with-animation
  36. @scrolltoupper="loadMoreMessages" id="messageList">
  37. <view class="message-list-inner">
  38. <view class="welcome-card" v-if="messages.length === 0 && !sending">
  39. <view class="welcome-icon">{{ mascotIcon || (isNutrition ? '🥗' : '🤖') }}</view>
  40. <text class="welcome-title">{{ isNutrition ? '你好!我是精准营养助手' : ('你好!我是' + (mascotName || '家庭助手')) }}</text>
  41. <text class="welcome-desc">{{ welcomeSubtitle }}</text>
  42. <view class="welcome-suggestions">
  43. <view class="welcome-suggestion" v-if="!isNutrition" @click="quickQuestion('小明最近任务完成怎么样?')">
  44. <text class="suggestion-icon">📋</text>
  45. <text class="suggestion-text">小明最近任务完成怎么样?</text>
  46. </view>
  47. <view class="welcome-suggestion" v-if="!isNutrition" @click="quickQuestion('我家孩子的能量评分怎么样?')">
  48. <text class="suggestion-icon">⚡</text>
  49. <text class="suggestion-text">孩子的能量评分怎么样?</text>
  50. </view>
  51. <view class="welcome-suggestion" v-if="!isNutrition" @click="quickQuestion('今天有什么需要我做的事情?')">
  52. <text class="suggestion-icon">✅</text>
  53. <text class="suggestion-text">今天有什么需要我做的事情?</text>
  54. </view>
  55. <view class="welcome-suggestion" v-if="isNutrition" @click="quickQuestion('根据报告,我的孩子需要补充哪些营养?')">
  56. <text class="suggestion-icon">🥦</text>
  57. <text class="suggestion-text">根据报告,我的孩子需要补充哪些营养?</text>
  58. </view>
  59. <view class="welcome-suggestion" v-if="isNutrition" @click="quickQuestion('有哪些食物或产品推荐?')">
  60. <text class="suggestion-icon">🛒</text>
  61. <text class="suggestion-text">有哪些食物或产品推荐?</text>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="message-group" v-for="(msg, idx) in messages" :key="msg.id">
  66. <!-- 用户消息 -->
  67. <view class="message message-user" v-if="msg.query">
  68. <view class="message-bubble user-bubble">{{ msg.query }}</view>
  69. </view>
  70. <!-- AI 回复 -->
  71. <view class="message message-ai" v-if="msg.answer">
  72. <view class="message-avatar">{{ mascotIcon || '🤖' }}</view>
  73. <view class="message-bubble ai-bubble">
  74. <text class="ai-answer-text">{{ msg.answer }}</text>
  75. <!-- 推荐卡片 -->
  76. <view class="rec-list" v-if="msg.recommendations && msg.recommendations.length > 0">
  77. <view class="rec-card" v-for="(rec, ri) in msg.recommendations" :key="ri" @click="gotoRec(rec)">
  78. <image class="rec-cover" v-if="rec.coverImage" :src="rec.coverImage" mode="aspectFill" />
  79. <view class="rec-info">
  80. <text class="rec-type-tag">{{ rec.type === 'product' ? '商品' : rec.type === 'activity' ? '活动' : '文章' }}</text>
  81. <text class="rec-name">{{ rec.name }}</text>
  82. <text class="rec-desc">{{ rec.description }}</text>
  83. <text class="rec-price" v-if="rec.price">¥{{ rec.price }}</text>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- AI 任务卡片 -->
  88. <view class="task-list" v-if="msg.tasks && msg.tasks.length > 0">
  89. <AITaskCard v-for="(task, ti) in msg.tasks" :key="ti" :task="task" :conversationId="currentConversationId" @accepted="onTaskAccepted" />
  90. </view>
  91. <!-- 报告来源标识 -->
  92. <view class="source-label" v-if="msg.sourceReport">
  93. 来源:{{ msg.sourceReport.type === 'nutrition' ? '营养报告' : '测评报告' }} #{{ msg.sourceReport.id }}
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 加载中 -->
  99. <view class="message message-ai" v-if="sending">
  100. <view class="message-avatar">{{ mascotIcon || '🤖' }}</view>
  101. <view class="message-bubble ai-bubble typing">
  102. <text class="typing-dot">.</text>
  103. <text class="typing-dot">.</text>
  104. <text class="typing-dot">.</text>
  105. </view>
  106. </view>
  107. <view id="scrollBottom"></view>
  108. </view>
  109. </scroll-view>
  110. <!-- 输入区 -->
  111. <view class="chat-input-area">
  112. <view class="chat-input-wrap">
  113. <input class="chat-input" v-model="inputText" placeholder="问我关于家庭和孩子的问题..."
  114. :disabled="sending" @confirm="sendMessage" confirm-type="send" />
  115. </view>
  116. <view class="chat-send-btn" :class="{ 'chat-send-active': inputText.trim() }"
  117. @click="sendMessage">
  118. <text class="send-icon">➤</text>
  119. </view>
  120. </view>
  121. </view>
  122. </template>
  123. <script>
  124. import { aiSendMessage, aiGetConversations, aiGetMessages, aiDeleteConversation, aiSendNutritionMessage } from '../../utils/api.js'
  125. import BaseEmpty from '../../components/BaseEmpty.vue'
  126. import AITaskCard from '../../components/AITaskCard.vue'
  127. export default {
  128. components: { BaseEmpty, AITaskCard },
  129. data() {
  130. return {
  131. inputText: '',
  132. messages: [],
  133. conversations: [],
  134. currentConversationId: '',
  135. sending: false,
  136. showConversations: false,
  137. scrollToId: '',
  138. pageLoaded: false,
  139. pendingFirstMessage: '',
  140. fromPage: '',
  141. mode: '',
  142. reportId: '',
  143. recommendations: [],
  144. mascotCode: '',
  145. mascotName: '',
  146. mascotIcon: ''
  147. }
  148. },
  149. computed: {
  150. isNutrition: function() {
  151. return this.mode === 'nutrition'
  152. },
  153. welcomeSubtitle: function() {
  154. if (this.isNutrition) {
  155. return '我可以基于菌群检测报告,为你提供个性化的营养建议和推荐'
  156. }
  157. if (this.fromPage) {
  158. var pageNames = {
  159. 'pages/body/index': '身',
  160. 'pages/wisdom/index': '智',
  161. 'pages/mind/index': '心',
  162. 'pages/index/index': '首页',
  163. 'pages/index/parent-index': '首页',
  164. 'pages/index/child-index': '首页',
  165. 'pages/profile/profile': '我的',
  166. 'pages/profile/children': '我的',
  167. 'pages/shop/index': '商城',
  168. 'pages/discover/index': '发现'
  169. }
  170. var pageName = pageNames[this.fromPage] || this.fromPage
  171. return '从 ' + pageName + ' 发起,我可以帮你了解:'
  172. }
  173. return '我可以帮你了解孩子的成长情况,比如:'
  174. }
  175. },
  176. onLoad: function(options) {
  177. this.mode = options.mode || ''
  178. this.fromPage = options.fromPage ? decodeURIComponent(options.fromPage) : ''
  179. this.reportId = options.reportId || ''
  180. if (options.firstMessage) {
  181. this.pendingFirstMessage = decodeURIComponent(options.firstMessage)
  182. }
  183. // 加载用户mascot设置
  184. var userInfo = uni.getStorageSync('userInfo')
  185. if (userInfo) {
  186. if (userInfo.mascot === 'xibao') {
  187. this.mascotCode = 'xibao'
  188. this.mascotName = '浠宝'
  189. this.mascotIcon = '🌟'
  190. } else if (userInfo.mascot === 'fubao') {
  191. this.mascotCode = 'fubao'
  192. this.mascotName = '福宝'
  193. this.mascotIcon = '💪'
  194. }
  195. }
  196. this.loadConversations()
  197. // 如果有预填消息,自动发送
  198. var self = this
  199. if (this.pendingFirstMessage) {
  200. this.$nextTick(function() {
  201. self.inputText = self.pendingFirstMessage
  202. self.pendingFirstMessage = ''
  203. self.sendMessage()
  204. })
  205. }
  206. },
  207. onShow() {
  208. if (this.pageLoaded) {
  209. this.loadConversations()
  210. }
  211. this.pageLoaded = true
  212. },
  213. methods: {
  214. goBack() {
  215. uni.navigateBack()
  216. },
  217. onTaskAccepted() {
  218. this.loadConversations()
  219. },
  220. async loadConversations() {
  221. try {
  222. const res = await aiGetConversations()
  223. this.conversations = res.data || []
  224. } catch (e) {
  225. console.log('加载会话列表失败', e)
  226. }
  227. },
  228. async switchConversation(convId) {
  229. this.currentConversationId = convId
  230. this.showConversations = false
  231. this.messages = []
  232. this.$nextTick(() => {
  233. this.scrollToBottom()
  234. })
  235. try {
  236. const res = await aiGetMessages({ conversationId: convId })
  237. this.messages = res.data || []
  238. this.$nextTick(() => {
  239. this.scrollToBottom()
  240. })
  241. } catch (e) {
  242. console.log('加载消息失败', e)
  243. }
  244. },
  245. newConversation() {
  246. this.currentConversationId = ''
  247. this.showConversations = false
  248. this.messages = []
  249. this.inputText = ''
  250. this.$nextTick(() => {
  251. this.scrollToBottom()
  252. })
  253. },
  254. async sendMessage() {
  255. const text = this.inputText.trim()
  256. if (!text || this.sending) return
  257. // 立即显示用户消息
  258. const tempMsg = { id: 'temp_' + Date.now(), query: text, answer: '' }
  259. this.messages.push(tempMsg)
  260. this.inputText = ''
  261. this.sending = true
  262. this.$nextTick(() => {
  263. this.scrollToBottom()
  264. })
  265. try {
  266. var params = {
  267. query: text,
  268. conversationId: this.currentConversationId
  269. }
  270. if (this.reportId) {
  271. params.reportId = this.reportId
  272. }
  273. var res, data
  274. if (this.mode === 'nutrition') {
  275. // 营养模式:调精准营养助手
  276. res = await aiSendNutritionMessage(params)
  277. data = res.data || {}
  278. // 更新最后一条消息的回复 + 推荐列表 + 任务
  279. const lastMsg = this.messages[this.messages.length - 1]
  280. if (lastMsg) {
  281. lastMsg.answer = data.answer || ''
  282. lastMsg.recommendations = data.recommendations || []
  283. lastMsg.tasks = data.tasks || []
  284. if (this.reportId) {
  285. lastMsg.sourceReport = { id: this.reportId, type: 'nutrition' }
  286. }
  287. }
  288. } else {
  289. res = await aiSendMessage(params)
  290. data = res.data || {}
  291. // 更新最后一条消息的回复 + 推荐列表 + 任务
  292. const lastMsg = this.messages[this.messages.length - 1]
  293. if (lastMsg) {
  294. lastMsg.answer = data.answer || ''
  295. lastMsg.recommendations = data.recommendations || []
  296. lastMsg.tasks = data.tasks || []
  297. if (this.reportId) {
  298. lastMsg.sourceReport = { id: this.reportId, type: 'assessment' }
  299. }
  300. }
  301. }
  302. // 更新 conversationId(新建会话时 Dify 返回)
  303. if (data.conversationId && !this.currentConversationId) {
  304. this.currentConversationId = data.conversationId
  305. // 刷新会话列表
  306. this.loadConversations()
  307. }
  308. } catch (e) {
  309. // 显示错误
  310. const lastMsg = this.messages[this.messages.length - 1]
  311. if (lastMsg) {
  312. lastMsg.answer = '抱歉,我暂时无法回答,请稍后再试。'
  313. }
  314. } finally {
  315. this.sending = false
  316. this.$nextTick(() => {
  317. this.scrollToBottom()
  318. })
  319. }
  320. },
  321. quickQuestion(text) {
  322. this.inputText = text
  323. this.sendMessage()
  324. },
  325. gotoRec(rec) {
  326. if (rec.url) {
  327. uni.navigateTo({ url: rec.url })
  328. }
  329. },
  330. loadMoreMessages() {
  331. // 分页加载历史(当前简化)
  332. },
  333. scrollToBottom() {
  334. this.scrollToId = 'scrollBottom'
  335. },
  336. formatTime(timestamp) {
  337. if (!timestamp) return ''
  338. const d = new Date(timestamp * 1000)
  339. const now = new Date()
  340. const diff = now - d
  341. if (diff < 86400000) {
  342. return d.getHours().toString().padStart(2, '0') + ':' + d.getMinutes().toString().padStart(2, '0')
  343. }
  344. return (d.getMonth() + 1) + '/' + d.getDate()
  345. }
  346. }
  347. }
  348. </script>
  349. <style scoped>
  350. .chat-container {
  351. display: flex;
  352. flex-direction: column;
  353. height: 100vh;
  354. background: var(--bg, #FFF7ED);
  355. position: relative;
  356. }
  357. /* 导航栏 */
  358. .chat-nav {
  359. display: flex;
  360. align-items: center;
  361. justify-content: space-between;
  362. padding: 88rpx 24rpx 16rpx;
  363. background: #fff;
  364. border-bottom: 1rpx solid var(--border-light, #E2E8F0);
  365. position: relative;
  366. z-index: 100;
  367. }
  368. .chat-nav.mascot-xibao {
  369. background: linear-gradient(135deg, #FFF7ED 0%, #FFE4CC 100%);
  370. border-bottom-color: #FF8C42;
  371. }
  372. .chat-nav.mascot-xibao .nav-title {
  373. color: #D97706;
  374. }
  375. .chat-nav.mascot-fubao {
  376. background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  377. border-bottom-color: #F59E0B;
  378. }
  379. .chat-nav.mascot-fubao .nav-title {
  380. color: #B45309;
  381. }
  382. .nav-back {
  383. width: 60rpx;
  384. height: 60rpx;
  385. display: flex;
  386. align-items: center;
  387. justify-content: center;
  388. }
  389. .nav-back-icon {
  390. font-size: 40rpx;
  391. color: var(--text, #1E293B);
  392. font-weight: 600;
  393. }
  394. .nav-title {
  395. font-size: 32rpx;
  396. font-weight: 600;
  397. color: var(--text, #1E293B);
  398. }
  399. .nav-actions {
  400. width: 60rpx;
  401. height: 60rpx;
  402. display: flex;
  403. align-items: center;
  404. justify-content: center;
  405. }
  406. .nav-action {
  407. font-size: 36rpx;
  408. color: var(--text-secondary, #64748B);
  409. }
  410. /* 会话列表侧拉 */
  411. .conv-overlay {
  412. position: fixed;
  413. top: 0;
  414. left: 0;
  415. right: 0;
  416. bottom: 0;
  417. background: rgba(0,0,0,0.3);
  418. z-index: 200;
  419. }
  420. .conv-sidebar {
  421. position: fixed;
  422. top: 0;
  423. right: -500rpx;
  424. width: 460rpx;
  425. height: 100vh;
  426. background: #fff;
  427. z-index: 210;
  428. transition: right 0.3s ease;
  429. display: flex;
  430. flex-direction: column;
  431. }
  432. .conv-sidebar-open {
  433. right: 0;
  434. }
  435. .conv-header {
  436. display: flex;
  437. justify-content: space-between;
  438. align-items: center;
  439. padding: 100rpx 24rpx 16rpx;
  440. border-bottom: 1rpx solid var(--border-light, #E2E8F0);
  441. }
  442. .conv-header-title {
  443. font-size: 28rpx;
  444. font-weight: 600;
  445. color: var(--text, #1E293B);
  446. }
  447. .conv-header-new {
  448. font-size: 24rpx;
  449. color: var(--color-primary, #5B9BD5);
  450. font-weight: 500;
  451. }
  452. .conv-list {
  453. flex: 1;
  454. overflow-y: auto;
  455. }
  456. .conv-item {
  457. padding: 20rpx 24rpx;
  458. border-bottom: 1rpx solid var(--border-light, #E2E8F0);
  459. }
  460. .conv-item-active {
  461. background: rgba(91, 155, 213, 0.06);
  462. }
  463. .conv-item-name {
  464. font-size: 26rpx;
  465. color: var(--text, #1E293B);
  466. display: block;
  467. margin-bottom: 6rpx;
  468. overflow: hidden;
  469. text-overflow: ellipsis;
  470. white-space: nowrap;
  471. }
  472. .conv-item-time {
  473. font-size: 20rpx;
  474. color: var(--muted, #94A3B8);
  475. }
  476. /* 消息列表 */
  477. .message-list {
  478. flex: 1;
  479. overflow-y: auto;
  480. padding: 20rpx 24rpx;
  481. }
  482. .message-list-inner {
  483. min-height: 100%;
  484. }
  485. /* 欢迎卡片 */
  486. .welcome-card {
  487. text-align: center;
  488. padding: 60rpx 20rpx 40rpx;
  489. }
  490. .welcome-icon {
  491. font-size: 80rpx;
  492. margin-bottom: 20rpx;
  493. transition: transform 0.3s;
  494. }
  495. .mascot-xibao .welcome-icon {
  496. animation: welcomeFloat 3s ease-in-out infinite;
  497. }
  498. .mascot-fubao .welcome-icon {
  499. animation: welcomeFloat 3s ease-in-out infinite 0.5s;
  500. }
  501. @keyframes welcomeFloat {
  502. 0%, 100% { transform: translateY(0); }
  503. 50% { transform: translateY(-10rpx); }
  504. }
  505. .welcome-title {
  506. font-size: 32rpx;
  507. font-weight: 600;
  508. color: var(--text, #1E293B);
  509. display: block;
  510. margin-bottom: 12rpx;
  511. }
  512. .welcome-desc {
  513. font-size: 24rpx;
  514. color: var(--text-secondary, #64748B);
  515. display: block;
  516. margin-bottom: 32rpx;
  517. }
  518. .welcome-suggestions {
  519. display: flex;
  520. flex-direction: column;
  521. gap: 16rpx;
  522. padding: 0 20rpx;
  523. }
  524. .welcome-suggestion {
  525. display: flex;
  526. align-items: center;
  527. background: #fff;
  528. padding: 20rpx 24rpx;
  529. border-radius: 16rpx;
  530. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  531. }
  532. .suggestion-icon {
  533. font-size: 28rpx;
  534. margin-right: 12rpx;
  535. }
  536. .suggestion-text {
  537. font-size: 24rpx;
  538. color: var(--text, #1E293B);
  539. }
  540. /* 消息 */
  541. .message {
  542. margin-bottom: 24rpx;
  543. }
  544. .message-user {
  545. display: flex;
  546. justify-content: flex-end;
  547. }
  548. .message-ai {
  549. display: flex;
  550. align-items: flex-start;
  551. }
  552. .message-avatar {
  553. width: 56rpx;
  554. height: 56rpx;
  555. font-size: 36rpx;
  556. margin-right: 12rpx;
  557. flex-shrink: 0;
  558. display: flex;
  559. align-items: center;
  560. justify-content: center;
  561. border-radius: 50%;
  562. transition: transform 0.2s;
  563. }
  564. .mascot-xibao .message-avatar {
  565. background: linear-gradient(135deg, #FFF7ED 0%, #FFE4CC 100%);
  566. border: 2rpx solid #FF8C42;
  567. }
  568. .mascot-fubao .message-avatar {
  569. background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  570. border: 2rpx solid #F59E0B;
  571. }
  572. .message-bubble {
  573. max-width: 70%;
  574. padding: 16rpx 20rpx;
  575. font-size: 26rpx;
  576. line-height: 1.6;
  577. border-radius: 16rpx;
  578. word-break: break-word;
  579. }
  580. .user-bubble {
  581. background: var(--color-primary, #5B9BD5);
  582. color: #fff;
  583. border-bottom-right-radius: 4rpx;
  584. }
  585. .ai-bubble {
  586. background: #fff;
  587. color: var(--text, #1E293B);
  588. border-bottom-left-radius: 4rpx;
  589. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  590. }
  591. /* 输入区 */
  592. .chat-input-area {
  593. display: flex;
  594. align-items: center;
  595. padding: 16rpx 24rpx;
  596. padding-bottom: calc(16rpx + env(safe-area-inset-bottom));
  597. background: #fff;
  598. border-top: 1rpx solid var(--border-light, #E2E8F0);
  599. }
  600. .chat-input-wrap {
  601. flex: 1;
  602. background: var(--bg, #FFF7ED);
  603. border-radius: 40rpx;
  604. padding: 0 24rpx;
  605. margin-right: 16rpx;
  606. }
  607. .chat-input {
  608. height: 72rpx;
  609. font-size: 26rpx;
  610. color: var(--text, #1E293B);
  611. }
  612. .chat-send-btn {
  613. width: 72rpx;
  614. height: 72rpx;
  615. border-radius: 50%;
  616. background: var(--border-light, #E2E8F0);
  617. display: flex;
  618. align-items: center;
  619. justify-content: center;
  620. flex-shrink: 0;
  621. }
  622. .chat-send-active {
  623. background: var(--color-primary, #5B9BD5);
  624. }
  625. .send-icon {
  626. font-size: 28rpx;
  627. color: #fff;
  628. }
  629. /* 打字动画 */
  630. .typing {
  631. display: flex;
  632. align-items: center;
  633. gap: 4rpx;
  634. min-height: 40rpx;
  635. }
  636. .typing-dot {
  637. font-size: 40rpx;
  638. line-height: 1;
  639. animation: typingBounce 1.4s infinite;
  640. }
  641. .typing-dot:nth-child(2) {
  642. animation-delay: 0.2s;
  643. }
  644. .typing-dot:nth-child(3) {
  645. animation-delay: 0.4s;
  646. }
  647. @keyframes typingBounce {
  648. 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  649. 30% { opacity: 1; transform: translateY(-8rpx); }
  650. }
  651. /* 推荐卡片 */
  652. .ai-answer-text {
  653. display: block;
  654. margin-bottom: 16rpx;
  655. line-height: 1.7;
  656. }
  657. .rec-list {
  658. border-top: 1rpx solid var(--border-light, #E2E8F0);
  659. padding-top: 16rpx;
  660. display: flex;
  661. flex-direction: column;
  662. gap: 12rpx;
  663. }
  664. /* 任务卡片列表 */
  665. .task-list {
  666. border-top: 1rpx solid var(--border-light, #E2E8F0);
  667. padding-top: 16rpx;
  668. display: flex;
  669. flex-direction: column;
  670. gap: 12rpx;
  671. }
  672. /* 报告来源标识 */
  673. .source-label {
  674. margin-top: 16rpx;
  675. font-size: 22rpx;
  676. color: var(--muted, #94A3B8);
  677. text-align: right;
  678. }
  679. .rec-card {
  680. display: flex;
  681. flex-direction: row;
  682. background: var(--bg, #FFF7ED);
  683. border-radius: 12rpx;
  684. overflow: hidden;
  685. padding: 12rpx;
  686. }
  687. .rec-cover {
  688. width: 120rpx;
  689. height: 120rpx;
  690. border-radius: 8rpx;
  691. margin-right: 12rpx;
  692. flex-shrink: 0;
  693. background: #E2E8F0;
  694. }
  695. .rec-info {
  696. flex: 1;
  697. display: flex;
  698. flex-direction: column;
  699. gap: 4rpx;
  700. min-width: 0;
  701. }
  702. .rec-type-tag {
  703. display: inline-block;
  704. font-size: 18rpx;
  705. color: var(--color-primary, #5B9BD5);
  706. background: rgba(91, 155, 213, 0.1);
  707. padding: 2rpx 12rpx;
  708. border-radius: 8rpx;
  709. align-self: flex-start;
  710. }
  711. .rec-name {
  712. font-size: 26rpx;
  713. font-weight: 600;
  714. color: var(--text, #1E293B);
  715. overflow: hidden;
  716. text-overflow: ellipsis;
  717. white-space: nowrap;
  718. }
  719. .rec-desc {
  720. font-size: 22rpx;
  721. color: var(--text-secondary, #64748B);
  722. overflow: hidden;
  723. text-overflow: ellipsis;
  724. white-space: nowrap;
  725. }
  726. .rec-price {
  727. font-size: 26rpx;
  728. color: #F97316;
  729. font-weight: 600;
  730. }
  731. /* Mascot badge in nav */
  732. .mascot-badge {
  733. display: flex;
  734. align-items: center;
  735. gap: 4rpx;
  736. padding: 6rpx 16rpx;
  737. background: #EEF2FF;
  738. border-radius: 20rpx;
  739. font-size: 22rpx;
  740. }
  741. .mascot-badge-icon {
  742. font-size: 24rpx;
  743. }
  744. .mascot-badge-name {
  745. color: #6366F1;
  746. font-weight: 500;
  747. }
  748. </style>