index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. <template>
  2. <view class="diet-page">
  3. <scroll-view class="content" scroll-y>
  4. <!-- ===== 今日餐桌主视觉 ===== -->
  5. <view class="dining-hero">
  6. <view class="hero-top">
  7. <view class="hero-icon-wrap"><text class="hero-icon">🍳</text></view>
  8. <view class="hero-text">
  9. <text class="hero-title">今日共餐</text>
  10. <text class="hero-subtitle">{{ heroSubtitle }}</text>
  11. </view>
  12. </view>
  13. <view class="hero-meals" v-if="hasMealConfig">
  14. <view class="hero-meal" v-for="m in heroMeals" :key="m.key">
  15. <text class="hero-meal-emoji">{{ m.emoji }}</text>
  16. <text class="hero-meal-label">{{ m.label }}</text>
  17. <text class="hero-meal-count">{{ m.count || '—' }}</text>
  18. </view>
  19. </view>
  20. <view class="hero-empty" v-else @tap="navTo('/pages/diet/meal-config')">
  21. <text class="hero-empty-text">还没设置共餐?点这里安排家人一起吃饭</text>
  22. <view class="hero-empty-btn">去设置共餐</view>
  23. </view>
  24. </view>
  25. <!-- 食材推荐器 -->
  26. <view class="card">
  27. <view class="card-header">
  28. <view class="card-basket-icon"><text class="card-basket-emoji">🧺</text></view>
  29. <text class="card-title">今日菜篮</text>
  30. </view>
  31. <view class="card-body">
  32. <view class="action-bar">
  33. <view class="action-btn" @tap="refreshIngredients">
  34. <text class="action-btn-text">🔄 换一批</text>
  35. </view>
  36. <view class="action-btn action-btn-primary" @tap="showFoodPicker">
  37. <text class="action-btn-text-primary">+ 添加食材</text>
  38. </view>
  39. <view class="action-btn action-btn-accent" @tap="generateRecipe" :class="{'action-btn-disabled': selectedIngredients.length === 0}">
  40. <text class="action-btn-text-accent">✨ 生成食谱</text>
  41. </view>
  42. </view>
  43. <view class="ingredient-list" v-if="ingredients.length > 0">
  44. <view class="ingredient-item" v-for="(item, index) in ingredients" :key="getIngredientKey(item, index)">
  45. <view class="ingredient-left">
  46. <view class="ingredient-badge">
  47. <text class="ingredient-badge-text">{{ index + 1 }}</text>
  48. </view>
  49. <view class="ingredient-info">
  50. <text class="ingredient-name">{{ item.name }}</text>
  51. <text class="ingredient-reason" v-if="item.reason">{{ item.reason }}</text>
  52. <text class="ingredient-balance" v-if="item.balanceReason">{{ item.balanceReason }}</text>
  53. </view>
  54. </view>
  55. <view class="ingredient-remove" @tap="removeIngredient(index)">
  56. <text class="remove-text">✕</text>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="empty-state" v-else>
  61. <text class="empty-icon">🥬</text>
  62. <text class="empty-text">{{ ingredientsLoading ? '加载中...' : '暂无推荐食材' }}</text>
  63. <text class="empty-sub" v-if="!ingredientsLoading">点击「添加食材」或「换一批」获取推荐</text>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 快捷入口 -->
  68. <view class="section-label">
  69. <text class="section-label-text">常用功能</text>
  70. </view>
  71. <view class="nav-grid">
  72. <view class="nav-item" @tap="navTo('/pages/diet/food-query')">
  73. <view class="nav-icon-wrap nav-icon-green">
  74. <text class="nav-icon">🥗</text>
  75. </view>
  76. <text class="nav-label">食材查询</text>
  77. </view>
  78. <view class="nav-item" @tap="navTo('/pages/diet/records')">
  79. <view class="nav-icon-wrap nav-icon-blue">
  80. <text class="nav-icon">📝</text>
  81. </view>
  82. <text class="nav-label">饮食记录</text>
  83. </view>
  84. <view class="nav-item" @tap="navTo('/pages/diet/preferences')">
  85. <view class="nav-icon-wrap nav-icon-orange">
  86. <text class="nav-icon">📋</text>
  87. </view>
  88. <text class="nav-label">调研表</text>
  89. </view>
  90. <view class="nav-item" @tap="navTo('/pages/diet/meal-config')">
  91. <view class="nav-icon-wrap nav-icon-purple">
  92. <text class="nav-icon">👨‍👩‍👧</text>
  93. </view>
  94. <text class="nav-label">共餐配置</text>
  95. </view>
  96. <view class="nav-item" @tap="navTo('/pages/diet/recommendation')">
  97. <view class="nav-icon-wrap nav-icon-red">
  98. <text class="nav-icon">🍽️</text>
  99. </view>
  100. <text class="nav-label">食谱推荐</text>
  101. </view>
  102. </view>
  103. <!-- 本周趋势 -->
  104. <view class="card" v-if="trendData.days > 0">
  105. <view class="card-header">
  106. <view class="card-dot"></view>
  107. <text class="card-title">本周饮食</text>
  108. </view>
  109. <view class="card-body">
  110. <view class="trend-row">
  111. <view class="trend-item">
  112. <text class="trend-num">{{ trendData.totalCalories || 0 }}</text>
  113. <text class="trend-unit">kcal</text>
  114. <text class="trend-label">总摄入</text>
  115. </view>
  116. <view class="trend-divider"></view>
  117. <view class="trend-item">
  118. <text class="trend-num">{{ trendData.days }}</text>
  119. <text class="trend-unit">天</text>
  120. <text class="trend-label">记录天数</text>
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. <!-- 底部留白 -->
  126. <view class="bottom-space"></view>
  127. </scroll-view>
  128. <!-- 食材选择弹窗 -->
  129. <view class="modal" v-if="showPicker" @tap="closePicker">
  130. <view class="modal-mask"></view>
  131. <view class="modal-content" @tap.stop>
  132. <view class="modal-header">
  133. <text class="modal-title">选择食材</text>
  134. <view class="modal-close" @tap="closePicker">
  135. <text class="close-text">✕</text>
  136. </view>
  137. </view>
  138. <view class="search-wrap">
  139. <input class="search-input" placeholder="搜索食材..." placeholder-style="color:#bbb" v-model="searchQuery" @input="searchFood" />
  140. </view>
  141. <scroll-view class="food-list" scroll-y>
  142. <view class="food-item" v-for="food in searchResults" :key="food.id" @tap="addFood(food)">
  143. <text class="food-name">{{ food.name }}</text>
  144. <text class="food-tag">{{ food.category }}</text>
  145. </view>
  146. </scroll-view>
  147. <view class="empty-state" v-if="searchResults.length === 0 && searchQuery">
  148. <text class="empty-text">未找到匹配食材</text>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. </template>
  154. <script>
  155. import { getDietIngredients, refreshDietIngredients, addDietIngredient, removeDietIngredient, generateDietRecommendation, getMealConfig, searchDietFoods } from '@/utils/api.js'
  156. import { parseDate } from '@/utils/format.js'
  157. export default {
  158. data: function() {
  159. return {
  160. familyId: null,
  161. familyMemberId: null,
  162. ingredients: [],
  163. selectedIngredients: [],
  164. ingredientsLoading: false,
  165. mealSummary: {},
  166. trendData: {},
  167. showPicker: false,
  168. searchQuery: '',
  169. searchResults: [],
  170. uploadPromptShown: false
  171. }
  172. },
  173. computed: {
  174. heroSubtitle: function() {
  175. var self = this
  176. var parts = this.heroMeals.filter(function(m) { return m.count && m.count !== '' })
  177. var count = parts.length > 0 ? (parts[0].count || '') : ''
  178. return (self.isWeekend(new Date()) ? '周末' : '工作日') + ' · ' + (count ? count : '全家一起吃饭')
  179. },
  180. heroMeals: function() {
  181. var defs = [
  182. { key: 'breakfast', label: '早餐', emoji: '🌅' },
  183. { key: 'lunch', label: '午餐', emoji: '☀️' },
  184. { key: 'dinner', label: '晚餐', emoji: '🌙' }
  185. ]
  186. var self = this
  187. return defs.map(function(d) {
  188. return { key: d.key, label: d.label, emoji: d.emoji, count: self.mealSummary[d.key] || '' }
  189. })
  190. },
  191. hasMealConfig: function() {
  192. return !!(this.mealSummary.breakfast || this.mealSummary.lunch || this.mealSummary.dinner)
  193. }
  194. },
  195. onLoad: function() {
  196. this.familyId = uni.getStorageSync('familyId')
  197. this.familyMemberId = uni.getStorageSync('currentChildId') || uni.getStorageSync('currentMemberId') || uni.getStorageSync('userId')
  198. this.loadIngredients()
  199. this.loadMealSummary()
  200. },
  201. onShow: function() {
  202. // onLoad 已加载过,onShow 只刷新食材(共餐配置不重复请求)
  203. this.loadIngredients()
  204. this.checkTodayMealConfig()
  205. },
  206. methods: {
  207. checkTodayMealConfig: function() {
  208. var self = this
  209. // 未配置日常共餐时不提醒(页面已有「去设置共餐」引导)
  210. if (!self.hasMealConfig) return
  211. var todayKey = 'diet_today_config_prompt_' + self.formatDate(new Date())
  212. if (uni.getStorageSync(todayKey)) return
  213. Promise.all([
  214. getMealConfig({ date_type: 'today', meal_type: 'breakfast' }),
  215. getMealConfig({ date_type: 'today', meal_type: 'lunch' }),
  216. getMealConfig({ date_type: 'today', meal_type: 'dinner' })
  217. ]).then(function(results) {
  218. var hasTodayConfig = false
  219. results.forEach(function(r) {
  220. if (r && r.code === 200 && r.data && r.data.id) {
  221. hasTodayConfig = true
  222. }
  223. })
  224. if (!hasTodayConfig) {
  225. self.showMealConfigPrompt()
  226. }
  227. })
  228. },
  229. showMealConfigPrompt: function() {
  230. var self = this
  231. uni.showModal({
  232. title: '调整今日共餐?',
  233. content: '今天的共餐人和平时一样吗?不一样的话,可以为今天重新选择共餐人(只对今天生效)。',
  234. confirmText: '重新选择',
  235. cancelText: '一样,不用了',
  236. success: function(modalRes) {
  237. var todayKey = 'diet_today_config_prompt_' + self.formatDate(new Date())
  238. uni.setStorageSync(todayKey, '1')
  239. if (modalRes.confirm) {
  240. self.navTo('/pages/diet/meal-config?date_type=today')
  241. }
  242. }
  243. })
  244. },
  245. navTo: function(url) {
  246. uni.navigateTo({ url: url })
  247. },
  248. getIngredientKey: function(item, index) {
  249. return 'ing-' + (item.id || index)
  250. },
  251. loadIngredients: function() {
  252. var self = this
  253. self.ingredientsLoading = true
  254. getDietIngredients().then(function(res) {
  255. self.ingredientsLoading = false
  256. if (res && res.code === 200 && res.data && res.data.ingredients) {
  257. self.ingredients = res.data.ingredients
  258. self.selectedIngredients = self.ingredients
  259. if (self.ingredients.length === 0 && !self.uploadPromptShown) {
  260. self.uploadPromptShown = true
  261. uni.showModal({
  262. title: '暂无推荐食材',
  263. content: '还未上传菌群报告,无法生成个性化食材推荐。是否前往上传报告?',
  264. confirmText: '去上传',
  265. cancelText: '稍后',
  266. success: function(modalRes) {
  267. if (modalRes.confirm) {
  268. uni.navigateTo({ url: '/pages/health/report-upload' })
  269. }
  270. }
  271. })
  272. }
  273. }
  274. }).catch(function() {
  275. self.ingredientsLoading = false
  276. })
  277. },
  278. refreshIngredients: function() {
  279. var self = this
  280. self.ingredientsLoading = true
  281. refreshDietIngredients().then(function(res) {
  282. self.ingredientsLoading = false
  283. if (res && res.code === 200 && res.data && res.data.ingredients) {
  284. self.ingredients = res.data.ingredients
  285. self.selectedIngredients = self.ingredients
  286. }
  287. }).catch(function() {
  288. self.ingredientsLoading = false
  289. })
  290. },
  291. addIngredient: function(index) {
  292. var self = this
  293. var item = this.ingredients[index]
  294. addDietIngredient({ food_id: item.foodId, name: item.name }).then(function(res) {
  295. self.loadIngredients()
  296. })
  297. },
  298. removeIngredient: function(index) {
  299. var self = this
  300. var item = this.ingredients[index]
  301. removeDietIngredient({ food_id: item.foodId }).then(function(res) {
  302. self.loadIngredients()
  303. })
  304. },
  305. generateRecipe: function() {
  306. var self = this
  307. var foodIds = this.ingredients.map(function(item) { return { food_id: item.foodId, name: item.name } })
  308. generateDietRecommendation({
  309. date: self.formatDate(new Date()),
  310. meal_type: 'all',
  311. selected_foods: JSON.stringify(foodIds)
  312. }).then(function(res) {
  313. if (res && res.data && res.data.id) {
  314. uni.showToast({ title: '食谱生成成功', icon: 'success' })
  315. setTimeout(function() {
  316. self.navTo('/pages/diet/recommendation')
  317. }, 1000)
  318. } else {
  319. uni.showToast({ title: (res && res.message) || '生成失败', icon: 'none' })
  320. }
  321. })
  322. },
  323. formatDate: function(date) {
  324. var d = parseDate(date)
  325. if (!d) return ''
  326. var m = (d.getMonth() + 1).toString()
  327. if (m.length < 2) m = '0' + m
  328. var day = d.getDate().toString()
  329. if (day.length < 2) day = '0' + day
  330. return d.getFullYear() + '-' + m + '-' + day
  331. },
  332. loadMealSummary: function() {
  333. var self = this
  334. var dateType = self.isWeekend(new Date()) ? 'weekend' : 'weekday'
  335. Promise.all([
  336. getMealConfig({ date_type: dateType, meal_type: 'breakfast' }),
  337. getMealConfig({ date_type: dateType, meal_type: 'lunch' }),
  338. getMealConfig({ date_type: dateType, meal_type: 'dinner' })
  339. ]).then(function(results) {
  340. self.mealSummary.breakfast = self.parseMembers(results[0])
  341. self.mealSummary.lunch = self.parseMembers(results[1])
  342. self.mealSummary.dinner = self.parseMembers(results[2])
  343. // 日常配置加载完成后,检查是否需要提醒重新选择今天的共餐人
  344. self.checkTodayMealConfig()
  345. })
  346. },
  347. parseMembers: function(result) {
  348. if (!result || result.code !== 200 || !result.data) return ''
  349. var config = result.data
  350. if (!config || !config.participantMemberIds) return ''
  351. try {
  352. var ids = JSON.parse(config.participantMemberIds)
  353. return '共 ' + ids.length + ' 人'
  354. } catch (e) {
  355. return ''
  356. }
  357. },
  358. isWeekend: function(date) {
  359. var day = date.getDay()
  360. return day === 0 || day === 6
  361. },
  362. showFoodPicker: function() {
  363. this.showPicker = true
  364. },
  365. closePicker: function() {
  366. this.showPicker = false
  367. this.searchQuery = ''
  368. this.searchResults = []
  369. },
  370. searchFood: function() {
  371. var self = this
  372. var kw = (this.searchQuery || '').trim()
  373. if (!kw) {
  374. this.searchResults = []
  375. return
  376. }
  377. searchDietFoods(kw).then(function(res) {
  378. if (res && res.code === 200 && res.data && res.data.foods) {
  379. self.searchResults = res.data.foods
  380. }
  381. })
  382. },
  383. addFood: function(food) {
  384. var self = this
  385. addDietIngredient({ food_id: food.id, name: food.name }).then(function(res) {
  386. self.closePicker()
  387. self.loadIngredients()
  388. })
  389. }
  390. }
  391. }
  392. </script>
  393. <style scoped>
  394. /* ===== 页面令牌(暖灶·家的味道) ===== */
  395. .diet-page {
  396. min-height: 100vh;
  397. background: linear-gradient(180deg, #FFF7ED 0%, #FFF3E6 100%);
  398. overflow: hidden;
  399. }
  400. .dining-hero {
  401. background: linear-gradient(135deg, #FF8C42, #FFB366);
  402. border-radius: 32rpx;
  403. padding: 36rpx 32rpx;
  404. margin-bottom: 24rpx;
  405. box-shadow: 0 8rpx 32rpx rgba(255, 140, 66, 0.25);
  406. }
  407. .hero-top { display: flex; align-items: center; margin-bottom: 24rpx; }
  408. .hero-icon-wrap {
  409. width: 88rpx; height: 88rpx; border-radius: 50%;
  410. background: rgba(255,255,255,0.22);
  411. display: flex; align-items: center; justify-content: center;
  412. margin-right: 20rpx; flex-shrink: 0;
  413. }
  414. .hero-icon { font-size: 44rpx; }
  415. .hero-title { font-size: 38rpx; font-weight: 700; color: #FFFFFF; display: block; }
  416. .hero-subtitle { font-size: 24rpx; color: rgba(255,255,255,0.85); margin-top: 6rpx; display: block; }
  417. .hero-meals { display: flex; }
  418. .hero-meal {
  419. flex: 1; margin: 0 8rpx;
  420. background: rgba(255,255,255,0.18);
  421. border-radius: 20rpx; padding: 20rpx 8rpx;
  422. display: flex; flex-direction: column; align-items: center;
  423. }
  424. .hero-meal:first-child { margin-left: 0; }
  425. .hero-meal:last-child { margin-right: 0; }
  426. .hero-meal-emoji { font-size: 40rpx; margin-bottom: 8rpx; }
  427. .hero-meal-label { font-size: 24rpx; color: #FFFFFF; }
  428. .hero-meal-count { font-size: 22rpx; color: rgba(255,255,255,0.9); margin-top: 6rpx; font-weight: 600; }
  429. .hero-empty { display: flex; flex-direction: column; align-items: center; padding: 12rpx 0; }
  430. .hero-empty-text { font-size: 26rpx; color: #FFFFFF; margin-bottom: 20rpx; }
  431. .hero-empty-btn {
  432. background: #FFFFFF; color: #C2410C; font-size: 28rpx; font-weight: 600;
  433. padding: 18rpx 44rpx; border-radius: 999rpx;
  434. }
  435. .content {
  436. padding: 24rpx 32rpx;
  437. box-sizing: border-box;
  438. width: 100%;
  439. overflow: hidden;
  440. }
  441. /* 共餐格子 */
  442. .card {
  443. background: #FFFFFF;
  444. border-radius: 24rpx;
  445. margin-bottom: 24rpx;
  446. box-shadow: 0 4rpx 20rpx rgba(255, 140, 66, 0.08);
  447. overflow: hidden;
  448. box-sizing: border-box;
  449. width: 100%;
  450. }
  451. .card-header {
  452. display: flex;
  453. align-items: center;
  454. padding: 28rpx 28rpx 0;
  455. }
  456. .card-basket-icon {
  457. width: 64rpx; height: 64rpx; border-radius: 18rpx;
  458. background: linear-gradient(135deg, #FF8C42, #FFB366);
  459. display: flex; align-items: center; justify-content: center;
  460. margin-right: 16rpx; flex-shrink: 0;
  461. }
  462. .card-basket-emoji { font-size: 32rpx; }
  463. .card-title {
  464. font-size: 30rpx;
  465. font-weight: 600;
  466. color: #333;
  467. }
  468. .card-body {
  469. padding: 24rpx 28rpx 28rpx;
  470. }
  471. /* 操作按钮栏 */
  472. .action-bar {
  473. display: flex;
  474. margin-bottom: 24rpx;
  475. box-sizing: border-box;
  476. width: 100%;
  477. }
  478. .action-btn {
  479. padding: 14rpx 24rpx;
  480. border-radius: 32rpx;
  481. background: #F5F5F5;
  482. margin-right: 16rpx;
  483. }
  484. .action-btn:last-child {
  485. margin-right: 0;
  486. }
  487. .action-btn-primary {
  488. background: #FF8C42;
  489. }
  490. .action-btn-accent { background: linear-gradient(135deg, #10B981, #34D399); }
  491. .action-btn-text-accent { font-size: 24rpx; color: #FFFFFF; }
  492. .action-btn-disabled {
  493. opacity: 0.4;
  494. }
  495. .action-btn-text {
  496. font-size: 24rpx;
  497. color: #666;
  498. }
  499. .action-btn-text-primary {
  500. font-size: 24rpx;
  501. color: #FFFFFF;
  502. }
  503. /* 食材列表 */
  504. .ingredient-list {
  505. margin-top: 8rpx;
  506. }
  507. .ingredient-item:active { background: #FFF9F0; }
  508. .ingredient-item {
  509. display: flex;
  510. align-items: center;
  511. justify-content: space-between;
  512. padding: 20rpx 0;
  513. border-bottom: 1rpx solid #F5F5F5;
  514. }
  515. .ingredient-item:last-child {
  516. border-bottom: none;
  517. }
  518. .ingredient-left {
  519. display: flex;
  520. align-items: center;
  521. flex: 1;
  522. }
  523. .ingredient-badge {
  524. width: 40rpx;
  525. height: 40rpx;
  526. border-radius: 12rpx;
  527. background: linear-gradient(135deg, #FF8C42, #FFB366);
  528. display: flex;
  529. align-items: center;
  530. justify-content: center;
  531. margin-right: 20rpx;
  532. flex-shrink: 0;
  533. }
  534. .ingredient-badge-text {
  535. font-size: 20rpx;
  536. color: #FFFFFF;
  537. font-weight: 600;
  538. }
  539. .ingredient-info {
  540. display: flex;
  541. flex-direction: column;
  542. flex: 1;
  543. }
  544. .ingredient-name {
  545. font-size: 28rpx;
  546. color: #333;
  547. font-weight: 500;
  548. }
  549. .ingredient-reason {
  550. font-size: 22rpx;
  551. color: #999;
  552. margin-top: 4rpx;
  553. }
  554. .ingredient-balance {
  555. font-size: 20rpx;
  556. color: #FF8C42;
  557. margin-top: 2rpx;
  558. }
  559. .ingredient-remove {
  560. width: 48rpx;
  561. height: 48rpx;
  562. display: flex;
  563. align-items: center;
  564. justify-content: center;
  565. flex-shrink: 0;
  566. }
  567. .remove-text {
  568. font-size: 28rpx;
  569. color: #ccc;
  570. }
  571. /* 区域标签 */
  572. .section-label {
  573. padding: 8rpx 0 16rpx;
  574. }
  575. .section-label-text {
  576. font-size: 28rpx;
  577. font-weight: 600;
  578. color: #333;
  579. }
  580. /* 快捷入口网格 */
  581. .nav-grid {
  582. display: flex;
  583. flex-wrap: wrap;
  584. margin-bottom: 24rpx;
  585. box-sizing: border-box;
  586. width: 100%;
  587. }
  588. .nav-item {
  589. width: 20%;
  590. display: flex;
  591. flex-direction: column;
  592. align-items: center;
  593. padding: 20rpx 0;
  594. position: relative;
  595. z-index: 1;
  596. }
  597. .nav-icon-wrap {
  598. width: 88rpx;
  599. height: 88rpx;
  600. border-radius: 24rpx;
  601. display: flex;
  602. align-items: center;
  603. justify-content: center;
  604. margin-bottom: 12rpx;
  605. transition: transform 0.15s ease;
  606. }
  607. .nav-icon-green { background: linear-gradient(135deg, #FFF1E6, #FFE0C0); }
  608. .nav-icon-blue { background: linear-gradient(135deg, #FFF7ED, #FFEEDD); }
  609. .nav-icon-orange{ background: linear-gradient(135deg, #FF8C42, #FFB366); }
  610. .nav-icon-purple{ background: linear-gradient(135deg, #FFE8D6, #FFD4B0); }
  611. .nav-icon-red { background: linear-gradient(135deg, #E8F8F1, #C8F0E0); }
  612. .nav-item:active .nav-icon-wrap { transform: scale(0.92); }
  613. .nav-icon {
  614. font-size: 36rpx;
  615. }
  616. .nav-label {
  617. font-size: 22rpx;
  618. color: #333;
  619. }
  620. /* 趋势卡片 */
  621. .trend-row {
  622. display: flex;
  623. align-items: center;
  624. box-sizing: border-box;
  625. width: 100%;
  626. }
  627. .trend-item {
  628. flex: 1;
  629. display: flex;
  630. flex-direction: column;
  631. align-items: center;
  632. }
  633. .trend-divider {
  634. width: 1rpx;
  635. height: 60rpx;
  636. background: #FDE8D0;
  637. }
  638. .trend-num {
  639. font-size: 48rpx;
  640. font-weight: 700;
  641. color: #FF8C42;
  642. }
  643. .trend-unit {
  644. font-size: 22rpx;
  645. color: #999;
  646. margin-top: 4rpx;
  647. }
  648. .trend-label {
  649. font-size: 22rpx;
  650. color: #666;
  651. margin-top: 4rpx;
  652. }
  653. /* 空状态 */
  654. .empty-state {
  655. display: flex;
  656. flex-direction: column;
  657. align-items: center;
  658. padding: 40rpx 0;
  659. }
  660. .empty-icon {
  661. font-size: 48rpx;
  662. margin-bottom: 12rpx;
  663. }
  664. .empty-text {
  665. font-size: 26rpx;
  666. color: #999;
  667. }
  668. .empty-sub {
  669. font-size: 22rpx;
  670. color: #ccc;
  671. margin-top: 8rpx;
  672. }
  673. /* 弹窗 */
  674. .modal {
  675. position: fixed;
  676. top: 0;
  677. left: 0;
  678. right: 0;
  679. bottom: 0;
  680. z-index: 999;
  681. display: flex;
  682. align-items: flex-end;
  683. justify-content: center;
  684. }
  685. .modal-mask {
  686. position: fixed;
  687. top: 0;
  688. left: 0;
  689. right: 0;
  690. bottom: 0;
  691. background: rgba(0, 0, 0, 0.5);
  692. }
  693. .modal-content {
  694. position: relative;
  695. width: 100%;
  696. max-height: 80vh;
  697. background: #FFFFFF;
  698. border-radius: 32rpx 32rpx 0 0;
  699. padding: 32rpx;
  700. z-index: 1;
  701. }
  702. .modal-header {
  703. display: flex;
  704. align-items: center;
  705. justify-content: space-between;
  706. margin-bottom: 24rpx;
  707. }
  708. .modal-title {
  709. font-size: 32rpx;
  710. font-weight: 600;
  711. color: #333;
  712. }
  713. .modal-close {
  714. width: 48rpx;
  715. height: 48rpx;
  716. display: flex;
  717. align-items: center;
  718. justify-content: center;
  719. }
  720. .close-text {
  721. font-size: 32rpx;
  722. color: #999;
  723. }
  724. .search-wrap {
  725. margin-bottom: 20rpx;
  726. }
  727. .search-input {
  728. border: 1rpx solid #eee;
  729. border-radius: 40rpx;
  730. padding: 20rpx 28rpx;
  731. font-size: 28rpx;
  732. background: #F8F8F8;
  733. }
  734. .food-list {
  735. max-height: 500rpx;
  736. }
  737. .food-item {
  738. display: flex;
  739. align-items: center;
  740. justify-content: space-between;
  741. padding: 24rpx 0;
  742. border-bottom: 1rpx solid #F5F5F5;
  743. }
  744. .food-name {
  745. font-size: 28rpx;
  746. color: #333;
  747. }
  748. .food-tag {
  749. font-size: 22rpx;
  750. color: #FF8C42;
  751. background: #FFF0E0;
  752. padding: 6rpx 16rpx;
  753. border-radius: 20rpx;
  754. }
  755. /* 底部留白 */
  756. .bottom-space {
  757. height: 40rpx;
  758. }
  759. </style>