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