mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-10 19:36:47 +08:00
文章计时,最多三十分钟
This commit is contained in:
@@ -49,7 +49,11 @@
|
|||||||
// 字符串的形式
|
// 字符串的形式
|
||||||
p: 'word-break:break-all;font-size: 28upx;letter-spacing:1rpx; line-height: 1.6;margin-bottom:25px',
|
p: 'word-break:break-all;font-size: 28upx;letter-spacing:1rpx; line-height: 1.6;margin-bottom:25px',
|
||||||
span: 'word-break:break-all;font-size: 28upx;letter-spacing:1rpx; line-height: 1.6'
|
span: 'word-break:break-all;font-size: 28upx;letter-spacing:1rpx; line-height: 1.6'
|
||||||
}
|
},
|
||||||
|
secondTime: 15,//默认时长
|
||||||
|
cumulativeDuration: 0,
|
||||||
|
setTime: null,
|
||||||
|
defaultMaxTime: 1800,//最大时长
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -74,15 +78,22 @@
|
|||||||
source:"h5",
|
source:"h5",
|
||||||
}
|
}
|
||||||
apiStat.sendEvent(event);
|
apiStat.sendEvent(event);
|
||||||
|
this.sendEventData()
|
||||||
// this.$store.dispatch("userTrigger", event);
|
// this.$store.dispatch("userTrigger", event);
|
||||||
this.setTime = setTimeout(()=>{
|
// this.setTime = setTimeout(()=>{
|
||||||
event.key = 'ReadArticle';
|
// event.key = 'ReadArticle';
|
||||||
event.title = "阅读文章";
|
// event.title = "阅读文章";
|
||||||
event.parameters='second:60';//增加60秒的学习时长
|
// event.parameters='second:60';//增加60秒的学习时长
|
||||||
event.content = "阅读了文章"
|
// event.content = "阅读了文章"
|
||||||
apiStat.sendEvent(event);
|
// apiStat.sendEvent(event);
|
||||||
// $this.$store.dispatch("userTrigger", event);
|
// // $this.$store.dispatch("userTrigger", event);
|
||||||
},61000);//1分钟后记录
|
// },61000);//1分钟后记录
|
||||||
|
|
||||||
|
},
|
||||||
|
destroyed() {
|
||||||
|
if(this.setTime){
|
||||||
|
clearTimeout(this.setTime);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onReachBottom(){
|
onReachBottom(){
|
||||||
this.getDetail()
|
this.getDetail()
|
||||||
@@ -91,6 +102,35 @@
|
|||||||
...mapGetters(['userInfo'])
|
...mapGetters(['userInfo'])
|
||||||
},
|
},
|
||||||
methods: {
|
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 = setTimeout(()=>{
|
||||||
|
this.cumulativeDuration += this.secondTime
|
||||||
|
if(this.cumulativeDuration <= this.defaultMaxTime){
|
||||||
|
apiStat.sendEvent(event);
|
||||||
|
this.secondTime = 60
|
||||||
|
this.sendEventData()
|
||||||
|
}else{
|
||||||
|
this.cumulativeDuration = 0
|
||||||
|
clearTimeout(this.setTime);
|
||||||
|
this.setTime = null
|
||||||
|
}
|
||||||
|
},this.secondTime * 1000);//15秒记录一次之后1分钟后记录
|
||||||
|
},
|
||||||
getDetail(){
|
getDetail(){
|
||||||
uni.showLoading({title:'加载中...'});
|
uni.showLoading({title:'加载中...'});
|
||||||
let $this=this;
|
let $this=this;
|
||||||
|
|||||||
Reference in New Issue
Block a user