大量修改与调整;适配家长查看部分;适配健康部分

This commit is contained in:
Saturneric 2021-04-09 23:51:13 +08:00
parent 82473c8d1f
commit 63e1cb524a
17 changed files with 313 additions and 92 deletions

View File

@ -39,3 +39,42 @@ export const getCourseGrades = (semester_id) => {
}
})
}
export const getStudentsGrade = () => {
return request({
url: "/course/grade/students",
method: "get",
data: {}
})
}
export const getGradeForParent = (openid) => {
return request({
url: "/course/grade/parent",
method: "get",
data: {
openid
}
})
}
export const getSemestersForParent = (openid) => {
return request({
url: "/course/semesters/parent",
method: "get",
data: {
openid
}
})
}
export const getSemesterGradesForParent = (openid, semester_id) => {
return request({
url: "/course/grade/semester/parent",
method: "get",
data: {
openid,
semesterId: semester_id
}
})
}

View File

@ -18,3 +18,24 @@ export const markMessage = (messageId) => {
}
})
}
export const createMessageAndSend = (openid, title, context) => {
return request({
url: "/message/",
method: "post",
data: {
title,
context
}
}).then(messageId => {
return request({
url: "/message/receiver",
method: "post",
data: {
messageId,
openid
}
})
})
}

View File

@ -13,7 +13,9 @@
"pages/my-students/my-students",
"pages/students-grade-analyse/students-grade-analyse",
"pages/my-health/my-health",
"pages/my-honors/my-honors"
"pages/my-honors/my-honors",
"pages/robot/robot",
"pages/my-children/my-children"
],
"window": {
"backgroundTextStyle": "light",

View File

@ -62,5 +62,9 @@ Page({
*/
onShareAppMessage: function () {
},
bindSend() {
}
})

View File

@ -18,7 +18,7 @@
</view>
</view>
<view class="weui-form__opr-area">
<a class="weui-btn weui-btn_primary">发送</a>
<a class="weui-btn weui-btn_primary" bindtap="bindSend">发送</a>
</view>
</view>

View File

@ -281,4 +281,11 @@ Page({
url: '/pages/my-honors/my-honors'
})
},
bindMyChildren(e) {
let query = e.currentTarget.dataset['index']
// 跳转
wx.navigateTo({
url: '/pages/my-children/my-children?openid=' + query
})
}
})

View File

@ -32,9 +32,8 @@
<view class="weui-cell weui-cell_active" wx:for="{{childrenInfo}}" wx:key="index">
<view class="weui-cell__hd">
<image src="{{item.avatarUrl}}"></image>
<text class="weui-badge">8</text>
</view>
<view class="weui-cell__bd">
<view class="weui-cell__bd" bindtap="bindMyChildren" data-index="{{item.openid}}">
<view>{{item.nickName}}</view>
<view class="demo_badge_desc">我的孩子</view>
</view>
@ -42,7 +41,6 @@
<view class="weui-cell weui-cell_active" bindtap="bindChildSupervisor" wx:for="{{supervisorsInfo}}" wx:key="index">
<view class="weui-cell__hd">
<image src="{{item.avatarUrl}}"></image>
<text class="weui-badge">8</text>
</view>
<view class="weui-cell__bd">
<view>{{item.nickName}}</view>
@ -63,42 +61,42 @@
</view>
<view class="weui-cell__ft"></view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access">
<view class="weui-cell weui-cell_active weui-cell_access" wx:if="{{userDocument.role === 'ROLE_PARENT'}}">
<view class="weui-cell__bd">
<text class="demo_badge_title">问答机器人</text>
<text class="weui-badge">8</text>
</view>
<view class="weui-cell__ft">详细信息</view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access" bindtap="bindMyGrade">
<view class="weui-cell weui-cell_active weui-cell_access" bindtap="bindMyGrade" wx:if="{{userDocument.role === 'ROLE_STUDENT'}}">
<view class="weui-cell__bd">
<text class="demo_badge_title">我的成绩</text>
<text class="weui-badge">New</text>
</view>
<view class="weui-cell__ft"></view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access" bindtap="bindMyHonors">
<view class="weui-cell weui-cell_active weui-cell_access" bindtap="bindMyHonors" wx:if="{{userDocument.role === 'ROLE_STUDENT'}}">
<view class="weui-cell__bd">
<text class="demo_badge_title">我的荣誉</text>
<text class="weui-badge">New</text>
</view>
<view class="weui-cell__ft"></view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access" bindtap="bindMyHealth">
<view class="weui-cell weui-cell_active weui-cell_access" bindtap="bindMyHealth" wx:if="{{userDocument.role === 'ROLE_STUDENT'}}">
<view class="weui-cell__bd">
<text class="demo_badge_title">我的健康</text>
<text class="weui-badge">New</text>
</view>
<view class="weui-cell__ft"></view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access" bindtap="bindMyStudents">
<view class="weui-cell weui-cell_active weui-cell_access" bindtap="bindMyStudents" wx:if="{{userDocument.role === 'ROLE_SUPERVISOR'}}">
<view class="weui-cell__bd">
<text class="demo_badge_title">我的学生</text>
<text class="weui-badge">New</text>
</view>
<view class="weui-cell__ft"></view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access" bindtap="bindStudentsGradeAnalyse">
<view class="weui-cell weui-cell_active weui-cell_access" bindtap="bindStudentsGradeAnalyse" wx:if="{{userDocument.role === 'ROLE_SUPERVISOR'}}">
<view class="weui-cell__bd">
<text class="demo_badge_title">学生成绩分析</text>
<text class="weui-badge">New</text>

