fix: 修复6项测试问题并补全配套资源
- 修复油脂类食物推荐量系数 (5.7→2.5) [ToolCalculatorServiceImpl] - AI营养师接入真实Coze API,替换Mock回复 [ToolAiNutritionistServiceImpl] - 食物百科详情新增钙/铁/维C/嘌呤/重量基准字段返回 [ToolFoodServiceImpl] - V2Food模型新增purine、servingSize字段 [V2Food.java] - 食物百科详情页动态重量标注+新增4项营养展示+替换Figma URL [food-detail.vue] - 修复营养素列表dataset传参Bug(WeChat camelCase) [nutrition-knowledge.vue] - 营养素详情页接入后端API+兜底本地数据+替换Figma URL [nutrient-detail.vue] - 新增数据库迁移脚本及参考初始化数据 [docs/sql/] - 新增前端占位图标5个 [static/images/] - 新增开发任务完成报告 [docs/] Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
<view class="key-nutrients-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">关键营养成分</text>
|
||||
<view class="unit-badge">每100g</view>
|
||||
<view class="unit-badge">{{ foodData.servingSize || '每100g' }}</view>
|
||||
</view>
|
||||
<view class="key-nutrients-grid">
|
||||
<view
|
||||
@@ -51,7 +51,7 @@
|
||||
<view class="nutrition-table-section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">营养成分表</text>
|
||||
<text class="unit-text">每100g</text>
|
||||
<text class="unit-text">{{ foodData.servingSize || '每100g' }}</text>
|
||||
</view>
|
||||
<view class="nutrition-table">
|
||||
<view
|
||||
@@ -92,8 +92,8 @@ import { getFoodDetail } from '@/api/tool.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
iconShare: 'https://www.figma.com/api/mcp/asset/f9f0d7b9-89c0-48d4-9e04-7140229e42f0',
|
||||
iconSearch: 'https://www.figma.com/api/mcp/asset/aa6bb75b-0a9d-43cb-aaa4-6a71993fbd4d',
|
||||
iconShare: '/static/images/icon-share.png',
|
||||
iconSearch: '/static/images/icon-search.png',
|
||||
loading: false,
|
||||
/** 加载失败时的具体错误信息,用于调试;有值时页面会展示「当前数据来自缓存」提示 */
|
||||
loadError: '',
|
||||
@@ -114,7 +114,7 @@ export default {
|
||||
category: '谷薯类',
|
||||
categoryType: 'grain',
|
||||
safetyTag: '放心吃',
|
||||
image: 'https://www.figma.com/api/mcp/asset/bf4ff04c-1322-474a-bd03-5b8a49fe33ad',
|
||||
image: '',
|
||||
keyNutrients: [
|
||||
{ name: '磷', value: '13', unit: 'mg', status: '正常' },
|
||||
{ name: '钾', value: '7', unit: 'mg', status: '正常' },
|
||||
@@ -315,8 +315,8 @@ export default {
|
||||
if (data.keyNutrients && Array.isArray(data.keyNutrients)) {
|
||||
return data.keyNutrients
|
||||
}
|
||||
// 从详细营养数据中提取关键营养素
|
||||
const nutrients = data.nutrients || data.nutritionData || {}
|
||||
// 从详细营养数据中提取关键营养素(兼容 data.nutrients 子对象和 data 平铺字段)
|
||||
const nutrients = data.nutrients || data.nutritionData || data
|
||||
const keyList = []
|
||||
if (nutrients.phosphorus !== undefined) keyList.push({ name: '磷', value: String(nutrients.phosphorus), unit: 'mg', status: this.getStatus(nutrients.phosphorus, 'phosphorus') })
|
||||
if (nutrients.potassium !== undefined) keyList.push({ name: '钾', value: String(nutrients.potassium), unit: 'mg', status: this.getStatus(nutrients.potassium, 'potassium') })
|
||||
@@ -328,7 +328,8 @@ export default {
|
||||
if (data.nutritionTable && Array.isArray(data.nutritionTable)) {
|
||||
return data.nutritionTable
|
||||
}
|
||||
const nutrients = data.nutrients || data.nutritionData || {}
|
||||
// 兼容 data.nutrients 子对象和 data 平铺字段
|
||||
const nutrients = data.nutrients || data.nutritionData || data
|
||||
const table = []
|
||||
const items = [
|
||||
{ key: 'potassium', name: '钾', unit: 'mg', thresholds: [200, 500] },
|
||||
@@ -336,12 +337,15 @@ export default {
|
||||
{ key: 'phosphorus', name: '磷', unit: 'mg', thresholds: [100, 300] },
|
||||
{ key: 'protein', name: '蛋白质', unit: 'g', thresholds: [5, 15] },
|
||||
{ key: 'sodium', name: '钠', unit: 'mg', thresholds: [100, 500] },
|
||||
{ key: 'iron', name: '铁', unit: 'mg', thresholds: [5, 15] },
|
||||
{ key: 'vitaminC', name: '维生素C', unit: 'mg', thresholds: [20, 60] },
|
||||
{ key: 'purine', name: '嘌呤', unit: 'mg', thresholds: [50, 150] }
|
||||
]
|
||||
items.forEach(item => {
|
||||
const val = nutrients[item.key]
|
||||
if (val !== undefined) {
|
||||
const level = val <= item.thresholds[0] ? 'low' : (val <= item.thresholds[1] ? 'medium' : 'high')
|
||||
if (val !== undefined && val !== null) {
|
||||
const numVal = Number(val)
|
||||
const level = numVal <= item.thresholds[0] ? 'low' : (numVal <= item.thresholds[1] ? 'medium' : 'high')
|
||||
const levelText = level === 'low' ? '低' : (level === 'medium' ? '中' : '高')
|
||||
table.push({ name: item.name, value: String(val), unit: item.unit, level, levelText })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user