From 912e4012856db01c9d69316beec8859d8caa0107 Mon Sep 17 00:00:00 2001 From: yindongqi Date: Wed, 9 Jul 2025 17:55:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(courseDetail):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E7=BB=93=E6=9D=9F=E6=97=B6=E7=9A=84=E8=8A=82?= =?UTF-8?q?=E6=B5=81=E9=97=AE=E9=A2=98=E5=92=8C=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加last30sTimer和nextSection节流变量防止重复调用接口 调整代码缩进格式保持一致性 --- src/components/study/courseDetail.vue | 94 +++++++++++++++++---------- 1 file changed, 61 insertions(+), 33 deletions(-) diff --git a/src/components/study/courseDetail.vue b/src/components/study/courseDetail.vue index 9543fbb..0e1e340 100644 --- a/src/components/study/courseDetail.vue +++ b/src/components/study/courseDetail.vue @@ -80,7 +80,7 @@
{{ xuhao[index] - }} + }} {{ item }}
@@ -97,7 +97,7 @@
{{ xuhao[index] - }} + }} {{ item }}
@@ -151,7 +151,7 @@
{{ current_question + 1 - }}/{{ questions.length }} + }}/{{ questions.length }}
@@ -222,6 +222,8 @@ export default { allSubmitCount: 2, //允许拍照次数 canTakePhoto: true, //节流 canTips: true, //节流 + last30sTimer: true, // 最后两秒多次调用结束视频接口,节流 + nextSection: true, // 下一课节流 }; }, created() { }, @@ -405,6 +407,22 @@ export default { }, 300000); } } + + //最后2s调用结束接口 + // 获取视频总时长 + let duration = document.getElementById("video").duration; + if (curTime >= (duration - 2)) { + if (_this.last30sTimer && _this.section[_this.choose_section_index].is_end != 1) { + // console.log("最后2秒我运行了11111111111111111"); + _this.last30sTimer = false; + for (let index = 0; index < 3; index++) { + _this.onPlayerEnded(); + } + setTimeout(() => { + _this.last30sTimer = true; + }, 10000); + } + } } function plays() { @@ -450,38 +468,47 @@ export default { ); }, onPlayerEnded() { - this.getData("/Home/saveRecord", { - token: getStore("token"), - id: this.choose_section_id, - record: '', - is_end: 1, - }).then( - (data) => { - if (data.code == 1) { - if (this.choose_section_index >= this.section.length - 1) { - this.section[this.choose_section_index].is_end = 1; - Toast("此视频已看完"); - location.reload(); - // MessageBox.confirm('此视频已看完').then(action => { - // this.toggleTabs(3) - // }, () => {}); - // Toast('已是最后一课'); - return; + if (this.section[this.choose_section_index].is_end != 1) { + this.getData("/Home/saveRecord", { + token: getStore("token"), + id: this.choose_section_id, + record: '', + is_end: 1, + }).then( + (data) => { + if (data.code == 1) { + if (this.choose_section_index >= this.section.length - 1) { + this.section[this.choose_section_index].is_end = 1; + Toast("此视频已看完"); + location.reload(); + // MessageBox.confirm('此视频已看完').then(action => { + // this.toggleTabs(3) + // }, () => {}); + // Toast('已是最后一课'); + return; + } else { + if (this.nextSection) { + this.nextSection = false; + let id = this.section[this.choose_section_index + 1]["id"]; + // 直接通过id改变课程状态为“已学完” + this.section[this.choose_section_index].is_end = 1; + // location.reload(); + // console.log("已刷新页面"); + this.changeSection(id); + Toast("正在为您跳入下一节课"); + + setTimeout(() => { + this.nextSection = true; + }, 5000); + } + } } else { - let id = this.section[this.choose_section_index + 1]["id"]; - // 直接通过id改变课程状态为“已学完” - this.section[this.choose_section_index].is_end = 1; - // location.reload(); - // console.log("已刷新页面"); - this.changeSection(id); - Toast("正在为您跳入下一节课"); + Toast(data.msg); } - } else { - Toast(data.msg); - } - }, - (err) => { } - ); + }, + (err) => { } + ); + } }, tk(daan) { let _this = this; @@ -1093,6 +1120,7 @@ export default { justify-content: center; align-items: center; } + .computer-take-photo { padding: 10px; border-radius: 10px;