Ver Fonte

15分钟提醒一次

y595705120 há 3 meses atrás
pai
commit
c8ca830a85

+ 1 - 1
config/index.js

@@ -4,7 +4,7 @@
 //
 // const TARGET = "http://study.ndjsxh.cn:8888/"
 // const TARGET = "http://localhost:8000/"
-const TARGET = "http://jjxh.hqedust.com/"
+const TARGET = "http://edu.jjxh.hqedust.com:8888"
 const path = require('path')
 
 module.exports = {

+ 17 - 21
src/containers/center/play/components/media.vue

@@ -30,6 +30,7 @@
         tickNum: 0,
         prevTime:0,
         isReady:false,
+        onblurTime: 0,
         onPlay: false
       }
     },
@@ -44,24 +45,7 @@
         }
       }
     },
-    props: {
-      media:{
-        type: Object,
-        default: ()=>{
-          return {id: '', percent:0}
-        }
-      },
-      dialog:{
-        type: Boolean,
-        default: true
-      },
-      options: {
-        type: Object,
-        default: () => {
-          return {}
-        }
-      }
-    },
+    props: ['media', 'dialog', 'options'],
     beforeDestroy() {
       if (this.timer) {
         clearInterval(this.timer); //关闭
@@ -74,7 +58,7 @@
     },
     created() {
       this.timer = setInterval(this.tick, 5 * 1000);
-      // this.startMonitor();
+      this.startMonitor();
     },
     methods: {
       playerReadied(player) {
@@ -123,6 +107,7 @@
         this.onPlay = false
       },
       doPlay(){
+        this.updateBlurtime()
         if( !this.$refs.videoPlayer || !this.$refs.videoPlayer.player ) return;
         if( !this.dialog ) return this.doPause();
         let myPlayer = this.$refs.videoPlayer.player;
@@ -133,13 +118,18 @@
       onPlayerStart() {
         this.onPlay = true
       },
+      updateBlurtime(){
+         this.onblurTime = Date.now() + 15*60 * 1000
+      },
       startMonitor() {
         let that = this
         window.onblur = function() {
-          that.doPause()
+          that.updateBlurtime()
+          // that.doPause()
         }
         window.onfocus = function () {
-          that.doPlay()
+          that.updateBlurtime()
+          // that.doPlay()
         }
       },
       tickWait(){
@@ -164,9 +154,15 @@
       tick( force = false) {
         let media = this.media;
         this.tickNum ++
+        console.log("tick", this.onblurTime )
+        if( this.onblurTime < Date.now() ){
+          this.tickWait();
+          return
+        }
         // 已经完成
         if( this.media.isFinish )  return;
 
+
         // 主动暂停
         let myPlayer = this.$refs.videoPlayer.player;
         let curTimes = parseInt(myPlayer.currentTime());

+ 1 - 1
src/containers/center/play/index.vue

@@ -110,7 +110,7 @@
     <el-dialog class="fc tc media-dialog" :visible.sync="mediaDialog" append-to-body top="50px" :title="media.name"
       :close-on-click-modal="false" width="640px">
 
-      <Media :options="options" :dialog="mediaDialog" :media="media" :duration="info.duration" @close="mediaDialog=false"
+      <Media :options="options" :dialog="mediaDialog" :media="media" :course="info"  @close="mediaDialog=false"
         @update="update">
       </Media>
       <span slot="footer" class="dialog-footer mt5">