案例和文章记录时长

This commit is contained in:
nisen
2023-11-08 09:45:36 +08:00
parent b560ba9bea
commit 97ac0e958f
2 changed files with 46 additions and 23 deletions

View File

@@ -158,7 +158,9 @@ export default {
diagSync:false,//控制弹窗 diagSync:false,//控制弹窗
isPraise:false, isPraise:false,
isFavorite: false, isFavorite: false,
setTime: null setTime: null,
defaultMaxTime: 180,//最大时长
cumulativeDuration:0,//累计时长
}; };
}, },
created(){ created(){
@@ -252,6 +254,18 @@ export default {
this.articleDetailData=res.result; this.articleDetailData=res.result;
//if(this.articleDetailData.toString()!='{}'){ //if(this.articleDetailData.toString()!='{}'){
this.getAuthorInfo(this.articleDetailData) this.getAuthorInfo(this.articleDetailData)
//记录时长
this.sendEventData()
//}
}else{
this.noData = false;
this.$message.error(res.message);
}
}).catch(err=>{
this.$message.error("获取数据失败")
})
},
sendEventData(){
let event = { let event = {
key: "ViewArticle",//后台的事件key 发布文章且审核通过 key: "ViewArticle",//后台的事件key 发布文章且审核通过
title: "查看文章",//事件的标题 title: "查看文章",//事件的标题
@@ -272,15 +286,14 @@ export default {
event.parameters='second:60';//增加60秒的学习时长 event.parameters='second:60';//增加60秒的学习时长
event.content = "阅读了文章" event.content = "阅读了文章"
$this.$store.dispatch("userTrigger", event); $this.$store.dispatch("userTrigger", event);
},61000);//1分钟后记录 if(this.cumulativeDuration<=this.defaultMaxTime){
//} sendEventData()
}else{ }else{
this.noData = false; this.cumulativeDuration = 0
this.$message.error(res.message); clearInterval(this.setTime);
this.setTime = null
} }
}).catch(err=>{ },61000);//1分钟后记录
this.$message.error("获取数据失败")
})
}, },
//获取文章发布人的人物信息 //获取文章发布人的人物信息
getAuthorInfo(data){ getAuthorInfo(data){

View File

@@ -223,7 +223,9 @@ export default {
Profess: [], Profess: [],
orgData: [], orgData: [],
setTimeCase: null, setTimeCase: null,
dataTime: sessionStorage.getItem('startTime') || 0 dataTime: sessionStorage.getItem('startTime') || 0,
defaultMaxTime: 180,//最大时长
cumulativeDuration:0,//累计时长
}; };
}, },
mounted() { mounted() {
@@ -545,6 +547,14 @@ export default {
event.parameters = "second:60"; event.parameters = "second:60";
event.content = '阅读了案例'; event.content = '阅读了案例';
$this.$store.dispatch("userTrigger", event); $this.$store.dispatch("userTrigger", event);
this.cumulativeDuration += 60
if(this.cumulativeDuration<=this.defaultMaxTime){
sendEventData()
}else{
this.cumulativeDuration = 0
clearInterval(this.setTimeCase);
this.setTimeCase = null
}
}, 61000);//1分钟之后发送阅读案例事件 }, 61000);//1分钟之后发送阅读案例事件
}, },
getCaseData() { getCaseData() {