Explorar o código

Merge branch 'seec' of http://gogs.seec.seecoder.cn/LiuQin/SEEC-Portal-Front into seec

mjh %!s(int64=4) %!d(string=hai) anos
pai
achega
c8800b9365
Modificáronse 1 ficheiros con 61 adicións e 22 borrados
  1. 61 22
      src/views/PortalPage/PortalPage.vue

+ 61 - 22
src/views/PortalPage/PortalPage.vue

@@ -9,7 +9,7 @@
     </span>
     <CarouselCard v-if="false"/>
 
-    <div id="portal-my-course-card-body" >
+    <div id="portal-my-course-card-body">
       <div id="portal-my-course-card-title" class="portal-card-title">
         <div class="portal-card-title-main">我的课程</div>
       </div>
@@ -29,8 +29,8 @@
       </div>
       <el-card id="portal-course-card-main">
         <el-row justify="space-around" type="flex">
-          <el-col v-for="item in courseList.slice(0, cardRowLength)" :key="item.id" :lg="7" :md="11" :xs="24">
-              <CourseCard :course-v-o="item"/>
+          <el-col v-for="item in courseList.slice(0, cardRowLength)" :key="item.id" :lg="7" :md="11" :sm="24" :xs="24">
+            <CourseCard :course-v-o="item"/>
           </el-col>
         </el-row>
       </el-card>
@@ -58,7 +58,7 @@
         <el-tabs v-model="activeTestName" @tab-click="changeTestPane">
           <el-tab-pane label="评测题" name="eval">
             <el-row justify="space-around">
-              <el-col v-for="item in evalExamList.slice(0, cardRowLength)" :key="item.id" :lg="7" :md="11" :xs="24">
+              <el-col v-for="item in evalExamList.slice(0, cardRowLength)" :key="item.id" :lg="7" :md="11" :sm="11" :xs="24">
                 <EvalCard :examVO="item"></EvalCard>
               </el-col>
             </el-row>
@@ -212,35 +212,62 @@ export default {
           "courseState": "NORMAL"
         }
       ],
+      courseListItem_blank: {
+        "id": 0,
+        "name": "暂未开放课程",
+        "teacher": {
+          "id": 3117,
+          "phone": "13382405535",
+          "username": "PortalTestTeacher",
+          "name": "PortalTestTeacher",
+          "email": "m15256072859@163.com",
+          "photo": null,
+          "role": "TEACHER",
+          "signature": "无",
+          "createdTime": "2022-02-21T13:21:26.171+08:00",
+          "valid": true
+        },
+        "semester": "2022春",
+        "imageUrl": null,
+        "description": "minim eu sit Lorem",
+        "startTime": "2022-02-28T11:08:07.608+08:00",
+        "endTime": "2022-02-28T11:08:07.608+08:00",
+        "invitationCode": "3117-4",
+        "moocUrl": null,
+        "evalId": null,
+        "coderId": 12,
+        "helperId": null,
+        "createdTime": "2022-02-20T11:54:34.084+08:00",
+        "price": 0,
+        "courseState": "NORMAL"
+      },
     };
   },
 
-  //数据流
-  watch: {
-    courseList(newList) {
-      let i = 3 - newList.length % 3;
-      for (i; i !== 0; i--) {
-        newList.push(this.courseListExample[0]);
-      }
-    },
-  },
-
   //生命周期函数
   beforeMount() {
     window.addEventListener("scroll", this.handleScroll, true);
   },
-  // beforeUnmount() {
-  //   window.removeEventListener("scroll", this.handleScroll);
-  // },
   async mounted() {
+    const that = this;
+    window.onresize = () => {
+      return (() => {
+        that.handleScroll();
+      })();
+    };
+
     // const res = await this.$apis.getAllCourses();
     // this.courseList = res.data.data;
     this.courseList = this.courseListExample;
-    console.log(this.courseList);
+    let i = 3 - this.courseList.length % 3;
+    for (i; i !== 0; i--) {
+      this.courseList.push(this.courseListItem_blank);
+    }
+    // console.log(this.courseList);
 
     const res2 = await this.$apis.getAllEvalExams();
     this.evalExamList = res2.data.data["examVOList"];
-    console.log(this.evalExamList);
+    // console.log(this.evalExamList);
   },
 
   //其他函数
@@ -255,14 +282,26 @@ export default {
       let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
       if (scrollTop > 100) {
         this.extending = true;
-        this.cardRowLength = 6;
+        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;
+        }
       } else if (scrollTop < 5) {
         this.extending = false;
-        this.cardRowLength = 3;
+        if (document.body.clientWidth >= 1200) {
+          this.cardRowLength = 3;
+        } else if (document.body.clientWidth >= 992 && document.body.clientWidth < 1200) {
+          this.cardRowLength = 2;
+        } else if (document.body.clientWidth < 992) {
+          this.cardRowLength = 1;
+        }
       }
     },
     changeTestPane(tab, event) {
-      console.log(tab, event);
+      // console.log(tab, event);
     }
   }
 };