chat.vue 25 KB

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