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

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/my-students/my-students",
"pages/students-grade-analyse/students-grade-analyse", "pages/students-grade-analyse/students-grade-analyse",
"pages/my-health/my-health", "pages/my-health/my-health",
"pages/my-honors/my-honors" "pages/my-honors/my-honors",
"pages/robot/robot",
"pages/my-children/my-children"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",

View File

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

View File

@ -18,7 +18,7 @@
</view> </view>
</view> </view>
<view class="weui-form__opr-area"> <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> </view>

View File

@ -281,4 +281,11 @@ Page({
url: '/pages/my-honors/my-honors' 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 weui-cell_active" wx:for="{{childrenInfo}}" wx:key="index">
<view class="weui-cell__hd"> <view class="weui-cell__hd">
<image src="{{item.avatarUrl}}"></image> <image src="{{item.avatarUrl}}"></image>
<text class="weui-badge">8</text>
</view> </view>
<view class="weui-cell__bd"> <view class="weui-cell__bd" bindtap="bindMyChildren" data-index="{{item.openid}}">
<view>{{item.nickName}}</view> <view>{{item.nickName}}</view>
<view class="demo_badge_desc">我的孩子</view> <view class="demo_badge_desc">我的孩子</view>
</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 weui-cell_active" bindtap="bindChildSupervisor" wx:for="{{supervisorsInfo}}" wx:key="index">
<view class="weui-cell__hd"> <view class="weui-cell__hd">
<image src="{{item.avatarUrl}}"></image> <image src="{{item.avatarUrl}}"></image>
<text class="weui-badge">8</text>
</view> </view>
<view class="weui-cell__bd"> <view class="weui-cell__bd">
<view>{{item.nickName}}</view> <view>{{item.nickName}}</view>
@ -63,42 +61,42 @@
</view> </view>
<view class="weui-cell__ft"></view> <view class="weui-cell__ft"></view>
</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"> <view class="weui-cell__bd">
<text class="demo_badge_title">问答机器人</text> <text class="demo_badge_title">问答机器人</text>
<text class="weui-badge">8</text> <text class="weui-badge">8</text>
</view> </view>
<view class="weui-cell__ft">详细信息</view> <view class="weui-cell__ft">详细信息</view>
</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"> <view class="weui-cell__bd">
<text class="demo_badge_title">我的成绩</text> <text class="demo_badge_title">我的成绩</text>
<text class="weui-badge">New</text> <text class="weui-badge">New</text>
</view> </view>
<view class="weui-cell__ft"></view> <view class="weui-cell__ft"></view>
</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"> <view class="weui-cell__bd">
<text class="demo_badge_title">我的荣誉</text> <text class="demo_badge_title">我的荣誉</text>
<text class="weui-badge">New</text> <text class="weui-badge">New</text>
</view> </view>
<view class="weui-cell__ft"></view> <view class="weui-cell__ft"></view>
</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"> <view class="weui-cell__bd">
<text class="demo_badge_title">我的健康</text> <text class="demo_badge_title">我的健康</text>
<text class="weui-badge">New</text> <text class="weui-badge">New</text>
</view> </view>
<view class="weui-cell__ft"></view> <view class="weui-cell__ft"></view>
</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"> <view class="weui-cell__bd">
<text class="demo_badge_title">我的学生</text> <text class="demo_badge_title">我的学生</text>
<text class="weui-badge">New</text> <text class="weui-badge">New</text>
</view> </view>
<view class="weui-cell__ft"></view> <view class="weui-cell__ft"></view>
</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"> <view class="weui-cell__bd">
<text class="demo_badge_title">学生成绩分析</text> <text class="demo_badge_title">学生成绩分析</text>
<text class="weui-badge">New</text> <text class="weui-badge">New</text>

View File

@ -1,6 +1,6 @@
// pages/my-grade/my-grade.js // 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({ Page({
@ -13,6 +13,7 @@ Page({
showSemester: false, showSemester: false,
targetSemesterInfo: {}, targetSemesterInfo: {},
targetCoursesInfo: [], targetCoursesInfo: [],
targetOpenid: '',
showIndex: 0 showIndex: 0
}, },
@ -20,28 +21,56 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
getGrade().then(res => { if(options.isParent === 'true') {
console.log(res) this.setData({
if(res.failedCourse === 0 && res.passedCourse === 0) { isParent: true,
this.setData({ targetOpenid: options.openid
recordNotFound: true })
}) getGradeForParent(options.openid).then(res => {
}
else {
this.setData({
gradeInfo: res
})
}
}).then(res => {
return getSemesters().then(res => {
console.log(res) console.log(res)
this.setData({ if(res.failedCourse === 0 && res.passedCourse === 0) {
semestersInfo: res this.setData({
recordNotFound: true
})
}
else {
this.setData({
gradeInfo: res
})
}
}).then(res => {
return getSemestersForParent(options.openid).then(res => {
console.log(res)
this.setData({
semestersInfo: res
})
}) })
}) })
}).catch(err => { } else {
console.log(err) getGrade().then(res => {
}) console.log(res)
if(res.failedCourse === 0 && res.passedCourse === 0) {
this.setData({
recordNotFound: true
})
}
else {
this.setData({
gradeInfo: res
})
}
}).then(res => {
return getSemesters().then(res => {
console.log(res)
this.setData({
semestersInfo: res
})
})
}).catch(err => {
console.log(err)
})
}
}, },
/** /**
@ -104,23 +133,44 @@ Page({
onClickSemesterItem(e) { onClickSemesterItem(e) {
let index = parseInt(e.currentTarget.dataset['index']) let index = parseInt(e.currentTarget.dataset['index'])
getSemesterGrades(this.data.semestersInfo[index].id).then(res => { if(this.data.isParent) {
console.log(res) getSemesterGradesForParent(this.data.targetOpenid, this.data.semestersInfo[index].id).then(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) console.log(res)
this.setData({ this.setData({
targetCoursesInfo: res 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,
}) })
}) })
}).then(res => { } else {
this.setData({ getSemesterGrades(this.data.semestersInfo[index].id).then(res => {
showSemester: true, 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,
})
}) })
}) }
} }
}) })

View File

@ -1,8 +1,10 @@
<!--pages/my-grade/my-grade.wxml--> <!--pages/my-grade/my-grade.wxml-->
<view class="page" data-weui-theme="{{theme}}"> <view class="page" data-weui-theme="{{theme}}">
<view class="page__hd" wx:if="{{!showSemester}}"> <view class="page__hd" wx:if="{{!showSemester}}">
<view class="page__title">我的成绩</view> <view class="page__title" wx:if="{{!isParent}}">我的成绩</view>
<view class="page__desc">我在学校学习生活的概况</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>
<view class="page__hd" wx:else> <view class="page__hd" wx:else>
<view class="page__title">{{targetSemesterInfo.semester}}</view> <view class="page__title">{{targetSemesterInfo.semester}}</view>
@ -119,7 +121,7 @@
</view> </view>
</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>

View File

@ -1,11 +1,18 @@
// pages/my-health/my-health.js // pages/my-health/my-health.js
import {getStepsToday, saveSteps, getStepsMonth, getStepsForParent} from '../../api/step'
const app = getApp()
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
userDocument:{},
stepsInfo: {},
monthStepsInfo: [],
recordNotFound: false
}, },
/** /**
@ -13,6 +20,45 @@ Page({
*/ */
onLoad: function (options) { 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--> <!--pages/my-health/my-health.wxml-->
<view class="page" data-weui-theme="{{theme}}"> <view class="page" data-weui-theme="{{theme}}">
<view class="page__hd"> <view class="page__hd">
<view class="page__title">我的健康</view> <view class="page__title" wx:if="{{isParent}}">孩子的健康</view>
<view class="page__desc">我今日的健康信息</view> <view class="page__title" wx:else>我的健康</view>
<view class="page__desc">微信运动健康信息</view>
</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>

View File

@ -19,23 +19,37 @@ Page({
honorTitle: "", honorTitle: "",
toast: false, toast: false,
hideToast: true, hideToast: true,
isParent: false
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.setData({ if(options.isParent === 'true') {
userDocument: app.globalData.userDocument
})
console.log(this.data)
getHonors(app.globalData.userBaseInfo.openid)
.then(res => {
console.log(res)
this.setData({ this.setData({
honorsInfo: res isParent: true
}) })
}) getHonors(options.openid)
.then(res => {
console.log(res)
this.setData({
honorsInfo: res
})
})
} else {
this.setData({
userDocument: app.globalData.userDocument
})
console.log(this.data)
getHonors(app.globalData.userBaseInfo.openid)
.then(res => {
console.log(res)
this.setData({
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" data-weui-theme="{{theme}}">
<view class="page__hd" wx:if="{{!showHonor}}"> <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 class="page__desc">科研竞赛社会工作等情况</view>
</view> </view>
<view class="page__bd" wx:if="{{showCreate}}"> <view class="page__bd" wx:if="{{showCreate}}">
@ -54,22 +55,18 @@
<view class="weui-form-preview"> <view class="weui-form-preview">
<view class="weui-form-preview__hd"> <view class="weui-form-preview__hd">
<view class="weui-form-preview__item"> <view class="weui-form-preview__item">
<label class="weui-form-preview__label">姓名</label> <label class="weui-form-preview__label">荣誉数目</label>
<em class="weui-form-preview__value">{{userDocument.realName}}</em> <em class="weui-form-preview__value">{{honorsInfo.length}}</em>
</view> </view>
</view> </view>
<view class="weui-form-preview__bd"> <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"> <view class="weui-form-preview__item">
<label class="weui-form-preview__label">已认证荣誉数目</label> <label class="weui-form-preview__label">已认证荣誉数目</label>
<text class="weui-form-preview__value">0</text> <text class="weui-form-preview__value">0</text>
</view> </view>
</view> </view>
<view class="weui-form-preview__ft"> <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>
</view> </view>

View File

@ -1,18 +1,25 @@
// pages/students-grade-analyse/students-grade-analyse.js // pages/students-grade-analyse/students-grade-analyse.js
import {getStudentsGrade} from '../../api/course'
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
studentsGradeInfo: {}
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { 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__hd">
<view class="weui-form-preview__item"> <view class="weui-form-preview__item">
<label class="weui-form-preview__label">学生总人数</label> <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> </view>
<view class="weui-form-preview__bd"> <view class="weui-form-preview__bd">
<view class="weui-form-preview__item"> <view class="weui-form-preview__item">
<label class="weui-form-preview__label">平均学分积</label> <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>
<view class="weui-form-preview__item"> <view class="weui-form-preview__item">
<label class="weui-form-preview__label">平均绩点</label> <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>
<view class="weui-form-preview__item"> <view class="weui-form-preview__item">
<label class="weui-form-preview__label">挂科记录数</label> <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>
<view class="weui-form-preview__item"> <view class="weui-form-preview__item">
<label class="weui-form-preview__label">学期数</label> <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> </view>
<view class="weui-form-preview__ft"> <view class="weui-form-preview__ft">
@ -50,21 +50,9 @@
<view class="page__bd"> <view class="page__bd">
<view class="weui-cells__title">学期概况</view> <view class="weui-cells__title">学期概况</view>
<view class="weui-cells demo_badge_cells"> <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"> <view class="weui-cell__bd">
<text class="demo_badge_title">2019-2020学年春季学期</text> <text class="demo_badge_title">{{item}}</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>
</view> </view>
<view class="weui-cell__ft"></view> <view class="weui-cell__ft"></view>
</view> </view>