guhongwei il y a 4 ans
Parent
commit
df47521b03
1 fichiers modifiés avec 17 ajouts et 17 suppressions
  1. 17 17
      src/views/index.vue

+ 17 - 17
src/views/index.vue

@@ -56,15 +56,9 @@ export default {
   created() {
     //兼容二维码地址问题
     let user = localStorage.getItem('user');
-    console.log(user);
+    // console.log(user);
     if (!user && this.token) this.$router.push({ path: '/login', query: { token: this.token } });
     this.getOtherList();
-    let today = this.getDay();
-    // let month = this.getMonth();
-    let todate = this.getDate();
-    this.$set(this.today, `date`, todate);
-    this.$set(this.today, `day`, today);
-
     if (this.user !== undefined) {
       this.$set(this, `classid`, this.user.classid);
       this.searchInfo();
@@ -98,7 +92,6 @@ export default {
       if (res.errcode == '0') this.$set(this, `classInfo`, res.data);
       let classid = this.classid;
       const result = await this.lessionlist({ classid });
-
       let lessones = {};
       for (const val of result.data) {
         lessones = val;
@@ -106,12 +99,11 @@ export default {
       var lesson = lessones.lessons.find(item => item.date === this.getDate());
       this.$set(this, `lesson`, lesson);
       // 获取课程开始-结束日期
-
       this.$set(this, `originLesson`, lessones.lessons);
-
+      this.getdqdate();
       var ress = this.originLesson.filter(item => item.date === this.date);
-      this.$set(this, `lesson`, ress);
-
+      console.log(ress);
+      // this.$set(this, `lesson`, ress);
       lessones.lessons.sort(function(a, b) {
         if (a.date < b.date) {
           return -1;
@@ -130,7 +122,6 @@ export default {
         let object = { date: i.date, day: this.getDay(i.date) };
         if (index !== 0) return object;
       });
-
       //排序
       var appArray = _.uniqWith(ltime, _.isEqual);
       appArray.sort(function(a, b) {
@@ -147,7 +138,6 @@ export default {
           return 0;
         }
       });
-
       this.$set(this, `arrange`, _.compact(appArray));
     },
     // 获取时间
@@ -165,14 +155,24 @@ export default {
       arr[2] = arr[2] * 1 >= 10 ? `${arr[2]}` : `0${arr[2]}`;
       return `${arr[0]}-${arr[1]}-${arr[2]}`;
     },
+    // 获取当前日期
+    getdqdate() {
+      // let today = this.getDay();
+      // let todate = this.getDate();
+      // this.$set(this.today, `date`, '2020-03-16');
+      // this.$set(this.today, `day`, '星期一');
+      let dangDate = {
+        date: this.getDate(),
+        day: this.getDay(),
+      };
+      this.getLesson(dangDate);
+    },
     //点击日期获取课程
     getLesson(date) {
       this.$set(this, `today`, date);
-
       var res = this.originLesson.filter(item => item.date === date.date);
-      this.$set(this, `lesson`, res);
+      if (res) this.$set(this, `lesson`, res);
     },
-
     turnto(data) {
       this.$set(this, `classid`, data._id);
       this.searchInfo();