2025-06-06 15:17:30 +08:00
|
|
|
// pages/parent/report/report.js
|
|
|
|
const tabService = require("../../../utils/tab-serve");
|
|
|
|
import {
|
|
|
|
getReport
|
|
|
|
} from '../../../utils/serve/parent'
|
2025-06-13 14:39:20 +08:00
|
|
|
import { getClassRoomRecord } from '../../../utils/serve/teacher';
|
|
|
|
import { getWeekdayWithValidation } from '../../../utils/utils';
|
2025-06-06 15:17:30 +08:00
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
report: {},
|
2025-06-13 14:39:20 +08:00
|
|
|
list: [],
|
|
|
|
isTrainee:false,
|
|
|
|
pageIndex:1,
|
|
|
|
hasMore:true,
|
|
|
|
roomList:[]
|
2025-06-06 15:17:30 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
async onLoad(options) {
|
2025-06-13 14:39:20 +08:00
|
|
|
if(wx.getStorageSync('roleId') && wx.getStorageSync('roleId') == 3 ){
|
|
|
|
this.setData({
|
|
|
|
isTrainee:true
|
|
|
|
},()=>{
|
|
|
|
this.getTrainClass(true)
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
await this.getStudentReport()
|
|
|
|
}
|
2025-06-06 15:17:30 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
async getStudentReport() {
|
|
|
|
const res = await getReport()
|
|
|
|
let list = []
|
|
|
|
res.data.categoryScoreList.forEach(e => {
|
|
|
|
list.push({
|
|
|
|
...e,
|
|
|
|
width: e.score >= 60 && e.score <= 80 ? (((e.score - 60) / 4)*5 + 25) + '%' : ((e.score - 60) / 0.4 + 2) + '%',
|
|
|
|
grade: e.score >= 90 ? 'grate' : e.score >= 80 ? 'good' : e.score >= 60 ? 'normal' : ''
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
res.data.width = res.data.totalScore >= 60 && res.data.totalScore <= 80 ? (((res.data.totalScore - 60) / 4)*5 + 25) + '%' : ((res.data.totalScore - 60) / 0.4 + 2) + '%',
|
|
|
|
res.data.grade = res.data.totalScore >= 90 ? 'grate' : res.data.totalScore >= 80 ? 'good' : res.data.totalScore >= 60 ? 'normal' : ''
|
|
|
|
res.data.totalScore = res.data.totalScore.toFixed(0)
|
|
|
|
res.data.bodyFunction = res.data.bodyFunction.toFixed(0)
|
|
|
|
res.data.bodyQuality = res.data.bodyQuality.toFixed(0)
|
|
|
|
res.data.bodyShape = res.data.bodyShape.toFixed(0)
|
|
|
|
this.setData({
|
|
|
|
report: res.data,
|
|
|
|
list
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2025-06-13 14:39:20 +08:00
|
|
|
//获取教练课堂记录 刷新 加载更多
|
|
|
|
async getTrainClass(refresh) {
|
|
|
|
if (!this.data.hasMore && !refresh) return //非刷新且没有
|
|
|
|
const res = await getClassRoomRecord({
|
|
|
|
pageIndex: this.data.pageIndex,
|
|
|
|
PageSize: 20,
|
|
|
|
})
|
|
|
|
let newList = res.data.datas.map(item => {
|
|
|
|
return {
|
|
|
|
...item,
|
|
|
|
time: getWeekdayWithValidation(Number(item.startingEndingTime.slice(0, 4)), Number(item.startingEndingTime.slice(5, 7)), Number(item.startingEndingTime.slice(8, 10)))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
roomList: refresh ? newList : [...this.data.roomList, ...newList],
|
|
|
|
page: this.data.page + 1,
|
|
|
|
hasMore: res.data.total > (this.data.pageIndex) * 20,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
//查看报告详情
|
|
|
|
goReportDetail(e){
|
|
|
|
wx.navigateTo({
|
|
|
|
url: '/subpackage/teacher/report-detail/report-detail?id='+e.currentTarget.id ,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2025-06-06 15:17:30 +08:00
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow() {
|
|
|
|
tabService.updateIndex(this, 2)
|
2025-06-13 14:39:20 +08:00
|
|
|
if(wx.getStorageSync('roleId') && wx.getStorageSync('roleId') == 5){ //学员
|
|
|
|
this.setData({
|
|
|
|
isTrainee:true
|
|
|
|
})
|
|
|
|
}
|
2025-06-06 15:17:30 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
async onPullDownRefresh() {
|
2025-06-13 14:39:20 +08:00
|
|
|
if(this.data.isTrainee){
|
|
|
|
this.setData({
|
|
|
|
pageIndex:1,
|
|
|
|
hasMore:true
|
|
|
|
},()=>{
|
|
|
|
this.getTrainClass(true)
|
|
|
|
wx.stopPullDownRefresh()
|
|
|
|
wx.showToast({
|
|
|
|
title: '刷新成功',
|
|
|
|
icon: 'none'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
await this.getStudentReport()
|
|
|
|
wx.stopPullDownRefresh()
|
|
|
|
wx.showToast({
|
|
|
|
title: '刷新成功!',
|
|
|
|
icon: 'none'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2025-06-06 15:17:30 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom() {
|
2025-06-13 14:39:20 +08:00
|
|
|
this.getTrainClass()
|
2025-06-06 15:17:30 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|