Commit 29067597 by 李伟康

增加埋点需在登陆后触发

1 parent add10f1d
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
import { bigdatautilApi } from '@/api' import { bigdatautilApi } from '@/api'
export default { export default {
name: 'App', name: 'App',
data() { data () {
return { return {
timer: null timer: null
} }
...@@ -25,46 +25,50 @@ export default { ...@@ -25,46 +25,50 @@ export default {
watch: { watch: {
watchFlag: { watchFlag: {
immediate: true, immediate: true,
handler(newval) { handler (newval) {
this.showWindow = newval this.showWindow = newval
this.hideLoading() this.hideLoading()
this.init()
} }
} }
}, },
computed: { computed: {
watchFlag() { watchFlag () {
return this.$store.state.app.showWindow return this.$store.state.app.showWindow
} }
}, },
mounted() { mounted () {
this.openListener()
window.addEventListener('pagehide', () => {
this.leave()
this.closeListener()
// console.log('页面要关闭了')
})
}, },
methods: { methods: {
init () {
this.openListener()
window.addEventListener('pagehide', () => {
this.leave()
this.closeListener()
// console.log('页面要关闭了')
})
},
// 心跳检测 // 心跳检测
openListener() { openListener () {
this.timer = setInterval(() => { this.timer = setInterval(() => {
this.heartbeat() this.heartbeat()
}, 60 * 1000) }, 60 * 1000)
}, },
closeListener() { closeListener () {
clearInterval(this.timer) clearInterval(this.timer)
}, },
// 心跳检测 // 心跳检测
heartbeat() { heartbeat () {
this.trackFn('heartbeat', 5) this.trackFn('heartbeat', 5)
}, },
//离开事件 //离开事件
leave() { leave () {
// console.log('离开时间') // console.log('离开时间')
this.trackFn('leaveReportTrack', 5) this.trackFn('leaveReportTrack', 5)
}, },
trackFn(name, actionType) { trackFn (name, actionType) {
const { id } = this.getQuery() const { id } = this.getQuery()
bigdatautilApi[name](id, actionType) bigdatautilApi[name](id, actionType)
} }
......
...@@ -26,6 +26,7 @@ const reportTrack = (id, view = 1, share_channel = '', url = commonUrl, method = ...@@ -26,6 +26,7 @@ const reportTrack = (id, view = 1, share_channel = '', url = commonUrl, method =
const userInfo = util.getUserInfo() const userInfo = util.getUserInfo()
const params = util.getLocalStorage('wx_scrm_link_params') || {} const params = util.getLocalStorage('wx_scrm_link_params') || {}
const ISWXWORK = util.getLocalStorage('is_wxwork') const ISWXWORK = util.getLocalStorage('is_wxwork')
if(!userInfo) return
if (ISWXWORK) { if (ISWXWORK) {
if (userInfo.loginList.length && userInfo.loginList[0].phone) userInfo.phone = userInfo.loginList[0].phone if (userInfo.loginList.length && userInfo.loginList[0].phone) userInfo.phone = userInfo.loginList[0].phone
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!