Feat(页面):监听页面打开次数和页面停留时长逻辑初步实现

This commit is contained in:
lifizer
2024-05-16 17:23:07 +08:00
parent 2b3c0e4355
commit 84c5ede725
7 changed files with 167 additions and 79 deletions
+33
View File
@@ -0,0 +1,33 @@
import {
pageToWatchShowCount,
pageToWatchShowTimer
} from '@/utils/util'
export const pageListenMixins = {
data(){
return {
pageTimer: null
}
},
onShow() {
this.pageToWatchShowCount(this.pageKeyId, this.pageShowTimerFn())
},
onHide() {
this.clearPageTimerFn()
},
methods: {
pageToWatchShowCount,
pageToWatchShowTimer,
pageShowTimerFn() {
this.pageTimer = setInterval(() => {
console.log('----页面监听----%s', this.pageKeyId)
this.pageToWatchShowTimer(this.pageKeyId)
}, 1000)
},
clearPageTimerFn() {
if (this.pageTimer) {
console.log('清除页面监听-----%s', this.pageKeyId)
clearInterval(this.pageTimer)
}
}
}
}