Просмотр исходного кода

切换课程时清除学习记录定时器

xuqiaoying 2 лет назад
Родитель
Сommit
41a91be497
1 измененных файлов с 13 добавлено и 13 удалено
  1. 13 13
      pages3/polyv/detail.vue

+ 13 - 13
pages3/polyv/detail.vue

@@ -621,9 +621,6 @@ import plv from "../static/polyv-sdk/index";
 import courseModule from "@/components/course/courseModule.vue";
 import courseChapter from "@/components/course/courseChapter.vue";
 import courseSection from "@/components/course/courseSection.vue";
-// import courseModuleMulu from "@/components/course/courseModuleMulu.vue"
-// import courseChapterMulu from "@/components/course/courseChapterMulu.vue";
-// import courseSectionMulu from "@/components/course/courseSectionMulu.vue";
 import {WEBVIEW_URL} from '@/common/request.js'
 // import { websocket } from "@/common/socket.js";
 import { mapGetters, mapMutations } from "vuex";
@@ -632,9 +629,6 @@ export default {
     courseModule,
     courseChapter,
     courseSection,
-    // courseModuleMulu,
-    // courseChapterMulu,
-    // courseSectionMulu,
   },
   data() {
     return {
@@ -1026,8 +1020,9 @@ export default {
     // 原来的mouted内容
     originMounted() {
       uni.$on("changeSection", (oldSectionId) => {
-        // console.log('originMounted->playVID:', this.playVID, oldSectionId);
-          this.hasStart = false;
+        // console.log('切换课程-originMounted->playVID:', this.playVID, oldSectionId);
+        this.studyTimer && clearInterval(this.studyTimer) // 清除定时器
+        this.hasStart = false;
         this.photoConfig = false;
         this.photoIndex = 0;
         var polyvPlayerContext = this.selectComponent("#playerVideo");
@@ -1042,7 +1037,8 @@ export default {
       });
       uni.$on("getSection", (item) => {
         //清除直播
-          this.hasStart = false;
+        this.studyTimer && clearInterval(this.studyTimer)
+        this.hasStart = false;
         this.isPlayRebuild = item.rebuild;
         this.photoConfig = false;
         this.photoIndex = 0;
@@ -1052,7 +1048,7 @@ export default {
         
         this.$store.commit("setPlayChannelId", { playChannelId: 0 });
         this.$store.commit("setPlaySectionId", { playSectionId: item.sectionId || item.menuId });
-        console.log('清除直播节点胡:', this.moduleId, this.chapterId, this.playSectionId )
+        console.log('清除直播节点胡:', this.moduleId, this.chapterId, this.playSectionId, this.hasStart )
         //获取拍照历史
         this.getPhotoLastRecord();
         this.playVideo(item);
@@ -1065,6 +1061,7 @@ export default {
       });
       uni.$on("getChannel", (item) => {
         //清除录播
+        this.studyTimer && clearInterval(this.studyTimer)
           this.hasStart = false;
         this.$store.commit("setPlayVID", { playVID: null });
 
@@ -1094,10 +1091,13 @@ export default {
       this.closePlv();
       //移除所有的事件监听器
       uni.$off();
-      // console.log('timer', this.timer, 'lockTimer:', this.lockTimer, 'studyTimer:', this.studyTimer);
       this.clearTimer && clearTimeout(this.clearTimer)
       this.toastTimer && clearTimeout(this.toastTimer)
-      this.studyTimer && clearInterval(this.studyTimer)
+      if (this.studyTimer) {
+        clearInterval(this.studyTimer)
+        this.hasStart = false
+      }
+      
       this.timer && clearInterval(this.timer)
       if (this.lockTimer) {
         clearInterval(this.lockTimer);
@@ -1777,10 +1777,10 @@ export default {
       return {};
     },
 		loadedmetadata(event) {
+      console.log('------: loadedmetadata', this.hasStart);
       if (this.hasStart) { // 防止loadedmetadata事件第二次触发
         return
       }
-      console.log('------: loadedmetadata');
 			var polyvPlayerContext = this.selectComponent("#playerVideo");
 			this.hasStart = true;
 			uni.$off('playPause')