mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-11 03:46:44 +08:00
修改正常视频记录时长问题
This commit is contained in:
@@ -386,7 +386,7 @@
|
|||||||
appendHandle: null, //追加学习时长的timeout句柄
|
appendHandle: null, //追加学习时长的timeout句柄
|
||||||
isAppendTime: false, //是否追加学习时长
|
isAppendTime: false, //是否追加学习时长
|
||||||
appentId: '', //当前追加的学习时长的id,此字段已经不再使用
|
appentId: '', //当前追加的学习时长的id,此字段已经不再使用
|
||||||
appentInterval: 5000, //追加学习时间的间隔 5秒加一次
|
appentInterval: 15, //追加学习时间的间隔 5秒加一次
|
||||||
handleTimeout: null,
|
handleTimeout: null,
|
||||||
completed: [],
|
completed: [],
|
||||||
tab: 1,
|
tab: 1,
|
||||||
@@ -1408,7 +1408,7 @@
|
|||||||
apiStat.sendEvent(postData).then(rs=>{
|
apiStat.sendEvent(postData).then(rs=>{
|
||||||
if(rs.status == 200) {
|
if(rs.status == 200) {
|
||||||
// this.appendStartTime = new Date();//重新计时
|
// this.appendStartTime = new Date();//重新计时
|
||||||
studyUtil.clearStudyDuration(); //清除本地存储
|
// studyUtil.clearStudyDuration(); //清除本地存储
|
||||||
} else {
|
} else {
|
||||||
console.log(rs.message);
|
console.log(rs.message);
|
||||||
}
|
}
|
||||||
@@ -1441,8 +1441,9 @@
|
|||||||
window.clearTimeout(this.appendHandle);
|
window.clearTimeout(this.appendHandle);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//追加学习时长, flag是否提交到后台
|
|
||||||
appendStudyTime() {
|
appendStudyTime() {
|
||||||
|
//重新覆盖时间
|
||||||
|
this.appendStartTime = new Date().getTime();
|
||||||
//console.log('开始追加学习时长',this.isAppendTime);
|
//console.log('开始追加学习时长',this.isAppendTime);
|
||||||
if (this.studyId == '') {
|
if (this.studyId == '') {
|
||||||
return;
|
return;
|
||||||
@@ -1451,50 +1452,72 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.isAppendTime) {
|
if (!this.isAppendTime) {
|
||||||
this.appendStartTime = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.appendHandle && window.clearTimeout(this.appendHandle);
|
||||||
if (this.appendHandle != null) {
|
|
||||||
window.clearTimeout(this.appendHandle);
|
|
||||||
}
|
|
||||||
//首先从本地读取
|
|
||||||
let duration = studyUtil.getStudyDuration();
|
|
||||||
//console.log('追加学习时长,当前本地积累的学习时长='+duration);
|
|
||||||
//追加学习长
|
|
||||||
let $this = this;
|
|
||||||
if (this.appendStartTime == null) {
|
|
||||||
this.appendStartTime = new Date();
|
|
||||||
this.appendHandle = setTimeout(function() {
|
|
||||||
$this.appendStudyTime();
|
|
||||||
}, $this.appentInterval); //设置定时追加学习时长
|
|
||||||
//保存之前的
|
|
||||||
if (duration >= 60 ) {
|
|
||||||
this.saveStudyDuration(duration);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//如果当前追加开始时间不为空
|
|
||||||
let now = new Date();
|
|
||||||
let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数
|
|
||||||
// console.log(m/1000,'时间');
|
|
||||||
|
|
||||||
let sen = Math.round(m / 1000); //计算秒数
|
|
||||||
// console.log('定时器时间',sen);
|
|
||||||
// 每次添加的是定时器计时的时间
|
|
||||||
duration = duration + sen;//追加的是秒
|
|
||||||
if (duration >= 60) { //一分钟保存一次
|
|
||||||
this.saveStudyDuration(duration);
|
|
||||||
} else {
|
|
||||||
studyUtil.setStudyDuration(duration); //添加到本地存储中
|
|
||||||
}
|
|
||||||
//重新覆盖时间
|
|
||||||
this.appendStartTime = new Date();
|
|
||||||
//启动下次追加学习时长
|
//启动下次追加学习时长
|
||||||
this.appendHandle = setTimeout(function() {
|
this.appendHandle = setTimeout(() => {
|
||||||
$this.appendStudyTime();
|
let endTime = new Date().getTime();
|
||||||
}, $this.appentInterval);
|
this.appentInterval = 60
|
||||||
|
let totalTime = Math.round((endTime - this.appendStartTime) / 1000);
|
||||||
|
this.saveStudyDuration(totalTime)
|
||||||
|
this.appendStudyTime();
|
||||||
|
}, this.appentInterval * 1000);
|
||||||
},
|
},
|
||||||
|
//追加学习时长, flag是否提交到后台
|
||||||
|
// appendStudyTime() {
|
||||||
|
// //console.log('开始追加学习时长',this.isAppendTime);
|
||||||
|
// if (this.studyId == '') {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (!this.contentData.id) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (!this.isAppendTime) {
|
||||||
|
// this.appendStartTime = null;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (this.appendHandle != null) {
|
||||||
|
// window.clearTimeout(this.appendHandle);
|
||||||
|
// }
|
||||||
|
// //首先从本地读取
|
||||||
|
// let duration = studyUtil.getStudyDuration();
|
||||||
|
// //console.log('追加学习时长,当前本地积累的学习时长='+duration);
|
||||||
|
// //追加学习长
|
||||||
|
// let $this = this;
|
||||||
|
// if (this.appendStartTime == null) {
|
||||||
|
// this.appendStartTime = new Date();
|
||||||
|
// this.appendHandle = setTimeout(function() {
|
||||||
|
// $this.appendStudyTime();
|
||||||
|
// }, $this.appentInterval); //设置定时追加学习时长
|
||||||
|
// //保存之前的
|
||||||
|
// if (duration >= 60 ) {
|
||||||
|
// this.saveStudyDuration(duration);
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// //如果当前追加开始时间不为空
|
||||||
|
// let now = new Date();
|
||||||
|
// let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数
|
||||||
|
// // console.log(m/1000,'时间');
|
||||||
|
|
||||||
|
// let sen = Math.round(m / 1000); //计算秒数
|
||||||
|
// // console.log('定时器时间',sen);
|
||||||
|
// // 每次添加的是定时器计时的时间
|
||||||
|
// duration = duration + sen;//追加的是秒
|
||||||
|
// if (duration >= 60) { //一分钟保存一次
|
||||||
|
// this.saveStudyDuration(duration);
|
||||||
|
// } else {
|
||||||
|
// studyUtil.setStudyDuration(duration); //添加到本地存储中
|
||||||
|
// }
|
||||||
|
// //重新覆盖时间
|
||||||
|
// this.appendStartTime = new Date();
|
||||||
|
// //启动下次追加学习时长
|
||||||
|
// this.appendHandle = setTimeout(function() {
|
||||||
|
// $this.appendStudyTime();
|
||||||
|
// }, $this.appentInterval);
|
||||||
|
// },
|
||||||
|
|
||||||
finishStudyItem() { //设置完成学习的内容,针对于音视频的内容
|
finishStudyItem() { //设置完成学习的内容,针对于音视频的内容
|
||||||
if (!this.contentData.studyItemId) {
|
if (!this.contentData.studyItemId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user