Showing
4 changed files
with
37 additions
and
4 deletions
@@ -6,5 +6,10 @@ lazyLoad($('img.lazy')); | @@ -6,5 +6,10 @@ lazyLoad($('img.lazy')); | ||
6 | 6 | ||
7 | // 商品曝光事件上报 | 7 | // 商品曝光事件上报 |
8 | if (yoho.isApp) { | 8 | if (yoho.isApp) { |
9 | - require('./student-market/goods-show-yas-rpter'); | 9 | + let GoodsShowYasRpter = require('common/goods-show-yas-rpter').default; |
10 | + | ||
11 | + new GoodsShowYasRpter({ | ||
12 | + goodsContainer: $('#goods-container'), | ||
13 | + goodsSelectorStr: '.good-info' | ||
14 | + }); | ||
10 | } | 15 | } |
public/js/activity/student-market/goods-show-yas-rpter.js
→
public/js/common/goods-show-yas-rpter.js
@@ -2,8 +2,15 @@ import qs from 'yoho-qs'; | @@ -2,8 +2,15 @@ import qs from 'yoho-qs'; | ||
2 | import yasTools from 'common/yas-tools'; | 2 | import yasTools from 'common/yas-tools'; |
3 | 3 | ||
4 | class GoodsShowYasRpter { | 4 | class GoodsShowYasRpter { |
5 | - constructor() { | 5 | + constructor(params) { |
6 | this.timer = null; | 6 | this.timer = null; |
7 | + this.goodsContainer = $(document); | ||
8 | + this.goodsSelectorStr = '.good-info'; | ||
9 | + | ||
10 | + if (params) { | ||
11 | + this.goodsContainer = params.goodsContainer ? $(params.goodsContainer) : this.goodsContainer; | ||
12 | + this.goodsSelectorStr = params.goodsSelectorStr || '.good-info'; | ||
13 | + } | ||
7 | 14 | ||
8 | this.reportParams = { | 15 | this.reportParams = { |
9 | C_ID: qs.physical_channel || 1, | 16 | C_ID: qs.physical_channel || 1, |
@@ -34,7 +41,7 @@ class GoodsShowYasRpter { | @@ -34,7 +41,7 @@ class GoodsShowYasRpter { | ||
34 | report() { | 41 | report() { |
35 | let cacheTheShowSkns = []; // 暂存此次上报的商品,上报后复制给 lastReportSkns | 42 | let cacheTheShowSkns = []; // 暂存此次上报的商品,上报后复制给 lastReportSkns |
36 | 43 | ||
37 | - $('.good-info').each((gindex, theGoods) => { | 44 | + this.goodsContainer.find(this.goodsSelectorStr).each((gindex, theGoods) => { |
38 | let $theGoods = $(theGoods); | 45 | let $theGoods = $(theGoods); |
39 | let proSkn = $theGoods.data('id'); | 46 | let proSkn = $theGoods.data('id'); |
40 | 47 | ||
@@ -67,4 +74,4 @@ class GoodsShowYasRpter { | @@ -67,4 +74,4 @@ class GoodsShowYasRpter { | ||
67 | 74 | ||
68 | } | 75 | } |
69 | 76 | ||
70 | -export default new GoodsShowYasRpter(); | 77 | +export default GoodsShowYasRpter; |
@@ -12,6 +12,7 @@ let $ = require('yoho-jquery'), | @@ -12,6 +12,7 @@ let $ = require('yoho-jquery'), | ||
12 | bp = require('./burying-point'), | 12 | bp = require('./burying-point'), |
13 | PullRefresh = require('plugin/pull-refresh'), | 13 | PullRefresh = require('plugin/pull-refresh'), |
14 | uuid = require('uuid'); | 14 | uuid = require('uuid'); |
15 | +const yoho = require('yoho-app'); | ||
15 | 16 | ||
16 | let installment = { | 17 | let installment = { |
17 | init: function() { | 18 | init: function() { |
@@ -206,4 +207,14 @@ $(window).load(function() { | @@ -206,4 +207,14 @@ $(window).load(function() { | ||
206 | 207 | ||
207 | $(function() { | 208 | $(function() { |
208 | installment.init(); | 209 | installment.init(); |
210 | + | ||
211 | + // 商品曝光事件上报 | ||
212 | + if (yoho.isApp) { | ||
213 | + let GoodsShowYasRpter = require('common/goods-show-yas-rpter').default; | ||
214 | + | ||
215 | + new GoodsShowYasRpter({ | ||
216 | + goodsContainer: $('#goods-list'), | ||
217 | + goodsSelectorStr: '.good-info' | ||
218 | + }); | ||
219 | + } | ||
209 | }); | 220 | }); |
@@ -476,3 +476,13 @@ $(function() { | @@ -476,3 +476,13 @@ $(function() { | ||
476 | }); | 476 | }); |
477 | 477 | ||
478 | require('./seckill/goods-list'); | 478 | require('./seckill/goods-list'); |
479 | + | ||
480 | +// 商品曝光事件上报 | ||
481 | +if (yoho.isApp) { | ||
482 | + let GoodsShowYasRpter = require('common/goods-show-yas-rpter').default; | ||
483 | + | ||
484 | + new GoodsShowYasRpter({ | ||
485 | + goodsContainer: $('#container'), | ||
486 | + goodsSelectorStr: '.good-info' | ||
487 | + }); | ||
488 | +} |
-
Please register or login to post a comment