electron-ban-pai/src/components/homepage.vue

564 lines
16 KiB
Vue
Raw Normal View History

2021-12-23 10:00:27 +08:00
<template>
2021-12-24 09:56:55 +08:00
<div>
2022-01-03 16:38:59 +08:00
<error-page v-if="showError" @closeError="closeError"></error-page>
2021-12-24 09:56:55 +08:00
<!-- 主体内容 -->
2022-01-08 17:37:07 +08:00
<div class="main-box" v-else>
2021-12-24 09:56:55 +08:00
<!-- 左侧 -->
<div class="main-left">
<!-- 班级详情 -->
2022-01-03 16:38:59 +08:00
<div class="left-one flex-s0">
<div class="left-content">
2021-12-24 09:56:55 +08:00
<div class="left-title">
<div class="pultitle">班级详情</div>
</div>
2022-01-03 16:38:59 +08:00
<div class="second-title" v-if="className!=''">{{className}}</div>
<div class="line" v-if="className!=''"></div>
<div class="three-content" v-if="className!=''">
2021-12-26 19:07:45 +08:00
<div>老师{{teacherName}}</div>
<div>班级人数{{classNum}}</div>
2021-12-24 09:56:55 +08:00
</div>
2022-01-03 16:38:59 +08:00
<div class="line" v-if="className!=''"></div>
2021-12-24 09:56:55 +08:00
<div class="left-last">
2022-04-28 16:49:18 +08:00
<div @click="chooseIndex(index)" v-for="(item,index) in daoArr" :key="index">
2021-12-26 19:07:45 +08:00
<div>{{item.num}}</div>
<div>{{item.title}}</div>
2021-12-24 09:56:55 +08:00
</div>
</div>
</div>
2022-01-03 16:38:59 +08:00
<loading :isShow="showLoading_one"></loading>
2021-12-24 09:56:55 +08:00
</div>
<!-- 宝宝食谱 -->
2022-01-03 16:38:59 +08:00
<div class="left-one flex-s0">
2021-12-24 09:56:55 +08:00
<div class="left-content">
<div class="left-title">
2022-01-08 17:37:07 +08:00
<div class="pultitle">今日食谱</div>
2021-12-24 09:56:55 +08:00
</div>
2021-12-26 19:07:45 +08:00
<div v-if="threeMeals.length!=0">
2021-12-25 13:09:46 +08:00
<div class="eat-three">
<div :class="threeMealIndex == index ? 'threeMealActive' : ''"
v-for="(item, index) in threeMeals" :key="index" @click="chooseMeal(index)">
{{ item.Type }}
</div>
2021-12-24 09:56:55 +08:00
</div>
2021-12-25 13:09:46 +08:00
<div class="line"></div>
<div v-for="(item, index) in threeMeals" :key="index">
<div v-if="index == threeMealIndex" class="meal-box">
<img :src="item.Images" />
<div class="clips2">{{ item.FoodName }}</div>
</div>
2021-12-24 09:56:55 +08:00
</div>
2021-12-26 19:07:45 +08:00
</div>
2021-12-24 09:56:55 +08:00
</div>
2022-01-03 16:38:59 +08:00
<loading :isShow="showLoading_two"></loading>
2021-12-24 09:56:55 +08:00
</div>
<!-- 通知公告 -->
<div class="left-one">
<v-touch v-on:swipeleft="touchEv" v-on:swiperight="touchEv">
<div class="left-content">
<div class="left-title">
<div class="pultitle">通知公告</div>
</div>
<div class="second-title">{{className}}</div>
<div class="line" v-if="noticeObj.Content!=''"></div>
<div class="three-content left-notice" v-if="noticeObj.Content!=''">
<div class="clips2">{{noticeObj.Content}}</div>
</div>
<div class="notice-time" v-if="noticeObj.Content!=''">
<div>{{noticeObj.PublishTime}}</div>
<!-- <div><img src="../../static/img/home/slices.png" />{{noticeObj.BroweTotal}}</div> -->
</div>
2021-12-24 09:56:55 +08:00
</div>
</v-touch>
2022-01-03 16:38:59 +08:00
<loading :isShow="showLoading_three"></loading>
2021-12-24 09:56:55 +08:00
</div>
</div>
<!-- 中部 -->
<div class="main-center">
<!-- 班级动态图文 -->
<div class="center-img-box">
<div class="center-title">班级动态</div>
<div class="img-box">
2022-04-28 16:49:18 +08:00
<video v-if="videoSrc" width="100%" class="home-swiper" controls :src="videoSrc"></video>
<swiper class="home-swiper" v-if="classImgArr.length && videoSrc==''" :options="swiperOption" style="position: relative;">
2022-01-10 18:41:59 +08:00
<swiper-slide v-for="(item,index) in classImgArr" :key="index" class="home-slide">
<img :src="item">
2022-01-03 16:38:59 +08:00
</swiper-slide>
</swiper>
2022-04-28 16:49:18 +08:00
<div v-if="videoSrc==''" class="swiper-pagination"></div>
2022-01-03 16:38:59 +08:00
<loading :isShow="showLoading_four"></loading>
2021-12-24 09:56:55 +08:00
</div>
</div>
<!-- 提醒 -->
<div class="remind-box">
<div class="msg-box">
2021-12-26 12:04:11 +08:00
<img src="../../static/img/home/icon-notice.png" />
2022-01-03 16:38:59 +08:00
<div v-if="noticeData!=0">{{noticeData}}</div>
2021-12-24 09:56:55 +08:00
</div>
<div class="msg-box">
<div>宝宝提醒</div>
2022-01-03 16:38:59 +08:00
<div v-if="babyNotice!=0">{{babyNotice}}</div>
2021-12-24 09:56:55 +08:00
</div>
<div class="msg-box">
2021-12-27 20:20:51 +08:00
<div >生日提醒</div>
2022-01-03 16:38:59 +08:00
<div v-if="babyBirthdayData!=0">{{babyBirthdayData}}</div>
2021-12-24 09:56:55 +08:00
</div>
</div>
</div>
<!-- 右侧 -->
<div class="main-right">
<div class="left-title">
<div class="pultitle">今日活动</div>
</div>
<div class="right-content">
2022-01-10 18:41:59 +08:00
<div v-if="noonArr.length!=0" id="innerbox">
2021-12-25 13:09:46 +08:00
<div v-for="(item, index) in noonArr" :key="index">
<div class="right-title">{{ item.Ampm }}</div>
<div class="line" style="margin: 0 6px"></div>
<div class="right-item-box" v-for="(itemc, indexc) in item.Content"
:class="indexc % 2 != 0 ? 'oddActive' : ''" :key="indexc">
<div>{{ itemc.TimePart }}</div>
2022-03-04 16:42:01 +08:00
<div class="">{{ itemc.Name }}</div>
2021-12-25 13:09:46 +08:00
</div>
2021-12-24 09:56:55 +08:00
</div>
2021-12-26 19:07:45 +08:00
</div>
2021-12-24 09:56:55 +08:00
</div>
2022-01-03 16:38:59 +08:00
<loading :isShow="showLoading_five"></loading>
2021-12-24 09:56:55 +08:00
</div>
</div>
<!-- 公告弹框 -->
<div v-if="isNotice" class="notice-k" @click="closeNotice">
<div @click.stop="isNotice=true" class="notice-box">
<div class="notice-title-box">
<!-- <img src="../../static/img/home/flower.png"> -->
<div>通知公告</div>
<!-- <img src="../../static/img/home/flower.png"> -->
</div>
<div style="padding: 0 20px;">
<div class="second-title">{{className}}</div>
<div class="line" v-if="noticeObj.Content!=''"></div>
<div class="three-content left-notice" style="height: auto;max-height: 600px;overflow: hidden;overflow-y: scroll;" v-if="noticeObj.Content!=''">
<div class="">{{noticeObj.Content}}</div>
</div>
<div class="notice-time" style="margin-top: 15px;" v-if="noticeObj.Content!=''">
<div>{{noticeObj.PublishTime}}</div>
<!-- <div><img src="../../static/img/home/slices.png" />{{noticeObj.BroweTotal}}</div> -->
</div>
</div>
</div>
</div>
2021-12-24 09:56:55 +08:00
</div>
2021-12-23 10:00:27 +08:00
</template>
<script>
2022-01-10 18:41:59 +08:00
import $ from 'jquery'
2022-01-03 16:38:59 +08:00
import storage from 'good-storage'
2021-12-24 09:56:55 +08:00
export default {
name: "homepage",
data() {
return {
2022-01-03 16:38:59 +08:00
threeMeals: [],
2021-12-24 09:56:55 +08:00
threeMealIndex: 0,
2021-12-26 15:21:26 +08:00
noticeData: 0,
2021-12-27 17:26:14 +08:00
babyBirthdayData: 0,
2022-01-03 16:38:59 +08:00
babyNotice:0,//宝宝提醒数量
2021-12-24 09:56:55 +08:00
dynamicPictureData: "",
2021-12-25 13:09:46 +08:00
noonArr: [],
2021-12-27 17:34:37 +08:00
moId:"",
model:"",
2021-12-26 19:07:45 +08:00
className:'',//班级名称
teacherName:'',//老师姓名
classNum:'',//班级人数
daoArr:[],//实到、未到、请假
2022-01-03 16:38:59 +08:00
classImgArr:[],
showLoading_one:true,
showLoading_two:true,
showLoading_three:true,
showLoading_four:true,
showLoading_five:true,
2022-01-08 17:37:07 +08:00
noticeObj:{
PublishTime:'',
Content:''
},
2022-01-03 16:38:59 +08:00
classGuid:'',
timer:null,
swiperOption: {
pagination: '.swiper-pagination',
paginationClickable: true,
autoplay: 3000,
autoplayDisableOnInteraction: false,
loop: true,
coverflow: {
rotate: 30,
stretch: 10,
depth: 60,
modifier: 2,
slideShadows : true
  }
},
2022-01-08 17:37:07 +08:00
showError:false,
2022-01-10 18:41:59 +08:00
monitorTimer:null,
chuTime:null,
2022-01-10 18:41:59 +08:00
animate:false,
topVal:0,
classCardId:'',
diffHeight:'',
2022-03-04 16:42:01 +08:00
isNotice:false,
2022-04-28 16:49:18 +08:00
classTimer:null,//班级人数心跳事件
videoSrc:'',//视频地址
swiperTime:null//班级动态心跳事件
2021-12-24 09:56:55 +08:00
};
},
2022-01-10 18:41:59 +08:00
destroyed() {
clearInterval(this.timer);
this.topVal = 0;
clearInterval(this.monitorTimer);
clearInterval(this.chuTime);
2022-03-04 16:42:01 +08:00
// 清除班级人数心跳
clearInterval(this.classTimer);
clearInterval(this.swiperTime);
2022-01-10 18:41:59 +08:00
},
2021-12-24 09:56:55 +08:00
methods: {
2022-04-28 16:49:18 +08:00
// 获取班级动态视频或图片列表
async getVideo(){
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.getVideo,
methods: "GET",
params: {
EquipmentID: this.$storage.get('EquipmentID')
},
});
if(data.data.data.VideoUrls!=undefined){
this.videoSrc = data.data.data.VideoUrls;
this.$storage.set('videoSrc',this.videoSrc);
}
if(data.data.data.PictureUrls.length){
this.classImgArr = data.data.data.PictureUrls;
this.$storage.set('classImgArr',this.classImgArr);
}
} else {
if(this.$storage.get('videoSrc')!=undefined){
this.videoSrc = this.$storage.get('videoSrc');
}
if(this.$storage.get('classImgArr')!=undefined){
this.classImgArr = this.$storage.get('classImgArr');
}
}
this.showLoading_four = false;
},
// 跳转
chooseIndex(index){
let current = '';
if(index==0) current = 1;
if(index==1) current = 3;
if(index==2) current = 4;
this.$emit('numEv',current)
},
// 手指滑动事件
touchEv(){
this.isNotice = true;
},
// 关闭通知公告弹框
closeNotice(){
this.isNotice = false;
},
2022-01-10 18:41:59 +08:00
// 滚动动画
scrollEv(){
this.topVal = 0;
clearInterval(this.monitorTimer);
let parentHeight = $('.right-content').height();
let childrenHeight = $('#innerbox').height();
this.diffHeight = childrenHeight - parentHeight;
this.monitorTimer = setInterval(()=>{
let topFlag = $('#innerbox').position().top;
if(-topFlag*1==0){
this.upEv();
}
if(-topFlag*1==this.diffHeight*1){
this.downEv();
2022-01-10 18:41:59 +08:00
}
},100)
},
downEv(){
$('#innerbox').animate({top:0+'px'},(this.diffHeight/4)*100,'linear');
},
upEv(){
$('#innerbox').animate({top:-this.diffHeight+'px'},(this.diffHeight/4)*100,'linear');
2022-01-10 18:41:59 +08:00
},
2022-01-03 16:38:59 +08:00
closeError(){
this.showError = false;
},
2021-12-24 09:56:55 +08:00
// 早中晚餐切换事件
chooseMeal(e) {
this.threeMealIndex = e;
},
// 宝宝食谱
async babyRecipeEv() {
2022-01-03 16:38:59 +08:00
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.babyRecipe,
methods: "get",
params: {
2022-01-08 17:37:07 +08:00
EquipmentID: this.$storage.get('EquipmentID')
2022-01-03 16:38:59 +08:00
},
});
if(data.data.data!=undefined){
this.threeMeals = data.data.data;
this.$storage.set('threeMeals',this.threeMeals);
}
} else {
2022-01-08 17:37:07 +08:00
if(this.$storage.get('threeMeals')!=undefined){
this.threeMeals = this.$storage.get('threeMeals');
}
2022-01-03 16:38:59 +08:00
}
this.showLoading_two = false;
2021-12-24 09:56:55 +08:00
},
2021-12-27 17:26:14 +08:00
// 通知消息数量
2021-12-24 09:56:55 +08:00
async notice() {
2022-01-03 16:38:59 +08:00
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.notice,
methods: "get",
params: {
2022-01-08 17:37:07 +08:00
EquipmentID: this.$storage.get('EquipmentID')
2022-01-03 16:38:59 +08:00
},
});
if(data.data.data!=null){
this.noticeData = data.data.count;
this.noticeObj = data.data.data;
this.noticeObj.PublishTime = this.noticeObj.PublishTime.slice(0,11);
this.$storage.set('noticeData',this.noticeData)
this.$storage.set('noticeObj',this.noticeObj)
this.$storage.set('PublishTime',this.noticeObj.PublishTime)
}
} else {
this.noticeData = this.$storage.get('noticeData');
2022-01-08 17:37:07 +08:00
if(this.$storage.get('noticeObj')!=undefined){
this.noticeObj = this.$storage.get('noticeObj');
this.noticeObj.PublishTime = this.$storage.get('PublishTime');
}
2022-01-03 16:38:59 +08:00
}
this.showLoading_three = false;
2021-12-24 09:56:55 +08:00
},
2022-01-03 16:38:59 +08:00
// 今日活动
2021-12-24 09:56:55 +08:00
async schedulingWeb() {
2022-01-03 16:38:59 +08:00
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.schedulingWeb,
methods: "get",
params: {
2022-01-08 17:37:07 +08:00
EquipmentID: this.$storage.get('EquipmentID')
2022-01-03 16:38:59 +08:00
},
});
if(data.data.data!=undefined){
this.noonArr = data.data.data[0].WeekData;
this.$storage.set('noonArr',this.noonArr)
this.animate = true;
2022-01-03 16:38:59 +08:00
}
} else {
if(this.$storage.get('noonArr')==undefined){
this.noonArr = [];
} else {
this.noonArr = this.$storage.get('noonArr');
this.animate = true;
2022-01-03 16:38:59 +08:00
}
}
this.showLoading_five = false;
2021-12-24 09:56:55 +08:00
},
2021-12-27 17:26:14 +08:00
// 获取当日宝宝生日
2021-12-24 09:56:55 +08:00
async babyBirthday() {
2022-01-03 16:38:59 +08:00
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.babyBirthday,
methods: "get",
params: {
2022-01-08 17:37:07 +08:00
EquipmentGuid: this.$storage.get('EquipmentID')
2022-01-03 16:38:59 +08:00
},
});
this.babyBirthdayData = data.data.count;
this.$storage.set('babyBirthdayData',this.babyBirthdayData)
} else {
this.babyBirthdayData = this.$storage.get('babyBirthdayData');
}
2021-12-24 09:56:55 +08:00
},
2022-01-03 16:38:59 +08:00
// 班级动态
2021-12-24 09:56:55 +08:00
async dynamicPicture() {
2022-01-03 16:38:59 +08:00
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.dynamicPicture,
methods: "post",
params: {
2022-01-08 17:37:07 +08:00
EquipmentID: this.$storage.get('EquipmentID')
2022-01-03 16:38:59 +08:00
},
});
2022-04-28 16:49:18 +08:00
// if(data.data.data!=null){
// this.classImgArr = data.data.data.PictureUrls;
// this.$storage.set('classImgArr',this.classImgArr);
// }
2022-01-03 16:38:59 +08:00
} else {
2022-04-28 16:49:18 +08:00
// if(this.$storage.get('classImgArr')!=undefined){
// this.classImgArr = this.$storage.get('classImgArr');
// }
2022-01-03 16:38:59 +08:00
}
this.showLoading_four = false;
2021-12-24 09:56:55 +08:00
},
2021-12-26 19:07:45 +08:00
// 班级情况
async classStatusEv() {
2022-01-03 16:38:59 +08:00
if(this.$storage.get('network')){
this.showError = false;
let data = await this.$axios({
url: this.$https.classStatus,
methods: "get",
params: {
2022-01-08 17:37:07 +08:00
EquipmentID: this.$storage.get('EquipmentID')
2022-01-03 16:38:59 +08:00
},
});
if(data.data.code==200){
let classInfo = data.data.data;
this.className = classInfo.ClassName;
this.$storage.set('className',this.className);
let newTeacher = [];
classInfo.Teachers.forEach(item=>{
newTeacher.push(item.TeacherName);
})
// 老师
this.teacherName = newTeacher.join(' ');
this.$storage.set('teacherName',this.teacherName);
// 班级人数
this.classNum = classInfo.StudentCount;
this.$storage.set('classNum',this.classNum);
// 实到、未到、请假
this.daoArr = [
{num:classInfo.Signed,title:'实到'},
{num:classInfo.NotSigned,title:'未到'},
{num:classInfo.Holiday,title:'请假'},
];
this.$storage.set('daoArr',this.daoArr);
// 班级guid
this.classGuid = classInfo.ClassGuid;
this.$storage.set('classGuid',this.classGuid);
// 调取宝宝提醒
this.remindEv();
}
} else {
2022-01-08 17:37:07 +08:00
if(this.$storage.get('className')!=undefined){
this.className = this.$storage.get('className');
} else {
2022-01-03 16:38:59 +08:00
this.showError = true;
}
2022-01-08 17:37:07 +08:00
if(this.$storage.get('teacherName')!=undefined){
this.teacherName = this.$storage.get('teacherName');
}
if(this.$storage.get('classNum')!=undefined){
this.classNum = this.$storage.get('classNum');
}
if(this.$storage.get('daoArr')!=undefined){
this.daoArr = this.$storage.get('daoArr');
}
if(this.$storage.get('classGuid')!=undefined){
this.classGuid = this.$storage.get('classGuid');
}
2022-01-03 16:38:59 +08:00
}
this.showLoading_one = false;
},
// 宝宝提醒
async remindEv() {
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.remind,
methods: "post",
params: {
2022-01-08 17:37:07 +08:00
EquipmentID: this.$storage.get('EquipmentID'),
2022-01-03 16:38:59 +08:00
page:1,
limit:100,
ClassGuid:this.classGuid
},
});
this.babyNotice = data.data.count;
this.$storage.set('babyNotice',this.babyNotice)
} else {
this.babyNotice = this.$storage.get('babyNotice');
}
2021-12-26 19:07:45 +08:00
},
2022-01-08 17:37:07 +08:00
plusReady(){
var device_type = navigator.userAgent;//获取userAgent信息
2022-01-08 17:37:07 +08:00
var that = this;
2022-03-04 16:42:01 +08:00
if(plus.networkinfo.getCurrentType()!=1){
2022-01-08 17:37:07 +08:00
that.$storage.set('network',true);
2022-03-04 16:42:01 +08:00
}
that.requestEv();
//网络更改
2022-01-08 17:37:07 +08:00
document.addEventListener( "netchange", function(res) {
var network = plus.networkinfo.getCurrentType();
if(network == 1) {
that.isNetwork = true;
that.$storage.set('network',false);
that.onLine = false;
}else {
that.activeIndex = '-1';
setTimeout(()=>{
that.activeIndex = that.cunIndex;
},100)
that.isNetwork = false;
that.$storage.set('network',true);
that.onLine = true;
}
})
},
requestEv(){
this.babyRecipeEv();
this.schedulingWeb();
this.babyBirthday();
this.dynamicPicture();
this.notice();
2022-01-10 18:41:59 +08:00
},
2021-12-24 09:56:55 +08:00
},
mounted() {
clearInterval(this.monitorTimer);
clearInterval(this.chuTime);
this.chuTime = setInterval(()=>{
if(this.animate){
this.scrollEv()
clearInterval(this.chuTime);
}
},1000)
2022-03-04 16:42:01 +08:00
// 清除班级人数心跳
clearInterval(this.classTimer);
// 班级详情
this.classStatusEv();
this.classTimer = setInterval(()=>{
this.classStatusEv();//班级人数心跳
},1000*60)
2022-01-08 17:37:07 +08:00
setTimeout(()=>{
this.plusReady();
2022-04-28 16:49:18 +08:00
// 视频
this.getVideo();
2022-01-08 17:37:07 +08:00
},500)
// 清除班级人数心跳
clearInterval(this.swiperTime);
this.swiperTime = setInterval(()=>{
this.getVideo();
},1000*6*5)
2022-01-03 16:38:59 +08:00
setTimeout(()=>{
this.timer = setInterval(()=>{
// 宝宝提醒
this.remindEv();
// 通知公告
this.notice();
// 生日提醒
this.babyBirthday();
},1000*60)
},5000)
2022-01-10 18:41:59 +08:00
2021-12-24 09:56:55 +08:00
},
};
2022-01-10 18:41:59 +08:00
</script>