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

475 lines
14 KiB
Vue
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

<template>
<div>
<error-page v-if="showError" @closeError="closeError"></error-page>
<!-- 主体内容 -->
<div class="main-box" v-else>
<!-- 左侧 -->
<div class="main-left">
<!-- 班级详情 -->
<div class="left-one flex-s0">
<div class="left-content">
<div class="left-title">
<div class="pultitle">班级详情</div>
</div>
<div class="second-title" v-if="className!=''">{{className}}</div>
<div class="line" v-if="className!=''"></div>
<div class="three-content" v-if="className!=''">
<div>老师:{{teacherName}}</div>
<div>班级人数:{{classNum}}</div>
</div>
<div class="line" v-if="className!=''"></div>
<div class="left-last">
<div v-for="(item,index) in daoArr" :key="index">
<div>{{item.num}}</div>
<div>{{item.title}}</div>
</div>
</div>
</div>
<loading :isShow="showLoading_one"></loading>
</div>
<!-- 宝宝食谱 -->
<div class="left-one flex-s0">
<div class="left-content">
<div class="left-title">
<div class="pultitle">今日食谱</div>
</div>
<div v-if="threeMeals.length!=0">
<div class="eat-three">
<div :class="threeMealIndex == index ? 'threeMealActive' : ''"
v-for="(item, index) in threeMeals" :key="index" @click="chooseMeal(index)">
{{ item.Type }}
</div>
</div>
<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>
</div>
</div>
</div>
<loading :isShow="showLoading_two"></loading>
</div>
<!-- 通知公告 -->
<div class="left-one">
<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>
</div>
<loading :isShow="showLoading_three"></loading>
</div>
</div>
<!-- 中部 -->
<div class="main-center">
<!-- 班级动态图文 -->
<div class="center-img-box">
<div class="center-title">班级动态</div>
<div class="img-box">
<swiper class="home-swiper" v-if="classImgArr.length" :options="swiperOption" style="position: relative;">
<swiper-slide v-for="(item,index) in classImgArr" :key="index" class="home-slide">
<img :src="item">
</swiper-slide>
</swiper>
<div class="swiper-pagination"></div>
<loading :isShow="showLoading_four"></loading>
</div>
</div>
<!-- 提醒 -->
<div class="remind-box">
<div class="msg-box">
<img src="../../static/img/home/icon-notice.png" />
<div v-if="noticeData!=0">{{noticeData}}</div>
</div>
<div class="msg-box">
<div>宝宝提醒</div>
<div v-if="babyNotice!=0">{{babyNotice}}</div>
</div>
<div class="msg-box">
<div >生日提醒</div>
<div v-if="babyBirthdayData!=0">{{babyBirthdayData}}</div>
</div>
</div>
</div>
<!-- 右侧 -->
<div class="main-right">
<div class="left-title">
<div class="pultitle">今日活动</div>
</div>
<div class="right-content">
<div v-if="noonArr.length!=0" id="innerbox">
<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>
<div class="clips3">{{ itemc.Name }}</div>
</div>
</div>
</div>
</div>
<loading :isShow="showLoading_five"></loading>
</div>
</div>
</div>
</template>
<script>
import $ from 'jquery'
import storage from 'good-storage'
export default {
name: "homepage",
data() {
return {
threeMeals: [],
threeMealIndex: 0,
noticeData: 0,
babyBirthdayData: 0,
babyNotice:0,//宝宝提醒数量
dynamicPictureData: "",
noonArr: [],
moId:"",
model:"",
className:'',//班级名称
teacherName:'',//老师姓名
classNum:'',//班级人数
daoArr:[],//实到、未到、请假
classImgArr:[],
showLoading_one:true,
showLoading_two:true,
showLoading_three:true,
showLoading_four:true,
showLoading_five:true,
noticeObj:{
PublishTime:'',
Content:''
},
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
  }
},
showError:false,
monitorTimer:null,
animate:false,
topVal:0,
scrollTime:null
};
},
destroyed() {
clearInterval(this.timer);
this.topVal = 0;
clearInterval(this.scrollTime);
},
methods: {
// 滚动动画
scrollEv(){
this.topVal = 0;
clearInterval(this.scrollTime);
this.scrollTime = setInterval(()=>{
let containerHeight = $('.right-content').height();
let contentHeight = $('#innerbox').height();
if(contentHeight + this.topVal <= containerHeight) {
$('#innerbox').animate({top:`${0}px`});
clearInterval(this.scrollTime);
this.topVal = 0;
this.scrollEv();
} else {
this.topVal = this.topVal - 50;
$('#innerbox').animate({top:`${this.topVal}px`});
}
},4000)
// $(function(){
// $('.pultitle').on('click',function(){
// $('#innerbox').animate({top:`${30}%`});
// })
// })
},
closeError(){
this.showError = false;
},
// 早中晚餐切换事件
chooseMeal(e) {
this.threeMealIndex = e;
},
// 宝宝食谱
async babyRecipeEv() {
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.babyRecipe,
methods: "get",
params: {
EquipmentID: this.$storage.get('EquipmentID')
},
});
if(data.data.data!=undefined){
this.threeMeals = data.data.data;
this.$storage.set('threeMeals',this.threeMeals);
}
} else {
if(this.$storage.get('threeMeals')!=undefined){
this.threeMeals = this.$storage.get('threeMeals');
}
}
this.showLoading_two = false;
},
// 通知消息数量
async notice() {
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.notice,
methods: "get",
params: {
EquipmentID: this.$storage.get('EquipmentID')
},
});
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)
storage.set('orgGuid',this.noticeObj.OrgGuid);
}
} else {
this.noticeData = this.$storage.get('noticeData');
if(this.$storage.get('noticeObj')!=undefined){
this.noticeObj = this.$storage.get('noticeObj');
this.noticeObj.PublishTime = this.$storage.get('PublishTime');
}
}
this.showLoading_three = false;
},
// 今日活动
async schedulingWeb() {
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.schedulingWeb,
methods: "get",
params: {
EquipmentID: this.$storage.get('EquipmentID')
},
});
if(data.data.data!=undefined){
this.noonArr = data.data.data[0].WeekData;
this.$storage.set('noonArr',this.noonArr)
this.scrollEv();
}
} else {
if(this.$storage.get('noonArr')==undefined){
this.noonArr = [];
} else {
this.noonArr = this.$storage.get('noonArr');
this.scrollEv();
}
}
this.showLoading_five = false;
},
// 获取当日宝宝生日
async babyBirthday() {
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.babyBirthday,
methods: "get",
params: {
EquipmentGuid: this.$storage.get('EquipmentID')
},
});
this.babyBirthdayData = data.data.count;
this.$storage.set('babyBirthdayData',this.babyBirthdayData)
} else {
this.babyBirthdayData = this.$storage.get('babyBirthdayData');
}
},
// 班级动态
async dynamicPicture() {
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.dynamicPicture,
methods: "post",
params: {
EquipmentID: this.$storage.get('EquipmentID')
},
});
if(data.data.data!=null){
this.classImgArr = data.data.data.PictureUrls;
this.$storage.set('classImgArr',this.classImgArr);
}
} else {
if(this.$storage.get('classImgArr')!=undefined){
this.classImgArr = this.$storage.get('classImgArr');
}
}
this.showLoading_four = false;
},
// 班级情况
async classStatusEv() {
if(this.$storage.get('network')){
this.showError = false;
let data = await this.$axios({
url: this.$https.classStatus,
methods: "get",
params: {
EquipmentID: this.$storage.get('EquipmentID')
},
});
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 {
if(this.$storage.get('className')!=undefined){
this.className = this.$storage.get('className');
} else {
this.showError = true;
}
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');
}
}
this.showLoading_one = false;
},
// 宝宝提醒
async remindEv() {
if(this.$storage.get('network')){
let data = await this.$axios({
// 调用 serviceAPI
url: this.$https.remind,
methods: "post",
params: {
EquipmentID: this.$storage.get('EquipmentID'),
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');
}
},
plusReady(){
var that = this;
// 手机有效
this.$storage.set('EquipmentID',plus.device.imei);
// this.$storage.set('EquipmentID','yaohaotest001');
if(plus.networkinfo.getCurrentType()!=1){
that.$storage.set('network',true);
}
// 网页网络监听有效
// window.addEventListener('online', this.updateOnlineStatus); //网络由异常到正常时触发
// window.addEventListener('offline', this.updateOnlineStatus); //网络由正常到异常时触发
//网络更改
document.addEventListener( "netchange", function(res) {
var network = plus.networkinfo.getCurrentType();
if(network == 1) {
that.isNetwork = true;
that.$storage.set('network',false);
that.onLine = false;
// plus.nativeUI.toast('您的网络已断开');
}else {
that.activeIndex = '-1';
setTimeout(()=>{
that.activeIndex = that.cunIndex;
},100)
that.isNetwork = false;
that.$storage.set('network',true);
that.onLine = true;
// plus.nativeUI.toast('您的网络已连接');
}
})
},
requestEv(){
// 班级详情
this.classStatusEv();
this.babyRecipeEv();
this.schedulingWeb();
this.babyBirthday();
this.dynamicPicture();
this.notice();
},
},
mounted() {
setTimeout(()=>{
this.plusReady();
},500)
setTimeout(()=>{
this.requestEv();
},1000)
setTimeout(()=>{
this.timer = setInterval(()=>{
// 宝宝提醒
this.remindEv();
// 通知公告
this.notice();
// 生日提醒
this.babyBirthday();
},1000*60)
},5000)
},
};
</script>