Authored by 郭成尧

goods-show-yas-reporter

... ... @@ -13,10 +13,10 @@ const isTest = process.env.NODE_ENV === 'test';
const domains = {
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
// gray
// api: 'http://apigray.yoho.cn/',
... ... @@ -24,10 +24,10 @@ const domains = {
// platformApi: 'http://172.16.6.210:8088/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/',
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/',
imSocket: 'ws://socket.yohobuy.com:10240',
imCs: 'http://im.yohobuy.com/api',
... ...
... ... @@ -10,7 +10,7 @@ global.jQuery = $;
let isAndroid = /(Android)/i.test(navigator.userAgent);
let isWechat = /micromessenger/i.test(navigator.userAgent);
lazyLoad($('img.lazy'), {q: 85});
lazyLoad($('img.lazy'), { q: 85 });
function swiperInit() {
$('.swiper-container').each(function() {
... ... @@ -312,4 +312,7 @@ $(function() {
if (window.__wxjs_environment === 'miniprogram') {
require('./miniprogram');
}
// 商品曝光事件上报
require('./feature/goods-show-yas-rpter');
});
... ...
import yohoApp from 'yoho-app';
class GoodsShowYasRpter {
constructor() {
this.timer = null;
this.reportData = {
P_NAME: this.getPname(),
P_PARAM: location.href,
F_INDEX: 1,
I_INDEX: 1,
PRD_SKN: 11111111,
C_ID: window._ChannelVary[window.cookie('_Channel')]
};
window.onscroll = () => {
this.reportCtl();
};
this.report();
}
reportCtl() {
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(() => {
this.report();
}, 3 * 1000);
}
report() {
$('.product-container').each((pcIndex, pCont) => {
let $pCont = $(pCont);
if ($.inviewport($pCont, { threshold: 0 })) {
$pCont.find('.feature-product-info').each((pIindex, elem) => {
console.log($.inviewport($(elem), { threshold: 0 }));
});
}
});
}
getPname() {
let pName = '';
if (yohoApp.isiOS) {
pName = 'iFP_SalesPromotion';
}
if (yohoApp.isAndroid) {
pName = 'aFP_SalesPromotion';
}
return pName;
}
}
export default new GoodsShowYasRpter();
... ...