...
|
...
|
@@ -21,7 +21,8 @@ |
|
|
viewArea: {
|
|
|
top: 0,
|
|
|
bottom: 0
|
|
|
}
|
|
|
},
|
|
|
waiting: []
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
...
|
...
|
@@ -50,28 +51,49 @@ |
|
|
|
|
|
return ((rect.top > this.viewArea.top && rect.top < this.viewArea.bottom) ||
|
|
|
rect.bottom > this.viewArea.top && rect.bottom < this.viewArea.bottom)
|
|
|
},
|
|
|
addIntoWaiting(param) {
|
|
|
this.waiting.push(param);
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
},
|
|
|
mounted() {
|
|
|
let timer = setInterval(() => {
|
|
|
this.$scrollEl = window;
|
|
|
this.scrollEvent = util.throttle(50, this.checkReport);
|
|
|
if (this.$scrollEl) {
|
|
|
this.$scrollEl.addEventListener('scroll', this.scrollEvent);
|
|
|
}
|
|
|
if (yoho.isYohoBuy) {
|
|
|
document.addEventListener('visibilitychange', () => {
|
|
|
if (!(document.visibilityState === 'visible')) {
|
|
|
let children = _.filter(this.$children, child => {
|
|
|
return child.$options.name === 'ExposureItem'
|
|
|
});
|
|
|
|
|
|
if (this.$children.length) {
|
|
|
clearInterval(timer);
|
|
|
this.checkReport(void 0, true);
|
|
|
}
|
|
|
}, 500);
|
|
|
_.each(children, child => {
|
|
|
child.record(false);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (document.visibilityState === 'visible') {
|
|
|
this.checkReport();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
let reportTimer = setInterval(() => {
|
|
|
if (!this.$children.length) { return clearInterval(reportTimer); }
|
|
|
_.each(_.filter(this.$children, child => child.$options.name === 'ExposureItem'), child => child.report());
|
|
|
}, 3000);
|
|
|
let timer = setInterval(() => {
|
|
|
this.$scrollEl = window;
|
|
|
this.scrollEvent = util.throttle(50, this.checkReport);
|
|
|
if (this.$scrollEl) {
|
|
|
this.$scrollEl.addEventListener('scroll', this.scrollEvent);
|
|
|
}
|
|
|
|
|
|
if (this.$children.length) {
|
|
|
clearInterval(timer);
|
|
|
this.checkReport(void 0, true);
|
|
|
}
|
|
|
}, 500);
|
|
|
|
|
|
let reportTimer = setInterval(() => {
|
|
|
if (!this.$children.length) { return clearInterval(reportTimer); }
|
|
|
if (!this.waiting.length) { return }
|
|
|
this.$yas.event('YB_SHOW_EVENT', this.waiting);
|
|
|
this.waiting = [];
|
|
|
}, 3000);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
</script>
|
...
|
...
|
|