chat.vue 20 KB

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