caichengyu hai 2 meses
pai
achega
efa2058829
Modificáronse 3 ficheiros con 95 adicións e 40 borrados
  1. 7 0
      src/apis/course.js
  2. 86 38
      src/components/videoCy/index.vue
  3. 2 2
      src/pages/course-detail/index.vue

+ 7 - 0
src/apis/course.js

@@ -502,4 +502,11 @@ export default {
 			data: data
 		})
 	},
+	//获取离开是否暂停视频
+	screencheck(data) {
+		return request({
+			url: '/order/screen/check/'+data,
+			method: 'get'
+		})
+	},
 }

+ 86 - 38
src/components/videoCy/index.vue

@@ -18,7 +18,11 @@
       ref="takePicture"
       @returnParameter="returnParameter"
     ></takePicture>
-    <count-down ref="countDown" @againSubmit="postStudyRecord(1)" @resetSection="resetSection"></count-down>
+    <count-down
+      ref="countDown"
+      @againSubmit="postStudyRecord(1)"
+      @resetSection="resetSection"
+    ></count-down>
     <media ref="media" @returnParameterVideo="returnParameterVideo"></media>
   </div>
 </template>
@@ -61,8 +65,10 @@ export default {
       viewSign: null, //2腾讯视频播放器,其他保利威视播放器
       needtoTakeVideo: false, //是否需要随机录制2秒视频
       timeNeedtoTakeVideo: null, //需要随机录制2秒视频定时器
-      curPlayOver:false,//当前视频已播放完毕
-      picDeviceName:'',//PHOTE
+      curPlayOver: false, //当前视频已播放完毕
+      picDeviceName: "", //PHOTE
+      leaveTips: false,
+      showtipsing: false,
     };
   },
   computed: {
@@ -151,10 +157,51 @@ export default {
           }
         }
       ); //播放器初始化完毕时触发。播放器提供的方法需要在此事件发生后才可以调用。
+      await this.screencheck(); //获取离开是否暂停视频
     });
     // document.addEventListener("visibilitychange", this.pauseVideo);
