update:运动馆

This commit is contained in:
ltx 2026-04-28 14:20:44 +08:00
parent afab9b0a53
commit 29d3ba66f8
2 changed files with 25 additions and 4 deletions

View File

@ -100,12 +100,26 @@ Page({
const res = await getPhysicalFitnessReport()
const rawList = (res.data && res.data.categoryScoreList) || []
const list = rawList.filter(item => !(item.name && item.name.includes('米') && item.name.includes('跑')))
// 雷达图根据 gradeId 过滤不适用的项目
const gradeId = list.length > 0 ? list[0].gradeId : null
let radarList = list
if (gradeId !== null && gradeId !== undefined) {
if (gradeId <= 2) {
radarList = list.filter(item => item.name !== '一分钟仰卧起坐' && item.name !== '立定跳远')
} else if (gradeId > 2 && gradeId <= 6) {
radarList = list.filter(item => item.name !== '立定跳远')
} else if (gradeId > 6) {
radarList = list.filter(item => item.name !== '一分钟跳绳')
}
}
const fitnessItems = list.map(item => ({
...item,
unit: UNIT_MAP[item.name] || '',
}))
this.setData({
fitnessReport: list,
fitnessReport: radarList,
fitnessItems,
})
} catch (e) {
@ -156,7 +170,7 @@ Page({
tapLegend:true,
background: 'rgba(0,0,0,0)',
color: ['#4A90E2', '#E74C3C'],
padding: [0, 0, 0, 10],
padding: [0, 0, 0, 15],
legend: {
show: true,
position: 'bottom',
@ -168,7 +182,7 @@ Page({
},
extra: {
radar: {
gridType: this.data.fitnessItems.length == 4 ? 'circle' : 'radar',
gridType: this.data.fitnessReport.length == 4 ? 'circle' : 'radar',
gridColor: '#CCCCCC',
gridCount: 4,
opacity: 0.15,

View File

@ -17,7 +17,14 @@ Page({
onLoad() {
const item = wx.getStorageSync('fitnessDetailItem') || null
if (item) {
this.setData({ item, name: item.name, unit: item.unit || '' })
const fmt = v => (v != null && !isNaN(v)) ? Number(v).toFixed(1) : v
const formattedItem = {
...item,
lastScore: fmt(item.lastScore),
classAvgScore: fmt(item.classAvgScore),
schoolAvgScore: fmt(item.schoolAvgScore),
}
this.setData({ item: formattedItem, name: item.name, unit: item.unit || '' })
wx.setNavigationBarTitle({ title: item.name + '详情' })
}
},