소스 검색

修改时长计算

lex 2 년 전
부모
커밋
5e321715d1
1개의 변경된 파일9개의 추가작업 그리고 3개의 파일을 삭제
  1. 9 3
      src/student/pre-register-active/video.tsx

+ 9 - 3
src/student/pre-register-active/video.tsx

@@ -214,7 +214,7 @@ export default defineComponent({
         if (tempTime.length >= 2) {
           // console.log(tempTime, 'tempTime', moreTime.value)
           // 处理在短时间内的时间差 【视屏拖动,点击可能会导致时间差太大】
-          const diffTime = tempTime[1] - tempTime[0] - currentTimer.counter.value > 5
+          const diffTime = tempTime[1] - tempTime[0] - currentTimer.counter.value > 2
           // 结束时间,如果 大于开始时间则清除
           if (tempTime[1] >= tempTime[0] && !diffTime) moreTime.value.push(tempTime)
           tempTime = []
@@ -229,8 +229,14 @@ export default defineComponent({
     const updateStat = async (pageBrowseTime = 10) => {
       try {
         const videoBrowseData = moreTime.value.length > 0 ? formatEffectiveTime(moreTime.value) : []
-        const time = moreTime.value.length > 0 ? formatTimer(moreTime.value) : 0
-        const rate = Math.floor((time / Math.floor(forms.player.duration)) * 100)
+        let time = moreTime.value.length > 0 ? formatTimer(moreTime.value) : 0
+        const videoCountTime = videoIntervalRef?.counter.value
+        const videoDuration = forms.player.duration
+        // 判断如何视屏播放时间大于视屏播放有效时间则说明数据有问题,进行重置数据
+        if (time > videoCountTime && time < videoDuration) {
+          time = videoDuration
+        }
+        const rate = Math.floor((time / Math.floor(videoDuration)) * 100)
 
         await request.post('/api-student/open/studentBrowseRecord/updateStat', {
           data: {