diff --git a/mixins/pageListenMixins.js b/mixins/pageListenMixins.js index 6fd42d7..b0dabe1 100644 --- a/mixins/pageListenMixins.js +++ b/mixins/pageListenMixins.js @@ -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, { diff --git a/utils/util.js b/utils/util.js index b54d61d..de312fe 100644 --- a/utils/util.js +++ b/utils/util.js @@ -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) }