100 lines
2.1 KiB
JavaScript
Raw Normal View History

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'
Page({
/**
* 页面的初始数据
*/
data: {
report: {},
list: []
},
/**
* 生命周期函数--监听页面加载
*/
async onLoad(options) {
await this.getStudentReport()
},
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
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
tabService.updateIndex(this, 2)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
async onPullDownRefresh() {
await this.getStudentReport()
wx.showToast({
title: '刷新成功!',
icon: 'none'
})
wx.stopPullDownRefresh()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})