goods-show-yas-reporter
Showing
3 changed files
with
71 additions
and
9 deletions
@@ -13,10 +13,10 @@ const isTest = process.env.NODE_ENV === 'test'; | @@ -13,10 +13,10 @@ const isTest = process.env.NODE_ENV === 'test'; | ||
13 | 13 | ||
14 | const domains = { | 14 | const domains = { |
15 | 15 | ||
16 | - // api: 'http://api.yoho.cn/', | ||
17 | - // service: 'http://service.yoho.cn/', | ||
18 | - // liveApi: 'http://testapi.live.yohops.com:9999/', | ||
19 | - // singleApi: 'http://api-test3.yohops.com:9999/', | 16 | + api: 'http://api.yoho.cn/', |
17 | + service: 'http://service.yoho.cn/', | ||
18 | + liveApi: 'http://testapi.live.yohops.com:9999/', | ||
19 | + singleApi: 'http://api-test3.yohops.com:9999/', | ||
20 | 20 | ||
21 | // gray | 21 | // gray |
22 | // api: 'http://apigray.yoho.cn/', | 22 | // api: 'http://apigray.yoho.cn/', |
@@ -24,10 +24,10 @@ const domains = { | @@ -24,10 +24,10 @@ const domains = { | ||
24 | // platformApi: 'http://172.16.6.210:8088/', | 24 | // platformApi: 'http://172.16.6.210:8088/', |
25 | 25 | ||
26 | 26 | ||
27 | - api: 'http://api-test3.yohops.com:9999/', | ||
28 | - service: 'http://service-test3.yohops.com:9999/', | ||
29 | - liveApi: 'http://testapi.live.yohops.com:9999/', | ||
30 | - singleApi: 'http://api-test3.yohops.com:9999/', | 27 | + // api: 'http://api-test3.yohops.com:9999/', |
28 | + // service: 'http://service-test3.yohops.com:9999/', | ||
29 | + // liveApi: 'http://testapi.live.yohops.com:9999/', | ||
30 | + // singleApi: 'http://api-test3.yohops.com:9999/', | ||
31 | 31 | ||
32 | imSocket: 'ws://socket.yohobuy.com:10240', | 32 | imSocket: 'ws://socket.yohobuy.com:10240', |
33 | imCs: 'http://im.yohobuy.com/api', | 33 | imCs: 'http://im.yohobuy.com/api', |
@@ -10,7 +10,7 @@ global.jQuery = $; | @@ -10,7 +10,7 @@ global.jQuery = $; | ||
10 | let isAndroid = /(Android)/i.test(navigator.userAgent); | 10 | let isAndroid = /(Android)/i.test(navigator.userAgent); |
11 | let isWechat = /micromessenger/i.test(navigator.userAgent); | 11 | let isWechat = /micromessenger/i.test(navigator.userAgent); |
12 | 12 | ||
13 | -lazyLoad($('img.lazy'), {q: 85}); | 13 | +lazyLoad($('img.lazy'), { q: 85 }); |
14 | 14 | ||
15 | function swiperInit() { | 15 | function swiperInit() { |
16 | $('.swiper-container').each(function() { | 16 | $('.swiper-container').each(function() { |
@@ -312,4 +312,7 @@ $(function() { | @@ -312,4 +312,7 @@ $(function() { | ||
312 | if (window.__wxjs_environment === 'miniprogram') { | 312 | if (window.__wxjs_environment === 'miniprogram') { |
313 | require('./miniprogram'); | 313 | require('./miniprogram'); |
314 | } | 314 | } |
315 | + | ||
316 | + // 商品曝光事件上报 | ||
317 | + require('./feature/goods-show-yas-rpter'); | ||
315 | }); | 318 | }); |
1 | + | ||
2 | +import yohoApp from 'yoho-app'; | ||
3 | + | ||
4 | +class GoodsShowYasRpter { | ||
5 | + constructor() { | ||
6 | + this.timer = null; | ||
7 | + | ||
8 | + this.reportData = { | ||
9 | + P_NAME: this.getPname(), | ||
10 | + P_PARAM: location.href, | ||
11 | + F_INDEX: 1, | ||
12 | + I_INDEX: 1, | ||
13 | + PRD_SKN: 11111111, | ||
14 | + C_ID: window._ChannelVary[window.cookie('_Channel')] | ||
15 | + }; | ||
16 | + window.onscroll = () => { | ||
17 | + this.reportCtl(); | ||
18 | + }; | ||
19 | + this.report(); | ||
20 | + } | ||
21 | + | ||
22 | + reportCtl() { | ||
23 | + if (this.timer) { | ||
24 | + clearTimeout(this.timer); | ||
25 | + } | ||
26 | + | ||
27 | + this.timer = setTimeout(() => { | ||
28 | + this.report(); | ||
29 | + }, 3 * 1000); | ||
30 | + } | ||
31 | + | ||
32 | + report() { | ||
33 | + $('.product-container').each((pcIndex, pCont) => { | ||
34 | + let $pCont = $(pCont); | ||
35 | + | ||
36 | + if ($.inviewport($pCont, { threshold: 0 })) { | ||
37 | + $pCont.find('.feature-product-info').each((pIindex, elem) => { | ||
38 | + console.log($.inviewport($(elem), { threshold: 0 })); | ||
39 | + }); | ||
40 | + } | ||
41 | + }); | ||
42 | + } | ||
43 | + | ||
44 | + getPname() { | ||
45 | + let pName = ''; | ||
46 | + | ||
47 | + if (yohoApp.isiOS) { | ||
48 | + pName = 'iFP_SalesPromotion'; | ||
49 | + } | ||
50 | + | ||
51 | + if (yohoApp.isAndroid) { | ||
52 | + pName = 'aFP_SalesPromotion'; | ||
53 | + } | ||
54 | + | ||
55 | + return pName; | ||
56 | + } | ||
57 | +} | ||
58 | + | ||
59 | +export default new GoodsShowYasRpter(); |
-
Please register or login to post a comment