Commit d4ed4bca by wangzhihui

Merge branch 'SAAS+V5.0.0' of http://192.168.3.233:8090/saas_plus/dj-car-life-sy…

…stem into SAAS+V5.0.0
2 parents 305b942c 2511ff15
...@@ -69,13 +69,11 @@ export default { ...@@ -69,13 +69,11 @@ export default {
recordList.push(item) recordList.push(item)
} }
localStorage.setItem("recordList", JSON.stringify(recordList)) localStorage.setItem("recordList", JSON.stringify(recordList))
if (recordList.length > 9) { if (!window.TRACK_TIMER) {
reportTrack({ console.log('---------------- 重新打开定时埋点 ----------------')
recordList this.sendTrack() //开启定时埋点
}).then((res) => {
if (res) localStorage.removeItem("recordList")
})
} }
if (recordList.length > 9) this.sendTrackData()
}, },
getRandomString (length = 30) { getRandomString (length = 30) {
const characters = const characters =
...@@ -113,7 +111,7 @@ export default { ...@@ -113,7 +111,7 @@ export default {
setBrowseTrackData () { setBrowseTrackData () {
try { try {
// || (this.$route.path != "/qualityControlList" && this.$route.path != "/shopConfig") // || (this.$route.path != "/qualityControlList" && this.$route.path != "/shopConfig")
if (!this.track_timerFlag) { if (!this.track_timerFlag && !this.track_event_code) { //无eventcode时不上报
return return
} else { } else {
this.track_timer_out = setTimeout(() => { this.track_timer_out = setTimeout(() => {
...@@ -150,6 +148,27 @@ export default { ...@@ -150,6 +148,27 @@ export default {
} }
return "" return ""
},
sendTrackData () {
let recordList = localStorage.getItem('recordList')
if (recordList && recordList.length) {
reportTrack({
recordList: JSON.parse(recordList)
}).then(res => {
if (res) localStorage.removeItem('recordList')
})
} else {
clearInterval(window.TRACK_TIMER)
window.TRACK_TIMER = null
console.log('---------------- 暂停定时埋点 ----------------')
}
},
/**定时发送埋点数据 */
sendTrack () {
window.TRACK_TIMER = setInterval(() => {
this.sendTrackData()
}, 30e3)
} }
} }
} }
import { reportTrack } from "@api/resident"
import reportTrackFunMixin from './reportTrackFunMixin' import reportTrackFunMixin from './reportTrackFunMixin'
function getRandomString (length = 10) { function getRandomString (length = 10) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
...@@ -13,20 +12,16 @@ export default { ...@@ -13,20 +12,16 @@ export default {
data () { data () {
return { return {
timerFlag: false, timerFlag: false,
track_set_timer: null
} }
}, },
beforeDestroy () { beforeDestroy () {
this.onPageHide() this.onPageHide()
window.removeEventListener('click', this.getTrackData) window.removeEventListener('click', this.getTrackData)
this.timerFlag = false this.timerFlag = false
clearTimeout(this.track_set_timer)
this.track_set_timer = null
}, },
mounted () { mounted () {
window.addEventListener('click', this.getTrackData) window.addEventListener('click', this.getTrackData)
this.timerFlag = true this.timerFlag = true
this.intervalRepoet()
}, },
methods: { methods: {
getTrackData (e) { getTrackData (e) {
...@@ -39,23 +34,7 @@ export default { ...@@ -39,23 +34,7 @@ export default {
else this.getTrackData(target.parentElement) else this.getTrackData(target.parentElement)
}, 10) }, 10)
}, },
intervalRepoet () {
if (!this.timerFlag) return
this.track_set_timer = setTimeout(() => {
this.sendData()
if (this.timerFlag) this.intervalRepoet()
}, 30 * 1e3)
},
getRandomString: getRandomString, getRandomString: getRandomString,
sendData () {
let recordList = localStorage.getItem('recordList')
if (recordList) {
reportTrack({
recordList: JSON.parse(recordList)
}).then(res => {
if (res) localStorage.removeItem('recordList')
})
}
}
} }
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!