mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-09 02:46:46 +08:00
文章计时
This commit is contained in:
@@ -91,9 +91,7 @@
|
||||
|
||||
},
|
||||
destroyed() {
|
||||
if(this.setTime){
|
||||
clearTimeout(this.setTime);
|
||||
}
|
||||
this.setTime && clearTimeout(this.setTime);
|
||||
},
|
||||
onReachBottom(){
|
||||
this.getDetail()
|
||||
@@ -104,24 +102,15 @@
|
||||
methods: {
|
||||
// 发送计时
|
||||
sendEventData(){
|
||||
let event = {
|
||||
key: "ReadArticle",//后台的事件key 发布文章且审核通过
|
||||
title: "阅读文章",//事件的标题
|
||||
parameters:"second:" + this.secondTime,//用户自定义参数 name:value,name:value
|
||||
content: "阅读了文章",//事件的内容
|
||||
source:'page',
|
||||
objId: this.id,//关联的id
|
||||
objType: "2",//关联的类型
|
||||
objInfo: this.detail.title,
|
||||
aid: this.userInfo.aid, //当前登录人的id
|
||||
aname: this.userInfo.name,//当前人的姓名
|
||||
status: 1 ,//状态,直接写1
|
||||
source:"h5",
|
||||
}
|
||||
this.setTime && clearTimeout(this.setTime);
|
||||
let startTime = new Date().getTime();
|
||||
this.setTime = setTimeout(()=>{
|
||||
this.cumulativeDuration += this.secondTime
|
||||
let endTime = new Date().getTime();
|
||||
let totalTime = Math.round((endTime - startTime) / 1000);
|
||||
this.cumulativeDuration += totalTime;
|
||||
console.log(this.cumulativeDuration,'时间');
|
||||
if(this.cumulativeDuration <= this.defaultMaxTime){
|
||||
apiStat.sendEvent(event);
|
||||
this.sendStudyTime(totalTime)
|
||||
this.secondTime = 60
|
||||
this.sendEventData()
|
||||
}else{
|
||||
@@ -131,6 +120,23 @@
|
||||
}
|
||||
},this.secondTime * 1000);//15秒记录一次之后1分钟后记录
|
||||
},
|
||||
//发送学习时间
|
||||
sendStudyTime(totalTime){
|
||||
apiStat.sendEvent({
|
||||
key: "ReadArticle",//后台的事件key 发布文章且审核通过
|
||||
title: "阅读文章",//事件的标题
|
||||
parameters:"second:" + totalTime,//用户自定义参数 name:value,name:value
|
||||
content: "阅读了文章",//事件的内容
|
||||
source:'page',
|
||||
objId: this.id,//关联的id
|
||||
objType: "2",//关联的类型
|
||||
objInfo: this.detail.title,
|
||||
aid: this.userInfo.aid, //当前登录人的id
|
||||
aname: this.userInfo.name,//当前人的姓名
|
||||
status: 1 ,//状态,直接写1
|
||||
source:"h5",
|
||||
});
|
||||
},
|
||||
getDetail(){
|
||||
uni.showLoading({title:'加载中...'});
|
||||
let $this=this;
|
||||
|
||||
Reference in New Issue
Block a user