Authored by 郭成尧

yas-reporter

... ... @@ -6,5 +6,10 @@ lazyLoad($('img.lazy'));
// 商品曝光事件上报
if (yoho.isApp) {
require('./student-market/goods-show-yas-rpter');
let GoodsShowYasRpter = require('common/goods-show-yas-rpter').default;
new GoodsShowYasRpter({
goodsContainer: $('#goods-container'),
goodsSelectorStr: '.good-info'
});
}
... ...
... ... @@ -2,8 +2,15 @@ import qs from 'yoho-qs';
import yasTools from 'common/yas-tools';
class GoodsShowYasRpter {
constructor() {
constructor(params) {
this.timer = null;
this.goodsContainer = $(document);
this.goodsSelectorStr = '.good-info';
if (params) {
this.goodsContainer = params.goodsContainer ? $(params.goodsContainer) : this.goodsContainer;
this.goodsSelectorStr = params.goodsSelectorStr || '.good-info';
}
this.reportParams = {
C_ID: qs.physical_channel || 1,
... ... @@ -34,7 +41,7 @@ class GoodsShowYasRpter {
report() {
let cacheTheShowSkns = []; // 暂存此次上报的商品,上报后复制给 lastReportSkns
$('.good-info').each((gindex, theGoods) => {
this.goodsContainer.find(this.goodsSelectorStr).each((gindex, theGoods) => {
let $theGoods = $(theGoods);
let proSkn = $theGoods.data('id');
... ... @@ -67,4 +74,4 @@ class GoodsShowYasRpter {
}
export default new GoodsShowYasRpter();
export default GoodsShowYasRpter;
... ...
... ... @@ -12,6 +12,7 @@ let $ = require('yoho-jquery'),
bp = require('./burying-point'),
PullRefresh = require('plugin/pull-refresh'),
uuid = require('uuid');
const yoho = require('yoho-app');
let installment = {
init: function() {
... ... @@ -206,4 +207,14 @@ $(window).load(function() {
$(function() {
installment.init();
// 商品曝光事件上报
if (yoho.isApp) {
let GoodsShowYasRpter = require('common/goods-show-yas-rpter').default;
new GoodsShowYasRpter({
goodsContainer: $('#goods-list'),
goodsSelectorStr: '.good-info'
});
}
});
... ...
... ... @@ -476,3 +476,13 @@ $(function() {
});
require('./seckill/goods-list');
// 商品曝光事件上报
if (yoho.isApp) {
let GoodsShowYasRpter = require('common/goods-show-yas-rpter').default;
new GoodsShowYasRpter({
goodsContainer: $('#container'),
goodsSelectorStr: '.good-info'
});
}
... ...