From afab9b0a534f19fd80ee358fa99ba76599abc7f8 Mon Sep 17 00:00:00 2001 From: ltx <1006158920@qq.com> Date: Mon, 27 Apr 2026 17:24:02 +0800 Subject: [PATCH] =?UTF-8?q?update:=E8=BF=90=E5=8A=A8=E9=A6=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/parent/report/report.js | 39 ++++- pages/parent/report/report.wxml | 14 +- pages/parent/report/report.wxss | 1 + .../teacher/report-detail/report-detail.js | 52 +++++- .../teacher/report-detail/report-detail.wxml | 52 +++++- .../teacher/report-detail/report-detail.wxss | 149 ++++++++++++++++++ utils/chart/u-charts.js | 46 ++++-- utils/http.js | 4 +- 8 files changed, 315 insertions(+), 42 deletions(-) diff --git a/pages/parent/report/report.js b/pages/parent/report/report.js index 1e4dd0e..12407d5 100644 --- a/pages/parent/report/report.js +++ b/pages/parent/report/report.js @@ -98,7 +98,8 @@ Page({ async fetchFitnessReport() { try { const res = await getPhysicalFitnessReport() - 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('跑'))) const fitnessItems = list.map(item => ({ ...item, unit: UNIT_MAP[item.name] || '', @@ -115,9 +116,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 => { @@ -133,11 +148,12 @@ 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], @@ -147,12 +163,12 @@ Page({ float: 'center', fontSize: 12, lineHeight: 11, - margin: 5, + margin: 0, itemGap: 20, }, extra: { radar: { - gridType: 'radar', + gridType: this.data.fitnessItems.length == 4 ? 'circle' : 'radar', gridColor: '#CCCCCC', gridCount: 4, opacity: 0.15, @@ -161,6 +177,7 @@ Page({ labelShow: true, labelColor: '#333', fontSize: 13, + labelMargin: 30, labelPointShow: false, max: 100, }, @@ -209,6 +226,10 @@ Page({ page: this.data.page + 1, hasMore: res.data.total > (this.data.pageIndex) * 20, }) + + if(this.data.isTrainee && this.data.activeTab === 1){ + this.drawRadarChart(this) + } }, //查看报告详情 @@ -224,8 +245,10 @@ Page({ onReady() { const windowInfo = wx.getWindowInfo() const pixelRatio = windowInfo.pixelRatio - const radarCWidth = windowInfo.windowWidth * 0.86 - const radarCHeight = windowInfo.windowWidth * 0.86 + // 宽度 = 屏幕宽度 - 页面两侧 padding(30rpx×2),不计 card padding(由负 margin 抵消) + const rpxRatio = windowInfo.windowWidth / 750 + const radarCWidth = Math.floor(windowInfo.windowWidth - 2 * 30 * rpxRatio) + const radarCHeight = Math.floor(radarCWidth * 1.05) // 稍高,给换行标签和 rank 留出空间 this.setData({ radarCWidth, radarCHeight, pixelRatio }, () => { if (this.data.isTrainee && this.data.activeTab === 1) { this.drawRadarChart(this) diff --git a/pages/parent/report/report.wxml b/pages/parent/report/report.wxml index 4eb0bbc..19b63fd 100644 --- a/pages/parent/report/report.wxml +++ b/pages/parent/report/report.wxml @@ -162,7 +162,7 @@ {{item.name}} - {{item.lastScore}} {{item.unit}} + {{item.scoreTrendChart.axisY[item.scoreTrendChart.axisY.length - 1] || '- -'}} {{item.unit}} @@ -181,21 +181,13 @@ 本次成绩 - {{selectedFitnessItem.lastScore}} {{selectedFitnessItem.unit}} + {{selectedFitnessItem.scoreTrendChart.axisY[selectedFitnessItem.scoreTrendChart.axisY.length - 1] || '- -'}} {{selectedFitnessItem.unit}} 上次成绩 - {{selectedFitnessItem.prevScore}} {{selectedFitnessItem.unit}} + {{selectedFitnessItem.scoreTrendChart.axisY[selectedFitnessItem.scoreTrendChart.axisY.length - 2] || '- -'}} {{selectedFitnessItem.unit}} - - 班级平均 - {{selectedFitnessItem.classAvgScore}} {{selectedFitnessItem.unit}} - - - 机构平均 - {{selectedFitnessItem.schoolAvgScore}} {{selectedFitnessItem.unit}} - 查看详细趋势 diff --git a/pages/parent/report/report.wxss b/pages/parent/report/report.wxss index 2524289..7d157ff 100644 --- a/pages/parent/report/report.wxss +++ b/pages/parent/report/report.wxss @@ -393,6 +393,7 @@ .radar-wrap { overflow: hidden; + margin: 0 -20rpx; /* 抵消 fitness-card 两侧 padding,让图表更宽 */ } .radar-legend { diff --git a/subpackage/teacher/report-detail/report-detail.js b/subpackage/teacher/report-detail/report-detail.js index b479a73..db0d387 100644 --- a/subpackage/teacher/report-detail/report-detail.js +++ b/subpackage/teacher/report-detail/report-detail.js @@ -9,7 +9,8 @@ Page({ * 页面的初始数据 */ data: { - reportDetail:{} + reportDetail:{}, + loading: true }, /** @@ -27,13 +28,21 @@ Page({ async getReport(){ let params = { classRoomId:this.data.classRoomId, + type:1 } if(this.data.studentNo){ params.studentNo = this.data.studentNo } const res = await getStudentClassRoomReport(params) + const age = res.data.age || 0 + const hrMax = 220 - age + const moderateHR = Math.round(hrMax * 0.6) // 中等强度下限 + const highHR = Math.round(hrMax * 0.75) // 高强度下限 this.setData({ - reportDetail:res.data + reportDetail: res.data, + moderateHR, + highHR, + loading: false },()=>{ this.drawCharts(this) }) @@ -74,6 +83,7 @@ Page({ }, ], pixelRatio: that.data.pixelRatio, animation: true, + enableMarkLine: true, background: "#FFFFFF", color: that.data.chartType == 1 ? ["#FFA30C"] : that.data.chartType == 2 ? ["#6CB7FB"] : ["#FF4949"], padding: [15, 15, 10, 0], @@ -97,13 +107,41 @@ Page({ yAxis: { gridType: "dash", gridColor: "#F1F1F1", - // data: [{ - // min: 40, - // // axisLine: false, - // fontSize: 12 - // }] + data: [{ + // min: Math.max(0, that.data.moderateHR - 20), + max: that.data.highHR + 20, + fontSize: 12 + }] }, extra: { + markLine: { + type: 'dash', + dashLength: 6, + data: [ + { + value: that.data.moderateHR, + lineColor: '#FFA30C', + showLabel: true, + labelText: '中强度', + labelFontColor: '#FFA30C', + labelBgColor: '#FFF8EC', + labelBgOpacity: 0.9, + labelAlign: 'left', + labelFontSize: 11 + }, + { + value: that.data.highHR, + lineColor: '#FF4949', + showLabel: true, + labelText: '高强度', + labelFontColor: '#FF4949', + labelBgColor: '#FFF0F0', + labelBgOpacity: 0.9, + labelAlign: 'left', + labelFontSize: 11 + } + ] + }, line: { type: "curve", width: 2, diff --git a/subpackage/teacher/report-detail/report-detail.wxml b/subpackage/teacher/report-detail/report-detail.wxml index 85fab75..1c04886 100644 --- a/subpackage/teacher/report-detail/report-detail.wxml +++ b/subpackage/teacher/report-detail/report-detail.wxml @@ -2,6 +2,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 心率统计 @@ -10,7 +50,16 @@ - + + + + 中等强度 {{moderateHR}}次/分 + + + + 高强度 {{highHR}}次/分 + +