Feat(页面):监听页面打开次数和页面停留时长接口对接

This commit is contained in:
lifizer
2024-06-14 17:59:10 +08:00
parent 344e0aa888
commit 2f217e8dc1
2 changed files with 17 additions and 9 deletions
+2 -2
View File
@@ -15,12 +15,12 @@ export const pageListenMixins = {
this.pageToWatchShowCount(this.pageKeyId)
},
onHide() {
this.clearPageTimerFn()
this.pageToHideHandle()
},
methods: {
pageToWatchShowCount,
pageToWatchShowTimer,
clearPageTimerFn() {
pageToHideHandle() {
const visitTime = TimeDifference(this.pageViewDateTime, getCurrDateTime())
if (visitTime > 0) {
this.pageToWatchShowTimer(this.pageKeyId, {
+15 -7
View File
@@ -111,31 +111,39 @@ export function clearAllInterval() {
for (let i = 1; i <= endTimerId; i++) {
clearInterval(i)
}
pushSysByOneMinutesHandle()
pushSysBySecondsHandle()
}
/**
* 定时推送埋点
* @returns {null}
*/
function pushSysByOneMinutesHandle() {
function pushSysBySecondsHandle() {
setInterval(() => {
const userInfo = uni.getStorageSync('userInfo')
if (!userInfo) {
return
}
let statsData = []
for (const key in Vue.prototype.$pageToWatchData) {
if (Vue.prototype.$pageToWatchData[key]) {
console.log(Vue.prototype.$pageToWatchData[key])
statsData = statsData.concat(Vue.prototype.$pageToWatchData[key])
}
}
console.log(statsData)
// 设备类型phone、pad、pc、unknow
const deviceType = uni.getSystemInfoSync().deviceType
// 系统名称ios、android
const osName = uni.getSystemInfoSync().osName
console.log(deviceType)
console.log(osName)
const postData = {
uid: '',
deviceType: 'android',
uid: userInfo.uid,
deviceType: deviceType === 'phone' ? osName : 'unknown',
statsData
}
console.log('开始上报数据-------------------')
pushSystemStatic(postData).catch(err => {
console.log(err)
})
}, 60 * 1000)
}, 30 * 1000)
}