+
   },
   methods: {
+    handleMouseOut() {
+      // console.log(111, this.leaveTips, this.showtipsing);
+      if (this.leaveTips && !this.showtipsing) {
+        this.showtipsing = true;
+         setTimeout(() => {
+        if (this.viewSign == 2) {
+          this.player_tencent.pause(); //暂停
+        } else {
+          this.player.j2s_pauseVideo(); //暂停
+        }
+      }, 100);
+        this.$confirm(`学习过程中请不要切换页面或其他操作,否则暂停学习!`, "提示", {
+          confirmButtonText: "确定",
+          closeOnClickModal: false,
+          closeOnPressEscape: false,
+          showCancelButton: false,
+          distinguishCancelAndClose: false,
+          showClose: false,
+        })
+          .then((_) => {
+            this.showtipsing = false;
+          })
+          .catch((_) => {});
+      }
+    },
+    screencheck() {
+       return new Promise((resolve) => {
+      // console.log(222,this.goodsData)
+      this.$request.screencheck(this.goodsData.orderGoodsId).then((res) => {
+        if (res.code == 200) {
+          if (res.data) {
+            this.leaveTips = true;
+    window.addEventListener("blur", this.handleMouseOut);
+          }
+        }
+      resolve();
+      }); 
+        });
+    },
     getBeforeWork() {},
     //初始化参数
     initData() {
@@ -164,8 +211,8 @@ export default {
       this.openPhotoStatus = 0;
       this.videoPauseSetTimeStatus = false;
       this.firstPlay = true;
-      this.curPlayOver=false;
-      this.needtoTakeVideo=false;
+      this.curPlayOver = false;
+      this.needtoTakeVideo = false;
       clearTimeout(this.videoPauseSetTimeout); //删除暂停计算拍照定时器
       clearTimeout(this.timeEventStatusTimeout); //删除双重保障定时器
     },
@@ -484,7 +531,7 @@ export default {
             preload: "auto",
             autoplay: autoPlay,
             controlBar: {
-              progressControl:isAllowSeek,
+              progressControl: isAllowSeek,
               playbackRateMenuButton: playbackRate,
             },
             // player-tencent 为播放器容器 ID,必须与 html 中一致
@@ -610,10 +657,9 @@ export default {
           if (this.viewSign == 2) {
             setTimeout(() => {
               this.player_tencent.currentTime(
-              Number(this.activeSection.videoCurrentTime) || 0
-            );
-          }, 2000);
-            
+                Number(this.activeSection.videoCurrentTime) || 0
+              );
+            }, 2000);
           }
           this.showRecordSetTimeOut = setTimeout(() => {
             this.showRecordStatus = false;
@@ -659,7 +705,7 @@ export default {
         type: "success",
         message: "播放完毕",
       });
-      this.curPlayOver=true;//当前视频已播放完毕
+      this.curPlayOver = true; //当前视频已播放完毕
       this.isFullScreen();
       clearTimeout(this.videoPauseSetTimeout); //删除暂停计算拍照定时器
       //如果未录制视频的,需要录制
@@ -669,7 +715,7 @@ export default {
       }
       this.postStudyRecord(1);
       console.log("当前视频播放完毕时触发");
-      this.curPlayOver=false;
+      this.curPlayOver = false;
     },
 
     //判断是全屏则退出全屏
@@ -726,8 +772,8 @@ export default {
       this.HideVideo = true;
     },
     //拍照成功回显 url
-    async returnParameter(url,deviceName) {
-      this.picDeviceName=deviceName;
+    async returnParameter(url, deviceName) {
+      this.picDeviceName = deviceName;
       let file = this.$tools.convertBase64UrlToBlob(url);
       try {
         var photoUrl = await this.$upload.upload(file, 0, {
@@ -892,7 +938,7 @@ export default {
       this.postCourseVideoRecord(videoUrl)
         .then(async (res) => {
           this.needtoTakeVideo = false;
-          if(this.curPlayOver){
+          if (this.curPlayOver) {
             this.onPlayOver();
           }
           //恢复播放
@@ -928,7 +974,7 @@ export default {
             // imageA: url,
             orderGoodsId: this.goodsData.orderGoodsId,
             gradeId: this.goodsData.gradeId,
-            deviceName:this.picDeviceName,
+            deviceName: this.picDeviceName,
           })
           .then((res) => {
             resolve(Number(res.data));
@@ -962,8 +1008,8 @@ export default {
           gradeId: this.goodsData.gradeId,
           orderGoodsId: this.goodsData.orderGoodsId,
           courseId: this.activeSection.courseId,
-          moduleId: this.activeSection.moduleId||0,
-          chapterId: this.activeSection.chapterId||0,
+          moduleId: this.activeSection.moduleId || 0,
+          chapterId: this.activeSection.chapterId || 0,
           sectionId: this.activeSection.sectionId,
           videoUrl: videoUrl,
           videoCurrentTime: parseInt(currentTime > 0 ? currentTime : 0),
@@ -1031,7 +1077,7 @@ export default {
           studyDuration: parseInt(PlayDuration > 0 ? PlayDuration : 0),
           videoCurrentTime: parseInt(currentTime > 0 ? currentTime : 0),
           erJianErZao: this.goodsData.erJianErZao,
-          deviceName:this.picDeviceName,
+          deviceName: this.picDeviceName,
         };
 
         if (imgUrl) {
@@ -1081,8 +1127,11 @@ export default {
                   //停止执行-退出页面
                   this.$router.back(-1);
                 });
-            } 
-            else if (err.code === 557||err.code === 5581||err.code === 5591) {
+            } else if (
+              err.code === 557 ||
+              err.code === 5581 ||
+              err.code === 5591
+            ) {
               if (this.viewSign == 2) {
                 polyvPlayerContext.pause();
               } else {
@@ -1090,8 +1139,7 @@ export default {
               }
               this.abnormal(data);
               this.$refs.countDown.openBoxsRestart(err.code);
-            }
-            else if (err.code === 559) {
+            } else if (err.code === 559) {
               console.log("拍照不够触发");
               this.abnormal(data);
               this.$message.error(err.msg);
@@ -1102,8 +1150,7 @@ export default {
             } else if (err.code === 558) {
               this.abnormal(data);
               this.$refs.countDown.openBoxs(parseInt(err.msg.split(",")[1]));
-            }
-             else if (err.code === 601) {
+            } else if (err.code === 601) {
               this.onPlayerError("提交异常", err.msg);
             } else {
               this.$message.error(err.msg || "未知错误");
@@ -1112,26 +1159,24 @@ export default {
       });
     },
     //异常记录
-    abnormal(data){
+    abnormal(data) {
       this.$request
-          .abnormal(data)
-        .then((res) => {
-          
-        })
+        .abnormal(data)
+        .then((res) => {})
         .catch((err) => {
           console.log(err, "err");
         });
     },
     //重置视频学习
-    resetSection(errcode){
+    resetSection(errcode) {
       let data = {
-          orderGoodsId: parseInt(this.goodsData.orderGoodsId),
-          courseId: this.activeSection.courseId,
-          sectionId: this.activeSection.sectionId,
-          errorCode:errcode
-        };
+        orderGoodsId: parseInt(this.goodsData.orderGoodsId),
+        courseId: this.activeSection.courseId,
+        sectionId: this.activeSection.sectionId,
+        errorCode: errcode,
+      };
       this.$request
-          .resetSection(data)
+        .resetSection(data)
         .then((res) => {
           location.reload();
         })
@@ -1153,7 +1198,7 @@ export default {
             // imageA: url,
             orderGoodsId: this.goodsData.orderGoodsId,
             gradeId: this.goodsData.gradeId,
-            deviceName:this.picDeviceName,
+            deviceName: this.picDeviceName,
           })
           .then((res) => {
             resolve(Number(res.data));
@@ -1196,6 +1241,9 @@ export default {
     },
   },
   beforeDestroy() {
+    if(this.leaveTips){
+      window.removeEventListener('blur', this.handleMouseOut);
+    }
     this.$bus.$off("toPlay");
     clearTimeout(this.videoPauseSetTimeout); //删除暂停计算拍照定时器
     // document.removeEventListener("visibilitychange", this.pauseVideo);

+ 2 - 2
src/pages/course-detail/index.vue

@@ -40,7 +40,7 @@ export default {
   provide() {
     return {
       getGoodsData: () => this.goodsData,
-      getBusinessData: () => this.businessData
+      getBusinessData: () => this.businessData,
     };
   },
   data() {
@@ -49,7 +49,7 @@ export default {
       goodsData: {}, //商品详情
       businessData: {}, //培训项目
       goodsPlayConfig: {}, //播放设置
-      goodsPhotographConfig: {} //拍照设置
+      goodsPhotographConfig: {} ,//拍照设置
     };
   },
   computed: {