index.vue 24 KB

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