index.vue 24 KB

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