update:运动馆

This commit is contained in:
ltx 2026-04-28 16:50:36 +08:00
parent 29d3ba66f8
commit f7e322d595
6 changed files with 54 additions and 19 deletions

View File

@ -187,7 +187,6 @@
<view class="score-label">上次成绩</view>
<view class="score-value">{{selectedFitnessItem.scoreTrendChart.axisY[selectedFitnessItem.scoreTrendChart.axisY.length - 2] || '- -'}}<text class="score-unit"> {{selectedFitnessItem.unit}}</text></view>
</view>
<view class="score-divider"></view>
</view>
<view class="popup-btn" bind:tap="goFitnessDetail">查看详细趋势</view>

View File

@ -164,7 +164,7 @@ Page({
pageIndex: this.data.page,
PageSize: 20,
})
if(!this.data.nowCourse.id && res.data.datas.length > 0){
if((!!this.data.nowCourse && !this.data.nowCourse.id) && res.data.datas.length > 0){
const detail = await getClassRoomReportDetails(res.data.datas[0].id)
this.setData({
nowCourseDetail:this.data.nowCourse.id ? this.data.nowCourseDetail: detail.data
@ -176,7 +176,7 @@ Page({
courseList: refresh ? res.data.datas : [...this.data.courseList, ...res.data.datas],
page: this.data.page + 1,
hasMore: res.data.total > (this.data.page) * 20,
nowCourse: !this.data.nowCourse.id || refresh ? res.data.datas[0] : this.data.nowCourse,
nowCourse: (!!this.data.nowCourse && !this.data.nowCourse.id) || refresh ? res.data.datas[0] : this.data.nowCourse,
})
},
@ -378,7 +378,11 @@ Page({
hasMore:true
},()=>{
if(this.data.isTrainer){
this.getTrainClass(true)
if(this.data.activeTab === 0){
this.getTrainClass(true)
}else if(this.data.activeTab === 1){
this.getFitnessStudents()
}
}else{
this.getClass()
}

View File

@ -20,7 +20,7 @@ Page({
const fmt = v => (v != null && !isNaN(v)) ? Number(v).toFixed(1) : v
const formattedItem = {
...item,
lastScore: fmt(item.lastScore),
lastScore: fmt(item.scoreTrendChart.axisY.slice(-1)[0]),
classAvgScore: fmt(item.classAvgScore),
schoolAvgScore: fmt(item.schoolAvgScore),
}

View File

@ -37,13 +37,13 @@
</view>
<text class="bar-val">{{item ? item.lastScore : 0}}</text>
</view>
<view class="compare-row">
<!-- <view class="compare-row">
<view class="compare-label">班级<text class="nl">平均成绩</text></view>
<view class="bar-track">
<view class="bar-fill bar-fill-light" style="width:{{item ? (item.classAvgScore / item.maxScore * 100) + '%' : '0%'}}"></view>
</view>
<text class="bar-val">{{item ? item.classAvgScore : 0}}</text>
</view>
</view> -->
<view class="compare-row">
<view class="compare-label">机构<text class="nl">平均成绩</text></view>
<view class="bar-track">

View File

@ -31,13 +31,28 @@ Page({
this.setData({ studentNo: options.studentNo || '' });
try {
const res = await getReport({ studentNo: options.studentNo });
const list = (res.data && res.data.categoryScoreList) || [];
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,
}, () => {
// 如果 onReady 已经触发,数据到位后立即绘图
@ -54,8 +69,9 @@ Page({
onReady() {
const info = wx.getWindowInfo();
const pixelRatio = info.pixelRatio;
const radarCWidth = info.windowWidth * 0.86;
const radarCHeight = info.windowWidth * 0.86;
const rpxRatio = info.windowWidth / 750;
const radarCWidth = Math.floor(info.windowWidth - 2 * 30 * rpxRatio);
const radarCHeight = Math.floor(radarCWidth * 1.05);
this.setData({ radarCWidth, radarCHeight, pixelRatio, readyFired: true }, () => {
// 如果数据已经加载完,直接绘图;否则等 onLoad 回调里触发
if (this.data.fitnessReport && this.data.fitnessReport.length > 0) {
@ -66,9 +82,23 @@ Page({
drawRadarChart(that) {
const list = that.data.fitnessReport || [];
const categories = list.map(i => i.name);
// 长文本自动换行(超过5字在中间插入换行)
const categories = list.map(i => {
const name = i.name || '';
if (name.length > 5) {
const mid = Math.ceil(name.length / 2);
return name.slice(0, mid) + '\n' + name.slice(mid);
}
return name;
});
const prevData = list.map(i => i.prevScore || 0);
const currentData = list.map(i => i.lastScore || 0);
// 本次成绩数据标签:显示分数 + 等级
const currentDataLabels = list.map(i => {
const score = i.lastScore != null ? i.lastScore : '';
const rank = i.rank != null ? i.rank : '';
return rank ? score + '\n' + rank : String(score);
});
const query = wx.createSelectorQuery().in(that);
query.select('#radarCanvas').fields({ node: true, size: true }).exec(res => {
@ -84,26 +114,27 @@ Page({
height: that.data.radarCHeight * that.data.pixelRatio,
categories,
series: [
{ name: '上次成绩', data: prevData, color: '#4A90E2' },
{ name: '本次成绩', data: currentData, color: '#E74C3C' },
{ name: '上次成绩', data: prevData, color: '#4A90E2', dataLabel: false },
{ name: '本次成绩', data: currentData, color: '#E74C3C', dataLabels: currentDataLabels, textColor: '#E74C3C', textSize: 11 },
],
pixelRatio: that.data.pixelRatio,
animation: true,
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',
float: 'center',
fontSize: 12,
lineHeight: 11,
margin: 5,
margin: 0,
itemGap: 20,
},
extra: {
radar: {
gridType: 'radar',
gridType: that.data.fitnessReport.length === 4 ? 'circle' : 'radar',
gridColor: '#CCCCCC',
gridCount: 4,
opacity: 0.15,
@ -112,6 +143,7 @@ Page({
labelShow: true,
labelColor: '#333',
fontSize: 13,
labelMargin: 30,
labelPointShow: false,
max: 100,
},

View File

@ -53,7 +53,7 @@
<view class="score-label">上次成绩</view>
<view class="score-value">{{selectedFitnessItem.prevScore}}<text class="score-unit"> {{selectedFitnessItem.unit}}</text></view>
</view>
<view class="score-divider"></view>
<!-- <view class="score-divider"></view>
<view class="score-row">
<view class="score-label">班级平均</view>
<view class="score-value">{{selectedFitnessItem.classAvgScore}}<text class="score-unit"> {{selectedFitnessItem.unit}}</text></view>
@ -61,7 +61,7 @@
<view class="score-row">
<view class="score-label">机构平均</view>
<view class="score-value">{{selectedFitnessItem.schoolAvgScore}}<text class="score-unit"> {{selectedFitnessItem.unit}}</text></view>
</view>
</view> -->
</view>
<view class="popup-btn" bind:tap="goFitnessDetail">查看详细趋势</view>