|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="page-exam-box">
|
|
|
+ <div class="page-exam-box" @scroll="scrollExamBox($event)" ref="exam-box">
|
|
|
<div class="exam-list" v-if="examList.length > 0">
|
|
|
<div
|
|
|
class="exam-item"
|
|
@@ -60,7 +60,10 @@ export default {
|
|
|
NOTEXAM: 4 // 未参考
|
|
|
},
|
|
|
examList: [],
|
|
|
- isInited: false // 是否已加载完毕
|
|
|
+ isInited: false, // 是否已加载完毕
|
|
|
+ examPage: 0,
|
|
|
+ examSize: 10,
|
|
|
+ canExamFlag: true // 加载考试标志
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -80,21 +83,27 @@ export default {
|
|
|
},
|
|
|
created() {
|
|
|
this.getExamListFun(); // 查询:考试的场次列表信息
|
|
|
+ window.addEventListener("scroll", this.handleExamScroll, true);
|
|
|
+ },
|
|
|
+ destroyed () {
|
|
|
+ window.removeEventListener("scroll", this.scrollHander);
|
|
|
},
|
|
|
methods: {
|
|
|
// 查询:考试场次的列表信息
|
|
|
getExamListFun() {
|
|
|
this.isInited = false;
|
|
|
this.$store.commit("toggleLoading", true);
|
|
|
- this.examList = [];
|
|
|
let params = {
|
|
|
- type: this.chooseEngneeringWork.value
|
|
|
+ // type: this.chooseEngneeringWork.name,
|
|
|
+ page: this.examPage,
|
|
|
+ size: this.examSize
|
|
|
};
|
|
|
this.$_http
|
|
|
.get(this.$_API.GET_JTXT_GET_EXAMS, { params })
|
|
|
.then(res => {
|
|
|
+ // console.log("--exams--" + JSON.stringify(res));
|
|
|
if (res.data) {
|
|
|
- res.data.forEach(item => {
|
|
|
+ res.data.content.forEach(item => {
|
|
|
let formateTimeDiff = this.formateTimeDiffFun(item.duration);
|
|
|
item.examTimeMins = formateTimeDiff.examTimeMins;
|
|
|
item.examTimeMinsTxt = formateTimeDiff.examTimeMinsTxt;
|
|
@@ -102,18 +111,44 @@ export default {
|
|
|
item.examStatus = obj.status;
|
|
|
item.examStatusTxt = obj.statusTxt;
|
|
|
});
|
|
|
+ // 分页到底了
|
|
|
+ if (res.data.last) {
|
|
|
+ this.canExamFlag = false;
|
|
|
+ Toast("没有更多内容了");
|
|
|
+ } else {
|
|
|
+ this.canExamFlag = true;
|
|
|
+ }
|
|
|
this.$nextTick(() => {
|
|
|
- this.examList = res.data;
|
|
|
+ this.examList = [...this.examList, ...res.data.content];
|
|
|
+ // console.log("----" + JSON.stringify(this.examList));
|
|
|
});
|
|
|
this.isInited = true;
|
|
|
}
|
|
|
this.$store.commit("toggleLoading", false);
|
|
|
})
|
|
|
.catch(() => {
|
|
|
+ this.canExamFlag = false;
|
|
|
+ Toast("系统异常");
|
|
|
this.$store.commit("toggleLoading", false);
|
|
|
});
|
|
|
},
|
|
|
- // 过滤秒为 时:分:秒 及 xx小时xx分钟xx秒
|
|
|
+
|
|
|
+ async handleExamScroll() {
|
|
|
+ let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
|
|
+ var windowHeight =
|
|
|
+ document.documentElement.clientHeight || document.body.clientHeight;
|
|
|
+ var scrollHeight =
|
|
|
+ document.documentElement.scrollHeight || document.body.scrollHeight;
|
|
|
+ // console.log("---scrollTop-----" + scrollTop);
|
|
|
+ // console.log("---windowHeight-----" + windowHeight);
|
|
|
+ // console.log("---scrollHeight-----" + scrollHeight);
|
|
|
+ if (this.canExamFlag && scrollTop + windowHeight >= scrollHeight - 100) {
|
|
|
+ this.canExamFlag = false;
|
|
|
+ console.log("触底");
|
|
|
+ this.examPage = this.examPage + 1;
|
|
|
+ await this.getExamListFun();
|
|
|
+ }
|
|
|
+ },
|
|
|
formateTimeDiffFun(secondes) {
|
|
|
let hours = Math.floor(secondes / (1000 * 60 * 60));
|
|
|
let minutes = Math.floor(
|
|
@@ -144,7 +179,7 @@ export default {
|
|
|
|
|
|
if (curTime >= startTimesCeconds) {
|
|
|
if (curTime >= endTimeCeconds) {
|
|
|
- if (this.exam.examHistoryObj[exam.id]) {
|
|
|
+ if (this.exam.examHistoryObj && this.exam.examHistoryObj[exam.id]) {
|
|
|
return {
|
|
|
status: this.examStatesType.EXAMOVER,
|
|
|
statusTxt: "已考完"
|