Feat(页面):监听页面打开次数和页面停留时长逻辑初步实现
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user