案例和文章设置第一次十五秒发请求

This commit is contained in:
nisen
2023-11-09 10:56:29 +08:00
parent ee5219533c
commit db856638ec
2 changed files with 32 additions and 7 deletions

View File

@@ -161,6 +161,8 @@ export default {
setTime: null,
defaultMaxTime: 1800,//最大时长
cumulativeDuration:0,//累计时长
judgmentTime:true,//是否发送
secondTime:15,//默认时长
};
},
created(){
@@ -182,6 +184,7 @@ export default {
window.removeEventListener("scroll",this.handleScroll);
clearTimeout(this.setTime);
this.cumulativeDuration = 0;
this.judgmentTime = true;
},
methods: {
banJump() {
@@ -284,7 +287,7 @@ export default {
let event = {
key: "ReadArticle",//后台的事件key 发布文章且审核通过
title: "阅读文章",//事件的标题
parameters:"second:60",//用户自定义参数 name:value,name:value
parameters:"second:" + this.secondTime,//用户自定义参数 name:value,name:value
content: "阅读了文章",//事件的内容
source:'page',
objId: this.articleId,//关联的id
@@ -294,17 +297,27 @@ export default {
aname: this.userInfo.name,//当前人的姓名
status: 1 //状态直接写1
}
// 十五秒的时候发一次,只记录一次
if(this.judgmentTime){
this.judgmentTime = false
setTimeout(() => {
this.$store.dispatch("userTrigger", event);
this.secondTime = 60
this.sendEventData()
},15000)
return
}
this.setTime = setTimeout(()=>{
this.$store.dispatch("userTrigger", event);
this.cumulativeDuration += 60
if(this.cumulativeDuration<=this.defaultMaxTime){
this.$store.dispatch("userTrigger", event);
this.sendEventData()
}else{
this.cumulativeDuration = 0
clearTimeout(this.setTime);
this.setTime = null
}
},61000);//1分钟后记录
},60000);//1分钟后记录
},
//获取文章发布人的人物信息
getAuthorInfo(data){

View File

@@ -226,6 +226,8 @@ export default {
dataTime: sessionStorage.getItem('startTime') || 0,
defaultMaxTime: 1800,//最大时长
cumulativeDuration:0,//累计时长
secondTime:15, //秒数
judgmentTime:true //判断是否开始计时
};
},
mounted() {
@@ -267,6 +269,7 @@ export default {
window.removeEventListener("scroll", this.handleScroll);
clearTimeout(this.setTimeCase);
this.cumulativeDuration = 0;
this.judgmentTime = true
},
methods: {
endTimeRequst(caseId, recordEndTime) {
@@ -543,7 +546,7 @@ export default {
let event = {
key: "ReadCase",//后台的事件key 发布文章且审核通过
title: '阅读案例',//事件的标题
parameters: "second:60",//用户自定义参数 name:value,name:value
parameters: "second:" + this.secondTime,//用户自定义参数 name:value,name:value
content: '阅读了案例',//事件的内容
objId: this.resolveId,//关联的id
objType: "3",//关联的类型
@@ -552,18 +555,27 @@ export default {
aname: this.userInfo.name,//当前人的姓名
status: 1 //状态直接写1
}
let $this = this;
// 十五秒的时候发一次,只记录一次
if(this.judgmentTime){
this.judgmentTime = false
setTimeout(() => {
this.$store.dispatch("userTrigger", event);
this.secondTime = 60
this.sendEventData()
},15000)
return
}
this.setTimeCase = setTimeout(() => {
$this.$store.dispatch("userTrigger", event);
this.cumulativeDuration += 60
if(this.cumulativeDuration<=this.defaultMaxTime){
this.$store.dispatch("userTrigger", event);
this.sendEventData()
}else{
this.cumulativeDuration = 0
clearTimeout(this.setTimeCase);
this.setTimeCase = null
}
}, 61000);//1分钟之后发送阅读案例事件
}, 60000);//1分钟之后发送阅读案例事件
},
getCaseData() {
let $this = this;