chat.vue 20 KB

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