chat.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  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="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 } from '../../utils/api.js'
  150. import BaseEmpty from '../../components/BaseEmpty.vue'
  151. import AITaskCard from '../../components/AITaskCard.vue'
  152. export default {
  153. components: { BaseEmpty, AITaskCard },
  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. // 加载用户mascot设置
  221. var userInfo = uni.getStorageSync('userInfo')
  222. if (userInfo) {
  223. if (userInfo.mascot === 'xibao') {
  224. this.mascotCode = 'xibao'
  225. this.mascotName = '浠宝'
  226. this.mascotIcon = '🌟'
  227. } else if (userInfo.mascot === 'fubao') {
  228. this.mascotCode = 'fubao'
  229. this.mascotName = '福宝'
  230. this.mascotIcon = '💪'
  231. }
  232. }
  233. this.loadConversations()
  234. // 如果有预填消息,自动发送
  235. var self = this
  236. if (this.pendingFirstMessage) {
  237. this.$nextTick(function() {
  238. self.inputText = self.pendingFirstMessage
  239. self.pendingFirstMessage = ''
  240. self.sendMessage()
  241. })
  242. }
  243. },
  244. onShow() {
  245. if (this.pageLoaded) {
  246. this.loadConversations()
  247. }
  248. this.pageLoaded = true
  249. },
  250. methods: {
  251. goBack() {
  252. uni.navigateBack()
  253. },
  254. onTaskAccepted() {
  255. this.loadConversations()
  256. },
  257. async loadConversations() {
  258. try {
  259. const res = await aiGetConversations()
  260. this.conversations = res.data || []
  261. } catch (e) {
  262. console.log('加载会话列表失败', e)
  263. }
  264. },
  265. async switchConversation(convId) {
  266. this.currentConversationId = convId
  267. this.showConversations = false
  268. this.messages = []
  269. this.$nextTick(() => {
  270. this.scrollToBottom()
  271. })
  272. try {
  273. const res = await aiGetMessages({ conversationId: convId })
  274. this.messages = res.data || []
  275. this.$nextTick(() => {
  276. this.scrollToBottom()
  277. })
  278. } catch (e) {
  279. console.log('加载消息失败', e)
  280. }
  281. },
  282. newConversation() {
  283. this.currentConversationId = ''
  284. this.showConversations = false
  285. this.messages = []
  286. this.inputText = ''
  287. this.$nextTick(() => {
  288. this.scrollToBottom()
  289. })
  290. },
  291. async sendMessage() {
  292. const text = this.inputText.trim()
  293. if (!text || this.sending) return
  294. // 立即显示用户消息
  295. const tempMsg = { id: 'temp_' + Date.now(), query: text, answer: '' }
  296. this.messages.push(tempMsg)
  297. this.inputText = ''
  298. this.sending = true
  299. this.$nextTick(() => {
  300. this.scrollToBottom()
  301. })
  302. try {
  303. var params = {
  304. query: text,
  305. conversationId: this.currentConversationId
  306. }
  307. if (this.reportId) {
  308. params.reportId = this.reportId
  309. }
  310. var res, data
  311. if (this.mode === 'nutrition') {
  312. res = await aiSendNutritionMessage(params)
  313. data = res.data || {}
  314. const lastMsg = this.messages[this.messages.length - 1]
  315. if (lastMsg) {
  316. lastMsg.answer = data.answer || ''
  317. lastMsg.recommendations = data.recommendations || []
  318. lastMsg.tasks = data.tasks || []
  319. if (this.reportId) {
  320. lastMsg.sourceReport = { id: this.reportId, type: 'nutrition' }
  321. }
  322. }
  323. } else if (this.mode === 'health') {
  324. res = await aiSendHealthCoachMessage(params)
  325. data = res.data || {}
  326. const lastMsg = this.messages[this.messages.length - 1]
  327. if (lastMsg) {
  328. lastMsg.answer = data.answer || ''
  329. lastMsg.recommendations = data.recommendations || []
  330. lastMsg.tasks = data.tasks || []
  331. }
  332. } else if (this.mode === 'butler') {
  333. // 传递 childId 让健康管家能加载家庭上下文
  334. var butlerParams = Object.assign({}, params)
  335. butlerParams.childId = uni.getStorageSync('currentChildId') || null
  336. res = await aiSendHealthButlerMessage(butlerParams)
  337. data = res.data || {}
  338. const butlerLastMsg = this.messages[this.messages.length - 1]
  339. if (butlerLastMsg) {
  340. butlerLastMsg.answer = data.answer || ''
  341. butlerLastMsg.recommendations = data.recommendations || []
  342. butlerLastMsg.tasks = data.tasks || []
  343. }
  344. } else {
  345. data = res.data || {}
  346. const lastMsg = this.messages[this.messages.length - 1]
  347. if (lastMsg) {
  348. lastMsg.answer = data.answer || ''
  349. lastMsg.recommendations = data.recommendations || []
  350. lastMsg.tasks = data.tasks || []
  351. if (this.reportId) {
  352. lastMsg.sourceReport = { id: this.reportId, type: 'assessment' }
  353. }
  354. }
  355. }
  356. // 更新 conversationId(新建会话时 Dify 返回)
  357. if (data.conversationId && !this.currentConversationId) {
  358. this.currentConversationId = data.conversationId
  359. // 刷新会话列表
  360. this.loadConversations()
  361. }
  362. } catch (e) {
  363. // 显示错误
  364. const lastMsg = this.messages[this.messages.length - 1]
  365. if (lastMsg) {
  366. lastMsg.answer = '抱歉,我暂时无法回答,请稍后再试。'
  367. }
  368. } finally {
  369. this.sending = false
  370. this.$nextTick(() => {
  371. this.scrollToBottom()
  372. })
  373. }
  374. },
  375. quickQuestion(text) {
  376. this.inputText = text
  377. this.sendMessage()
  378. },
  379. gotoRec(rec) {
  380. if (rec.url) {
  381. uni.navigateTo({ url: rec.url })
  382. }
  383. },
  384. loadMoreMessages() {
  385. // 分页加载历史(当前简化)
  386. },
  387. scrollToBottom() {
  388. this.scrollToId = 'scrollBottom'
  389. },
  390. formatTime(timestamp) {
  391. if (!timestamp) return ''
  392. const d = new Date(timestamp * 1000)
  393. const now = new Date()
  394. const diff = now - d
  395. if (diff < 86400000) {
  396. return d.getHours().toString().padStart(2, '0') + ':' + d.getMinutes().toString().padStart(2, '0')
  397. }
  398. return (d.getMonth() + 1) + '/' + d.getDate()
  399. }
  400. }
  401. }
  402. </script>
  403. <style scoped>
  404. .chat-container {
  405. display: flex;
  406. flex-direction: column;
  407. height: 100vh;
  408. background: var(--bg, #FFF7ED);
  409. position: relative;
  410. }
  411. /* 导航栏 */
  412. .chat-nav {
  413. display: flex;
  414. align-items: center;
  415. justify-content: space-between;
  416. padding: 88rpx 24rpx 16rpx;
  417. background: #fff;
  418. border-bottom: 1rpx solid var(--border-light, #E2E8F0);
  419. position: relative;
  420. z-index: 100;
  421. }
  422. .chat-nav.mascot-xibao {
  423. background: linear-gradient(135deg, #FFF7ED 0%, #FFE4CC 100%);
  424. border-bottom-color: #FF8C42;
  425. }
  426. .chat-nav.mascot-xibao .nav-title {
  427. color: #D97706;
  428. }
  429. .chat-nav.mascot-fubao {
  430. background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  431. border-bottom-color: #F59E0B;
  432. }
  433. .chat-nav.mascot-fubao .nav-title {
  434. color: #B45309;
  435. }
  436. .nav-back {
  437. width: 60rpx;
  438. height: 60rpx;
  439. display: flex;
  440. align-items: center;
  441. justify-content: center;
  442. }
  443. .nav-back-icon {
  444. font-size: 40rpx;
  445. color: var(--text, #1E293B);
  446. font-weight: 600;
  447. }
  448. .nav-title {
  449. font-size: 32rpx;
  450. font-weight: 600;
  451. color: var(--text, #1E293B);
  452. }
  453. .nav-actions {
  454. width: 60rpx;
  455. height: 60rpx;
  456. display: flex;
  457. align-items: center;
  458. justify-content: center;
  459. }
  460. .nav-action {
  461. font-size: 36rpx;
  462. color: var(--text-secondary, #64748B);
  463. }
  464. /* 会话列表侧拉 */
  465. .conv-overlay {
  466. position: fixed;
  467. top: 0;
  468. left: 0;
  469. right: 0;
  470. bottom: 0;
  471. background: rgba(0,0,0,0.3);
  472. z-index: 200;
  473. }
  474. .conv-sidebar {
  475. position: fixed;
  476. top: 0;
  477. right: -500rpx;
  478. width: 460rpx;
  479. height: 100vh;
  480. background: #fff;
  481. z-index: 210;
  482. transition: right 0.3s ease;
  483. display: flex;
  484. flex-direction: column;
  485. }
  486. .conv-sidebar-open {
  487. right: 0;
  488. }
  489. .conv-header {
  490. display: flex;
  491. justify-content: space-between;
  492. align-items: center;
  493. padding: 100rpx 24rpx 16rpx;
  494. border-bottom: 1rpx solid var(--border-light, #E2E8F0);
  495. }
  496. .conv-header-title {
  497. font-size: 28rpx;
  498. font-weight: 600;
  499. color: var(--text, #1E293B);
  500. }
  501. .conv-header-new {
  502. font-size: 24rpx;
  503. color: var(--color-primary, #5B9BD5);
  504. font-weight: 500;
  505. }
  506. .conv-list {
  507. flex: 1;
  508. overflow-y: auto;
  509. }
  510. .conv-item {
  511. padding: 20rpx 24rpx;
  512. border-bottom: 1rpx solid var(--border-light, #E2E8F0);
  513. }
  514. .conv-item-active {
  515. background: rgba(91, 155, 213, 0.06);
  516. }
  517. .conv-item-name {
  518. font-size: 26rpx;
  519. color: var(--text, #1E293B);
  520. display: block;
  521. margin-bottom: 6rpx;
  522. overflow: hidden;
  523. text-overflow: ellipsis;
  524. white-space: nowrap;
  525. }
  526. .conv-item-time {
  527. font-size: 20rpx;
  528. color: var(--muted, #94A3B8);
  529. }
  530. /* 消息列表 */
  531. .message-list {
  532. flex: 1;
  533. overflow-y: auto;
  534. padding: 20rpx 24rpx;
  535. }
  536. .message-list-inner {
  537. min-height: 100%;
  538. }
  539. /* 欢迎卡片 */
  540. .welcome-card {
  541. text-align: center;
  542. padding: 60rpx 20rpx 40rpx;
  543. }
  544. .welcome-icon {
  545. font-size: 80rpx;
  546. margin-bottom: 20rpx;
  547. transition: transform 0.3s;
  548. }
  549. .mascot-xibao .welcome-icon {
  550. animation: welcomeFloat 3s ease-in-out infinite;
  551. }
  552. .mascot-fubao .welcome-icon {
  553. animation: welcomeFloat 3s ease-in-out infinite 0.5s;
  554. }
  555. @keyframes welcomeFloat {
  556. 0%, 100% { transform: translateY(0); }
  557. 50% { transform: translateY(-10rpx); }
  558. }
  559. .welcome-title {
  560. font-size: 32rpx;
  561. font-weight: 600;
  562. color: var(--text, #1E293B);
  563. display: block;
  564. margin-bottom: 12rpx;
  565. }
  566. .welcome-desc {
  567. font-size: 24rpx;
  568. color: var(--text-secondary, #64748B);
  569. display: block;
  570. margin-bottom: 32rpx;
  571. }
  572. .welcome-suggestions {
  573. display: flex;
  574. flex-direction: column;
  575. gap: 16rpx;
  576. padding: 0 20rpx;
  577. }
  578. .welcome-suggestion {
  579. display: flex;
  580. align-items: center;
  581. background: #fff;
  582. padding: 20rpx 24rpx;
  583. border-radius: 16rpx;
  584. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  585. }
  586. .suggestion-icon {
  587. font-size: 28rpx;
  588. margin-right: 12rpx;
  589. }
  590. .suggestion-text {
  591. font-size: 24rpx;
  592. color: var(--text, #1E293B);
  593. }
  594. /* 消息 */
  595. .message {
  596. margin-bottom: 24rpx;
  597. }
  598. .message-user {
  599. display: flex;
  600. justify-content: flex-end;
  601. }
  602. .message-ai {
  603. display: flex;
  604. align-items: flex-start;
  605. }
  606. .message-avatar {
  607. width: 56rpx;
  608. height: 56rpx;
  609. font-size: 36rpx;
  610. margin-right: 12rpx;
  611. flex-shrink: 0;
  612. display: flex;
  613. align-items: center;
  614. justify-content: center;
  615. border-radius: 50%;
  616. transition: transform 0.2s;
  617. }
  618. .mascot-xibao .message-avatar {
  619. background: linear-gradient(135deg, #FFF7ED 0%, #FFE4CC 100%);
  620. border: 2rpx solid #FF8C42;
  621. }
  622. .mascot-fubao .message-avatar {
  623. background: linear-gradient(135deg, #FFFBEB 0%, #FEF3C7 100%);
  624. border: 2rpx solid #F59E0B;
  625. }
  626. .message-bubble {
  627. max-width: 70%;
  628. padding: 16rpx 20rpx;
  629. font-size: 26rpx;
  630. line-height: 1.6;
  631. border-radius: 16rpx;
  632. word-break: break-word;
  633. }
  634. .user-bubble {
  635. background: var(--color-primary, #5B9BD5);
  636. color: #fff;
  637. border-bottom-right-radius: 4rpx;
  638. }
  639. .ai-bubble {
  640. background: #fff;
  641. color: var(--text, #1E293B);
  642. border-bottom-left-radius: 4rpx;
  643. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  644. }
  645. /* 输入区 */
  646. .chat-input-area {
  647. display: flex;
  648. align-items: center;
  649. padding: 16rpx 24rpx;
  650. padding-bottom: calc(16rpx + env(safe-area-inset-bottom));
  651. background: #fff;
  652. border-top: 1rpx solid var(--border-light, #E2E8F0);
  653. }
  654. .chat-input-wrap {
  655. flex: 1;
  656. background: var(--bg, #FFF7ED);
  657. border-radius: 40rpx;
  658. padding: 0 24rpx;
  659. margin-right: 16rpx;
  660. }
  661. .chat-input {
  662. height: 72rpx;
  663. font-size: 26rpx;
  664. color: var(--text, #1E293B);
  665. }
  666. .chat-send-btn {
  667. width: 72rpx;
  668. height: 72rpx;
  669. border-radius: 50%;
  670. background: var(--border-light, #E2E8F0);
  671. display: flex;
  672. align-items: center;
  673. justify-content: center;
  674. flex-shrink: 0;
  675. }
  676. .chat-send-active {
  677. background: var(--color-primary, #5B9BD5);
  678. }
  679. .send-icon {
  680. font-size: 28rpx;
  681. color: #fff;
  682. }
  683. /* 打字动画 */
  684. .typing {
  685. display: flex;
  686. align-items: center;
  687. gap: 4rpx;
  688. min-height: 40rpx;
  689. }
  690. .typing-dot {
  691. font-size: 40rpx;
  692. line-height: 1;
  693. animation: typingBounce 1.4s infinite;
  694. }
  695. .typing-dot:nth-child(2) {
  696. animation-delay: 0.2s;
  697. }
  698. .typing-dot:nth-child(3) {
  699. animation-delay: 0.4s;
  700. }
  701. @keyframes typingBounce {
  702. 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  703. 30% { opacity: 1; transform: translateY(-8rpx); }
  704. }
  705. /* 推荐卡片 */
  706. .ai-answer-text {
  707. display: block;
  708. margin-bottom: 16rpx;
  709. line-height: 1.7;
  710. }
  711. .rec-list {
  712. border-top: 1rpx solid var(--border-light, #E2E8F0);
  713. padding-top: 16rpx;
  714. display: flex;
  715. flex-direction: column;
  716. gap: 12rpx;
  717. }
  718. /* 任务卡片列表 */
  719. .task-list {
  720. border-top: 1rpx solid var(--border-light, #E2E8F0);
  721. padding-top: 16rpx;
  722. display: flex;
  723. flex-direction: column;
  724. gap: 12rpx;
  725. }
  726. /* 报告来源标识 */
  727. .source-label {
  728. margin-top: 16rpx;
  729. font-size: 22rpx;
  730. color: var(--muted, #94A3B8);
  731. text-align: right;
  732. }
  733. .rec-card {
  734. display: flex;
  735. flex-direction: row;
  736. background: var(--bg, #FFF7ED);
  737. border-radius: 12rpx;
  738. overflow: hidden;
  739. padding: 12rpx;
  740. }
  741. .rec-cover {
  742. width: 120rpx;
  743. height: 120rpx;
  744. border-radius: 8rpx;
  745. margin-right: 12rpx;
  746. flex-shrink: 0;
  747. background: #E2E8F0;
  748. }
  749. .rec-info {
  750. flex: 1;
  751. display: flex;
  752. flex-direction: column;
  753. gap: 4rpx;
  754. min-width: 0;
  755. }
  756. .rec-type-tag {
  757. display: inline-block;
  758. font-size: 18rpx;
  759. color: var(--color-primary, #5B9BD5);
  760. background: rgba(91, 155, 213, 0.1);
  761. padding: 2rpx 12rpx;
  762. border-radius: 8rpx;
  763. align-self: flex-start;
  764. }
  765. .rec-name {
  766. font-size: 26rpx;
  767. font-weight: 600;
  768. color: var(--text, #1E293B);
  769. overflow: hidden;
  770. text-overflow: ellipsis;
  771. white-space: nowrap;
  772. }
  773. .rec-desc {
  774. font-size: 22rpx;
  775. color: var(--text-secondary, #64748B);
  776. overflow: hidden;
  777. text-overflow: ellipsis;
  778. white-space: nowrap;
  779. }
  780. .rec-price {
  781. font-size: 26rpx;
  782. color: #F97316;
  783. font-weight: 600;
  784. }
  785. /* Mascot badge in nav */
  786. .mascot-badge {
  787. display: flex;
  788. align-items: center;
  789. gap: 4rpx;
  790. padding: 6rpx 16rpx;
  791. background: #EEF2FF;
  792. border-radius: 20rpx;
  793. font-size: 22rpx;
  794. }
  795. .mascot-badge-icon {
  796. font-size: 24rpx;
  797. }
  798. .mascot-badge-name {
  799. color: #6366F1;
  800. font-weight: 500;
  801. }
  802. .chat-disclaimer {
  803. text-align: center;
  804. font-size: 22rpx;
  805. color: #999;
  806. padding: 16rpx 0 20rpx;
  807. background: #f5f5f5;
  808. }
  809. </style>