谢杰标 2 年 前
コミット
02e12b87ca
2 ファイル変更44 行追加38 行削除
  1. 7 12
      components/myPlayer/polyvPlayer.vue
  2. 37 26
      pages3/polyv/detail.vue

+ 7 - 12
components/myPlayer/polyvPlayer.vue

@@ -99,12 +99,6 @@ export default {
     if (this.vid) {
       this.changeVid(this.vid);
     }
-    // if (this.vct > 0) {
-    //   this.videoToastShow = true;
-    //   setTimeout(() => {
-    //     this.closeToast();
-    //   }, 3000);
-    // }
   },
   methods: {
     loadPlayerScript(callback) {
@@ -162,7 +156,6 @@ export default {
       this.$emit(state);
     },
     playing() {
-      console.log(polyvPlayerContext, "polyvPlayerContext");
       // #ifdef MP-WEIXIN
       polyvPlayerContext.seek(this.videoCurrentTime || 0);
       // #endif
@@ -214,11 +207,11 @@ export default {
     },
     onVideoSeek(start, end, vid) {
       polyvPlayerContext.toggleFullscreen();
-      if (this.allowSeek !== "on") {
+      if (this.allowSeek == "off") {
         return;
       }
       if (end - start > 10) {
-        polyvPlayerContext.j2s_seekVideo(start);
+        this.seekVideo(start);
       }
     },
     seekVideo(time) {
@@ -374,10 +367,12 @@ export default {
     vct: {
       handler(time) {
         if (time > 0 && !this.videoToastShow) {
-          this.videoToastShow = true;
           setTimeout(() => {
-            this.closeToast();
-          }, 3000);
+            this.videoToastShow = true;
+            setTimeout(() => {
+              this.closeToast();
+            }, 3000);
+          }, 8000);
         }
       },
       immediate: true,

+ 37 - 26
pages3/polyv/detail.vue

@@ -307,7 +307,6 @@ export default {
     return {
       markContent: "http://admin.zhujianpeixun.com/",
       showMark: false,
-      hasStart: false,
       lockTimer: null,
       orderGoodsId: 0,
       noticeShow: false,
@@ -318,7 +317,7 @@ export default {
       vid: "",
       goodsId: 0,
       goodsData: {},
-      photoPopup: false,
+      showCamera: false,
       goodsPlayConfig: null,
       autoplay: false,
       isAllowSeek: "no",
@@ -367,12 +366,13 @@ export default {
       jjShiGongYuan: false,
       pauseTime: 0,
       pauseTimer: null,
-      barTimer: null,
       isReach: false,
       noticeShow1: false,
       refPlv: null,
-      isCache: true,
+      isCache: false,
       isHaverebuild: false,
+      isPlaying: false,
+      beforeHideIsPlaying: false,
     };
   },
   computed: {
@@ -440,7 +440,6 @@ export default {
     this.courseId = Number(id) || "";
     this.goodsId = Number(goodsId);
     this.gradeId = Number(gradeId);
-    this.isCache = false;
     if (skipPort) {
       await this.$method.skipLogin(skipPort);
     }
@@ -449,10 +448,11 @@ export default {
     }
     // 公众号模板消息的数据埋点
     informId && this.clickOfficial(informId);
-    await this.init();
+    this.init();
   },
   async onShow() {
     if (this.isCache) {
+      this.isCache = false;
       // #ifdef H5
       location.reload();
       // #endif
@@ -460,6 +460,14 @@ export default {
       this.init();
       // #endif
     }
+    if (this.beforeHideIsPlaying) {
+      console.log("🚀 ~ file: detail.vue:464 ~ onShow ~ beforeHideIsPlaying:", this.beforeHideIsPlaying)
+      // 二建二造提示弹出来
+      if (this.playSecIsLearn && this.erJianErZao && this.pauseTimer == null) {
+        return;
+      }
+      this.refPlv.resumeVideo();
+    }
   },
   onUnload() {
     console.log("onUnloadonUnloadonUnloadonUnload");
@@ -467,16 +475,16 @@ export default {
     clearInterval(this.lockTimer);
   },
   onHide() {
-    setTimeout(() => {
-      this.isCache = true;
-    }, 2000);
+    this.beforeHideIsPlaying = this.isPlaying;
+    if (this.isPlaying) {
+      this.refPlv.playPause();
+    }
     this.originUnload();
   },
   mounted() {},
   methods: {
     ...mapMutations(["updateChapterOpen", "updateLiveLast"]),
     async init() {
-      this.isCache = false;
       // #ifdef MP-WEIXIN
       this.isAllowSeek = "no";
       // #endif
@@ -486,8 +494,15 @@ export default {
       // 锁
       lockAction();
       this.lockTimer = setInterval(lockAction, 10000);
-      await this.isCanLearn();
-      this.courseCourseList();
+      this.isCanLearn()
+        .then((res) => {
+          this.courseCourseList();
+        })
+        .catch(() => {
+          setTimeout(() => {
+            this.isCache = true; // onshowc重新触发校验
+          }, 2000);
+        });
     },
     // 七大员是否能进入学习
     async qCheckIsCanLearn() {
@@ -666,8 +681,11 @@ export default {
           console.log("暂停时间", Date.now() - this.pauseTime, this.pauseTime);
           if (Date.now() - this.pauseTime > 5 * 60 * 1000) {
             // 5 * 60 * 1000
-            let text = this.photoPopup ? "拍照停留" : "暂停";
-            this.photoPopup = false;
+            let text = "暂停";
+            if (this.showCamera) {
+              text = "拍照停留";
+              this.refPlv.closeCamera();
+            }
             uni.showModal({
               title: "提示",
               showCancel: false,
@@ -712,7 +730,6 @@ export default {
         this.postStudyRecord(0);
         //清除直播
         this.studyTimer && clearInterval(this.studyTimer);
-        this.hasStart = false;
         this.photoConfig = false;
         this.moduleId = item.moduleId || null;
         this.chapterId = item.chapterId || null;
@@ -730,15 +747,9 @@ export default {
         this.pauseTimer = null;
       }
     },
-    clearBarTimer() {
-      if (this.barTimer) {
-        clearInterval(this.barTimer);
-        this.barTimer = null;
-      }
-    },
     // 原来onUnload里面的内容
     originUnload() {
-      if (this.sectionId > 0 && this.hasStart) {
+      if (this.sectionId > 0 && this.isPlaying) {
         //退出提交记录
         this.postStudyRecord();
       }
@@ -752,10 +763,8 @@ export default {
 
       if (this.studyTimer) {
         clearInterval(this.studyTimer);
-        this.hasStart = false;
       }
       this.clearPauseTimer();
-      this.clearBarTimer();
       if (this.lockTimer) {
         clearInterval(this.lockTimer);
         this.$api
@@ -1487,6 +1496,7 @@ export default {
     },
     playing() {
       console.log("playing");
+      this.isPlaying = true;
       this.studyLog();
       if (!this.recordObj.videoCurrentTime) {
         this.postStudyRecord(0);
@@ -1497,17 +1507,19 @@ export default {
       }, 15000);
     },
     openCamera() {
+      this.showCamera = true;
       this.$refs["camera"].openCamera();
       this.refPlv.playPause();
       this.refPlv.exitFullScreen();
     },
     pause() {
+      this.isPlaying = false;
       this.erJianErZaoPauseTip();
       clearInterval(this.studyTimer);
     },
     async ended() {
       console.log("🚀 ~ file: detail.vue:1519 ~ ended ~ ended:", "结束");
-      this.hasStart = false;
+      this.isPlaying = false;
       uni.showToast({
         icon: "none",
         title: "播放完毕",
@@ -1585,7 +1597,6 @@ export default {
                 this.$store.commit("setPlaySectionId", {
                   playSectionId: data.sectionId,
                 });
-                this.hasStart = false;
                 this.photoConfig = false;
                 this.sectionItem = data;
                 this.playVideo(data);