View File

@ -1,6 +1,6 @@
// pages/my-grade/my-grade.js
import {getGrade, getSemesters, getSemesterGrades, getCourseGrades} from '../../api/course'
import {getGrade, getSemesters, getSemesterGrades, getCourseGrades, getGradeForParent, getSemestersForParent, getSemesterGradesForParent} from '../../api/course'
Page({
@ -13,6 +13,7 @@ Page({
showSemester: false,
targetSemesterInfo: {},
targetCoursesInfo: [],
targetOpenid: '',
showIndex: 0
},
@ -20,6 +21,32 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.isParent === 'true') {
this.setData({
isParent: true,
targetOpenid: options.openid
})
getGradeForParent(options.openid).then(res => {
console.log(res)
if(res.failedCourse === 0 && res.passedCourse === 0) {
this.setData({
recordNotFound: true
})
}
else {
this.setData({
gradeInfo: res
})
}
}).then(res => {
return getSemestersForParent(options.openid).then(res => {
console.log(res)
this.setData({
semestersInfo: res
})
})
})
} else {
getGrade().then(res => {
console.log(res)
if(res.failedCourse === 0 && res.passedCourse === 0) {
@ -42,6 +69,8 @@ Page({
}).catch(err => {
console.log(err)
})
}
},
/**
@ -104,6 +133,26 @@ Page({
onClickSemesterItem(e) {
let index = parseInt(e.currentTarget.dataset['index'])
if(this.data.isParent) {
getSemesterGradesForParent(this.data.targetOpenid, this.data.semestersInfo[index].id).then(res => {
console.log(res)
this.setData({
targetSemesterInfo: res
})
return Promise.resolve(this.data.semestersInfo[index].id)
}).then(sem_id => {
return getCourseGrades(sem_id).then(res => {
console.log(res)
this.setData({
targetCoursesInfo: res
})
})
}).then(res => {
this.setData({
showSemester: true,
})
})
} else {
getSemesterGrades(this.data.semestersInfo[index].id).then(res => {
console.log(res)
this.setData({
@ -123,4 +172,5 @@ Page({
})
})
}
}
})

View File

@ -1,8 +1,10 @@
<!--pages/my-grade/my-grade.wxml-->
<view class="page" data-weui-theme="{{theme}}">
<view class="page__hd" wx:if="{{!showSemester}}">
<view class="page__title">我的成绩</view>
<view class="page__desc">我在学校学习生活的概况</view>
<view class="page__title" wx:if="{{!isParent}}">我的成绩</view>
<view class="page__title" wx:else>孩子的成绩</view>
<view class="page__desc" wx:if="{{!isParent}}">我在学校学习生活的概况</view>
<view class="page__desc" wx:else>孩子在学校学习生活的概况</view>
</view>
<view class="page__hd" wx:else>
<view class="page__title">{{targetSemesterInfo.semester}}</view>
@ -119,7 +121,7 @@
</view>
</view>
<i-spin size="large" fix wx:if="{{ recordNotFound }}" custom><view>未找到您的成绩记录</view></i-spin>
<i-spin size="large" fix wx:if="{{ recordNotFound }}" custom><view>未找到成绩记录</view></i-spin>
</view>

View File

@ -1,11 +1,18 @@
// pages/my-health/my-health.js
import {getStepsToday, saveSteps, getStepsMonth, getStepsForParent} from '../../api/step'
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
userDocument:{},
stepsInfo: {},
monthStepsInfo: [],
recordNotFound: false
},
/**
@ -13,6 +20,45 @@ Page({
*/
onLoad: function (options) {
if(options.isParent === 'true') {
getStepsForParent(options.openid).then(res =>{
console.log(res)
this.setData({
stepsInfo: res,
monthStepsInfo: res.stepList
})
if(res.recordCount === 0) {
this.setData({
recordNotFound: true
})
}
})
} else {
const that = this
new Promise((resolve, reject) =>{
wx.getWeRunData({
success (res) {
// 拿 encryptedData 到开发者后台解密开放数据
const encryptedData = res.encryptedData
// 或拿 cloudID 通过云调用直接获取开放数据
const cloudID = res.cloudID
// iv
const iv = res.iv
saveSteps(encryptedData, iv).then(res => {
console.log(res)
that.setData({
stepsInfo: res,
monthStepsInfo: res.stepList
})
resolve(res)
})
}
})
}).then(res => {
})
}
},
/**

View File

@ -1,3 +1,5 @@
{
"usingComponents": {}
"usingComponents": {
"i-spin": "../../dist/spin/index"
}
}

View File

@ -1,8 +1,50 @@
<!--pages/my-health/my-health.wxml-->
<view class="page" data-weui-theme="{{theme}}">
<view class="page__hd">
<view class="page__title">我的健康</view>
<view class="page__desc">我今日的健康信息</view>
<view class="page__title" wx:if="{{isParent}}">孩子的健康</view>
<view class="page__title" wx:else>我的健康</view>
<view class="page__desc">微信运动健康信息</view>
</view>
<view class="page__bd">
<view class="page__bd">
<view class="weui-form-preview">
<view class="weui-form-preview__hd">
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">姓名</label>
<em class="weui-form-preview__value">{{stepsInfo.realName}}</em>
</view>
</view>
<view class="weui-form-preview__bd">
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">我的步数</label>
<text class="weui-form-preview__value">{{stepsInfo.count}}</text>
</view>
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">记录时间</label>
<text class="weui-form-preview__value">{{stepsInfo.updateTime}}</text>
</view>
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">平均步数</label>
<text class="weui-form-preview__value">{{stepsInfo.averageSteps}}</text>
</view>
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">记录个数</label>
<text class="weui-form-preview__value">{{stepsInfo.recordCount}}</text>
</view>
</view>
</view>
</view>
<view class="weui-panel">
<view class="weui-panel__hd">健康记录列表</view>
<view class="weui-panel__bd" wx:for="{{monthStepsInfo}}" wx:key="index" data-index="{{index}}">
<view class="weui-media-box weui-media-box_text">
<h4 class="weui-media-box__title">记录时间 {{item.timestamp}}</h4>
<view class="weui-media-box__info">
<view class="weui-media-box__info__meta">步数 {{item.step}}</view>
</view>
</view>
</view>
</view>
</view>
<i-spin size="large" fix wx:if="{{ recordNotFound }}" custom><view>未找到健康记录</view></i-spin>
</view>

View File

@ -19,12 +19,25 @@ Page({
honorTitle: "",
toast: false,
hideToast: true,
isParent: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.isParent === 'true') {
this.setData({
isParent: true
})
getHonors(options.openid)
.then(res => {
console.log(res)
this.setData({
honorsInfo: res
})
})
} else {
this.setData({
userDocument: app.globalData.userDocument
})
@ -36,6 +49,7 @@ Page({
honorsInfo: res
})
})
}
},
/**

View File

@ -1,3 +1,5 @@
{
"usingComponents": {}
"usingComponents": {
"i-spin": "../../dist/spin/index"
}
}

View File

@ -1,6 +1,7 @@
<view class="page" data-weui-theme="{{theme}}">
<view class="page__hd" wx:if="{{!showHonor}}">
<view class="page__title">我的荣誉</view>
<view class="page__title" wx:if="{{!isParent}}">我的荣誉</view>
<view class="page__title" wx:else>孩子荣誉</view>
<view class="page__desc">科研竞赛社会工作等情况</view>
</view>
<view class="page__bd" wx:if="{{showCreate}}">
@ -54,22 +55,18 @@
<view class="weui-form-preview">
<view class="weui-form-preview__hd">
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">姓名</label>
<em class="weui-form-preview__value">{{userDocument.realName}}</em>
<label class="weui-form-preview__label">荣誉数目</label>
<em class="weui-form-preview__value">{{honorsInfo.length}}</em>
</view>
</view>
<view class="weui-form-preview__bd">
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">荣誉数目</label>
<text class="weui-form-preview__value">{{honorsInfo.length}}</text>
</view>
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">已认证荣誉数目</label>
<text class="weui-form-preview__value">0</text>
</view>
</view>
<view class="weui-form-preview__ft">
<a class="weui-form-preview__btn weui-form-preview__btn_primary" bindtap="onClickAdd">添加荣誉</a>
<a class="weui-form-preview__btn weui-form-preview__btn_primary" bindtap="onClickAdd" wx:if="{{!isParent}}">添加荣誉</a>
</view>
</view>
</view>

View File

@ -1,18 +1,25 @@
// pages/students-grade-analyse/students-grade-analyse.js
import {getStudentsGrade} from '../../api/course'
Page({
/**
* 页面的初始数据
*/
data: {
studentsGradeInfo: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
getStudentsGrade().then(res =>{
console.log(res)
this.setData({
studentsGradeInfo: res
})
})
},
/**

View File

@ -10,25 +10,25 @@
<view class="weui-form-preview__hd">
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">学生总人数</label>
<em class="weui-form-preview__value">254</em>
<em class="weui-form-preview__value">{{studentsGradeInfo.studentsNumber}}</em>
</view>
</view>
<view class="weui-form-preview__bd">
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">平均学分积</label>
<text class="weui-form-preview__value">75.6</text>
<text class="weui-form-preview__value">{{studentsGradeInfo.weightedAverage}}</text>
</view>
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">平均绩点</label>
<text class="weui-form-preview__value">2.85</text>
<text class="weui-form-preview__value">{{studentsGradeInfo.gpa}}</text>
</view>
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">挂科记录数</label>
<text class="weui-form-preview__value">12</text>
<text class="weui-form-preview__value">{{studentsGradeInfo.failedRecord}}</text>
</view>
<view class="weui-form-preview__item">
<label class="weui-form-preview__label">学期数</label>
<text class="weui-form-preview__value">5</text>
<text class="weui-form-preview__value">{{studentsGradeInfo.semesterListSize}}</text>
</view>
</view>
<view class="weui-form-preview__ft">
@ -50,21 +50,9 @@
<view class="page__bd">
<view class="weui-cells__title">学期概况</view>
<view class="weui-cells demo_badge_cells">
<view class="weui-cell weui-cell_active weui-cell_access">
<view class="weui-cell weui-cell_active weui-cell_access" wx:for="{{studentsGradeInfo.semesterList}}" wx:key="index">
<view class="weui-cell__bd">
<text class="demo_badge_title">2019-2020学年春季学期</text>
</view>
<view class="weui-cell__ft"></view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access">
<view class="weui-cell__bd">
<text class="demo_badge_title">2020-2021学年秋季学期</text>
</view>
<view class="weui-cell__ft"></view>
</view>
<view class="weui-cell weui-cell_active weui-cell_access">
<view class="weui-cell__bd">
<text class="demo_badge_title">2020-2021学年春季学期</text>
<text class="demo_badge_title">{{item}}</text>
</view>
<view class="weui-cell__ft"></view>
</view>