chat.vue 25 KB

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