|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div id="portal-body">
|
|
|
|
|
|
- <CarouselCard id="portal-carousel-card"/>
|
|
|
+ <CarouselCard style="grid-column-start: 1; grid-column-end: 3;"/>
|
|
|
|
|
|
<div>
|
|
|
<el-card :style="{height: courseRowHeight + 'px'}">
|
|
|
@@ -42,7 +42,6 @@
|
|
|
:style="{height: (courseRowHeight - 63) + 'px', marginTop: (courseRowHeight / 2 - 100) + 'px'}"
|
|
|
class="portal-card-main" style="cursor: pointer"
|
|
|
@click="this.$router.push('/manage')">
|
|
|
- <!-- <div style="font-size: small; font-weight: bold; color: #666666">去管理课程</div>-->
|
|
|
<el-icon :size="72" color="#bfbfbf">
|
|
|
<SetUp/>
|
|
|
</el-icon>
|
|
|
@@ -73,36 +72,44 @@
|
|
|
<div class="portal-card-title-main">我的测试</div>
|
|
|
</div>
|
|
|
<el-divider class="portal-card-divider"/>
|
|
|
- <div v-if="isTeacher">
|
|
|
- 教师请前往
|
|
|
- <span style="cursor: pointer;color: red"
|
|
|
- @click="$router.push('/manage')">管理页面</span>
|
|
|
- 查看相关测试。
|
|
|
+
|
|
|
+ <div v-if="!isLogin"
|
|
|
+ :style="{height: (testRowHeight - 63) + 'px', marginTop: (testRowHeight / 2 - 100) + 'px'}"
|
|
|
+ class="portal-card-main" style="cursor: pointer"
|
|
|
+ @click="this.$router.push('/auth')">
|
|
|
+ <el-icon :size="72" color="#bfbfbf">
|
|
|
+ <Lock/>
|
|
|
+ </el-icon>
|
|
|
+ <div style="font-size: small; font-weight: bold; color: #666666">登录以查看</div>
|
|
|
</div>
|
|
|
- <div v-if="isStudent">
|
|
|
- <div v-if="isLogin" :style="{height: (testRowHeight - 63) + 'px'}" class="portal-card-main">
|
|
|
- <div class="portal-my-card-main">
|
|
|
- <div v-if="myTestList.length !== 0">
|
|
|
- <MyTestCard v-for="test in myTestList" :key="test.id" :testVO="test"/>
|
|
|
- </div>
|
|
|
- <div v-else>
|
|
|
- 您尚未参加任何测试,前往
|
|
|
- <span style="cursor: pointer;color: red"
|
|
|
- @click="$router.push('/test')">全部测试
|
|
|
- </span>
|
|
|
- 页面参加更多优质测试。
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div v-else :style="{height: (testRowHeight - 63) + 'px', marginTop: (testRowHeight / 2 - 100) + 'px'}"
|
|
|
- class="portal-card-main" style="cursor: pointer"
|
|
|
- @click="this.$router.push('/auth')">
|
|
|
- <el-icon :size="72" color="#bfbfbf">
|
|
|
- <Lock/>
|
|
|
- </el-icon>
|
|
|
- <div style="font-size: small; font-weight: bold; color: #666666">登录以查看</div>
|
|
|
+
|
|
|
+ <div v-if="isLogin && isStudent && myTestList!==null && myTestList.length!==0" :style="{height: (testRowHeight - 63) + 'px'}"
|
|
|
+ class="portal-card-main">
|
|
|
+ <div class="portal-my-card-main">
|
|
|
+ <MyTestCard v-for="test in myTestList" :key="test.id" :testVO="test"/>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <div v-if="isLogin && isStudent && myTestList!==null && myTestList.length===0"
|
|
|
+ :style="{height: (testRowHeight - 63) + 'px', marginTop: (testRowHeight / 2 - 100) + 'px'}"
|
|
|
+ class="portal-card-main" style="cursor: pointer"
|
|
|
+ @click="this.$router.push('/test')">
|
|
|
+ <el-icon :size="72" color="#bfbfbf">
|
|
|
+ <ShoppingCart/>
|
|
|
+ </el-icon>
|
|
|
+ <div style="font-size: small; font-weight: bold; color: #666666">去参加测试</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div v-show="isLogin && isTeacher"
|
|
|
+ :style="{height: (testRowHeight - 63) + 'px', marginTop: (testRowHeight / 2 - 100) + 'px'}"
|
|
|
+ class="portal-card-main" style="cursor: pointer"
|
|
|
+ @click="this.$router.push('/manage')">
|
|
|
+ <el-icon :size="72" color="#bfbfbf">
|
|
|
+ <SetUp/>
|
|
|
+ </el-icon>
|
|
|
+ <div style="font-size: small; font-weight: bold; color: #666666">去管理测试</div>
|
|
|
+ </div>
|
|
|
+
|
|
|
</el-card>
|
|
|
</div>
|
|
|
|
|
|
@@ -146,10 +153,10 @@ import EvalCard from "@/components/EvalCard";
|
|
|
import CoderCard from "@/components/CoderCard";
|
|
|
import MyCourseCard from "@/views/PortalPage/components/MyCourseCard";
|
|
|
import MyTestCard from "@/views/PortalPage/components/MyTestCard";
|
|
|
-import {Lock, SetUp, ShoppingCart} from "@element-plus/icons-vue";
|
|
|
+import { Lock, SetUp, ShoppingCart } from "@element-plus/icons-vue";
|
|
|
|
|
|
export default {
|
|
|
- //属性
|
|
|
+ //数据
|
|
|
name: "PortalPage",
|
|
|
components: {
|
|
|
SetUp,
|
|
|
@@ -165,16 +172,14 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- extending: false,
|
|
|
cardRowLength: 3,
|
|
|
activeTestPaneName: "eval",
|
|
|
evalExamList: [],
|
|
|
courseList: [],
|
|
|
coderExamList: [],
|
|
|
- myCourseList: null,
|
|
|
+ myCourseList: [],
|
|
|
myEvalExamList: [],
|
|
|
myCoderExamList: [],
|
|
|
- myTestList: [],
|
|
|
courseRowHeight: 360,
|
|
|
testRowHeight: 300,
|
|
|
};
|
|
|
@@ -188,11 +193,14 @@ export default {
|
|
|
},
|
|
|
isStudent() {
|
|
|
return this.$store.getters.isStudent;
|
|
|
- }
|
|
|
+ },
|
|
|
+ myTestList() {
|
|
|
+ return [].concat(this.myEvalExamList).concat(this.myCoderExamList);
|
|
|
+ },
|
|
|
},
|
|
|
|
|
|
//生命周期函数
|
|
|
- beforeMount() {
|
|
|
+ created() {
|
|
|
window.addEventListener("scroll", this.handleResize, true);
|
|
|
},
|
|
|
async mounted() {
|
|
|
@@ -205,35 +213,38 @@ export default {
|
|
|
|
|
|
this.$apis.getExampleCourses().then(res => {
|
|
|
this.courseList = res.data.data;
|
|
|
+ while (this.courseList.length < 6) {
|
|
|
+ this.courseList.push({});
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.$apis.getAllEvalExams().then(res => {
|
|
|
+ // todo ERROR: 缺少 token 就无法请求
|
|
|
+ this.evalExamList = res.data.data.examVOList;
|
|
|
+ while (this.evalExamList.length < 6) {
|
|
|
+ this.evalExamList.push({});
|
|
|
+ }
|
|
|
});
|
|
|
- // this.$apis.getAllEvalExams().then(res => {
|
|
|
- // this.evalExamList = res.data.data["examVOList"];
|
|
|
- // });
|
|
|
- // todo
|
|
|
- this.evalExamList = this.$apis.getAllEvalExams().data.data["examVOList"];
|
|
|
- // this.$apis.getAllCoderExams().then(res => {
|
|
|
- // this.coderExamList = res.data.data.res;
|
|
|
- // });
|
|
|
- // todo
|
|
|
- this.coderExamList = this.$apis.getAllCoderExams().data.data.res;
|
|
|
+ this.$apis.getAllCoderExams().then(res => {
|
|
|
+ // todo ERROR: 缺少 token 就无法请求
|
|
|
+ this.coderExamList = res.data.data.res;
|
|
|
+ while (this.coderExamList.length < 6) {
|
|
|
+ this.coderExamList.push({});
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
if (this.isLogin && this.isStudent) {
|
|
|
- this.$apis.getStudentCourses(this.$store.state.user.id)
|
|
|
- .then(res => {
|
|
|
- this.myCourseList = res.data.data;
|
|
|
- })
|
|
|
- .catch();
|
|
|
- this.$apis.getStudentEvalExams({state: 0})
|
|
|
- .then(
|
|
|
- res => {
|
|
|
- this.myEvalExamList = res.data.data.examVOList;
|
|
|
- })
|
|
|
- .catch();
|
|
|
- this.$apis.getStudentCoderExams({})
|
|
|
- .then(res => {
|
|
|
- this.myCoderExamList = res.data.data.res;
|
|
|
- })
|
|
|
- .catch();
|
|
|
- this.myTestList = [].concat(this.myEvalExamList).concat(this.myCoderExamList);
|
|
|
+ this.$apis.getStudentCourses(this.$store.state.user.id).then(res => {
|
|
|
+ this.myCourseList = res.data.data;
|
|
|
+ that.handleResize();
|
|
|
+ });
|
|
|
+ this.$apis.getStudentEvalExams({ state: 0 }).then(res => {
|
|
|
+ this.myEvalExamList = res.data.data.examVOList;
|
|
|
+ that.handleResize();
|
|
|
+ });
|
|
|
+ this.$apis.getStudentCoderExams({}).then(res => {
|
|
|
+ this.myCoderExamList = res.data.data.res;
|
|
|
+ that.handleResize();
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
await this.$nextTick(() => {
|
|
|
@@ -250,19 +261,20 @@ export default {
|
|
|
this.$router.push("/course");
|
|
|
},
|
|
|
handleResize() {
|
|
|
+ // todo 优化
|
|
|
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
|
|
|
if (scrollTop > 100) {
|
|
|
- this.extending = true;
|
|
|
+ this.courseRowHeight = 640;
|
|
|
if (document.body.clientWidth >= 1200) {
|
|
|
this.cardRowLength = 6;
|
|
|
- } else if (document.body.clientWidth >= 992 && document.body.clientWidth < 1200) {
|
|
|
- this.cardRowLength = 4;
|
|
|
- } else if (document.body.clientWidth < 992) {
|
|
|
- this.cardRowLength = 2;
|
|
|
}
|
|
|
- this.courseRowHeight = 640;
|
|
|
}
|
|
|
- this.testRowHeight = this.$refs.portalTestCardBodyMain.$el.clientHeight;
|
|
|
+ if (document.body.clientWidth >= 992 && document.body.clientWidth < 1200) {
|
|
|
+ this.cardRowLength = 4;
|
|
|
+ } else if (document.body.clientWidth < 992) {
|
|
|
+ this.cardRowLength = 2;
|
|
|
+ }
|
|
|
+ this.testRowHeight = Math.max(this.$refs.portalTestCardBodyMain.$el.clientHeight, 300);
|
|
|
},
|
|
|
changeTestPane() {
|
|
|
const that = this;
|