Commit a6ad07dc authored by 张杰's avatar 张杰

优化家长首页显示效果

parent c568053a
......@@ -29,5 +29,15 @@ module.exports = {
pictureId: pictureId
}
return request.post('/wxsite/parents/updateStudentPicture.do', param)
},
getRecipe() {
return request.get("/wxsite/parents/getCurrentRecipe.do")
},
getSchedule(classId) {
var url = "/wxsite/parents/getCurrentSchedule.do?classId=" + classId
return request.get(url)
}
}
......@@ -11,14 +11,14 @@ const ERR_NOT_ACCESS_TOKEN = 21;
var DEF_APP_CONFIG = {
appId: "wxe19b38d5dbc061c6", // 勾芒小程序测试号
// 开发环境
// domain: 'https://dev.gomoretech.com/preschool',
// baseUrl: "https://dev.gomoretech.com/preschool"
domain: 'https://dev.gomoretech.com/preschool',
baseUrl: "https://dev.gomoretech.com/preschool"
// 川哥本地环境
// domain: 'http://192.168.199.230:8080/preschool',
// baseUrl: "http://192.168.199.230:8080/preschool",
// 正式环境
domain: 'https://preschool.gomoretech.com/preschool',
baseUrl: "https://preschool.gomoretech.com/preschool"
// domain: 'https://preschool.gomoretech.com/preschool',
// baseUrl: "https://preschool.gomoretech.com/preschool"
}
const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : DEF_APP_CONFIG;
const APP_ID = extConfig.appId || DEF_APP_CONFIG.appId;
......@@ -96,10 +96,8 @@ module.exports.request = function (url, method = 'GET', data = {},
icon: 'none',
duration: 2000
})
resolve(userData.msg)
}else{
resolve(userData.obj);
}
resolve(userData.obj);
} else {
if (userData.code != ERR_ACCESS_TOKEN_EXPIRED) {
if (userData.code != ERR_NOT_ACCESS_TOKEN) {
......
......@@ -17,6 +17,7 @@ App({
}
},
globalData: {
innerAudioContext: null,
isLogin: false,
userInfo: null,
//一些默认值
......
......@@ -4,6 +4,8 @@
"pages/home/teacher/index",
"pages/home/reviewer/index",
"pages/home/sign/index",
"pages/home/recipe/recipe",
"pages/home/schedule/schedule",
"pages/reset_psw/index",
"pages/home/parents/index",
"pages/add_record/index",
......
......@@ -25,7 +25,22 @@ Page({
//顶部加载提示信息
hideTopMore: true,
// 底部加载提示信息
hideBottomMore: true
hideBottomMore: true,
selectedIndex: 0,
current: {
// poster: ' ',
name: ' ',
author: '比来童园',
src: ' ',
},
scheduleImage: '',
recipeImage: '',
innerAudioContext: {},
isPlaying: false,
btnImage: '/src/img/play.png',
isRecipeNull: false,
attachment: null,
musicUrl: null
},
scrollToUpper: function(e) {
......@@ -41,7 +56,99 @@ Page({
scrollToLower: function(e) {
this.data.page++
this.httpRequest()
this.httpRequest()
},
tapTabItem: function(e) {
console.log(e.currentTarget.dataset.index)
this.setData({
selectedIndex: e.currentTarget.dataset.index
})
},
getRecipe: function(e) {
request.getRecipe().then(res => {
var url = utils.handleImgShow(res)
console.log(url)
this.setData({
recipeImage: url,
isRecipeNull: res == null
})
}).catch(function(err) {
wx.showToast({
title: err.message,
icon: 'none',
duration: 2000
});
});
},
getSchedule: function(e) {
const that = this
if (app.globalData.login.students.length == 0) {
wx.showToast({
title: '无学生信息, 请联系管理员',
icon: 'none'
})
return
}
let student = app.globalData.login.students[0]
var classId = student.classId
request.getSchedule(classId).then(res => {
console.log("ddd")
let b = res.attachment == null
console.log(b)
this.setData({
attachment: res.attachment,
musicUrl: res.musicUrl
})
var url = utils.handleImgShow(res.attachment)
console.log(url)
const innerAudioContext = wx.createInnerAudioContext()
this.data.innerAudioContext = innerAudioContext
innerAudioContext.src = res.musicUrl
innerAudioContext.loop = true
innerAudioContext.onPlay(() => {
})
innerAudioContext.onPause(() => {
})
innerAudioContext.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
})
innerAudioContext.onEnded((res) => {
})
this.setData({
scheduleImage: url,
current: {
name: res.musicName,
}
})
}).catch(function(err) {
wx.showToast({
title: err.message,
icon: 'none',
duration: 2000
});
});
},
tapUserInfoImg: function(e) {
......@@ -95,6 +202,19 @@ Page({
}
})
},
/* 跳转食谱 */
operateRecipe: function() {
wx.navigateTo({
url: '/pages/home/recipe/recipe',
})
},
/* 跳转课表 */
operateSchedule: function() {
wx.navigateTo({
url: '/pages/home/schedule/schedule',
})
},
updateStudentPicture: function() {
request.updateStudentPicture(this.data.student.id, this.data.pictureId).then(res => {
......@@ -133,6 +253,8 @@ Page({
onLoad: function(options) {
this.fillStudent()
this.httpRequest()
this.getSchedule()
this.getRecipe()
},
......
......@@ -15,7 +15,8 @@
</view>
<view class='kg-separater'></view>
<scroll-view style='height:calc(100vh - 200rpx)' scroll-y='true' bindscrolltolower='scrollToLower' bindscrolltoupper='scrollToUpper'>
<!-- 首页 -->
<scroll-view hidden="{{selectedIndex != '0'}}" style='height:calc(100vh - 200rpx - 100rpx)' scroll-y='true' bindscrolltolower='scrollToLower' bindscrolltoupper='scrollToUpper'>
<!-- <view class='kg-text-light-gray more-text' hidden='{{hideTopMore}}'>下拉加载中…</view> -->
<view wx:for="{{records}}" wx:key="item">
......@@ -37,7 +38,7 @@
<image src='{{picItem}}' class='home-student-picture' catchtap='previewPic' data-index='{{index}}' data-picIndex='{{picIndex}}' mode='aspectFill'></image>
</view>
</view>
<text class='kg-text-light-gray' style='margin-left:60rpx;margin-right:35rpx;'>{{item.pictureRemark ? item.pictureRemark : ''}}</text>
<text class='kg-text-light-gray' style='margin-left:60rpx;margin-right:35rpx;'>{{item.pictureRemark ? item.pictureRemark : ''}}</text>
<view class='kg-separater' style='height:2rpx;margin-left:80rpx;margin-right:0rpx;'></view>
......@@ -48,8 +49,8 @@
<template is='imgTextView' data="{{img:'eat',text:'饮食'}}"> </template>
</view>
<view class='kg-flex-row timeline-content-detail'>
<text class='kg-text-normal-gray' >{{dietItem.z_recordType}}</text>
<text class='kg-text-normal-gray' >{{dietItem.z_eatState}}</text>
<text class='kg-text-normal-gray'>{{dietItem.z_recordType}}</text>
<text class='kg-text-normal-gray'>{{dietItem.z_eatState}}</text>
</view>
</view>
......@@ -61,8 +62,8 @@
<template is='imgTextView' data="{{img:'sleep',text:'睡眠'}}"> </template>
</view>
<view class='kg-flex-row timeline-content-detail'>
<text class='kg-text-normal-gray' >午睡</text>
<text class='kg-text-normal-gray' >{{sleepItem.value ? sleepItem.value : '0'}}分钟</text>
<text class='kg-text-normal-gray'>午睡</text>
<text class='kg-text-normal-gray'>{{sleepItem.value ? sleepItem.value : '0'}}分钟</text>
</view>
</view>
......@@ -74,15 +75,53 @@
<template is='imgTextView' data="{{img:'wc',text:'大小便'}}"> </template>
</view>
<view class='kg-flex-row timeline-content-detail'>
<text class='kg-text-normal-gray' >{{wcItem.z_recordType}}</text>
<text class='kg-text-normal-gray' >{{wcItem.value ? wcItem.value : '0'}}次</text>
<text class='kg-text-normal-gray'>{{wcItem.z_recordType}}</text>
<text class='kg-text-normal-gray'>{{wcItem.value ? wcItem.value : '0'}}次</text>
</view>
</view>
<text class='kg-text-light-gray' style='margin-left:60rpx;margin-right:35rpx;'>{{item.remark ? item.remark : ''}}</text>
</view>
</view>
</view>
<image hidden="{{records.length != 0}}" src='/src/img/empty_data.png' class='empty-data'></image>
</scroll-view>
<!-- 食谱 -->
<view hidden="{{selectedIndex != '1'}}">
<image hidden="{{isRecipeNull == true}}" src='{{recipeImage}}'></image>
<image hidden="{{isRecipeNull != true}}" src='/src/img/empty_data.png' class='empty-data'></image>
</view>
<!-- 课表 -->
<view hidden="{{selectedIndex != '2'}}">
<image hidden='{{attachment == null}}' class='scheduleImage' src='{{scheduleImage}}' mode='widthFix'></image>
<view hidden='{{musicUrl == null}}' class='kg-home-header kg-flex-row music-board' style='width:100vw;height:120rpx;'>
<view class='kg-flex-row'>
<image src='{{btnImage}}' style='width:120rpx;height:120rpx;' bindtap='tapPlayButton'></image>
<text style='font-size: 26rpx;margin-left:32rpx;color:#4f4f4f;'>{{current.name}}</text>
</view>
</view>
<image hidden="{{attachment != null && musicUrl != null}}" src='/src/img/empty_data.png' class='empty-data'></image>
</view>
<view style='position:fixed;bottom: 0rpx;height:100rpx;background-color:white;width:100vw;'>
<view class='kg-separater' style='height:4rpx;'></view>
<view class='kg-flex-row tab-bg'>
<view class='kg-flex-column tab-item' bindtap='tapTabItem' data-index='0'>
<image class='tab-image' src="{{selectedIndex=='0' ? '/src/img/home_select.png' : '/src/img/home_unselect.png'}} "></image>
<view style='text-align:center;font-size: 24rpx;'>首页</view>
</view>
<view class='kg-flex-column tab-item' bindtap='tapTabItem' data-index='1'>
<image class='tab-image' src="{{selectedIndex=='1' ? '/src/img/recipe_select.png' : '/src/img/recipe_unselect.png'}} "></image>
<view style='text-align:center;font-size: 24rpx;'>食谱</view>
</view>
<view class='kg-flex-column tab-item' bindtap='tapTabItem' data-index='2'>
<image class='tab-image' src="{{selectedIndex=='2' ? '/src/img/schedule_select.png' : '/src/img/schedule_unselect.png'}} "></image>
<view style='text-align:center;font-size: 24rpx;'>课表</view>
</view>
</view>
</scroll-view>
\ No newline at end of file
</view>
\ No newline at end of file
......@@ -66,4 +66,50 @@
text-align: center;
height: 40rpx;
line-height: 40rpx;
}
.btn {
margin-left: 50rpx;
margin-right: 0rpx;
width: calc((100vw - 150rpx)/2);
}
.tab-bg {
width: 100vw;
height: 96rpx;
}
.tab-item {
width: calc(100vw/3);
height: 96;
align-items:center;
}
.tab-image {
width: 50rpx;
height: 50rpx;
}
.scheduleImage {
width: 100vw;
}
.music-board {
border-bottom: 1rpx solid #dcdcdc;
border-top: 1rpx solid #dcdcdc;
margin-left: 0rpx;
}
.recipe-image {
width: 100vw;
height: auto;
}
.empty-data {
margin-top: 100rpx;
margin-left: calc(50vw/2);
width: 50vw;
height: 50vw;
}
\ No newline at end of file
// pages/home/recipe/recipe.js
const req = require('../../../api/parrent.js')
const utils = require('../../../utils/util.js')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
image: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
req.getRecipe().then(res=>{
var url = utils.handleImgShow(res)
console.log(url)
this.setData({
image: url
})
}).catch(function (err) {
wx.showToast({
title: err.message,
icon: 'none',
duration: 2000
});
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "食谱"
}
\ No newline at end of file
<!--pages/home/recipe/recipe.wxml-->
<image src='{{image}}'></image>
/* pages/home/recipe/recipe.wxss */
.image {
width: 100vw;
height: auto;
}
\ No newline at end of file
// pages/home/schedule/schedule.js
const utils = require('../../../utils/util.js')
const req = require('../../../api/parrent.js')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
current: {
// poster: ' ',
name: ' ',
author: '比来童园',
src: ' ',
},
image: '',
innerAudioContext: {},
isPlaying: false,
btnImage: '/src/img/play.png'
},
tapCover: function() {
console.log("tapCoverView")
wx.showToast({
title: 'tapCoverView',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
const that = this
if (app.globalData.login.students.length == 0) {
wx.showToast({
title: '无学生信息, 请联系管理员',
icon: 'none'
})
return
}
let student = app.globalData.login.students[0]
var classId = student.classId
req.getSchedule(classId).then(res => {
var url = utils.handleImgShow(res.attachment)
console.log(url)
const innerAudioContext = wx.createInnerAudioContext()
this.data.innerAudioContext = innerAudioContext
innerAudioContext.src = res.musicUrl
innerAudioContext.loop = true
innerAudioContext.onPlay(() => {
})
innerAudioContext.onPause(() => {
})
innerAudioContext.onError((res) => {
console.log(res.errMsg)
console.log(res.errCode)
})
innerAudioContext.onEnded((res) => {
})
this.setData({
image: url,
current: {
name: res.musicName,
}
})
}).catch(function(err) {
wx.showToast({
title: err.message,
icon: 'none',
duration: 2000
});
});
},
tapPlayButton: function() {
this.data.isPlaying = !this.data.isPlaying
let btnImage = '/src/img/play.png'
if (this.data.isPlaying) {
this.data.innerAudioContext.play()
btnImage = '/src/img/stop.png'
wx.showToast({
title: '开始播放',
icon: 'none'
})
} else {
this.data.innerAudioContext.pause()
wx.showToast({
title: '已暂停',
icon: 'none'
})
}
this.setData({
btnImage: btnImage
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
this.data.innerAudioContext.destroy()
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "课表"
}
\ No newline at end of file
<!--pages/home/schedule/schedule.wxml-->
<view>
<image class='scheduleImage' src='{{image}}' mode='widthFix'></image>
<view class='kg-home-header kg-flex-row music-board' style='width:100vw;height:120rpx;'>
<view class='kg-flex-row'>
<image src='{{btnImage}}' style='width:120rpx;height:120rpx;' bindtap='tapPlayButton'></image>
<text style='font-size: 26rpx;margin-left:32rpx;color:#4f4f4f;'>{{current.name}}</text>
</view>
</view>
</view>
\ No newline at end of file
/* pages/home/schedule/schedule.wxss */
.scheduleImage {
width: 100vw;
}
.music-board {
border-bottom: 1rpx solid #dcdcdc;
border-top: 1rpx solid #dcdcdc;
margin-left: 0rpx;
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
"ignore": []
},
"setting": {
"urlCheck": true,
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
......@@ -36,7 +36,7 @@
"list": []
},
"miniprogram": {
"current": 1,
"current": 2,
"list": [
{
"id": -1,
......@@ -47,7 +47,14 @@
{
"id": -1,
"name": "教师首页",
"pathName": "pages/home/teacher/index"
"pathName": "pages/home/teacher/index",
"query": ""
},
{
"id": -1,
"name": "课表",
"pathName": "pages/home/schedule/schedule",
"scene": null
}
]
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment