Authored by 李奇

商品曝光组件修改

... ... @@ -27,7 +27,6 @@
data() {
return {
visible: false,
waitingReport: [],
isVisible: false,
appPrefix: yoho.isiOS ? 'i' : (yoho.isAndroid ? 'a' : 'h5')
};
... ... @@ -45,19 +44,9 @@
};
console.log('push', this.index);
this.waitingReport.push(param);
this.$parent.addIntoWaiting(param);
}
this.isVisiable = visible;
},
report() {
if (this.waitingReport.length) {
console.log('>>>>>>>>>report<<<<<<<<<', this.waitingReport)
this.$yas.event('YB_SHOW_EVENT', this.waitingReport);
this.reset();
}
},
reset() {
this.waitingReport = [];
}
}
};
... ...
... ... @@ -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>
... ...
... ... @@ -41,8 +41,8 @@ import Vue from 'vue';
import lazyload from 'vue-lazyload';
import infinitScroll from 'vue-infinite-scroll';
import bus from 'common/vue-bus';
import Exposure from 'component/exposure/exposure.vue';
import ExposureItem from 'component/exposure/exposure-item.vue';
import Exposure from 'component/product/exposure/exposure.vue';
import ExposureItem from 'component/product/exposure/exposure-item.vue';
Vue.use(lazyload, { preLoad: 3 });
Vue.use(infinitScroll);
... ...