Kaynağa Gözat

自动播放

谢杰标 2 yıl önce
ebeveyn
işleme
2c9dc03e8c

+ 51 - 75
src/pages/course-detail/index.vue

@@ -2792,7 +2792,7 @@
       :close-on-press-escape="false"
       :show-close="false"
     >
-      <template v-if="!isLastVideo()"
+      <template v-if="!isLastVideo"
         ><p>当前视频已学完,继续学习下一个视频?</p>
         <div class="btn1">
           <el-button type="info" plain round @click="dialogPalyVisible = false"
@@ -3175,6 +3175,7 @@ export default {
       sectionExam: [], //节试卷集合
       compareFaceData: 0, // 拍照匹配相似度
       dialogPalyVisible: false,
+      allVideoList: [],
     };
   },
   computed: {
@@ -3224,6 +3225,18 @@ export default {
         return courseName;
       };
     },
+    isLastVideo() {
+      try {
+        let { sectionId, chapterId } = this.sectionItem;
+        let _m = this.menuList;
+        let lastVideo = _m.slice(-1)[0].list.slice(-1)[0].list.slice(-1)[0];
+        return (
+          sectionId == lastVideo.sectionId && chapterId == lastVideo.chapterId
+        );
+      } catch (error) {
+        return false;
+      }
+    },
   },
   async mounted() {
     this.courseId = +this.$route.query.courseId || "";
@@ -3273,6 +3286,7 @@ export default {
     }
 
     await this.getGoodsDetail(); //商品详情
+    this.studyRecordMenuAllList();
     this.dictList();
     // this.userConfirmInfoDetail().then((res) => {
     this.getbaseprofiletplists().then(async (res) => {
@@ -3371,6 +3385,8 @@ export default {
     pauseVideo() {
       if (document.visibilityState === "hidden") {
         this.player && this.player.j2s_pauseVideo();
+      }else{
+        this.player && this.player.j2s_resumeVideo();
       }
     },
     openChangeCourseBoxs() {
@@ -5151,31 +5167,16 @@ export default {
         self.detail = res.data;
       });
     },
-    openModule(menuItem, status = false) {
-      //重修目录点击
-      console.log(menuItem, "menuItem");
+    openModule(menuItem, status = false, isAuto = false) {
       menuItem.showList = !menuItem.showList;
-
-      if (!menuItem.list.length) {
-        if (menuItem.isRebuild) {
-          this.getReChapterList(menuItem.id, menuItem.courseId, menuItem);
-        } else {
-          this.getBuyChapterList(
-            menuItem.id,
-            menuItem.courseId,
-            menuItem,
-            status
-          );
-        }
-      }
-    },
-    getReChapterList(moduleId, courseId, menuItem) {
-      this.$request
+      let { list, isRebuild, id, courseId } = menuItem;
+      if (list.length) return;
+      return this.$request
         .reChapterList({
-          moduleId: moduleId,
+          moduleId: id,
           gradeId: this.gradeId,
           courseId: courseId,
-          rebuild: 1,
+          rebuild: isRebuild ? 1 : undefined,
         })
         .then((res) => {
           for (let i = 0; i < res.data.length; i++) {
@@ -5184,32 +5185,14 @@ export default {
             item.showList = false;
             item.list = [];
             item.parent = menuItem;
-            item.isRebuild = 1;
+            isRebuild ? (item.isRebuild = 1) : (item.menuType = 2);
           }
           menuItem.list = res.data;
-        });
-    },
-
-    getBuyChapterList(moduleId, courseId, menuItem, status) {
-      this.$request
-        .reChapterList({
-          moduleId: moduleId,
-          gradeId: this.gradeId,
-          courseId: courseId,
-        })
-        .then((res) => {
-          for (let i = 0; i < res.data.length; i++) {
-            let item = res.data[i];
-            item.id = item.chapterId;
-            item.menuType = 2;
-            item.showList = false;
-            item.list = [];
-            item.parent = menuItem;
+          if(isAuto){
+            return Promise.resolve(res.data)
           }
-          menuItem.list = res.data;
+          if (isRebuild) return;
           if (status) {
-            console.log(this.sectionItem, "this.sectionItem");
-            console.log(menuItem.list, "menuItem.list");
             const FindIndexs = menuItem.list.findIndex((item) => {
               return item.chapterId == this.sectionItem.chapterId;
             });
@@ -5220,7 +5203,6 @@ export default {
             }
           } else {
             if (this.needOpen) {
-              // this.needOpen = false;
               this.openChapter(menuItem.list[0]);
             }
           }
@@ -5895,6 +5877,7 @@ export default {
             goodsId: this.goodsId,
           })
           .then((res) => {
+            this.allVideoList = res.data;
             resolve(res.data);
           });
       });
@@ -6024,8 +6007,11 @@ export default {
     async playNextVideo() {
       this.dialogPalyVisible = false;
       this.autoplay = true;
-      let { sectionId, chapterId } = this.sectionItem;
-      let chapterList = this.menuList[0].list.filter((e) => e.type == 1);
+      let { sectionId, chapterId, moduleId } = this.sectionItem;
+      let moduleIndex = this.menuList.findIndex((e) => e.id == moduleId);
+      let chapterList = this.menuList[moduleIndex].list.filter(
+        (e) => e.type == 1
+      );
       let playChapterIndex = chapterList.findIndex(
         (e) => e.chapterId == chapterId
       );
@@ -6038,10 +6024,8 @@ export default {
       if (playVideoIndex < playChapter.length - 1) {
         this.getResource(playChapter[playVideoIndex + 1], 1);
       } else if (playChapterIndex < chapterList.length - 1) {
-        // 不是最后一章
-        let nextChapter = chapterList[playChapterIndex + 1].list.filter(
-          (e) => e.type == 1
-        );
+        // 不是最后一杰
+        let nextChapter = chapterList[playChapterIndex + 1].list
         if (nextChapter.length) {
           this.getResource(nextChapter.list[0], 1);
         } else {
@@ -6050,28 +6034,22 @@ export default {
           this.getResource(data[0], 1);
         }
       } else {
-        // 最后一节的最后一个视频
-      }
-    },
-    isLastVideo() {
-      try {
-        let { sectionId, chapterId } = this.sectionItem;
-        let chapterList = this.menuList[0].list.filter((e) => e.type == 1);
-        let playChapterIndex = chapterList.findIndex(
-          (e) => e.chapterId == chapterId
-        );
-        let playChapter = chapterList[playChapterIndex].list.filter(
-          (e) => e.type == 1
-        );
-        let playVideoIndex = playChapter.findIndex(
-          (e) => e.sectionId == sectionId
-        );
-        return (
-          playVideoIndex == playChapter.length - 1 &&
-          playChapterIndex == chapterList.length - 1
-        );
-      } catch (error) {
-        return false;
+        // 章最后一个视频  跳去下一章
+        let nextChapterList = this.menuList[moduleIndex + 1].list
+        if (!nextChapterList.length) {
+          this.needOpen = true;
+          nextChapterList = await this.openModule(
+            this.menuList[moduleIndex + 1],
+            false,
+            true
+          );
+        }
+        if(nextChapterList[0].list.length){
+          this.getResource(nextChapterList[0].list[0], 1);
+        }else{
+          let data = await this.openChapter(nextChapterList[0]);
+          this.getResource(data[0], 1);
+        }
       }
     },
     timeEventLiving() {
@@ -6980,7 +6958,6 @@ export default {
                   !this.sectionItem.moduleId
                 ) {
                   this.menuIndex = [i];
-                  // this.needOpen = false;
                   this.openChapter(this.menuList[i]);
                   break;
                 }
@@ -6995,7 +6972,6 @@ export default {
                     break;
                   } else if (res.rows[i].type == 2) {
                     this.menuIndex = [i];
-                    // this.needOpen = false;
                     this.openChapter(this.menuList[i]);
                     break;
                   }

Dosya farkı çok büyük olduğundan ihmal edildi
+ 593 - 234
src/pages/person-center/my-course/index.vue


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor