mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-11 11:56:47 +08:00
文章计时
This commit is contained in:
@@ -91,9 +91,7 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
destroyed() {
|
destroyed() {
|
||||||
if(this.setTime){
|
this.setTime && clearTimeout(this.setTime);
|
||||||
clearTimeout(this.setTime);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onReachBottom(){
|
onReachBottom(){
|
||||||
this.getDetail()
|
this.getDetail()
|
||||||
@@ -104,24 +102,15 @@
|
|||||||
methods: {
|
methods: {
|
||||||
// 发送计时
|
// 发送计时
|
||||||
sendEventData(){
|
sendEventData(){
|
||||||
let event = {
|
this.setTime && clearTimeout(this.setTime);
|
||||||
key: "ReadArticle",//后台的事件key 发布文章且审核通过
|
let startTime = new Date().getTime();
|
||||||
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 = setTimeout(()=>{
|
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){
|
if(this.cumulativeDuration <= this.defaultMaxTime){
|
||||||
apiStat.sendEvent(event);
|
this.sendStudyTime(totalTime)
|
||||||
this.secondTime = 60
|
this.secondTime = 60
|
||||||
this.sendEventData()
|
this.sendEventData()
|
||||||
}else{
|
}else{
|
||||||
@@ -131,6 +120,23 @@
|
|||||||
}
|
}
|
||||||
},this.secondTime * 1000);//15秒记录一次之后1分钟后记录
|
},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(){
|
getDetail(){
|
||||||
uni.showLoading({title:'加载中...'});
|
uni.showLoading({title:'加载中...'});
|
||||||
let $this=this;
|
let $this=this;
|
||||||
|
|||||||
Reference in New Issue
Block a user