fix(courseDetail): 修复视频结束时的节流问题和代码格式
添加last30sTimer和nextSection节流变量防止重复调用接口 调整代码缩进格式保持一致性
This commit is contained in:
parent
14b0afc1df
commit
912e401285
@ -80,7 +80,7 @@
|
|||||||
<div class="lianxiTiMu" v-for="(item, index) in current_question_data.content" :key="index"
|
<div class="lianxiTiMu" v-for="(item, index) in current_question_data.content" :key="index"
|
||||||
@click="responseQ(item)">
|
@click="responseQ(item)">
|
||||||
<span class="lianxiXueZe" v-bind:class="{ active: current_question_data.response == item }">{{ xuhao[index]
|
<span class="lianxiXueZe" v-bind:class="{ active: current_question_data.response == item }">{{ xuhao[index]
|
||||||
}}</span>
|
}}</span>
|
||||||
<span class="lianxiXueZe1">{{ item }}</span>
|
<span class="lianxiXueZe1">{{ item }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="lianxiTiMu cuoti" v-if="current_question_data.is_wrong == 1">
|
<div class="lianxiTiMu cuoti" v-if="current_question_data.is_wrong == 1">
|
||||||
@ -97,7 +97,7 @@
|
|||||||
<div class="lianxiTiMu" v-for="(item, index) in current_question_data.content" :key="index"
|
<div class="lianxiTiMu" v-for="(item, index) in current_question_data.content" :key="index"
|
||||||
@click="responseQ(item)">
|
@click="responseQ(item)">
|
||||||
<span class="lianxiXueZe" v-bind:class="{ active: current_question_data.response == item }">{{ xuhao[index]
|
<span class="lianxiXueZe" v-bind:class="{ active: current_question_data.response == item }">{{ xuhao[index]
|
||||||
}}</span>
|
}}</span>
|
||||||
<span class="lianxiXueZe1">{{ item }}</span>
|
<span class="lianxiXueZe1">{{ item }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="lianxiTiMu cuoti" v-if="current_question_data.is_wrong == 1">
|
<div class="lianxiTiMu cuoti" v-if="current_question_data.is_wrong == 1">
|
||||||
@ -151,7 +151,7 @@
|
|||||||
<div class="lianxiBottomR" @click="popupVisible = true">
|
<div class="lianxiBottomR" @click="popupVisible = true">
|
||||||
<img src="../../../static/img/gengduo.png" alt="" /><span>{{
|
<img src="../../../static/img/gengduo.png" alt="" /><span>{{
|
||||||
current_question + 1
|
current_question + 1
|
||||||
}}</span>/{{ questions.length }}
|
}}</span>/{{ questions.length }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -222,6 +222,8 @@ export default {
|
|||||||
allSubmitCount: 2, //允许拍照次数
|
allSubmitCount: 2, //允许拍照次数
|
||||||
canTakePhoto: true, //节流
|
canTakePhoto: true, //节流
|
||||||
canTips: true, //节流
|
canTips: true, //节流
|
||||||
|
last30sTimer: true, // 最后两秒多次调用结束视频接口,节流
|
||||||
|
nextSection: true, // 下一课节流
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() { },
|
created() { },
|
||||||
@ -405,6 +407,22 @@ export default {
|
|||||||
}, 300000);
|
}, 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() {
|
function plays() {
|
||||||
@ -450,38 +468,47 @@ export default {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
onPlayerEnded() {
|
onPlayerEnded() {
|
||||||
this.getData("/Home/saveRecord", {
|
if (this.section[this.choose_section_index].is_end != 1) {
|
||||||
token: getStore("token"),
|
this.getData("/Home/saveRecord", {
|
||||||
id: this.choose_section_id,
|
token: getStore("token"),
|
||||||
record: '',
|
id: this.choose_section_id,
|
||||||
is_end: 1,
|
record: '',
|
||||||
}).then(
|
is_end: 1,
|
||||||
(data) => {
|
}).then(
|
||||||
if (data.code == 1) {
|
(data) => {
|
||||||
if (this.choose_section_index >= this.section.length - 1) {
|
if (data.code == 1) {
|
||||||
this.section[this.choose_section_index].is_end = 1;
|
if (this.choose_section_index >= this.section.length - 1) {
|
||||||
Toast("此视频已看完");
|
this.section[this.choose_section_index].is_end = 1;
|
||||||
location.reload();
|
Toast("此视频已看完");
|
||||||
// MessageBox.confirm('此视频已看完').then(action => {
|
location.reload();
|
||||||
// this.toggleTabs(3)
|
// MessageBox.confirm('此视频已看完').then(action => {
|
||||||
// }, () => {});
|
// this.toggleTabs(3)
|
||||||
// Toast('已是最后一课');
|
// }, () => {});
|
||||||
return;
|
// 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 {
|
} else {
|
||||||
let id = this.section[this.choose_section_index + 1]["id"];
|
Toast(data.msg);
|
||||||
// 直接通过id改变课程状态为“已学完”
|
|
||||||
this.section[this.choose_section_index].is_end = 1;
|
|
||||||
// location.reload();
|
|
||||||
// console.log("已刷新页面");
|
|
||||||
this.changeSection(id);
|
|
||||||
Toast("正在为您跳入下一节课");
|
|
||||||
}
|
}
|
||||||
} else {
|
},
|
||||||
Toast(data.msg);
|
(err) => { }
|
||||||
}
|
);
|
||||||
},
|
}
|
||||||
(err) => { }
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
tk(daan) {
|
tk(daan) {
|
||||||
let _this = this;
|
let _this = this;
|
||||||
@ -1093,6 +1120,7 @@ export default {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.computer-take-photo {
|
.computer-take-photo {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user