health-report.vue 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. <template>
  2. <view class="report-container">
  3. <!-- 顶部导航 -->
  4. <view class="nav-bar">
  5. <text class="nav-back" @click="goBack">‹ 返回</text>
  6. <text class="nav-title">健康报告详情</text>
  7. <view class="nav-placeholder"></view>
  8. </view>
  9. <!-- 报告头部 -->
  10. <view class="report-header" v-if="report">
  11. <view class="report-type-tag">{{ reportTypeLabel }}</view>
  12. <view class="report-scores">
  13. <view class="score-item">
  14. <view class="score-circle-lg">
  15. <text class="score-num">{{ report.overallScore || '--' }}</text>
  16. <text class="score-unit">分</text>
  17. </view>
  18. <text class="score-label">综合评分</text>
  19. </view>
  20. <view class="score-item" v-if="report.gutHealthScore">
  21. <view class="score-circle-lg score-circle-green">
  22. <text class="score-num">{{ report.gutHealthScore }}</text>
  23. <text class="score-unit">分</text>
  24. </view>
  25. <text class="score-label">肠道健康</text>
  26. </view>
  27. </view>
  28. <view class="report-info-row" v-if="report.gutAge || report.gutType">
  29. <text class="info-chip" v-if="report.gutAge">肠道年龄:{{ report.gutAge }}</text>
  30. <text class="info-chip" v-if="report.gutType">肠道分型:{{ report.gutType }}</text>
  31. </view>
  32. <text class="report-date">报告日期:{{ formatDate(report.reportDate) }}</text>
  33. </view>
  34. <!-- ===== 评分可视化面板 (仅菌群报告) ===== -->
  35. <view class="score-dashboard" v-if="report && report.reportType === 'gut_flora'">
  36. <view class="main-scores">
  37. <view class="main-score-item" v-for="item in mainScores" :key="item.key">
  38. <view class="score-ring-wrap">
  39. <svg width="140" height="140" viewBox="0 0 120 120">
  40. <circle cx="60" cy="60" r="50" fill="none" stroke="#EEEEEE" stroke-width="8"/>
  41. <circle cx="60" cy="60" r="50" fill="none" v-bind:stroke="item.color" stroke-width="8" v-bind:stroke-dasharray="item.circumference" v-bind:stroke-dashoffset="item.offset" stroke-linecap="round" transform="rotate(-90 60 60)"/>
  42. <text x="60" y="52" text-anchor="middle" font-size="32" font-weight="bold" fill="#333">{{ item.score }}</text>
  43. <text x="60" y="72" text-anchor="middle" font-size="14" fill="#999">分</text>
  44. </svg>
  45. </view>
  46. <text class="main-score-label">{{ item.label }}</text>
  47. </view>
  48. </view>
  49. <view class="flora-score-row" v-if="hasFloraScores">
  50. <view class="flora-score-item" v-for="item in floraScores" :key="item.key">
  51. <view class="flora-score-circle" v-bind:style="{ background: item.color }">
  52. <text class="flora-score-num">{{ item.score }}</text>
  53. </view>
  54. <text class="flora-score-label">{{ item.label }}</text>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 指标列表 -->
  59. <view class="section">
  60. <view class="section-title">
  61. <text>指标明细</text>
  62. <text class="section-sub">共 {{ indicators.length }} 项</text>
  63. </view>
  64. <!-- 按分类分组 -->
  65. <view class="category-group" v-for="group in groupedIndicators" :key="group.name">
  66. <view class="category-header">
  67. <text class="category-name">{{ group.name }}</text>
  68. <text class="category-count">{{ group.items.length }}项</text>
  69. </view>
  70. <view class="indicator-card" v-for="ind in group.items" :key="ind._idx">
  71. <view class="ind-header">
  72. <text class="ind-name">{{ ind.indicatorName }}</text>
  73. <view class="ind-status" :class="ind._cls">
  74. <text>{{ ind._label }}</text>
  75. </view>
  76. </view>
  77. <view class="ind-body">
  78. <view class="ind-value-wrap">
  79. <text class="ind-value">{{ ind.indicatorValue || '--' }}</text>
  80. <text class="ind-unit">{{ ind.unit || '' }}</text>
  81. </view>
  82. <text class="ind-ref">参考值:{{ ind.refRange || '暂无' }}</text>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="empty-indicators" v-if="indicators.length === 0 && !loading">
  87. <text>暂无指标数据</text>
  88. </view>
  89. </view>
  90. <!-- ===== 营养缺乏分析 ===== -->
  91. <view class="section" v-if="deficiencyRecords && deficiencyRecords.length > 0">
  92. <view class="section-title">
  93. <text>🔬 营养缺乏分析</text>
  94. <text class="section-sub">{{ deficiencyRecords.length }}项</text>
  95. </view>
  96. <view class="deficiency-list">
  97. <view class="deficiency-card" v-for="dr in deficiencyRecords" :key="dr.nutrient">
  98. <view class="deficiency-header">
  99. <text class="deficiency-nutrient">{{ dr.nutrient }}</text>
  100. <view class="deficiency-type-tag" :class="'dtype-' + dr.deficiencyType">
  101. <text>{{ dr.deficiencyTypeLabel }}</text>
  102. </view>
  103. </view>
  104. <view class="deficiency-severity-row">
  105. <view class="severity-bar">
  106. <view class="severity-fill" :style="{ width: (dr.severity * 100) + '%', background: dr.severityColor }"></view>
  107. </view>
  108. <text class="severity-val">{{ dr.severity }}</text>
  109. </view>
  110. <view class="deficiency-meta" v-if="dr.indicatorName">
  111. <text class="meta-label">关联指标:</text>
  112. <text class="meta-value">{{ dr.indicatorName }} ({{ dr.indicatorValue }})</text>
  113. </view>
  114. <view class="deficiency-foods" v-if="dr.foodSuggestions">
  115. <text class="foods-label">推荐食物:</text>
  116. <text class="foods-value">{{ dr.foodSuggestions }}</text>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. <!-- ===== 食材推荐 ===== -->
  122. <view class="section" v-if="foods && foods.length > 0">
  123. <view class="section-title">
  124. <text>🥗 食材推荐</text>
  125. <text class="section-sub">共 {{ foods.length }} 项</text>
  126. </view>
  127. <view class="food-list">
  128. <view class="food-card" v-for="food in foods" :key="food.id">
  129. <view class="food-header">
  130. <text class="food-name">{{ food.name }}</text>
  131. <view class="food-score" :class="food.scoreClass">
  132. <text>{{ food.score || '--' }}</text>
  133. </view>
  134. </view>
  135. <view class="food-meta" v-if="food.category">
  136. <text class="food-category">{{ food.category }}</text>
  137. </view>
  138. <view class="food-nutrition" v-if="food.energyKj || food.protein || food.fat || food.carbs">
  139. <view class="nutrition-item" v-if="food.energyKj">
  140. <text class="n-label">能量</text>
  141. <text class="n-value">{{ food.energyKj }} kJ</text>
  142. </view>
  143. <view class="nutrition-item" v-if="food.protein">
  144. <text class="n-label">蛋白质</text>
  145. <text class="n-value">{{ food.protein }}g</text>
  146. </view>
  147. <view class="nutrition-item" v-if="food.fat">
  148. <text class="n-label">脂肪</text>
  149. <text class="n-value">{{ food.fat }}g</text>
  150. </view>
  151. <view class="nutrition-item" v-if="food.carbs">
  152. <text class="n-label">碳水</text>
  153. <text class="n-value">{{ food.carbs }}g</text>
  154. </view>
  155. </view>
  156. </view>
  157. </view>
  158. </view>
  159. <!-- ===== 五维雷达图 (菌群报告) ===== -->
  160. <view class="section" v-if="report && report.reportType === 'gut_flora' && radarDimensions.length > 0">
  161. <view class="section-title">
  162. <text>五维雷达图</text>
  163. </view>
  164. <view class="radar-wrap">
  165. <canvas canvas-id="radarCanvas" id="radarCanvas" class="radar-canvas" @touchstart.prevent></canvas>
  166. </view>
  167. </view>
  168. <!-- 底部占位 -->
  169. <view class="bottom-spacer"></view>
  170. <!-- 营养分析入口按钮(已屏蔽)
  171. <view class="nutrition-fab" @click="goNutritionChat" v-if="report">
  172. <text class="fab-icon">🥗</text>
  173. <text class="fab-text">精准营养分析</text>
  174. </view> -->
  175. </view>
  176. </template>
  177. <script>
  178. import config from '@/config.js'
  179. import { getDeficiencyAnalysis } from '@/utils/api.js'
  180. const healthRequest = function(url, data) {
  181. var token = uni.getStorageSync('token')
  182. return new Promise(function(resolve, reject) {
  183. uni.request({
  184. url: config.API_BASE_URL + url,
  185. method: 'POST',
  186. data: data,
  187. header: {
  188. 'Content-Type': 'application/json',
  189. 'Authorization': token ? 'Bearer ' + token : ''
  190. },
  191. success: function(res) {
  192. if (res.data.code === 200) {
  193. resolve(res.data)
  194. } else {
  195. reject(res.data)
  196. }
  197. },
  198. fail: function(err) {
  199. reject(err)
  200. }
  201. })
  202. })
  203. }
  204. export default {
  205. data() {
  206. return {
  207. childId: null,
  208. reportId: null,
  209. report: null,
  210. reportDetail: null,
  211. indicators: [],
  212. deficiencyRecords: [],
  213. foods: [],
  214. loading: false
  215. }
  216. },
  217. computed: {
  218. reportTypeLabel: function() {
  219. if (!this.report) return ''
  220. return this.report.reportType === 'gut_flora' ? '肠道检测报告' : '体检报告'
  221. },
  222. // 预计算分组,每个指标附加 _cls (CSS类) 和 _label (显示标签)
  223. groupedIndicators: function() {
  224. var result = []
  225. var groupMap = {}
  226. var idx = 0
  227. for (var i = 0; i < this.indicators.length; i++) {
  228. var ind = this.indicators[i]
  229. var cat = ind.category || '其他'
  230. // Compute status css class
  231. var cls = 'status-normal'
  232. var label = '正常'
  233. var status = ind.status || ''
  234. var s = status.toLowerCase()
  235. if (s.indexOf('偏高') !== -1 || s.indexOf('过高') !== -1 || s.indexOf('concern') !== -1) {
  236. cls = 'status-warning'
  237. label = '偏高'
  238. } else if (s.indexOf('偏低') !== -1 || s.indexOf('过低') !== -1 || s.indexOf('注意') !== -1 || s.indexOf('warning') !== -1) {
  239. cls = 'status-warn'
  240. label = '偏低'
  241. } else if (s.indexOf('正常') !== -1 || s.indexOf('normal') !== -1 || s.indexOf('低风险') !== -1) {
  242. cls = 'status-normal'
  243. label = '正常'
  244. } else if (status) {
  245. label = status
  246. }
  247. ind._cls = cls
  248. ind._label = label
  249. ind._idx = idx
  250. idx++
  251. // Group
  252. if (!groupMap[cat]) {
  253. groupMap[cat] = { name: cat, items: [] }
  254. result.push(groupMap[cat])
  255. }
  256. groupMap[cat].items.push(ind)
  257. }
  258. return result
  259. },
  260. circumference: function() {
  261. return Math.round(2 * Math.PI * 50)
  262. },
  263. mainScores: function() {
  264. if (!this.report) return []
  265. var items = []
  266. var r = this.report
  267. var pairs = [
  268. {key:'overall', label:'综合评分', score: r.overallScore, color:'#5B9BD5'},
  269. {key:'gut', label:'肠道健康', score: r.gutHealthScore, color:'#4CAF50'},
  270. {key:'chronic', label:'慢病控制', score: r.chronicDiseaseScore, color:'#FF9800'},
  271. {key:'nutrition', label:'营养均衡', score: r.nutritionScore, color:'#2196F3'}
  272. ]
  273. var circ = Math.round(2 * Math.PI * 50)
  274. for (var i = 0; i < pairs.length; i++) {
  275. var p = pairs[i]
  276. var s = p.score || 0
  277. items.push({key: p.key, label: p.label, score: s, color: p.color, circumference: circ, offset: Math.round(circ - (s / 100) * circ)})
  278. }
  279. return items
  280. },
  281. hasFloraScores: function() {
  282. if (!this.report) return false
  283. var r = this.report
  284. return (r.balanceScore != null) || (r.diversityScore != null) || (r.beneficialScore != null) || (r.harmfulScore != null) || (r.coreGenusScore != null)
  285. },
  286. floraScores: function() {
  287. if (!this.report) return []
  288. var r = this.report
  289. var items = []
  290. var pairs = [
  291. {key:'balance', label:'菌群平衡', score: r.balanceScore},
  292. {key:'diversity', label:'菌群多样性', score: r.diversityScore},
  293. {key:'beneficial', label:'有益菌', score: r.beneficialScore},
  294. {key:'harmful', label:'有害菌', score: r.harmfulScore},
  295. {key:'coreGenus', label:'核心菌属', score: r.coreGenusScore}
  296. ]
  297. for (var i = 0; i < pairs.length; i++) {
  298. var p = pairs[i]
  299. if (p.score != null) {
  300. var s = p.score
  301. var color = '#4CAF50'
  302. if (s < 30) { color = '#F44336' }
  303. else if (s < 60) { color = '#FFC107' }
  304. items.push({key: p.key, label: p.label, score: s, color: color})
  305. }
  306. }
  307. return items
  308. },
  309. radarDimensions: function() {
  310. if (!this.report) return []
  311. var r = this.report
  312. var dims = []
  313. if (r.overallScore != null) dims.push({ label: '综合', value: r.overallScore })
  314. if (r.gutHealthScore != null) dims.push({ label: '肠道', value: r.gutHealthScore })
  315. if (r.nutritionScore != null) dims.push({ label: '营养', value: r.nutritionScore })
  316. if (r.chronicDiseaseScore != null) dims.push({ label: '慢病', value: r.chronicDiseaseScore })
  317. if (r.gutBalanceScore != null) dims.push({ label: '菌群平衡', value: r.gutBalanceScore })
  318. return dims
  319. }
  320. },
  321. onLoad: function(options) {
  322. var childId = options.childId
  323. var reportId = options.reportId
  324. this.childId = childId ? parseInt(childId) : null
  325. this.reportId = reportId ? parseInt(reportId) : null
  326. // 如果没有传 childId,尝试从 storage 读取(可能是家长自己的)
  327. if (!this.childId) {
  328. var savedChildId = uni.getStorageSync('currentChildId')
  329. if (savedChildId) this.childId = parseInt(savedChildId)
  330. }
  331. this.loadData()
  332. },
  333. onReady: function() {
  334. if (this.radarDimensions.length >= 3) {
  335. this.drawRadarChart()
  336. }
  337. },
  338. methods: {
  339. loadData: function() {
  340. var self = this
  341. uni.showLoading({ title: '加载中...' })
  342. // Load report + indicators in parallel
  343. var promises = []
  344. if (this.reportId) {
  345. promises.push(healthRequest('/api/health/report/latest', { childId: this.childId }))
  346. promises.push(healthRequest('/api/health/indicator/list', { reportId: this.reportId }))
  347. } else if (this.childId) {
  348. promises.push(healthRequest('/api/health/report/latest', { childId: this.childId }))
  349. }
  350. Promise.all(promises.map(function(p) {
  351. return p.catch(function(e) { return null })
  352. })).then(function(results) {
  353. uni.hideLoading()
  354. if (results[0] && results[0].data) {
  355. self.report = results[0].data
  356. self.reportId = self.report.id
  357. self.loadDeficiencyRecords()
  358. // Load indicators after getting reportId
  359. if (self.reportId) {
  360. healthRequest('/api/health/indicator/list', { reportId: self.reportId }).then(function(res) {
  361. if (res.data) {
  362. self.indicators = res.data
  363. }
  364. }).catch(function(e) {
  365. console.log('获取指标失败', e)
  366. })
  367. healthRequest('/api/health/report/detail', { reportId: self.reportId }).then(function(res) {
  368. if (res.data) {
  369. self.reportDetail = res.data
  370. }
  371. }).catch(function(e) {
  372. console.log('获取报告详情失败', e)
  373. })
  374. healthRequest('/api/health/foods', { reportId: self.reportId }).then(function(res) {
  375. if (res.data) {
  376. self.foods = res.data.map(function(f) {
  377. f.scoreClass = self.getFoodScoreClass(f.score)
  378. return f
  379. })
  380. }
  381. }).catch(function(e) {
  382. console.log('获取食材推荐失败', e)
  383. })
  384. }
  385. }
  386. }).catch(function(e) {
  387. uni.hideLoading()
  388. uni.showToast({ title: '加载失败', icon: 'none' })
  389. })
  390. },
  391. goBack: function() {
  392. uni.navigateBack()
  393. },
  394. // AI问答功能已屏蔽
  395. goNutritionChat: function() {},
  396. loadDeficiencyRecords: function() {
  397. if (!this.childId) return
  398. var self = this
  399. getDeficiencyAnalysis(this.childId).then(function(res) {
  400. if (res.code === 200 && res.data) {
  401. self.deficiencyRecords = res.data.map(function(dr) {
  402. dr.deficiencyTypeLabel = self.getDeficiencyTypeLabel(dr.deficiencyType)
  403. dr.severityColor = self.getSeverityColor(dr.severity)
  404. return dr
  405. })
  406. }
  407. }).catch(function(e) {
  408. console.log('获取缺乏分析失败', e)
  409. })
  410. },
  411. getDeficiencyTypeLabel: function(type) {
  412. if (type === 'deficiency') return '缺乏'
  413. if (type === 'excess') return '偏高'
  414. if (type === 'borderline') return '边界值'
  415. return '未分类'
  416. },
  417. getSeverityColor: function(severity) {
  418. if (severity >= 0.7) return '#EF4444'
  419. if (severity >= 0.3) return '#F59E0B'
  420. return '#10B981'
  421. },
  422. drawRadarChart: function() {
  423. var dims = this.radarDimensions
  424. if (!dims || dims.length < 3) return
  425. var ctx = uni.createCanvasContext('radarCanvas', this)
  426. var cw = 300
  427. var ch = 300
  428. var cx = cw / 2
  429. var cy = ch / 2
  430. var maxR = 110
  431. var n = dims.length
  432. var angleStep = (2 * Math.PI) / n
  433. for (var level = 1; level <= 5; level++) {
  434. var r = maxR * (level / 5)
  435. ctx.setStrokeStyle('#E5E7EB')
  436. ctx.setLineWidth(1)
  437. ctx.beginPath()
  438. for (var j = 0; j < n; j++) {
  439. var a = j * angleStep - Math.PI / 2
  440. var x = cx + r * Math.cos(a)
  441. var y = cy + r * Math.sin(a)
  442. if (j === 0) ctx.moveTo(x, y)
  443. else ctx.lineTo(x, y)
  444. }
  445. ctx.closePath()
  446. ctx.stroke()
  447. }
  448. for (var k = 0; k < n; k++) {
  449. var a2 = k * angleStep - Math.PI / 2
  450. ctx.beginPath()
  451. ctx.moveTo(cx, cy)
  452. ctx.lineTo(cx + maxR * Math.cos(a2), cy + maxR * Math.sin(a2))
  453. ctx.setStrokeStyle('#E5E7EB')
  454. ctx.setLineWidth(1)
  455. ctx.stroke()
  456. }
  457. ctx.beginPath()
  458. for (var m = 0; m < n; m++) {
  459. var angle = m * angleStep - Math.PI / 2
  460. var val = dims[m].value || 0
  461. var rr = maxR * (val / 100)
  462. var px = cx + rr * Math.cos(angle)
  463. var py = cy + rr * Math.sin(angle)
  464. if (m === 0) ctx.moveTo(px, py)
  465. else ctx.lineTo(px, py)
  466. }
  467. ctx.closePath()
  468. ctx.setFillStyle('rgba(249, 115, 22, 0.2)')
  469. ctx.fill()
  470. ctx.setStrokeStyle('#F97316')
  471. ctx.setLineWidth(2)
  472. ctx.stroke()
  473. for (var q = 0; q < n; q++) {
  474. var angle3 = q * angleStep - Math.PI / 2
  475. var lx = cx + (maxR + 20) * Math.cos(angle3)
  476. var ly = cy + (maxR + 20) * Math.sin(angle3)
  477. ctx.setFontSize(11)
  478. ctx.setFillStyle('#6B7280')
  479. ctx.setTextAlign('center')
  480. ctx.setTextBaseline('middle')
  481. ctx.fillText(dims[q].label + ' ' + (dims[q].value || '--'), lx, ly)
  482. }
  483. ctx.draw()
  484. },
  485. getFoodScoreClass: function(score) {
  486. if (score == null) return 'score-unknown'
  487. if (score >= 80) return 'score-high'
  488. if (score >= 60) return 'score-mid'
  489. return 'score-low'
  490. },
  491. formatDate: function(dateStr) {
  492. if (!dateStr) return '--'
  493. try {
  494. var d = new Date(dateStr)
  495. var y = d.getFullYear()
  496. var m = ('' + (d.getMonth() + 1)).padStart(2, '0')
  497. var day = ('' + d.getDate()).padStart(2, '0')
  498. return y + '-' + m + '-' + day
  499. } catch (e) {
  500. return dateStr
  501. }
  502. }
  503. }
  504. }
  505. </script>
  506. <style scoped>
  507. .report-container {
  508. min-height: 100vh;
  509. background: #f5f7fa;
  510. }
  511. /* ===== 导航栏 ===== */
  512. .nav-bar {
  513. position: sticky;
  514. top: 0;
  515. background: #fff;
  516. display: flex;
  517. flex-direction: row;
  518. align-items: center;
  519. justify-content: space-between;
  520. padding: 20rpx 30rpx;
  521. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.06);
  522. z-index: 100;
  523. }
  524. .nav-back {
  525. font-size: 32rpx;
  526. color: #5B9BD5;
  527. }
  528. .nav-title {
  529. font-size: 32rpx;
  530. font-weight: bold;
  531. color: #333;
  532. }
  533. .nav-placeholder {
  534. width: 80rpx;
  535. }
  536. /* ===== 报告头部 ===== */
  537. .report-header {
  538. background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
  539. margin: 20rpx 30rpx;
  540. border-radius: 20rpx;
  541. padding: 30rpx 24rpx;
  542. }
  543. .report-type-tag {
  544. display: inline-block;
  545. background: #1565C0;
  546. color: #fff;
  547. font-size: 22rpx;
  548. padding: 6rpx 20rpx;
  549. border-radius: 20rpx;
  550. margin-bottom: 20rpx;
  551. }
  552. .report-scores {
  553. display: flex;
  554. flex-direction: row;
  555. margin-bottom: 20rpx;
  556. }
  557. .score-item {
  558. display: flex;
  559. flex-direction: column;
  560. align-items: center;
  561. margin-right: 60rpx;
  562. }
  563. .score-circle-lg {
  564. width: 140rpx;
  565. height: 140rpx;
  566. border-radius: 70rpx;
  567. background: #fff;
  568. display: flex;
  569. flex-direction: column;
  570. align-items: center;
  571. justify-content: center;
  572. margin-bottom: 8rpx;
  573. }
  574. .score-circle-green {
  575. background: #E8F5E9;
  576. }
  577. .score-num {
  578. font-size: 48rpx;
  579. font-weight: bold;
  580. color: #1565C0;
  581. }
  582. .score-circle-green .score-num {
  583. color: #2E7D32;
  584. }
  585. .score-unit {
  586. font-size: 22rpx;
  587. color: #64B5F6;
  588. }
  589. .score-circle-green .score-unit {
  590. color: #81C784;
  591. }
  592. .score-label {
  593. font-size: 24rpx;
  594. color: #666;
  595. }
  596. .report-info-row {
  597. display: flex;
  598. flex-direction: row;
  599. margin-bottom: 16rpx;
  600. }
  601. .info-chip {
  602. background: #fff;
  603. color: #333;
  604. font-size: 24rpx;
  605. padding: 8rpx 20rpx;
  606. border-radius: 20rpx;
  607. margin-right: 16rpx;
  608. }
  609. .report-date {
  610. font-size: 22rpx;
  611. color: #888;
  612. }
  613. /* ===== 指标明细 ===== */
  614. .section {
  615. margin: 20rpx 30rpx;
  616. }
  617. .section-title {
  618. display: flex;
  619. flex-direction: row;
  620. align-items: baseline;
  621. margin-bottom: 20rpx;
  622. font-size: 30rpx;
  623. font-weight: bold;
  624. color: #333;
  625. }
  626. .section-sub {
  627. font-size: 22rpx;
  628. color: #999;
  629. font-weight: normal;
  630. margin-left: 12rpx;
  631. }
  632. .category-group {
  633. margin-bottom: 30rpx;
  634. }
  635. .category-header {
  636. display: flex;
  637. flex-direction: row;
  638. align-items: center;
  639. justify-content: space-between;
  640. margin-bottom: 12rpx;
  641. }
  642. .category-name {
  643. font-size: 26rpx;
  644. font-weight: bold;
  645. color: #333;
  646. }
  647. .category-count {
  648. font-size: 22rpx;
  649. color: #999;
  650. }
  651. .indicator-card {
  652. background: #fff;
  653. border-radius: 16rpx;
  654. padding: 20rpx;
  655. margin-bottom: 12rpx;
  656. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  657. }
  658. .ind-header {
  659. display: flex;
  660. flex-direction: row;
  661. align-items: center;
  662. justify-content: space-between;
  663. margin-bottom: 12rpx;
  664. }
  665. .ind-name {
  666. font-size: 28rpx;
  667. color: #333;
  668. font-weight: 500;
  669. }
  670. .ind-status {
  671. font-size: 22rpx;
  672. padding: 4rpx 16rpx;
  673. border-radius: 16rpx;
  674. }
  675. .status-normal {
  676. background: #E8F5E9;
  677. color: #2E7D32;
  678. }
  679. .status-warning {
  680. background: #FFF3E0;
  681. color: #E65100;
  682. }
  683. .status-warn {
  684. background: #F3E5F5;
  685. color: #7B1FA2;
  686. }
  687. .ind-body {
  688. display: flex;
  689. flex-direction: row;
  690. align-items: baseline;
  691. justify-content: space-between;
  692. }
  693. .ind-value-wrap {
  694. display: flex;
  695. flex-direction: row;
  696. align-items: baseline;
  697. }
  698. .ind-value {
  699. font-size: 36rpx;
  700. font-weight: bold;
  701. color: #1565C0;
  702. }
  703. .ind-unit {
  704. font-size: 24rpx;
  705. color: #999;
  706. margin-left: 8rpx;
  707. }
  708. .ind-ref {
  709. font-size: 22rpx;
  710. color: #bbb;
  711. }
  712. .empty-indicators {
  713. text-align: center;
  714. padding: 60rpx;
  715. color: #999;
  716. font-size: 28rpx;
  717. }
  718. /* ===== 底部 ===== */
  719. .bottom-spacer {
  720. height: 130rpx;
  721. }
  722. /* ===== 营养分析入口 FAB ===== */
  723. .nutrition-fab {
  724. position: fixed;
  725. bottom: 40rpx;
  726. left: 50%;
  727. transform: translateX(-50%);
  728. background: linear-gradient(135deg, #43A047, #66BB6A);
  729. color: #fff;
  730. display: flex;
  731. flex-direction: row;
  732. align-items: center;
  733. padding: 20rpx 40rpx;
  734. border-radius: 50rpx;
  735. box-shadow: 0 8rpx 24rpx rgba(67, 160, 71, 0.4);
  736. z-index: 200;
  737. }
  738. .fab-icon {
  739. font-size: 36rpx;
  740. margin-right: 12rpx;
  741. }
  742. .fab-text {
  743. font-size: 30rpx;
  744. font-weight: 600;
  745. }
  746. .score-dashboard {
  747. margin: 20rpx 30rpx;
  748. background: #fff;
  749. border-radius: 20rpx;
  750. padding: 24rpx;
  751. box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  752. }
  753. .main-scores {
  754. display: flex;
  755. flex-direction: row;
  756. flex-wrap: wrap;
  757. justify-content: space-around;
  758. }
  759. .main-score-item {
  760. display: flex;
  761. flex-direction: column;
  762. align-items: center;
  763. margin-bottom: 20rpx;
  764. width: 45%;
  765. }
  766. .score-ring-wrap {
  767. margin-bottom: 8rpx;
  768. }
  769. .main-score-label {
  770. font-size: 24rpx;
  771. color: #666;
  772. font-weight: 500;
  773. }
  774. .flora-score-row {
  775. display: flex;
  776. flex-direction: row;
  777. justify-content: space-around;
  778. margin-top: 16rpx;
  779. padding-top: 20rpx;
  780. border-top: 2rpx solid #F0F0F0;
  781. }
  782. .flora-score-item {
  783. display: flex;
  784. flex-direction: column;
  785. align-items: center;
  786. }
  787. .flora-score-circle {
  788. width: 80rpx;
  789. height: 80rpx;
  790. border-radius: 40rpx;
  791. display: flex;
  792. align-items: center;
  793. justify-content: center;
  794. margin-bottom: 8rpx;
  795. }
  796. .flora-score-num {
  797. font-size: 28rpx;
  798. font-weight: bold;
  799. color: #fff;
  800. }
  801. .flora-score-label {
  802. font-size: 20rpx;
  803. color: #888;
  804. }
  805. /* ===== 营养缺乏分析 ===== */
  806. .deficiency-list {
  807. display: flex;
  808. flex-direction: column;
  809. }
  810. .deficiency-card {
  811. background: #FAFAFA;
  812. border-radius: 16rpx;
  813. padding: 20rpx;
  814. margin-bottom: 12rpx;
  815. }
  816. .deficiency-header {
  817. display: flex;
  818. flex-direction: row;
  819. align-items: center;
  820. justify-content: space-between;
  821. margin-bottom: 12rpx;
  822. }
  823. .deficiency-nutrient {
  824. font-size: 28rpx;
  825. font-weight: bold;
  826. color: #333;
  827. }
  828. .deficiency-type-tag {
  829. font-size: 22rpx;
  830. padding: 4rpx 16rpx;
  831. border-radius: 16rpx;
  832. background: #FFF3E0;
  833. color: #E65100;
  834. }
  835. .dtype-deficiency {
  836. background: #FEE2E2;
  837. color: #DC2626;
  838. }
  839. .dtype-excess {
  840. background: #FFF3E0;
  841. color: #E65100;
  842. }
  843. .dtype-borderline {
  844. background: #FEF3C7;
  845. color: #D97706;
  846. }
  847. .dtype-unclassified {
  848. background: #F3F4F6;
  849. color: #6B7280;
  850. }
  851. .deficiency-severity-row {
  852. display: flex;
  853. flex-direction: row;
  854. align-items: center;
  855. margin-bottom: 8rpx;
  856. }
  857. .severity-bar {
  858. flex: 1;
  859. height: 12rpx;
  860. background: #F3F4F6;
  861. border-radius: 6rpx;
  862. overflow: hidden;
  863. margin-right: 16rpx;
  864. }
  865. .severity-fill {
  866. height: 100%;
  867. border-radius: 6rpx;
  868. }
  869. .severity-val {
  870. font-size: 24rpx;
  871. color: #9CA3AF;
  872. width: 60rpx;
  873. text-align: right;
  874. }
  875. .deficiency-meta {
  876. font-size: 22rpx;
  877. color: #6B7280;
  878. margin-bottom: 6rpx;
  879. }
  880. .deficiency-foods {
  881. font-size: 22rpx;
  882. color: #374151;
  883. margin-top: 8rpx;
  884. }
  885. .foods-label {
  886. color: #9CA3AF;
  887. }
  888. .foods-value {
  889. color: #2E7D32;
  890. }
  891. /* ===== 雷达图 ===== */
  892. .radar-wrap {
  893. display: flex;
  894. justify-content: center;
  895. align-items: center;
  896. }
  897. .radar-canvas {
  898. width: 300px;
  899. height: 300px;
  900. margin: 0 auto;
  901. }
  902. /* ===== 食材推荐 ===== */
  903. .food-list {
  904. display: flex;
  905. flex-direction: column;
  906. }
  907. .food-card {
  908. background: #fff;
  909. border-radius: 16rpx;
  910. padding: 20rpx;
  911. margin-bottom: 12rpx;
  912. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  913. }
  914. .food-header {
  915. display: flex;
  916. flex-direction: row;
  917. align-items: center;
  918. justify-content: space-between;
  919. margin-bottom: 8rpx;
  920. }
  921. .food-name {
  922. font-size: 28rpx;
  923. font-weight: bold;
  924. color: #333;
  925. }
  926. .food-score {
  927. font-size: 24rpx;
  928. padding: 4rpx 16rpx;
  929. border-radius: 16rpx;
  930. font-weight: 600;
  931. }
  932. .score-high {
  933. background: #DCFCE7;
  934. color: #16A34A;
  935. }
  936. .score-mid {
  937. background: #FEF3C7;
  938. color: #D97706;
  939. }
  940. .score-low {
  941. background: #FEE2E2;
  942. color: #DC2626;
  943. }
  944. .score-unknown {
  945. background: #F3F4F6;
  946. color: #6B7280;
  947. }
  948. .food-meta {
  949. margin-bottom: 8rpx;
  950. }
  951. .food-category {
  952. font-size: 22rpx;
  953. color: #6B7280;
  954. background: #F3F4F6;
  955. padding: 2rpx 12rpx;
  956. border-radius: 12rpx;
  957. }
  958. .food-nutrition {
  959. display: flex;
  960. flex-direction: row;
  961. flex-wrap: wrap;
  962. gap: 16rpx;
  963. margin-top: 8rpx;
  964. }
  965. .nutrition-item {
  966. display: flex;
  967. flex-direction: column;
  968. align-items: center;
  969. min-width: 100rpx;
  970. }
  971. .n-label {
  972. font-size: 20rpx;
  973. color: #9CA3AF;
  974. }
  975. .n-value {
  976. font-size: 24rpx;
  977. color: #374151;
  978. font-weight: 500;
  979. }
  980. </style>