fix(courseDetail): 修复视频结束时的节流问题和代码格式

添加last30sTimer和nextSection节流变量防止重复调用接口
调整代码缩进格式保持一致性
This commit is contained in:
yindongqi 2025-07-09 17:55:00 +08:00
parent 14b0afc1df
commit 912e401285

View File

@ -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("211111111111111111");
_this.last30sTimer = false;
for (let index = 0; index < 3; index++) {
_this.onPlayerEnded();
}
setTimeout(() => {
_this.last30sTimer = true;
}, 10000);
}
}
}
function plays() {
@ -450,6 +468,7 @@ export default {
);
},
onPlayerEnded() {
if (this.section[this.choose_section_index].is_end != 1) {
this.getData("/Home/saveRecord", {
token: getStore("token"),
id: this.choose_section_id,
@ -468,6 +487,8 @@ export default {
// 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;
@ -475,6 +496,11 @@ export default {
// console.log("");
this.changeSection(id);
Toast("正在为您跳入下一节课");
setTimeout(() => {
this.nextSection = true;
}, 5000);
}
}
} else {
Toast(data.msg);
@ -482,6 +508,7 @@ export default {
},
(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;