Commit 14cec8da authored by 李维's avatar 李维

修复最后一题跳转错误的问题

parent 0503c238
...@@ -1687,6 +1687,8 @@ ...@@ -1687,6 +1687,8 @@
"__id__": 15 "__id__": 15
}, },
"_enabled": true, "_enabled": true,
"setTimeoutIDs": [],
"setIntervalIDs": [],
"_id": "42XWQfk9tE94NY0efe9K5z" "_id": "42XWQfk9tE94NY0efe9K5z"
}, },
{ {
......
...@@ -448,10 +448,8 @@ cc.Class({ ...@@ -448,10 +448,8 @@ cc.Class({
console.log("preloadArr: ", JSON.stringify(preloadArr)); console.log("preloadArr: ", JSON.stringify(preloadArr));
cc.assetManager.loadAny(preloadArr, null, null, (err, data) => { cc.assetManager.loadAny(preloadArr, null, null, (err, data) => {
// console.log(' preload data, ', data); // console.log(' preload data, ', data);
// this.loadEnd(); // this.loadEnd();
this.addServerListener(); this.addServerListener();
if (window && window["air"]) { if (window && window["air"]) {
window["air"].hideAirClassLoading(); window["air"].hideAirClassLoading();
} }
...@@ -550,10 +548,8 @@ cc.Class({ ...@@ -550,10 +548,8 @@ cc.Class({
// return; // return;
console.log(" in getState 1"); console.log(" in getState 1");
callMiddleLayerFunction("PSQS_get_course_info", {}, (data) => { callMiddleLayerFunction("PSQS_get_course_info", {}, (data) => {
console.log("PSQS_get_course_info",data.first, data.last, data.playTime, JSON.stringify(data.saveData)); console.log("PSQS_get_course_info",data.first, data.last, data.playTime, JSON.stringify(data.saveData));
this.isFirst = data.first; //this.checkIsFirst(); this.isFirst = data.first; //this.checkIsFirst();
this.isLast = data.last // this.checkIsLast(); this.isLast = data.last // this.checkIsLast();
this.playTimes = data.playTime// this.checkPlayTimes(); this.playTimes = data.playTime// this.checkPlayTimes();
...@@ -585,7 +581,7 @@ cc.Class({ ...@@ -585,7 +581,7 @@ cc.Class({
}, },
getJumpData() { getJumpData() {
return {step: 1}; return {step: 7};
}, },
maskSpr: null, maskSpr: null,
...@@ -655,11 +651,11 @@ cc.Class({ ...@@ -655,11 +651,11 @@ cc.Class({
resetQuesIndex(jumpTime) { resetQuesIndex(jumpTime) {
this.quesIndex = -1; this.quesIndex = -1;
for (let i = 0; i < this.data.quesArr.length; i++) { for (let i = 0; i < this.data.quesArr.length; i++) {
const startTime = this.data.quesArr[i].ques_start; const startTime = this.data.quesArr[i].ques_start;
const endTime = this.data.quesArr[i].ques_end; const endTime = this.data.quesArr[i].ques_end;
if (Number(jumpTime) >= Number(startTime) && Number(jumpTime) < Number(endTime)) { if (Number(jumpTime) >= Number(startTime) && Number(jumpTime) < Number(endTime)) {
this.quesIndex = i; this.quesIndex = i;
// console.log("重定位题号:",this.quesIndex) // console.log("重定位题号:",this.quesIndex)
} }
} }
}, },
...@@ -694,9 +690,8 @@ cc.Class({ ...@@ -694,9 +690,8 @@ cc.Class({
addServerListener() { addServerListener() {
console.log(" in addServerListener"); console.log(" in addServerListener");
const c = window.courseware;
// this.loadEnd(()=>{}); // this.loadEnd(()=>{});
const c = window.courseware;
if (!c) { if (!c) {
return; return;
} }
...@@ -940,7 +935,7 @@ cc.Class({ ...@@ -940,7 +935,7 @@ cc.Class({
this.hideMask(); this.hideMask();
this.video.pause(); this.video.pause();
this.videoControlBar.emit("update_video_status", 0); this.videoControlBar.emit("update_video_status", 0);
this.wrongTimes++; this.wrongTimes++;
...@@ -1033,13 +1028,13 @@ cc.Class({ ...@@ -1033,13 +1028,13 @@ cc.Class({
}, },
getCurrentQuesIndexByTime(curretnTime) { getCurrentQuesIndexByTime(curretnTime) {
let qIndex = -1; let qIndex = -1;
for(let i=0; i<this.data.quesArr.length; i++) { for(let i=0; i<this.data.quesArr.length; i++) {
if(curretnTime>=Number(this.data.quesArr[i].ques_end)) { if(curretnTime>=Number(this.data.quesArr[i].ques_end)) {
qIndex = i; qIndex = i;
} }
} }
return qIndex; return qIndex;
}, },
checkNextQues() { checkNextQues() {
...@@ -1053,7 +1048,7 @@ cc.Class({ ...@@ -1053,7 +1048,7 @@ cc.Class({
}, },
startQuesVideo(currentTime = null) { startQuesVideo(currentTime = null) {
console.log(" in startQuesVideo"); console.log("in startQuesVideo", currentTime);
this.wrongTimes = 0; this.wrongTimes = 0;
const video = this.video; const video = this.video;
...@@ -1073,16 +1068,21 @@ cc.Class({ ...@@ -1073,16 +1068,21 @@ cc.Class({
} }
} }
// 如果是最后一题
if(this.isTheEndVideo) {
this.curEndTime = -1;
}
delayCall(0.01, () => { delayCall(0.01, () => {
video.play(); video.play();
this.videoControlBar.emit("update_video_status", 1); this.videoControlBar.emit("update_video_status", 1);
}); });
}, },
isWaitingUserAction: false, isWaitingUserAction: false,
startWaitVideo() { startWaitVideo() {
console.log(" in startWaitVideo "); console.log("in startWaitVideo");
this.isWaitingUserAction = true; this.isWaitingUserAction = true;
this.curQues.hotZoneBg.active = true; this.curQues.hotZoneBg.active = true;
this.hand.active = true; this.hand.active = true;
...@@ -1118,8 +1118,8 @@ cc.Class({ ...@@ -1118,8 +1118,8 @@ cc.Class({
}, },
hideWaitingVideo() { hideWaitingVideo() {
console.log(" in hiddeWaitVideo "); console.log(" in hiddeWaitVideo ");
this.isWaitingUserAction = false; this.isWaitingUserAction = false;
this.curQues.hotZoneBg.active = false; this.curQues.hotZoneBg.active = false;
this.hand.active = false; this.hand.active = false;
}, },
...@@ -1137,7 +1137,7 @@ cc.Class({ ...@@ -1137,7 +1137,7 @@ cc.Class({
}, },
startRightVideo() { startRightVideo() {
console.log(" in startRightVideo "); console.log("in startRightVideo");
// const videoNode = this.curQues?.videoObj?.right_video; // const videoNode = this.curQues?.videoObj?.right_video;
// const video = videoNode.getComponent(cc.VideoPlayer); // const video = videoNode.getComponent(cc.VideoPlayer);
...@@ -1159,7 +1159,7 @@ cc.Class({ ...@@ -1159,7 +1159,7 @@ cc.Class({
}, },
startWrongVideo() { startWrongVideo() {
console.log(" in startWrongVideo "); console.log("in startWrongVideo");
// const videoNode = this.curQues?.videoObj?.wrong_video; // const videoNode = this.curQues?.videoObj?.wrong_video;
// const video = videoNode.getComponent(cc.VideoPlayer); // const video = videoNode.getComponent(cc.VideoPlayer);
...@@ -1187,7 +1187,7 @@ cc.Class({ ...@@ -1187,7 +1187,7 @@ cc.Class({
}, },
startEndVideo() { startEndVideo() {
console.log(" in startEndVideo "); console.log("in startEndVideo");
// const videoNode = this.curQues?.videoObj?.end_video; // const videoNode = this.curQues?.videoObj?.end_video;
// const video = videoNode.getComponent(cc.VideoPlayer); // const video = videoNode.getComponent(cc.VideoPlayer);
...@@ -1225,12 +1225,13 @@ cc.Class({ ...@@ -1225,12 +1225,13 @@ cc.Class({
}, },
initCurQues() { initCurQues() {
if(this.quesIndex >=0) { if(this.quesIndex >= 0) {
this.curQues = this.data.quesArr[this.quesIndex]; this.curQues = this.data.quesArr[this.quesIndex];
console.log("curQues: ", this.curQues); console.log("curQues: ", this.curQues);
} else { } else {
console.log('题目序号不能为负数'); this.curQues = this.data.quesArr[this.data.quesArr.length-1];
} console.log('题目序号为负 - 跳转到最后一段音频');
}
}, },
videoDuration: null, videoDuration: null,
...@@ -1363,6 +1364,7 @@ cc.Class({ ...@@ -1363,6 +1364,7 @@ cc.Class({
this.startQuesVideo(this.jumpTime); this.startQuesVideo(this.jumpTime);
}, },
isTheEndVideo: false,
setJumpTime() { setJumpTime() {
let isFind = false; let isFind = false;
for (let i = 0; i < this.data.quesArr.length; i++) { for (let i = 0; i < this.data.quesArr.length; i++) {
...@@ -1377,8 +1379,10 @@ cc.Class({ ...@@ -1377,8 +1379,10 @@ cc.Class({
} }
if (!isFind) { if (!isFind) {
// 没有找到就是最后一题
const lastQuesData = this.data.quesArr[this.data.quesArr.length - 1]; const lastQuesData = this.data.quesArr[this.data.quesArr.length - 1];
this.jumpTime = lastQuesData.ques_end; this.jumpTime = lastQuesData.ques_end;
this.isTheEndVideo = true;
} }
}, },
...@@ -1386,7 +1390,6 @@ cc.Class({ ...@@ -1386,7 +1390,6 @@ cc.Class({
if (this.playTimes == 0) { if (this.playTimes == 0) {
return; return;
} }
switch (this.video.node.name) { switch (this.video.node.name) {
case "ques_video": case "ques_video":
this.startWaitVideo(); this.startWaitVideo();
...@@ -1470,18 +1473,18 @@ cc.Class({ ...@@ -1470,18 +1473,18 @@ cc.Class({
}, },
updateCheckStop() { updateCheckStop() {
// console.log("检查停止时间", this.curEndTime); // console.log("检查停止时间", this.curEndTime);
if (!this.video || this.curEndTime == -1) { if (!this.video || this.curEndTime == -1) {
return; return;
} }
if (this.video.currentTime >= this.curEndTime) { if (this.video.currentTime >= this.curEndTime) {
this.video.pause(); this.video.pause();
this.videoControlBar.emit("update_video_status", 0); this.videoControlBar.emit("update_video_status", 0);
this.video.currentTime = this.curEndTime; this.video.currentTime = this.curEndTime;
this.curEndTime = -1; this.curEndTime = -1;
this.curVideoPlayEnd(); this.curVideoPlayEnd();
// this.videoControlBar.active = false; // this.videoControlBar.active = false;
} }
}, },
...@@ -1490,31 +1493,31 @@ cc.Class({ ...@@ -1490,31 +1493,31 @@ cc.Class({
return; return;
} }
// 更新当前进度条 // 更新当前进度条
if(this.videoDuration== null) { if(this.videoDuration== null) {
this.videoControlBar.emit("update_video_progress", 0) this.videoControlBar.emit("update_video_progress", 0)
} else { } else {
this.videoControlBar.emit("update_video_progress", this.video.currentTime / this.videoDuration) this.videoControlBar.emit("update_video_progress", this.video.currentTime / this.videoDuration)
} }
// 如果没有正在拖动中 检查是否为题目停止 // 如果没有正在拖动中 检查是否为题目停止
if(!this.isDragProgressBar) { if(!this.isDragProgressBar) {
this.updateCheckStop(); this.updateCheckStop();
} }
}, },
// 重置题目相关数据 - 在用户拖动进度条完成以后 // 重置题目相关数据 - 在用户拖动进度条完成以后
restQuesData(curretnTime) { restQuesData(curretnTime) {
let userDragTime = curretnTime; let userDragTime = curretnTime;
this.resetQuesIndex(userDragTime); this.resetQuesIndex(userDragTime);
this.initCurQues(); this.initCurQues();
if(this.quesIndex >= 0) { if(this.quesIndex >= 0) {
this.curEndTime = Number(this.curQues.ques_end); this.curEndTime = Number(this.curQues.ques_end);
} else { } else {
// 如果没有找到题目索引 则把当前截止时间设置为无穷大 // 如果没有找到题目索引 则把当前截止时间设置为无穷大
this.curEndTime = -1; this.curEndTime = -1;
} }
this.video.currentTime = userDragTime; this.video.currentTime = userDragTime;
}, },
// 是否正在拖动进度条 // 是否正在拖动进度条
...@@ -2924,8 +2927,7 @@ cc.Class({ ...@@ -2924,8 +2927,7 @@ cc.Class({
console.log("clicked"); console.log("clicked");
this.video.pause(); this.video.pause();
this.videoControlBar.emit("update_video_status", 0); this.videoControlBar.emit("update_video_status", 0);
this.curQues.isRight = isRight; this.curQues.isRight = isRight;
if (isRight) { if (isRight) {
this.startRightVideo(); this.startRightVideo();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment