Authored by 李奇

资源位曝光检查逻辑修改

... ... @@ -70,12 +70,12 @@ export default {
},
checkReport(evt, isInit) {
_.each(this.$children, (component, index) => {
const visiable = this.isVisiable(component.$el, this.$scrollEl);
const visible = this.isVisible(component.$el, this.$scrollEl);
if (visiable && (this.componentStatus[index] !== visiable || isInit)) {
if (visible && (this.componentStatus[index] !== visible || isInit)) {
this.record(component, index + 1);
}
this.componentStatus[index] = visiable;
this.componentStatus[index] = visible;
});
},
record(component, index) {
... ... @@ -96,12 +96,14 @@ export default {
F_ID: reportData.template_id,
F_INDEX: index,
ACTION_URL: item.url
})
});
});
break;
case 'focus':
break;
case 'tfGoodsList':
// 楼层内存在多个item, 交给子组件各自检测
component.checkReqFromParent();
break;
case 'newSingleImage':
param = {
... ... @@ -124,13 +126,18 @@ export default {
}
}
},
isVisiable($el, $parent) {
isVisible($el, $parent) {
const rect = $el.getBoundingClientRect();
const parentRect = $parent.getBoundingClientRect();
return ((parentRect.top >= rect.top && parentRect.top <= (rect.top + rect.height)) ||
((parentRect.top + parentRect.height) >= rect.top && (parentRect.top + parentRect.height) <= (rect.top + rect.height)) ||
(rect.top >= parentRect.top && (rect.top + rect.height) <= (parentRect.top + parentRect.height)));
},
checkReqFromChild(index) {
// 重置子组件显示状态方可重新记录
this.componentStatus[index] = false;
this.checkReport();
}
}
};
... ...
... ... @@ -96,6 +96,10 @@ export default {
}
},
touchEnd(ev) {
// 手动触发父组件曝光检查
this.$parent.checkReqFromChild(this.index);
let wd = this.$refs.goodsList.scrollWidth - this.$refs.goodsList.offsetWidth;
let moreWd = this.$refs.more.offsetWidth;
let scrollLeft = this.$refs.goodsList.scrollLeft;
... ... @@ -125,6 +129,12 @@ export default {
}
this.$refs.linkA.click();
},
// 用于检测楼层内部item的曝光状态, 暴露给父组件调用
checkReqFromParent() {
console.log('out from self check')
// TODO 检测组件内child item曝光、并返回给parent
}
},
components: {Resource}
... ...