recommendation.vue 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773
  1. <template>
  2. <view class="recommendation-page" :style="{ '--font-scale': fontScale }">
  3. <scroll-view class="content" scroll-y :refresher-enabled="true" :refresher-triggered="refreshing" @refresherrefresh="onRefresh" @scrolltolower="loadMore">
  4. <view class="food-section">
  5. <!-- 成员切换条(统一组件 MemberSelector:家庭总览 / 个人 / 各成员) -->
  6. <MemberSelector
  7. variant="minimal"
  8. v-if="memberList.length > 1"
  9. :members="memberList"
  10. :selected-member-id="currentMemberId"
  11. :show-overview="true"
  12. :overview-active="currentView === 'family'"
  13. self-label="我"
  14. @overview="switchView('family')"
  15. @select="switchMember" />
  16. <!-- Tab 切换行:今日食谱 | 适合 | 戒备 | 全部 -->
  17. <view class="filter-bar">
  18. <view class="filter-item" :class="{'filter-active': currentTab === 'recipe'}" @tap="switchTab('recipe')">
  19. <text>🍽️ 今日食谱</text>
  20. </view>
  21. <view class="filter-item" :class="{'filter-active': currentTab === 'suitable'}" @tap="switchTab('suitable')">
  22. <text>✅ 适合</text>
  23. </view>
  24. <view class="filter-item" :class="{'filter-active': currentTab === 'unsuitable'}" @tap="switchTab('unsuitable')">
  25. <text>❌ 戒备</text>
  26. </view>
  27. <view class="filter-item" :class="{'filter-active': currentTab === 'all'}" @tap="switchTab('all')">
  28. <text>📋 全部</text>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 食材区(适合 / 戒备 / 全部 Tab 内容) -->
  33. <view class="food-section" v-if="currentTab !== 'recipe'">
  34. <!-- 模式切换(仅家庭模式展示) -->
  35. <view class="mode-bar" v-if="familyMode">
  36. <view class="mode-btn" :class="{'active': sortType === 'desc'}" @tap="setSort('desc')">
  37. <text>推荐值 ↓</text>
  38. </view>
  39. <view class="mode-btn" :class="{'active': sortType === 'asc'}" @tap="setSort('asc')">
  40. <text>推荐值 ↑</text>
  41. </view>
  42. </view>
  43. <!-- 搜索栏 -->
  44. <view class="search-bar">
  45. <input class="search-input" placeholder="搜索食材..." v-model="searchQuery" @confirm="searchFood" />
  46. <view class="search-btn" @tap="searchFood">搜索</view>
  47. </view>
  48. <!-- 分类标签 -->
  49. <view class="category-tabs">
  50. <view class="tab-item" :class="{'tab-active': activeCategory === 'all'}" @tap="switchCategory('all')">
  51. <text>全部</text>
  52. </view>
  53. <view class="tab-item" :class="{'tab-active': activeCategory === '蔬菜'}" @tap="switchCategory('蔬菜')">
  54. <text>蔬菜</text>
  55. </view>
  56. <view class="tab-item" :class="{'tab-active': activeCategory === '水果'}" @tap="switchCategory('水果')">
  57. <text>水果</text>
  58. </view>
  59. <view class="tab-item" :class="{'tab-active': activeCategory === '肉禽'}" @tap="switchCategory('肉禽')">
  60. <text>肉禽</text>
  61. </view>
  62. <view class="tab-item" :class="{'tab-active': activeCategory === '水产'}" @tap="switchCategory('水产')">
  63. <text>水产</text>
  64. </view>
  65. <view class="tab-item" :class="{'tab-active': activeCategory === '谷物'}" @tap="switchCategory('谷物')">
  66. <text>谷物</text>
  67. </view>
  68. <view class="tab-item" :class="{'tab-active': activeCategory === '蛋奶'}" @tap="switchCategory('蛋奶')">
  69. <text>蛋奶</text>
  70. </view>
  71. </view>
  72. <!-- 家庭总览(有一人戒备取全员最低值,全员适合取平均值) -->
  73. <view class="family-overview" v-if="currentView === 'family' && familyOverview && familyOverview.length > 0">
  74. <view class="overview-title">
  75. <text>🏠 家庭推荐概况(共 {{ familyMembers.length }} 人 · 一人戒备取最低,全员适合取平均)</text>
  76. </view>
  77. <view class="overview-item" v-for="(item, idx) in familyOverview" :key="idx">
  78. <view class="overview-header">
  79. <text class="food-name">{{ item.name }}</text>
  80. <view class="score-badge" :class="item.color">
  81. <text>{{ item.score }}</text>
  82. </view>
  83. </view>
  84. <view class="overview-detail">
  85. <text class="category-label">{{ item.category }}</text>
  86. <view class="member-scores">
  87. <text v-for="(s, mi) in item.memberScores" :key="mi"
  88. class="member-score"
  89. :class="s.score >= 0 ? 'score-green' : 'score-red'">
  90. {{ s.name }}:{{ s.score >= 0 ? '+' : '' }}{{ s.score }}
  91. </text>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 食材列表 -->
  97. <view class="food-list" v-if="currentView === 'personal'">
  98. <view class="food-card" v-for="(item, idx) in pagedFoods" :key="getFoodKey(item, idx)">
  99. <!-- 健康问卷个性化调整提示条:blocked 红 / warning 黄 / boost 绿(normal/空不渲染) -->
  100. <view v-if="item.adjustment === 'blocked'" class="health-adjust-bar">
  101. <text class="health-adjust-text health-adjust-blocked">⚠ 健康问卷不建议:{{ item.adjustmentReason }}</text>
  102. </view>
  103. <view v-else-if="item.adjustment === 'warning'" class="health-adjust-bar">
  104. <text class="health-adjust-text health-adjust-warning">注意:{{ item.adjustmentReason }}</text>
  105. </view>
  106. <view v-else-if="item.adjustment === 'boost'" class="health-adjust-bar">
  107. <text class="health-adjust-text health-adjust-boost">✓ 符合饮食习惯偏好</text>
  108. </view>
  109. <view class="food-left">
  110. <view class="ingredient-badge" :class="item.scoreClass">
  111. <text class="ingredient-badge-text">{{ idx + 1 }}</text>
  112. </view>
  113. <view class="food-info">
  114. <text class="food-name">{{ item.name }}</text>
  115. <view class="food-meta" v-if="item.category">
  116. <text class="meta-item">{{ item.category }}</text>
  117. </view>
  118. </view>
  119. </view>
  120. <view class="food-right">
  121. <text class="score-value" :class="item.scoreClass">{{ item.score || '--' }}</text>
  122. <view class="food-status-badge" :class="'badge-' + item.status">
  123. <text>{{ item.statusText }}</text>
  124. </view>
  125. </view>
  126. <!-- 健康问卷个性化调整提示条(diet.food.healthAdjustUi · B2):blocked 红条 / warning 黄条 / boost 绿条,normal 或缺失不渲染 -->
  127. <view class="adjustment-tip" v-if="item.adjustment === 'blocked'">
  128. <text class="adjustment-tip-text adjustment-tip-blocked">⚠ 健康问卷不建议:{{ item.adjustmentReason }}</text>
  129. </view>
  130. <view class="adjustment-tip" v-if="item.adjustment === 'warning'">
  131. <text class="adjustment-tip-text adjustment-tip-warning">注意:{{ item.adjustmentReason }}</text>
  132. </view>
  133. <view class="adjustment-tip" v-if="item.adjustment === 'boost'">
  134. <text class="adjustment-tip-text adjustment-tip-boost">✓ 符合饮食习惯偏好</text>
  135. </view>
  136. </view>
  137. </view>
  138. <view class="food-empty-state" v-if="!foodLoading && filteredFoods.length === 0 && currentView === 'personal'">
  139. <text class="food-empty-icon">🥗</text>
  140. <text class="food-empty-text">暂无匹配食材</text>
  141. </view>
  142. <view class="loading-state" v-if="foodLoading">
  143. <text class="loading-text">加载中...</text>
  144. </view>
  145. </view>
  146. <!-- 今日食谱区(recipe Tab 内容) -->
  147. <view v-if="currentTab === 'recipe'">
  148. <!-- 局部加载态:切换视角 / 刷新期间先清空旧数据,不残留上一视角食谱(AC-36,不整页遮罩) -->
  149. <view class="recipe-loading" v-if="recipeLoading">
  150. <text class="recipe-loading-text">正在加载今日食谱...</text>
  151. </view>
  152. <!-- 失败态:接口异常 → 明确提示 + 重试入口,文案与空态区分(AC-16 / AC-38) -->
  153. <view class="empty-state" v-else-if="recipeError">
  154. <view class="empty-icon-wrap"><text class="empty-icon">⚠️</text></view>
  155. <text class="empty-title">今日食谱加载失败</text>
  156. <text class="empty-sub">{{ recipeError }}</text>
  157. <view class="generate-btn" @tap="retryRecommendation">
  158. <text>点击重试</text>
  159. </view>
  160. </view>
  161. <!-- 无推荐状态 / 视角级空态(AC-04;不回退展示其它视角食谱) -->
  162. <view class="empty-state" v-else-if="!recommendation">
  163. <view class="empty-icon-wrap"><text class="empty-icon">🍽️</text></view>
  164. <text class="empty-title">今日菜单空着</text>
  165. <text class="empty-sub">点击生成今日三餐食谱</text>
  166. <view class="generate-btn" @tap="generateRecipe">
  167. <text>生成食谱</text>
  168. </view>
  169. </view>
  170. <!-- 整份空态:所有餐次菜数为 0(删除后可能出现,AC-35) -->
  171. <view class="empty-state" v-else-if="allMealsEmpty">
  172. <view class="empty-icon-wrap"><text class="empty-icon">🍽️</text></view>
  173. <text class="empty-title">今天的菜品都删完啦</text>
  174. <text class="empty-sub">点击重新生成今日三餐食谱</text>
  175. <view class="generate-btn" @tap="regenerate">
  176. <text>重新生成</text>
  177. </view>
  178. </view>
  179. <!-- 有推荐状态 -->
  180. <view v-else>
  181. <!-- 日期和状态 -->
  182. <view class="card header-card">
  183. <view class="card-accent"></view>
  184. <view class="card-body">
  185. <text class="date-text">{{ recommendation.date }}</text>
  186. <view class="status-badge" :class="'status-' + recommendation.status">
  187. <text>{{ statusText }}</text>
  188. </view>
  189. </view>
  190. </view>
  191. <!-- 菜品列表 -->
  192. <view class="meal-section" v-for="(meal, index) in meals" :key="index">
  193. <view class="meal-header">
  194. <view class="meal-icon-wrap" :class="'meal-icon-' + meal.type">
  195. <text class="meal-icon">{{ meal.icon }}</text>
  196. </view>
  197. <text class="meal-name">{{ meal.name }}</text>
  198. <text class="meal-count">{{ meal.participants }} 人份</text>
  199. <!-- D2① 只读状态提示:当前 N 菜 1 汤 / 未达标准,不静默补菜 -->
  200. <text class="meal-standard" v-if="dishStandard(meal)">{{ dishStandard(meal) }}</text>
  201. </view>
  202. <view class="dish-list">
  203. <!-- 餐次级空态:某餐菜数删至 0(AC-34),提供「重新生成」入口 -->
  204. <view class="meal-empty" v-if="meal.dishes.length === 0">
  205. <text class="meal-empty-text">本餐暂无菜品</text>
  206. <view class="meal-empty-btn" @tap="regenerate"><text>重新生成</text></view>
  207. </view>
  208. <view class="dish-item" v-for="(dish, dIndex) in meal.dishes" :key="dIndex">
  209. <view class="dish-header">
  210. <text class="dish-name">{{ dish.name }}</text>
  211. <text class="dish-cal">{{ dish.calories }} kcal</text>
  212. </view>
  213. <view class="dish-ingredients">
  214. <text class="ingredient-tag" v-for="(ing, iIndex) in dish.ingredients" :key="iIndex">
  215. {{ ing.name }} {{ ing.amount }}g
  216. </text>
  217. </view>
  218. <view class="dish-method">
  219. <text class="method-text">🍳 {{ dish.method }}</text>
  220. </view>
  221. <!-- D1①:收敛为单一「🗑 删除」;按钮组合由 dishActions 数据位驱动,便于回退 -->
  222. <view class="dish-actions" v-if="dishActions === 'delete-only'">
  223. <view class="action-btn delete-btn"
  224. :class="{'action-btn-disabled': isDeleting(meal.name, dIndex)}"
  225. @tap="deleteDish(meal.name, dIndex)">🗑 删除</view>
  226. </view>
  227. </view>
  228. </view>
  229. </view>
  230. <!-- 营养汇总 -->
  231. <view class="card nutrition-card">
  232. <view class="card-accent"></view>
  233. <view class="card-body">
  234. <text class="card-title">今日营养汇总</text>
  235. <view class="nutrition-grid">
  236. <view class="nutrition-item">
  237. <text class="nutrition-value">{{ summary.calories }}</text>
  238. <text class="nutrition-unit">kcal</text>
  239. <text class="nutrition-label">热量</text>
  240. </view>
  241. <view class="nutrition-item">
  242. <text class="nutrition-value">{{ summary.protein }}</text>
  243. <text class="nutrition-unit">g</text>
  244. <text class="nutrition-label">蛋白质</text>
  245. </view>
  246. <view class="nutrition-item">
  247. <text class="nutrition-value">{{ summary.carbs }}</text>
  248. <text class="nutrition-unit">g</text>
  249. <text class="nutrition-label">碳水</text>
  250. </view>
  251. <view class="nutrition-item">
  252. <text class="nutrition-value">{{ summary.fat }}</text>
  253. <text class="nutrition-unit">g</text>
  254. <text class="nutrition-label">脂肪</text>
  255. </view>
  256. </view>
  257. </view>
  258. </view>
  259. <!-- 操作按钮 -->
  260. <view class="action-area">
  261. <view class="btn-row">
  262. <view class="btn-secondary" @tap="regenerate">重新生成</view>
  263. <view class="btn-primary" @tap="completeRecipe" v-if="recommendation.status !== 'completed'">
  264. 标记完成
  265. </view>
  266. </view>
  267. </view>
  268. </view>
  269. </view>
  270. </scroll-view>
  271. <!-- 共餐人选择弹层(需求7:家庭总览「生成食谱」先选共餐人,确认后生成) -->
  272. <view class="participant-mask" v-if="showParticipantPicker" @tap="cancelParticipants">
  273. <view class="participant-sheet" @tap.stop>
  274. <view class="participant-sheet-header">
  275. <text class="participant-sheet-title">选择共餐人</text>
  276. <text class="participant-sheet-sub">为今天的食谱挑选一起用餐的家庭成员</text>
  277. </view>
  278. <view class="participant-list">
  279. <view class="participant-item" v-for="member in pendingParticipantOptions" :key="member.id"
  280. :class="{'participant-item-selected': member.selected}"
  281. @tap="toggleParticipant(member)">
  282. <view class="participant-check" v-if="member.selected">
  283. <text class="participant-check-icon">✓</text>
  284. </view>
  285. <text class="participant-name">{{ member.nickname }}</text>
  286. </view>
  287. <view class="participant-empty" v-if="pendingParticipantOptions.length === 0">
  288. <text class="participant-empty-text">暂无家庭成员可选</text>
  289. </view>
  290. </view>
  291. <view class="participant-actions">
  292. <view class="participant-btn participant-btn-cancel" @tap="cancelParticipants">
  293. <text>取消</text>
  294. </view>
  295. <view class="participant-btn participant-btn-confirm" @tap="confirmParticipants">
  296. <text>确认生成({{ pendingParticipantIds.length }} 人)</text>
  297. </view>
  298. </view>
  299. </view>
  300. </view>
  301. </view>
  302. </template>
  303. <script>
  304. import { getDietRecommendation, generateDietRecommendation, completeDietRecommendation, regenerateDietRecommendation, updateDietRecommendation } from '@/utils/api.js'
  305. import config from '@/config.js'
  306. import MemberSelector from '@/components/MemberSelector.vue'
  307. import { memberIdOf } from '@/utils/memberNormalize.js'
  308. import fontScaleMixin from '@/mixins/font-scale.js'
  309. export default {
  310. mixins: [fontScaleMixin],
  311. components: { MemberSelector },
  312. data() {
  313. return {
  314. recommendation: null,
  315. meals: [],
  316. summary: {},
  317. loading: false,
  318. // ===== 推荐食材(原「食材查询」页迁移)=====
  319. searchQuery: '',
  320. activeCategory: 'all',
  321. filterType: 'suitable',
  322. sortType: 'desc',
  323. currentView: 'personal',
  324. currentTab: 'recipe',
  325. visibleCount: 20,
  326. memberSelectLocked: false,
  327. allFoods: [],
  328. familyData: null,
  329. familyMembers: [],
  330. familyOverview: [],
  331. currentMemberId: null,
  332. memberList: [],
  333. foodLoading: false,
  334. refreshing: false,
  335. // ===== 共餐人选择(需求7:家庭总览生成食谱先选共餐人)=====
  336. showParticipantPicker: false,
  337. pendingParticipantIds: [],
  338. // ===== 今日食谱视角隔离 / 删除交互 / 空·加载·失败三态(本轮增量)=====
  339. recipeLoading: false,
  340. recipeError: '',
  341. deleting: false,
  342. deletingKey: '',
  343. // D1① 可回退数据位:'delete-only'(当前)/ 'replace-and-delete'(备选,改此值 + 模板分支即可)
  344. dishActions: 'delete-only'
  345. }
  346. },
  347. computed: {
  348. statusText: function() {
  349. var map = {
  350. 'pending': '待确认',
  351. 'accepted': '已接受',
  352. 'completed': '已完成'
  353. }
  354. return map[this.recommendation && this.recommendation.status] || '待确认'
  355. },
  356. familyMode: function() {
  357. return this.currentView === 'family'
  358. },
  359. filteredFoods: function() {
  360. var self = this
  361. var result = self.currentView === 'family'
  362. ? self.familyOverview
  363. : self.allFoods
  364. // 分类筛选(食材分类为中文,用关键词集合匹配不同数据源的分类命名)
  365. if (self.activeCategory !== 'all') {
  366. var keywords = self.getCategoryKeywords(self.activeCategory)
  367. result = result.filter(function(f) {
  368. if (!f.category) return false
  369. for (var ki = 0; ki < keywords.length; ki++) {
  370. if (f.category.indexOf(keywords[ki]) !== -1) return true
  371. }
  372. return false
  373. })
  374. }
  375. // 搜索筛选
  376. if (self.searchQuery) {
  377. result = result.filter(function(f) {
  378. return (f.name && f.name.indexOf(self.searchQuery) !== -1) ||
  379. (f.category && f.category.indexOf(self.searchQuery) !== -1)
  380. })
  381. }
  382. // 适合/戒备筛选(戒备 = 推荐指数 < 0)
  383. if (self.filterType === 'suitable') {
  384. result = result.filter(function(f) {
  385. return f.score >= 0
  386. })
  387. } else if (self.filterType === 'unsuitable') {
  388. result = result.filter(function(f) {
  389. return f.score < 0
  390. })
  391. }
  392. // 排序(戒备模式默认升序,见 setFilter)
  393. var sortFn = self.sortType === 'asc'
  394. ? function(a, b) { return (a.score || 0) - (b.score || 0) }
  395. : function(a, b) { return (b.score || 0) - (a.score || 0) }
  396. // 健康问卷个性化调整(B3):suitable Tab 中 blocked 项整体排到列表末尾(保持可见不置顶;组内各按既有分值序)
  397. if (self.filterType === 'suitable') {
  398. var nonBlocked = []
  399. var blocked = []
  400. result.forEach(function(f) {
  401. if (f.adjustment === 'blocked') {
  402. blocked.push(f)
  403. } else {
  404. nonBlocked.push(f)
  405. }
  406. })
  407. result = nonBlocked.slice().sort(sortFn).concat(blocked.slice().sort(sortFn))
  408. } else {
  409. result = result.slice().sort(sortFn)
  410. }
  411. // 健康问卷个性化调整分组(diet.food.healthAdjustUi · B3):suitable Tab 中 blocked 项整体排到列表末尾
  412. // (保持可见但不置顶,组内仍按既有分值排序,stable 分组;unsuitable / all 位置不变、仅带提示条)
  413. if (self.filterType === 'suitable') {
  414. result = result.filter(function(f) { return f.adjustment !== 'blocked' })
  415. .concat(result.filter(function(f) { return f.adjustment === 'blocked' }))
  416. }
  417. return result
  418. },
  419. pagedFoods: function() {
  420. return this.filteredFoods.slice(0, this.visibleCount)
  421. },
  422. // 整份食谱空态:所有餐次菜数为 0(AC-35)
  423. allMealsEmpty: function() {
  424. var meals = this.meals || []
  425. if (meals.length === 0) return true
  426. for (var i = 0; i < meals.length; i++) {
  427. if (meals[i].dishes && meals[i].dishes.length > 0) return false
  428. }
  429. return true
  430. },
  431. // 共餐人选择弹层列表(原始 memberList 归一化为 {id, nickname, selected},避免模板内方法调用)
  432. pendingParticipantOptions: function() {
  433. var self = this
  434. var ids = self.pendingParticipantIds || []
  435. return (self.memberList || []).map(function(m) {
  436. var id = memberIdOf(m)
  437. return {
  438. id: id,
  439. nickname: m.nickname || m.roleLabel || '成员',
  440. selected: ids.indexOf(id) >= 0
  441. }
  442. })
  443. }
  444. },
  445. onLoad: function(options) {
  446. var opts = options || {}
  447. this.currentMemberId = opts.memberId ? parseInt(opts.memberId) : null
  448. this.loadRecommendation()
  449. this.loadMembers()
  450. this.loadFamilyData()
  451. this.loadFoods()
  452. },
  453. onShow: function() {
  454. this.loadRecommendation()
  455. },
  456. methods: {
  457. goBack: function() {
  458. uni.navigateBack()
  459. },
  460. // 按当前视角加载今日食谱:view_key 同源、局部 loading 先清空防串数据(AC-01/03/09/36)
  461. loadRecommendation: function() {
  462. var self = this
  463. var viewKey = self.buildViewKey()
  464. self.recipeError = ''
  465. // 视角尚未就绪(首次 onLoad 时 loadRecommendation 先于异步 loadMembers,personal 且无 currentMemberId):
  466. // 不发请求、清空残留,由 loadMembers 成功回调补发一次
  467. if (!viewKey) {
  468. self.recipeLoading = false
  469. self.recommendation = null
  470. self.meals = []
  471. self.summary = {}
  472. return Promise.resolve()
  473. }
  474. var today = self.formatDate(new Date())
  475. self.recipeLoading = true
  476. self.recommendation = null
  477. self.meals = []
  478. self.summary = {}
  479. return getDietRecommendation({ date: today, view_key: viewKey }).then(function(res) {
  480. self.recipeLoading = false
  481. var d = res && res.data
  482. if (d && d.id) {
  483. self.recommendation = d
  484. self.parseMenu(d.menu)
  485. var ns = d.nutritionSummary
  486. self.summary = ns ? (typeof ns === 'string' ? JSON.parse(ns) : ns) : {}
  487. } else {
  488. self.recommendation = null
  489. self.meals = []
  490. self.summary = {}
  491. }
  492. }).catch(function(err) {
  493. self.recipeLoading = false
  494. self.recommendation = null
  495. self.meals = []
  496. self.summary = {}
  497. self.recipeError = (err && err.message) || '加载失败,请重试'
  498. })
  499. },
  500. // 视角键生成(K1 可回退的唯一落点):家庭总览固定 'family';个人/成员 'member:<id>';
  501. // loadMembers 未完成、memberList 为空且无 currentMemberId 时返回 null 且不发请求。
  502. // 后端把 view_key 当不透明字符串,语义全在此方法一处。
  503. buildViewKey: function() {
  504. if (this.currentView === 'family') return 'family'
  505. if (this.currentView === 'personal') {
  506. if (this.currentMemberId !== null && this.currentMemberId !== undefined) {
  507. return 'member:' + this.currentMemberId
  508. }
  509. return null
  510. }
  511. return null
  512. },
  513. // 失败态重试:按当前视角重新加载,不重置用户当前视角
  514. retryRecommendation: function() {
  515. this.loadRecommendation()
  516. },
  517. parseMenu: function(menuJson) {
  518. try {
  519. var menu = (typeof menuJson === 'string') ? JSON.parse(menuJson || '{}') : (menuJson || {})
  520. this.meals = []
  521. var mealMap = {
  522. 'breakfast': { name: '早餐', icon: '🌅' },
  523. 'lunch': { name: '午餐', icon: '☀️' },
  524. 'dinner': { name: '晚餐', icon: '🌙' }
  525. }
  526. if (menu.meals) {
  527. var self = this
  528. menu.meals.forEach(function(meal) {
  529. var config = mealMap[meal.type] || { name: meal.name || meal.type, icon: '🍽️' }
  530. var dishes = (meal.dishes || []).map(function(dish) {
  531. var ing = (dish.ingredients || []).map(function(item) {
  532. return { name: item.name, amount: item.amount || item.grams || 0 }
  533. })
  534. return {
  535. name: dish.name,
  536. // 汤/菜可识别:dish.type = dish|soup,存量无 type 时默认 'dish'(AC-25)
  537. type: dish.type || 'dish',
  538. calories: dish.calories || (dish.nutrition && dish.nutrition.calories) || 0,
  539. ingredients: ing,
  540. method: dish.method || dish.cooking_method || ''
  541. }
  542. })
  543. self.meals.push({
  544. name: config.name,
  545. icon: config.icon,
  546. type: meal.type,
  547. participants: meal.participants || 1,
  548. dishes: dishes
  549. })
  550. })
  551. }
  552. } catch (e) {
  553. console.error('解析菜单失败', e)
  554. }
  555. },
  556. generateRecipe: function() {
  557. var self = this
  558. // 家庭总览:先弹共餐人多选,确认后再生成(需求7)
  559. if (self.currentView === 'family') {
  560. self.openParticipantPicker()
  561. return
  562. }
  563. // 个人/成员:只对当前选中人生成(participant_member_ids 只传当前成员)
  564. self.loading = true
  565. var participantIds = self.currentMemberId ? [self.currentMemberId] : []
  566. uni.showLoading({ title: '正在生成食谱...' })
  567. return generateDietRecommendation({
  568. date: self.formatDate(new Date()),
  569. meal_type: 'all',
  570. participant_member_ids: JSON.stringify(participantIds),
  571. view_key: self.buildViewKey()
  572. }).then(function(res) {
  573. self.loading = false
  574. uni.hideLoading()
  575. if (res && res.data && res.data.id) {
  576. uni.showToast({ title: '食谱生成成功', icon: 'success' })
  577. self.loadRecommendation()
  578. } else {
  579. uni.showToast({ title: (res && res.message) || '生成失败', icon: 'none' })
  580. }
  581. }).catch(function() {
  582. self.loading = false
  583. uni.hideLoading()
  584. uni.showToast({ title: '生成失败', icon: 'none' })
  585. })
  586. },
  587. // 打开共餐人多选弹层(默认勾选全部家庭成员)
  588. openParticipantPicker: function() {
  589. var self = this
  590. var ids = []
  591. var members = self.memberList || []
  592. for (var i = 0; i < members.length; i++) {
  593. var id = memberIdOf(members[i])
  594. if (id !== null && id !== undefined && ids.indexOf(id) < 0) ids.push(id)
  595. }
  596. self.pendingParticipantIds = ids
  597. self.showParticipantPicker = true
  598. },
  599. // 多选切换共餐人
  600. toggleParticipant: function(member) {
  601. var self = this
  602. if (!member) return
  603. var id = (member.id !== null && member.id !== undefined) ? member.id : memberIdOf(member)
  604. if (id === null || id === undefined) return
  605. var ids = (self.pendingParticipantIds || []).slice()
  606. var idx = ids.indexOf(id)
  607. if (idx >= 0) {
  608. ids.splice(idx, 1)
  609. } else {
  610. ids.push(id)
  611. }
  612. self.pendingParticipantIds = ids
  613. },
  614. // 确认共餐人 → 生成食谱(participant_member_ids = 所选共餐人)
  615. confirmParticipants: function() {
  616. var self = this
  617. self.showParticipantPicker = false
  618. self.loading = true
  619. generateDietRecommendation({
  620. date: self.formatDate(new Date()),
  621. meal_type: 'all',
  622. participant_member_ids: JSON.stringify(self.pendingParticipantIds || []),
  623. view_key: self.buildViewKey()
  624. }).then(function(res) {
  625. self.loading = false
  626. if (res && res.data && res.data.id) {
  627. uni.showToast({ title: '食谱生成成功', icon: 'success' })
  628. self.loadRecommendation()
  629. } else {
  630. uni.showToast({ title: (res && res.message) || '生成失败', icon: 'none' })
  631. }
  632. }).catch(function() {
  633. self.loading = false
  634. uni.showToast({ title: '生成失败', icon: 'none' })
  635. })
  636. },
  637. // 取消共餐人选择
  638. cancelParticipants: function() {
  639. this.showParticipantPicker = false
  640. this.pendingParticipantIds = []
  641. },
  642. // D2① 只读菜数状态:当前 X 菜 Y 汤 / 未达标准;与删除逻辑解耦,绝不触发补菜请求
  643. dishStandard: function(meal) {
  644. if (!meal || (meal.type !== 'lunch' && meal.type !== 'dinner')) return ''
  645. var dishes = meal.dishes || []
  646. var mainCount = 0
  647. var soupCount = 0
  648. for (var i = 0; i < dishes.length; i++) {
  649. if (dishes[i].type === 'soup') soupCount += 1
  650. else mainCount += 1
  651. }
  652. var n = meal.participants || 1
  653. var expected = 4 + Math.max(0, n - 3)
  654. var reached = mainCount >= expected && soupCount >= 1
  655. var text = '当前 ' + mainCount + ' 菜 ' + soupCount + ' 汤'
  656. return reached ? (text + ' · 达标') : (text + ' / 未达标准')
  657. },
  658. // 防重复点击:删除中的那一道菜按钮禁用(AC-37)
  659. isDeleting: function(mealName, dishIndex) {
  660. return this.deleting && this.deletingKey === (mealName + ':' + dishIndex)
  661. },
  662. // 从 this.meals 组装「移除目标菜」后的整份 menu_json(不含 icon 等纯展示字段,避免结构漂移)
  663. buildMenuPayload: function(mealName, dishIndex) {
  664. var payloadMeals = []
  665. var meals = this.meals || []
  666. for (var i = 0; i < meals.length; i++) {
  667. var meal = meals[i]
  668. var dishes = []
  669. var src = meal.dishes || []
  670. for (var j = 0; j < src.length; j++) {
  671. if (meal.name === mealName && j === dishIndex) continue
  672. var d = src[j]
  673. var ings = []
  674. var srcIng = d.ingredients || []
  675. for (var k = 0; k < srcIng.length; k++) {
  676. ings.push({ name: srcIng[k].name, amount: srcIng[k].amount || 0 })
  677. }
  678. dishes.push({
  679. name: d.name,
  680. type: d.type || 'dish',
  681. calories: d.calories || 0,
  682. ingredients: ings,
  683. method: d.method || ''
  684. })
  685. }
  686. payloadMeals.push({
  687. type: meal.type,
  688. name: meal.name,
  689. participants: meal.participants || 1,
  690. dishes: dishes
  691. })
  692. }
  693. return JSON.stringify({ meals: payloadMeals })
  694. },
  695. // D1① 单一主操作「🗑 删除」:复用 POST /api/diet/recommendation/update 整份覆盖。
  696. // 删除与补菜完全解耦(不调任何补菜 / 重新生成接口);失败保留原数据可重试(AC-13/15/16/18)
  697. deleteDish: function(mealName, dishIndex) {
  698. var self = this
  699. if (self.deleting) return
  700. if (!self.recommendation || !self.recommendation.id) return
  701. var targetMeal = null
  702. for (var i = 0; i < (self.meals || []).length; i++) {
  703. if (self.meals[i].name === mealName) {
  704. targetMeal = self.meals[i]
  705. break
  706. }
  707. }
  708. if (!targetMeal || !targetMeal.dishes || dishIndex < 0 || dishIndex >= targetMeal.dishes.length) return
  709. self.deleting = true
  710. self.deletingKey = mealName + ':' + dishIndex
  711. uni.showLoading({ title: '删除中...' })
  712. var payload = self.buildMenuPayload(mealName, dishIndex)
  713. return updateDietRecommendation({ id: self.recommendation.id, menu_json: payload }).then(function(res) {
  714. self.deleting = false
  715. self.deletingKey = ''
  716. uni.hideLoading()
  717. if (!res) {
  718. uni.showToast({ title: '删除失败,请重试', icon: 'none' })
  719. return
  720. }
  721. targetMeal.dishes.splice(dishIndex, 1)
  722. uni.showToast({ title: '已删除', icon: 'success' })
  723. }).catch(function(err) {
  724. self.deleting = false
  725. self.deletingKey = ''
  726. uni.hideLoading()
  727. uni.showToast({ title: (err && err.message) || '删除失败,请重试', icon: 'none' })
  728. })
  729. },
  730. // D1 可回退入口:当前 dishActions='delete-only' 时模板不渲染,与 deleteDish 完全独立、互不引用。
  731. // 若产品改选「双按钮」,只需把 dishActions 切为 'replace-and-delete' 并在模板补分支。
  732. replaceDish: function(mealName, dishIndex) {
  733. uni.showToast({ title: '该功能已下线,请用「删除」或「重新生成」', icon: 'none' })
  734. },
  735. regenerate: function() {
  736. var self = this
  737. if (!self.recommendation || !self.recommendation.id) return
  738. var regData = { id: self.recommendation.id }
  739. uni.showLoading({ title: '重新生成中...' })
  740. regenerateDietRecommendation(regData).then(function(res) {
  741. uni.hideLoading()
  742. if (res && res.data && res.data.id) {
  743. self.loadRecommendation()
  744. } else {
  745. uni.showToast({ title: (res && res.message) || '重新生成失败', icon: 'none' })
  746. }
  747. }).catch(function() {
  748. uni.hideLoading()
  749. uni.showToast({ title: '重新生成失败', icon: 'none' })
  750. })
  751. },
  752. completeRecipe: function() {
  753. var self = this
  754. if (!self.recommendation) return
  755. completeDietRecommendation({ id: self.recommendation.id }).then(function() {
  756. uni.showToast({ title: '已标记完成', icon: 'success' })
  757. self.loadRecommendation()
  758. })
  759. },
  760. formatDate: function(date) {
  761. var d = date
  762. var m = (d.getMonth() + 1).toString().padStart(2, '0')
  763. var day = d.getDate().toString().padStart(2, '0')
  764. return d.getFullYear() + '-' + m + '-' + day
  765. },
  766. // ===== 推荐食材(原「食材查询」页迁移)=====
  767. getFoodKey: function(item, idx) {
  768. return item.id || idx
  769. },
  770. loadMembers: function() {
  771. var self = this
  772. var token = uni.getStorageSync('token')
  773. if (!token) return
  774. uni.request({
  775. // config 在契约测试桩下可能为 undefined(stub 仅提供 default 键),防御性取址
  776. url: ((config && config.API_BASE_URL) || '') + '/api/food/recommendation/members',
  777. method: 'POST',
  778. header: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token },
  779. success: function(res) {
  780. if (res.data && res.data.code === 200 && res.data.data) {
  781. self.memberList = res.data.data
  782. // 默认选中「个人」= isSelf 行(统一身份键 familyMemberId,不再用 userId)。
  783. // 仅限首次 onLoad:切到家庭总览(switchView('family') 置 memberSelectLocked)后,
  784. // loadMembers 不得再自动默认选「个人」,个人/成员 chip 保持不高亮。
  785. if (!self.memberSelectLocked && !self.currentMemberId && self.memberList.length > 0) {
  786. var defaultMember = self.getSelfRow() || self.memberList[0]
  787. self.currentMemberId = memberIdOf(defaultMember)
  788. }
  789. // onLoad 先 loadRecommendation 后异步 loadMembers:此时个人视角键才就绪,补发一次(AC-01/10)
  790. self.loadRecommendation()
  791. }
  792. }
  793. })
  794. },
  795. loadFoods: function() {
  796. var self = this
  797. var token = uni.getStorageSync('token')
  798. if (!token) return
  799. self.foodLoading = true
  800. var url = config.API_BASE_URL + '/api/health/foods'
  801. var data = {}
  802. if (self.currentMemberId) {
  803. data.memberId = self.currentMemberId
  804. }
  805. uni.request({
  806. url: url,
  807. method: 'POST',
  808. data: data,
  809. header: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token },
  810. success: function(res) {
  811. self.foodLoading = false
  812. if (res.data && res.data.code === 200 && res.data.data) {
  813. self.allFoods = res.data.data.map(function(f) {
  814. f.scoreClass = self.getScoreClass(f.score)
  815. f.statusText = self.getStatusText(f.score)
  816. f.status = f.score >= 0 ? 'suitable' : 'unsuitable'
  817. return f
  818. })
  819. }
  820. },
  821. fail: function() {
  822. self.foodLoading = false
  823. }
  824. })
  825. },
  826. loadFamilyData: function() {
  827. var self = this
  828. var token = uni.getStorageSync('token')
  829. if (!token) return
  830. var familyId = uni.getStorageSync('familyId')
  831. if (!familyId) return
  832. uni.request({
  833. url: config.API_BASE_URL + '/api/health/foods/by-family',
  834. method: 'POST',
  835. header: { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token },
  836. success: function(res) {
  837. if (res.data && res.data.code === 200 && res.data.data) {
  838. self.familyData = res.data.data
  839. self.familyMembers = Object.keys(res.data.data.byMember || {}).map(function(key) {
  840. return { userId: key, nickname: res.data.data.memberNames[key] || '成员' }
  841. })
  842. // 优先使用后端持久化总览(overview):overviewScore = 分段聚合展示值
  843. // (有成员<0取全员最低值、全员>=0取平均值);旧版后端无该字段时回退 minIndexScore
  844. if (res.data.data.overview && res.data.data.overview.length > 0) {
  845. self.familyOverview = res.data.data.overview.map(function(o) {
  846. var score = (o.overviewScore !== undefined && o.overviewScore !== null)
  847. ? o.overviewScore : o.minIndexScore
  848. return {
  849. id: o.foodId,
  850. name: o.foodName,
  851. category: o.category,
  852. score: score,
  853. scoreClass: self.getScoreClass(score),
  854. color: self.getScoreClass(score),
  855. statusText: self.getStatusText(score),
  856. status: score >= 0 ? 'suitable' : 'unsuitable',
  857. aggregateRule: o.aggregateRule || '',
  858. minScore: o.minIndexScore,
  859. memberCount: o.memberCount || 0,
  860. memberScores: (o.memberScores || []).map(function(s) {
  861. return { name: s.nickname || '', score: s.score }
  862. })
  863. }
  864. })
  865. } else {
  866. // 后端未返回 overview 时的降级路径:前端按同一分段聚合口径计算
  867. self.buildFamilyOverview(res.data.data.total || res.data.data.totalList, res.data.data.byMember, res.data.data.memberNames)
  868. }
  869. }
  870. }
  871. })
  872. },
  873. buildFamilyOverview: function(totalList, byMember, memberNames) {
  874. var self = this
  875. var overview = []
  876. var list = totalList || []
  877. for (var i = 0; i < list.length; i++) {
  878. var food = list[i]
  879. var memberScores = []
  880. for (var j = 0; j < self.familyMembers.length; j++) {
  881. var member = self.familyMembers[j]
  882. var memberFoods = byMember[member.userId]
  883. if (memberFoods) {
  884. for (var k = 0; k < memberFoods.length; k++) {
  885. if (memberFoods[k].foodId === food.id) {
  886. var score = memberFoods[k].indexScore || 0
  887. memberScores.push({ name: member.nickname, score: score })
  888. break
  889. }
  890. }
  891. }
  892. }
  893. // 降级路径:与后端同口径 —— 有人 < 0 取全员最低值,全员 >= 0 取平均值(四舍五入)
  894. if (memberScores.length > 0) {
  895. var minScore = memberScores[0].score
  896. var sum = 0
  897. var hasNegative = false
  898. for (var mi = 0; mi < memberScores.length; mi++) {
  899. var s = memberScores[mi].score
  900. if (s < minScore) minScore = s
  901. sum += s
  902. if (s < 0) hasNegative = true
  903. }
  904. var score = hasNegative ? minScore : Math.round(sum / memberScores.length)
  905. overview.push({
  906. id: food.id,
  907. name: food.name,
  908. category: food.category,
  909. score: score,
  910. scoreClass: self.getScoreClass(score),
  911. color: self.getScoreClass(score),
  912. statusText: self.getStatusText(score),
  913. status: score >= 0 ? 'suitable' : 'unsuitable',
  914. aggregateRule: hasNegative ? 'MIN_NEGATIVE' : 'AVG_POSITIVE',
  915. minScore: minScore,
  916. memberCount: memberScores.length,
  917. memberScores: memberScores
  918. })
  919. }
  920. }
  921. // 按总览展示值排序(从高到低)
  922. overview.sort(function(a, b) {
  923. return b.score - a.score
  924. })
  925. self.familyOverview = overview
  926. },
  927. getScoreClass: function(score) {
  928. if (score === undefined || score === null) return 'neutral'
  929. if (score >= 0) return 'good'
  930. return 'bad'
  931. },
  932. getStatusText: function(score) {
  933. if (score === undefined || score === null) return '未知'
  934. if (score >= 0) return '适合'
  935. return '戒备'
  936. },
  937. searchFood: function() {
  938. // 搜索由 computed 自动处理
  939. },
  940. switchCategory: function(category) {
  941. this.activeCategory = category
  942. this.visibleCount = 20
  943. },
  944. getCategoryKeywords: function(category) {
  945. var map = {
  946. '蔬菜': ['蔬菜'],
  947. '水果': ['水果'],
  948. '肉禽': ['肉类', '肉禽'],
  949. '水产': ['水产', '水产品'],
  950. '谷物': ['谷物', '主食', '全谷物'],
  951. '蛋奶': ['蛋类', '蛋奶', '乳制品']
  952. }
  953. return map[category] || []
  954. },
  955. setFilter: function(type) {
  956. this.filterType = type
  957. // 适合/全部:倒序,推荐值大的排前面;戒备:升序,推荐值小的排前面
  958. if (type === 'unsuitable') {
  959. this.sortType = 'asc'
  960. } else {
  961. this.sortType = 'desc'
  962. }
  963. this.visibleCount = 20
  964. },
  965. setSort: function(type) {
  966. this.sortType = type
  967. },
  968. switchTab: function(tab) {
  969. // 4 Tab:今日食谱 | 适合 | 戒备 | 全部;切 Tab 重置分页(请求式上滑加载从首批重新开始)
  970. this.currentTab = tab
  971. this.visibleCount = 20
  972. if (tab !== 'recipe') {
  973. this.filterType = tab
  974. this.sortType = tab === 'unsuitable' ? 'asc' : 'desc'
  975. } else {
  976. // 切回「今日食谱」按当前视角重载,避免展示切换前残留(AC-09)
  977. this.loadRecommendation()
  978. }
  979. },
  980. loadMore: function() {
  981. // 上滑触底加载更多:未达全量末尾时每批追加 20 条,到达末尾自动停止
  982. if (this.visibleCount < this.filteredFoods.length) {
  983. this.visibleCount += 20
  984. }
  985. },
  986. switchView: function(view) {
  987. this.currentView = view
  988. if (view === 'family') {
  989. // 家庭总览 ↔ 个人/成员互斥:清空成员选中态(个人/成员 chip 不高亮);
  990. // 并锁定「不再自动默认选个人」,loadMembers 再次加载时不回灌默认选中
  991. this.currentMemberId = null
  992. this.memberSelectLocked = true
  993. }
  994. // 视角切换后按新 buildViewKey() 重载今日食谱(AC-03)
  995. this.loadRecommendation()
  996. },
  997. // 取「本人」行(isSelf):后端已按 user_id 折叠,此处仅取第一行 isSelf
  998. getSelfRow: function() {
  999. var members = this.memberList || []
  1000. for (var i = 0; i < members.length; i++) {
  1001. if (members[i] && members[i].isSelf) return members[i]
  1002. }
  1003. return null
  1004. },
  1005. switchMember: function(member) {
  1006. // 统一身份键:familyMemberId(= family_members.id);userId 仅用于折叠,不再作主键
  1007. this.currentMemberId = memberIdOf(member)
  1008. this.currentView = 'personal'
  1009. this.visibleCount = 20
  1010. this.loadFoods()
  1011. // 成员切换联动今日食谱(AC-01/02),仍保留 loadFoods + visibleCount=20 既有行为
  1012. this.loadRecommendation()
  1013. },
  1014. onRefresh: function() {
  1015. var self = this
  1016. self.refreshing = true
  1017. self.loadFoods()
  1018. self.loadFamilyData()
  1019. // 下拉刷新按当前视角重载今日食谱(AC-09)
  1020. self.loadRecommendation()
  1021. setTimeout(function() {
  1022. self.refreshing = false
  1023. }, 500)
  1024. }
  1025. }
  1026. }
  1027. </script>
  1028. <style scoped lang="scss">
  1029. .recommendation-page {
  1030. /* 翻页失效根因修复:父容器必须是「确定高度」而不是由内容撑开的 min-height。
  1031. 原 min-height:100vh 下 scroll-view 会随内容一起长高,退化为页面级滚动,
  1032. @scrolltolower 永不触发 → visibleCount 卡在 20 → 下滑不追加食材。
  1033. 页面内内容全部在 scroll-view 内部,弹层为 position:fixed,故固定 100vh 安全。 */
  1034. height: 100vh;
  1035. background-color: $app-bg;
  1036. display: flex;
  1037. flex-direction: column;
  1038. }
  1039. .nav-placeholder {
  1040. width: 80rpx;
  1041. }
  1042. .content {
  1043. /* 保留既有 flex 布局;height:0 给出确定基准,min-height:0 阻止 min-content 把
  1044. 滚动容器撑高。配合父级 height:100vh,flex:1 才能算出确定高度,让
  1045. scroll-y 形成内部滚动视口并派发 @scrolltolower(H5 / 小程序通用)。 */
  1046. flex: 1;
  1047. height: 0;
  1048. min-height: 0;
  1049. padding: $uni-space-page;
  1050. box-sizing: border-box;
  1051. width: 100%;
  1052. overflow: hidden;
  1053. }
  1054. .empty-state { display: flex; flex-direction: column; align-items: center; padding: 120rpx 40rpx; }
  1055. .empty-icon-wrap {
  1056. width: 160rpx; height: 160rpx; border-radius: 50%;
  1057. background: linear-gradient(135deg, $dim-body, $dim-body-light);
  1058. display: flex; align-items: center; justify-content: center;
  1059. box-shadow: 0 10rpx 30rpx rgba(255, 140, 66, 0.3);
  1060. margin-bottom: 40rpx;
  1061. }
  1062. .empty-icon { font-size: calc($uni-font-size-5xl * var(--font-scale, 1)); }
  1063. .empty-title { font-size: calc(34rpx * var(--font-scale, 1)); font-weight: 700; color: $facade-text-strong; display: block; margin-bottom: 16rpx; }
  1064. .empty-sub { font-size: calc(26rpx * var(--font-scale, 1)); color: $facade-text-muted; display: block; margin-bottom: 48rpx; }
  1065. .generate-btn {
  1066. background: linear-gradient(135deg, $dim-body, $dim-body-light);
  1067. color: $app-surface; padding: 28rpx 60rpx; border-radius: 999rpx;
  1068. font-size: calc(30rpx * var(--font-scale, 1)); font-weight: 600;
  1069. box-shadow: 0 6rpx 20rpx rgba(255, 140, 66, 0.25);
  1070. }
  1071. .card {
  1072. display: flex;
  1073. background-color: $app-surface;
  1074. border-radius: 24rpx;
  1075. margin-bottom: $uni-space-lg;
  1076. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
  1077. overflow: hidden;
  1078. }
  1079. .card-accent { width: 8rpx; background: linear-gradient(180deg, $dim-body, $dim-body-light); flex-shrink: 0; }
  1080. .card-body {
  1081. flex: 1;
  1082. padding: $uni-space-page;
  1083. }
  1084. .card-title {
  1085. font-size: calc(30rpx * var(--font-scale, 1));
  1086. font-weight: 600;
  1087. color: $facade-text-strong;
  1088. margin-bottom: 20rpx;
  1089. display: block;
  1090. }
  1091. .header-card .card-body {
  1092. display: flex;
  1093. justify-content: space-between;
  1094. align-items: center;
  1095. }
  1096. .date-text {
  1097. font-size: calc(28rpx * var(--font-scale, 1));
  1098. color: $facade-text-strong;
  1099. font-weight: 500;
  1100. }
  1101. .status-badge {
  1102. padding: 8rpx 20rpx;
  1103. border-radius: 24rpx;
  1104. font-size: calc(24rpx * var(--font-scale, 1));
  1105. }
  1106. .status-pending { background: $tint-warm-soft; color: $brand-primary-deep; }
  1107. .status-accepted {
  1108. background: #E8F1FB;
  1109. color: $mat-blue-base;
  1110. }
  1111. .status-completed {
  1112. background-color: $mat-green-tint;
  1113. color: $mat-green;
  1114. }
  1115. .meal-section {
  1116. background-color: $app-surface;
  1117. border-radius: 24rpx;
  1118. margin-bottom: $uni-space-lg;
  1119. overflow: hidden;
  1120. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06);
  1121. }
  1122. .meal-header { display: flex; flex-wrap: wrap; align-items: center; padding: 24rpx $uni-space-page; border-bottom: 1rpx solid #FDE8D0; }
  1123. .meal-icon-wrap { width: 64rpx; height: 64rpx; border-radius: 24rpx; display: flex; align-items: center; justify-content: center; margin-right: 16rpx; }
  1124. .meal-icon-breakfast { background: linear-gradient(135deg, $dim-body-light, #FFD48A); }
  1125. .meal-icon-lunch { background: linear-gradient(135deg, $status-warning, $accent-amber-light); }
  1126. .meal-icon-dinner { background: linear-gradient(135deg, $facade-violet-light, $accent-violet-300); }
  1127. .meal-icon {
  1128. font-size: calc(36rpx * var(--font-scale, 1));
  1129. margin-right: 12rpx;
  1130. }
  1131. .meal-name {
  1132. font-size: calc(28rpx * var(--font-scale, 1));
  1133. font-weight: 600;
  1134. color: $facade-text-strong;
  1135. flex: 1;
  1136. }
  1137. .meal-count {
  1138. font-size: calc(24rpx * var(--font-scale, 1));
  1139. color: $facade-text-muted;
  1140. }
  1141. .dish-list {
  1142. padding: 20rpx $uni-space-page;
  1143. }
  1144. .dish-item { padding: 24rpx; border-radius: 24rpx; background: $flat-bg; margin-bottom: 16rpx; }
  1145. .dish-item:last-child { margin-bottom: 0; }
  1146. .dish-header {
  1147. display: flex;
  1148. justify-content: space-between;
  1149. margin-bottom: 12rpx;
  1150. }
  1151. .dish-name { font-size: calc(28rpx * var(--font-scale, 1)); font-weight: 600; color: $facade-text-strong; }
  1152. .dish-cal { font-size: calc(24rpx * var(--font-scale, 1)); color: $brand-primary-deep; font-weight: 600; }
  1153. .dish-ingredients {
  1154. display: flex;
  1155. flex-wrap: wrap;
  1156. gap: 12rpx;
  1157. margin-bottom: 12rpx;
  1158. }
  1159. .ingredient-tag {
  1160. padding: 6rpx 16rpx;
  1161. background-color: $facade-fill-2;
  1162. border-radius: 24rpx;
  1163. font-size: calc(22rpx * var(--font-scale, 1));
  1164. color: $facade-text-body;
  1165. }
  1166. .dish-method {
  1167. margin-bottom: 16rpx;
  1168. }
  1169. .method-text {
  1170. font-size: calc(24rpx * var(--font-scale, 1));
  1171. color: $facade-text-muted;
  1172. }
  1173. .dish-actions { display: flex; gap: 16rpx; margin-top: 8rpx; }
  1174. .action-btn { padding: 12rpx 26rpx; border-radius: 999rpx; font-size: calc(24rpx * var(--font-scale, 1)); }
  1175. /* 既有按钮样式保留备用,便于 D1 回退到双按钮组合(当前 dishActions='delete-only' 不渲染) */
  1176. .like-btn { background: $mat-green-tint; color: $mat-green; }
  1177. .swap-btn { background: #E8F1FB; color: $mat-blue-base; }
  1178. .skip-btn { background: $fortune-0-tint; color: $mat-red; }
  1179. /* 本轮增量:删除主操作 / 防重复点击 / 菜数只读状态 / 空·加载态 */
  1180. .delete-btn { background: $fortune-0-tint; color: $mat-red; }
  1181. .action-btn-disabled { opacity: 0.5; }
  1182. .meal-standard {
  1183. flex-basis: 100%;
  1184. text-align: right;
  1185. font-size: calc(22rpx * var(--font-scale, 1));
  1186. color: $facade-text-muted;
  1187. margin-top: 8rpx;
  1188. }
  1189. .meal-empty {
  1190. padding: 40rpx 0;
  1191. display: flex;
  1192. flex-direction: column;
  1193. align-items: center;
  1194. }
  1195. .meal-empty-text {
  1196. font-size: calc(26rpx * var(--font-scale, 1));
  1197. color: $facade-text-muted;
  1198. margin-bottom: 20rpx;
  1199. }
  1200. .meal-empty-btn {
  1201. padding: 12rpx 40rpx;
  1202. border-radius: 999rpx;
  1203. background: $tint-warm-soft;
  1204. color: $brand-primary-deep;
  1205. font-size: calc(24rpx * var(--font-scale, 1));
  1206. }
  1207. .recipe-loading {
  1208. display: flex;
  1209. align-items: center;
  1210. justify-content: center;
  1211. padding: 60rpx 0;
  1212. }
  1213. .recipe-loading-text {
  1214. font-size: calc(26rpx * var(--font-scale, 1));
  1215. color: $facade-text-muted;
  1216. }
  1217. .nutrition-grid {
  1218. display: flex;
  1219. justify-content: space-around;
  1220. }
  1221. .nutrition-item {
  1222. text-align: center;
  1223. }
  1224. .nutrition-card .card-body { background: $flat-bg; border-radius: 0 0 24rpx 24rpx; }
  1225. .nutrition-value { font-size: calc(40rpx * var(--font-scale, 1)); font-weight: 700; color: $brand-primary-deep; display: block; }
  1226. .nutrition-unit {
  1227. font-size: calc(22rpx * var(--font-scale, 1));
  1228. color: $facade-text-muted;
  1229. }
  1230. .nutrition-label {
  1231. font-size: calc(22rpx * var(--font-scale, 1));
  1232. color: $facade-text-body;
  1233. display: block;
  1234. margin-top: 4rpx;
  1235. }
  1236. .action-area {
  1237. padding: 40rpx $uni-space-page;
  1238. }
  1239. .btn-row {
  1240. display: flex;
  1241. gap: 20rpx;
  1242. }
  1243. .btn-secondary {
  1244. flex: 1; padding: 28rpx 0; background: $app-surface;
  1245. border: 2rpx solid $dim-body; border-radius: 999rpx;
  1246. text-align: center; font-size: calc(28rpx * var(--font-scale, 1)); color: $brand-primary-deep;
  1247. }
  1248. .btn-primary {
  1249. flex: 1; padding: 28rpx 0;
  1250. background: linear-gradient(135deg, $dim-body, $dim-body-light);
  1251. border-radius: 999rpx; text-align: center;
  1252. font-size: calc(28rpx * var(--font-scale, 1)); color: $app-surface; font-weight: 600;
  1253. box-shadow: 0 6rpx 20rpx rgba(255, 140, 66, 0.25);
  1254. }
  1255. /* ===== 推荐食材(原「食材查询」页迁移)===== */
  1256. .section-title-bar {
  1257. display: flex;
  1258. flex-direction: column;
  1259. padding: 8rpx 0 16rpx;
  1260. }
  1261. .section-title {
  1262. font-size: calc(34rpx * var(--font-scale, 1));
  1263. font-weight: 700;
  1264. color: $facade-text-strong;
  1265. }
  1266. .section-subtitle {
  1267. font-size: calc(24rpx * var(--font-scale, 1));
  1268. color: $facade-text-muted;
  1269. margin-top: 6rpx;
  1270. }
  1271. .food-section {
  1272. background-color: $app-surface;
  1273. border-radius: 24rpx;
  1274. padding: 20rpx;
  1275. margin-bottom: 32rpx;
  1276. }
  1277. /* 模式切换(排序) */
  1278. .mode-bar {
  1279. display: flex;
  1280. padding: 16rpx 0;
  1281. gap: 20rpx;
  1282. }
  1283. .mode-btn {
  1284. flex: 1;
  1285. padding: 12rpx 0;
  1286. text-align: center;
  1287. border-radius: 24rpx;
  1288. background: $facade-fill-2;
  1289. color: $facade-text-body;
  1290. font-size: calc(26rpx * var(--font-scale, 1));
  1291. }
  1292. .mode-btn.active {
  1293. background: linear-gradient(135deg, $status-success, $status-success-light-3);
  1294. color: $app-surface;
  1295. }
  1296. /* 搜索栏 */
  1297. .search-bar {
  1298. display: flex;
  1299. padding: 20rpx 0;
  1300. }
  1301. .search-input {
  1302. flex: 1;
  1303. border: 1rpx solid $facade-border-soft;
  1304. border-radius: 24rpx;
  1305. padding: 16rpx 24rpx;
  1306. font-size: calc(26rpx * var(--font-scale, 1));
  1307. background-color: $facade-fill-ghost;
  1308. }
  1309. .search-btn {
  1310. margin-left: 20rpx;
  1311. padding: 16rpx 32rpx;
  1312. background-color: $dim-body;
  1313. color: $app-surface;
  1314. border-radius: 24rpx;
  1315. font-size: calc(26rpx * var(--font-scale, 1));
  1316. }
  1317. /* 分类标签 */
  1318. .category-tabs {
  1319. display: flex;
  1320. flex-wrap: wrap;
  1321. gap: 16rpx;
  1322. margin-bottom: 20rpx;
  1323. }
  1324. .tab-item {
  1325. padding: 12rpx 24rpx;
  1326. border: 1rpx solid $facade-border-soft;
  1327. border-radius: 24rpx;
  1328. font-size: calc(24rpx * var(--font-scale, 1));
  1329. color: $facade-text-body;
  1330. background-color: $app-surface;
  1331. }
  1332. .tab-active {
  1333. border-color: $dim-body;
  1334. color: $dim-body;
  1335. background-color: $flat-card;
  1336. }
  1337. /* 筛选栏 */
  1338. .filter-bar {
  1339. display: flex;
  1340. gap: 20rpx;
  1341. margin-bottom: 20rpx;
  1342. }
  1343. .filter-item {
  1344. flex: 1;
  1345. text-align: center;
  1346. padding: 12rpx 8rpx;
  1347. border: 1rpx solid $facade-border-soft;
  1348. border-radius: 24rpx;
  1349. font-size: calc(24rpx * var(--font-scale, 1));
  1350. color: $facade-text-body;
  1351. background-color: $app-surface;
  1352. }
  1353. .filter-active {
  1354. border-color: $mat-green;
  1355. color: $mat-green;
  1356. background-color: $mat-green-tint;
  1357. }
  1358. /* 家庭总览 */
  1359. .family-overview {
  1360. background: $facade-fill-ghost-2;
  1361. border-radius: 16rpx;
  1362. padding: 20rpx;
  1363. margin-bottom: 20rpx;
  1364. }
  1365. .overview-title {
  1366. font-size: calc(28rpx * var(--font-scale, 1));
  1367. font-weight: 600;
  1368. color: $facade-text-strong;
  1369. margin-bottom: 16rpx;
  1370. padding-bottom: 16rpx;
  1371. border-bottom: 1rpx solid $facade-fill;
  1372. }
  1373. .overview-item {
  1374. padding: 16rpx 0;
  1375. border-bottom: 1rpx solid $facade-fill-2;
  1376. }
  1377. .overview-item:last-child {
  1378. border-bottom: none;
  1379. }
  1380. .overview-header {
  1381. display: flex;
  1382. align-items: center;
  1383. justify-content: space-between;
  1384. margin-bottom: 8rpx;
  1385. }
  1386. .overview-detail {
  1387. display: flex;
  1388. flex-direction: column;
  1389. gap: 8rpx;
  1390. }
  1391. .category-label {
  1392. font-size: calc(22rpx * var(--font-scale, 1));
  1393. color: $facade-text-muted;
  1394. }
  1395. .member-scores {
  1396. display: flex;
  1397. flex-wrap: wrap;
  1398. gap: 12rpx;
  1399. }
  1400. .member-score {
  1401. font-size: calc(20rpx * var(--font-scale, 1));
  1402. padding: 4rpx 12rpx;
  1403. border-radius: 16rpx;
  1404. background: $facade-fill-2;
  1405. }
  1406. .score-green {
  1407. color: $status-success;
  1408. background: $mat-green-tint;
  1409. }
  1410. .score-red {
  1411. color: $status-danger;
  1412. background: $status-danger-soft;
  1413. }
  1414. .score-badge {
  1415. min-width: 72rpx;
  1416. text-align: center;
  1417. padding: 4rpx 14rpx;
  1418. border-radius: 16rpx;
  1419. font-size: calc(24rpx * var(--font-scale, 1));
  1420. font-weight: 700;
  1421. color: $app-surface;
  1422. background: linear-gradient(135deg, $dim-body, $dim-body-light);
  1423. }
  1424. .score-badge.good {
  1425. background: linear-gradient(135deg, $status-success, $status-success-light-3);
  1426. }
  1427. .score-badge.bad {
  1428. background: linear-gradient(135deg, $status-danger, $status-danger-deep);
  1429. }
  1430. /* 食材列表 */
  1431. .food-list {
  1432. display: flex;
  1433. flex-direction: column;
  1434. gap: 16rpx;
  1435. }
  1436. .food-card {
  1437. background: $facade-fill-ghost-2;
  1438. border-radius: 16rpx;
  1439. padding: 18rpx 20rpx;
  1440. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
  1441. display: flex;
  1442. flex-wrap: wrap;
  1443. align-items: center;
  1444. justify-content: space-between;
  1445. width: 100%;
  1446. box-sizing: border-box;
  1447. }
  1448. /* 健康问卷个性化调整提示条(blocked 红 / warning 黄 / boost 绿;normal/空不渲染) */
  1449. .health-adjust-bar {
  1450. width: 100%;
  1451. margin-bottom: 12rpx;
  1452. }
  1453. .health-adjust-text {
  1454. display: block;
  1455. padding: 8rpx 16rpx;
  1456. border-radius: 8rpx;
  1457. font-size: calc(22rpx * var(--font-scale, 1));
  1458. line-height: 1.4;
  1459. }
  1460. .health-adjust-blocked {
  1461. background: $fortune-0-tint;
  1462. color: $mat-red;
  1463. }
  1464. .health-adjust-warning {
  1465. background: rgba(245, 158, 11, 0.14);
  1466. color: #b45309;
  1467. }
  1468. .health-adjust-boost {
  1469. background: $mat-green-tint;
  1470. color: $mat-green;
  1471. }
  1472. .food-left {
  1473. display: flex;
  1474. align-items: center;
  1475. flex: 1;
  1476. min-width: 0;
  1477. }
  1478. .ingredient-badge {
  1479. width: 36rpx;
  1480. height: 36rpx;
  1481. border-radius: 8rpx;
  1482. background: linear-gradient(135deg, $dim-body, $dim-body-light);
  1483. display: flex;
  1484. align-items: center;
  1485. justify-content: center;
  1486. margin-right: 16rpx;
  1487. flex-shrink: 0;
  1488. }
  1489. .ingredient-badge.good {
  1490. background: linear-gradient(135deg, $status-success, $status-success-light-3);
  1491. }
  1492. .ingredient-badge.bad {
  1493. background: linear-gradient(135deg, $status-danger, $status-danger-deep);
  1494. }
  1495. .ingredient-badge-text {
  1496. font-size: calc(18rpx * var(--font-scale, 1));
  1497. color: $app-surface;
  1498. font-weight: 600;
  1499. }
  1500. .food-info {
  1501. display: flex;
  1502. flex-direction: column;
  1503. flex: 1;
  1504. min-width: 0;
  1505. overflow: hidden;
  1506. }
  1507. .food-name {
  1508. font-size: calc(28rpx * var(--font-scale, 1));
  1509. font-weight: 600;
  1510. color: $text-charcoal;
  1511. display: block;
  1512. white-space: nowrap;
  1513. overflow: hidden;
  1514. text-overflow: ellipsis;
  1515. }
  1516. .food-meta {
  1517. display: flex;
  1518. flex-wrap: wrap;
  1519. gap: 8rpx;
  1520. margin-top: 6rpx;
  1521. }
  1522. .meta-item {
  1523. flex-shrink: 0;
  1524. font-size: calc(20rpx * var(--font-scale, 1));
  1525. color: $facade-text-faint;
  1526. background: $facade-fill-2;
  1527. padding: 4rpx 14rpx;
  1528. border-radius: 8rpx;
  1529. }
  1530. .food-right {
  1531. display: flex;
  1532. align-items: center;
  1533. gap: 12rpx;
  1534. flex-shrink: 0;
  1535. }
  1536. .score-value {
  1537. font-size: calc(28rpx * var(--font-scale, 1));
  1538. font-weight: 700;
  1539. min-width: 60rpx;
  1540. text-align: right;
  1541. }
  1542. .score-value.good { color: $status-success; }
  1543. .score-value.bad { color: $status-danger; }
  1544. .food-status-badge {
  1545. padding: 6rpx 16rpx;
  1546. border-radius: 24rpx;
  1547. font-size: calc(22rpx * var(--font-scale, 1));
  1548. font-weight: 500;
  1549. }
  1550. .badge-suitable {
  1551. background: $mat-green-tint;
  1552. color: $mat-green;
  1553. }
  1554. .badge-unsuitable {
  1555. background: $fortune-0-tint;
  1556. color: $mat-red;
  1557. }
  1558. /* 健康问卷个性化调整提示条(diet.food.healthAdjustUi · B2) */
  1559. .adjustment-tip {
  1560. margin-top: 12rpx;
  1561. align-self: flex-start;
  1562. max-width: 100%;
  1563. }
  1564. .adjustment-tip-text {
  1565. display: inline-flex;
  1566. align-items: center;
  1567. padding: 6rpx 16rpx;
  1568. border-radius: 10rpx;
  1569. font-size: calc(22rpx * var(--font-scale, 1));
  1570. line-height: 1.5;
  1571. }
  1572. .adjustment-tip-blocked {
  1573. background: $status-danger-soft;
  1574. color: $status-danger;
  1575. }
  1576. .adjustment-tip-warning {
  1577. background: $status-warning-soft;
  1578. color: $status-warning;
  1579. }
  1580. .adjustment-tip-boost {
  1581. background: $status-success-soft;
  1582. color: $status-success;
  1583. }
  1584. /* 空状态 */
  1585. .food-empty-state {
  1586. text-align: center;
  1587. padding: 60rpx 40rpx;
  1588. }
  1589. .food-empty-icon {
  1590. font-size: calc($uni-font-size-5xl * var(--font-scale, 1));
  1591. display: block;
  1592. margin-bottom: 20rpx;
  1593. }
  1594. .food-empty-text {
  1595. font-size: calc(30rpx * var(--font-scale, 1));
  1596. color: $facade-text-strong;
  1597. font-weight: 500;
  1598. display: block;
  1599. margin-bottom: 12rpx;
  1600. }
  1601. .loading-state {
  1602. text-align: center;
  1603. padding: 60rpx 0;
  1604. }
  1605. .loading-text {
  1606. font-size: calc(26rpx * var(--font-scale, 1));
  1607. color: $facade-text-muted;
  1608. }
  1609. /* ===== 共餐人选择弹层(需求7)===== */
  1610. .participant-mask {
  1611. position: fixed;
  1612. left: 0;
  1613. top: 0;
  1614. right: 0;
  1615. bottom: 0;
  1616. background: rgba(0, 0, 0, 0.45);
  1617. z-index: 999;
  1618. display: flex;
  1619. align-items: flex-end;
  1620. }
  1621. .participant-sheet {
  1622. box-sizing: border-box;
  1623. width: 100%;
  1624. background: $app-surface;
  1625. border-radius: 24rpx 24rpx 0 0;
  1626. padding: 32rpx 32rpx 40rpx;
  1627. }
  1628. .participant-sheet-header {
  1629. padding-bottom: 24rpx;
  1630. }
  1631. .participant-sheet-title {
  1632. font-size: calc(32rpx * var(--font-scale, 1));
  1633. font-weight: 600;
  1634. color: $facade-text-strong;
  1635. display: block;
  1636. }
  1637. .participant-sheet-sub {
  1638. font-size: calc(24rpx * var(--font-scale, 1));
  1639. color: $facade-text-muted;
  1640. display: block;
  1641. margin-top: 8rpx;
  1642. }
  1643. .participant-list {
  1644. display: flex;
  1645. flex-wrap: wrap;
  1646. gap: 20rpx;
  1647. padding: 16rpx 0 24rpx;
  1648. max-height: 60vh;
  1649. overflow-y: auto;
  1650. }
  1651. .participant-item {
  1652. box-sizing: border-box;
  1653. position: relative;
  1654. display: flex;
  1655. align-items: center;
  1656. padding: 16rpx 24rpx;
  1657. border: 2rpx solid $facade-fill-2;
  1658. border-radius: 24rpx;
  1659. background: $app-surface;
  1660. min-width: 160rpx;
  1661. }
  1662. .participant-item-selected {
  1663. border-color: $dim-body;
  1664. background: linear-gradient(135deg, $dim-body, $dim-body-light);
  1665. }
  1666. .participant-name {
  1667. font-size: calc(26rpx * var(--font-scale, 1));
  1668. color: $facade-text-body;
  1669. }
  1670. .participant-item-selected .participant-name {
  1671. color: $app-surface;
  1672. font-weight: 600;
  1673. }
  1674. .participant-check {
  1675. position: absolute;
  1676. top: -8rpx;
  1677. right: -8rpx;
  1678. width: 32rpx;
  1679. height: 32rpx;
  1680. border-radius: 50%;
  1681. background-color: $app-surface;
  1682. color: $dim-body;
  1683. display: flex;
  1684. align-items: center;
  1685. justify-content: center;
  1686. z-index: 2;
  1687. }
  1688. .participant-check-icon {
  1689. font-size: calc(20rpx * var(--font-scale, 1));
  1690. font-weight: 700;
  1691. }
  1692. .participant-empty {
  1693. width: 100%;
  1694. padding: 20rpx 0;
  1695. text-align: center;
  1696. }
  1697. .participant-empty-text {
  1698. font-size: calc(24rpx * var(--font-scale, 1));
  1699. color: $facade-text-muted;
  1700. }
  1701. .participant-actions {
  1702. display: flex;
  1703. gap: 20rpx;
  1704. }
  1705. .participant-btn {
  1706. flex: 1;
  1707. padding: 26rpx 0;
  1708. border-radius: 999rpx;
  1709. text-align: center;
  1710. font-size: calc(28rpx * var(--font-scale, 1));
  1711. }
  1712. .participant-btn-cancel {
  1713. background: $facade-fill-2;
  1714. color: $facade-text-body;
  1715. }
  1716. .participant-btn-confirm {
  1717. background: linear-gradient(135deg, $dim-body, $dim-body-light);
  1718. color: $app-surface;
  1719. font-weight: 600;
  1720. }
  1721. </style>