正常音频计时

This commit is contained in:
nisen
2023-11-20 17:15:26 +08:00
parent 5d7df19bce
commit 58645d9718

View File

@@ -486,6 +486,9 @@
appendStudyOtherHandle:null,
articleMore:true,
scormUrl:'',
maxDuration:0, //非音频最大时长
cumulativeDuration:0, //非音频累计时长
defaultMaxTime:1800, //非音频默认最大时间
}
},
computed: {
@@ -957,8 +960,31 @@
//用户的学习时长,音视频课程学习,单独的处理,不再追加学习时长
this.isAppendTime = false;
this.appendStudyOtherHandle = setTimeout(function() {
// 开始之前把响应式清空
$this.maxDuration = 0;
$this.cumulativeDuration = 0;
// 没有设置默认时长三十分钟,
$this.maxDuration = con.duration !== 0 ? con.duration * 2 : $this.defaultMaxTime;
//静默处理
apiStat.sendEvent({
"key": "StudyCourse",//课程学习的key
"title": "学习课程",//事件的标题
"parameters":"second:15",//second:value,total:value 本次的学习时长
"content": "学习课程【"+$this.courseInfo.name+"】",//事件的内容
"objId": $this.courseInfo.id,//课程的id
"objType": "1",//类型
"source":"h5",
"objInfo": ""+$this.courseInfo.name,
"aid":$this.userInfo.aid, //当前登录人的id
"aname":$this.userInfo.name,//当前人的姓名
"status": 1 //状态
}).then(rs=>{
if(rs.status !== 200) {
console.log(rs.message);
}
});
$this.appendStudyOtherTime();
}, 1000*60*2); //非音视频课程学习,2分钟后记录因为一次记录是60秒
}, 1000 * 15); //非音视频课程学习,15秒后记录因为一次记录是60秒
//this.appendStudyTime();
//非视频音频的5秒后学习完成
if(con.contentType!=50){
@@ -1287,7 +1313,7 @@
//静默处理
apiStat.sendEvent(postData).then(rs=>{
if(rs.status == 200) {
this.appendStartTime = new Date();//重新计时
//this.appendStartTime = new Date();//重新计时
studyUtil.clearStudyDuration(); //清除本地存储
} else {
console.log(rs.message);
@@ -1299,6 +1325,8 @@
stopStudyTime(){
//console.log('停止追加学习时长');
this.isAppendTime=false;
//暂停让他为空 从新计时
this.appendStartTime = null
if (this.appendHandle != null) {
window.clearTimeout(this.appendHandle);
}
@@ -1331,7 +1359,7 @@
$this.appendStudyTime();
}, $this.appentInterval); //设置定时追加学习时长
//保存之前的
if (duration >0 ) {
if (duration >= 60 ) {
this.saveStudyDuration(duration);
}
return;
@@ -1339,13 +1367,16 @@
//如果当前追加开始时间不为空
let now = new Date();
let m = now.getTime() - this.appendStartTime.getTime(); //相差的毫秒数
let sen = parseInt(m / 1000); //计算秒数
duration = duration + $this.appentInterval/1000;//追加的是秒
let sen = Math.round(m / 1000); //计算秒数
// 每次添加的是定时器计时的时间
duration = duration + sen;//追加的是秒
if (sen>=60) { //一分钟保存一次
this.saveStudyDuration(duration);
} else {
studyUtil.setStudyDuration(duration); //添加到本地存储中
}
//重新覆盖时间
this.appendStartTime = new Date();
//启动下次追加学习时长
this.appendHandle = setTimeout(function() {
$this.appendStudyTime();
@@ -1360,31 +1391,44 @@
if (!this.curContent.id) {
return;
}
let postData={
"key": "StudyCourseOther",//课程学习的key
"title": "非音视频课内容",//事件的标题
"parameters":"second:60",//second:value 本次的学习时长
"content": "学习课程",//事件的内容
"objId": this.courseInfo.id,//课程的id
"objType": "1",//类型
"source":"h5",
"objInfo": ""+this.courseInfo.name,
"aid":this.userInfo.aid, //当前登录人的id
"aname":this.userInfo.name,//当前人的姓名
"status": 1 //状态
}
//静默处理
apiStat.sendEvent(postData).then(rs=>{
if(rs.status != 200) {
console.log(rs.message);
}
});
//每一分钟保存一次
let $this=this;
this.appendStudyOtherHandle = setTimeout(function() {
$this.appendStudyOtherTime();
}, 1000*60);
// 取消阅读的每分钟六十秒的计时,最多是设置的时间或默认时间
let $this=this;
let startTime = new Date().getTime();
this.appendStudyOtherHandle = setTimeout(function() {
let endTime = new Date().getTime();
let totalTime = Math.round((endTime - startTime) / 1000);
$this.cumulativeDuration += totalTime;
if($this.cumulativeDuration <= $this.maxDuration){
//静默处理
$this.sendOtherTime(totalTime)
$this.appendStudyOtherTime();
}else{
clearTimeout(this.appendStudyOtherHandle);
$this.cumulativeDuration = 0;
$this.maxDuration = 0;
}
}, 1000*60);
},
sendOtherTime(totalTime){
apiStat.sendEvent({
"key": "StudyCourseOther",//课程学习的key
"title": "非音视频课内容",//事件的标题
"parameters":"second:" + totalTime,//second:value 本次的学习时长
"content": "学习课程",//事件的内容
"objId": this.courseInfo.id,//课程的id
"objType": "1",//类型
"source":"h5",
"objInfo": ""+this.courseInfo.name,
"aid":this.userInfo.aid, //当前登录人的id
"aname":this.userInfo.name,//当前人的姓名
"status": 1 //状态
}).then(rs=>{
if(rs.status != 200) {
console.log(rs.message);
}
});
},
//先保存学习的内容,针对于音视频的内容
saveStudyItem(){