Authored by 于良

领券中心、经典店铺数据曝光 review by 盖剑秋

... ... @@ -186,6 +186,12 @@ export function getShopInfo() {
return new BrandStoreService(app.host).fetchShopInfo(shopId, uid)
.then(json => {
dispatch(shopInfoSuccess(json));
// 数据曝光
let params = {
SHOP_ID: json.shops_id ? json.shops_id : '0',
}
dispatch(shopDataExposure('YB_SHOW_CLASSICAL_SHOP_INFO', params));
})
.catch(error => {
dispatch(shopInfoFailure(error));
... ... @@ -202,6 +208,16 @@ export function getShopInfo() {
};
}
function shopDataExposure(eventName, data) {
return (dispatch, getState) => {
let params = {
DATA: data,
};
// console.log(eventName)
// console.log(params)
ReactNative.NativeModules.YH_CommonHelper.logEvent(eventName, params);
};
}
export function shopResourceRequest() {
return {
... ... @@ -243,6 +259,8 @@ export function getShopResources() {
dispatch(getHotProduct());
dispatch(getProductList());
// 数据曝光
dispatch(shopDataExposure('YB_SHOW_CLASSICAL_SHOP_RESOURCE_LIST', ''));
})
.catch(error => {
dispatch(shopResourcesFailure(error));
... ... @@ -296,7 +314,8 @@ export function getShopCouponList() {
return new BrandStoreService(app.host).fetchShopCouponList(shopId, uid)
.then(json => {
let payload = parseCouponList(json);
dispatch(shopCouponListSuccess(payload));
dispatch(shopCouponListSuccess(payload.shopCoupons));
dispatch(shopDataExposure('YB_SHOW_CLASSICAL_SHOP_COUPON_LIST', payload.logShopCoupons))
})
.catch(error => {
dispatch(shopCouponListFailure(error));
... ... @@ -319,6 +338,7 @@ function parseCouponList(json) {
}
let shopCoupons = [];
let logShopCoupons = [];
_.forEach(json, value => {
let couPonstatus = parseInt(value.status, 10);
... ... @@ -332,10 +352,17 @@ function parseCouponList(json) {
money: parseInt(value.money, 10),
status: couPonstatus === 1
});
logShopCoupons.push({
COUPON_ID: value.coupon_id,
});
}
});
return shopCoupons;
return {
shopCoupons,
logShopCoupons,
};
}
export function hotProductRequest() {
... ... @@ -379,6 +406,17 @@ export function getHotProduct() {
});
let payload = json.product_list;
dispatch(hotProductSuccess(payload));
// 数据曝光
let logData = [];
payload && payload.map((item, i) => {
logData.push({
I_INDEX: i,
IMAGE_URL: item.default_images ? item.default_images : '',
PRODUCT_SKN: item.product_skn ? item.product_skn : 0,
});
});
dispatch(shopDataExposure('YB_SHOW_CLASSICAL_SHOP_HOT_PRODUCT_LIST', logData))
})
.catch(error => {
dispatch(hotProductFailure(error));
... ... @@ -805,6 +843,17 @@ export function getProductListForPersopn(reload=false) {
payload.list = list;
}
dispatch(productListForPersonSuccess(payload));
// 数据曝光
let logData = [];
payload.list && payload.list.map((item, i) => {
logData.push({
I_INDEX: i,
IMAGE_URL: item.default_images ? item.default_images : '',
PRODUCT_SKN: item.product_skn ? item.product_skn : 0,
});
});
dispatch(shopDataExposure('YB_SHOW_CLASSICAL_SHOP_HOT_TAB_PRODUCT_LIST', logData));
})
.catch(error => {
dispatch(productListForPersonFailure(error));
... ... @@ -867,6 +916,18 @@ export function getProductListForNew(reload=false) {
payload.list = list;
}
dispatch(productListForNewSuccess(payload));
// 数据曝光
let logData = [];
payload.list && payload.list.map((item, i) => {
logData.push({
I_INDEX: i,
IMAGE_URL: item.default_images ? item.default_images : '',
PRODUCT_SKN: item.product_skn ? item.product_skn : 0,
});
});
dispatch(shopDataExposure('YB_SHOW_CLASSICAL_NEW_TAB_PRODUCT_LIST', logData));
})
.catch(error => {
dispatch(productListForNewFailure(error));
... ...
... ... @@ -77,7 +77,8 @@ export function couponCenter(reload = false) {
payload = parseFloors(json);
}
dispatch(couponCenterSuccess(payload));
dispatch(couponCenterSuccess(payload.floors));
dispatch(dataExposure(payload.logFloors));
})
.catch(error => {
dispatch(couponCenterFailure(error));
... ... @@ -146,6 +147,7 @@ function parseFloors(json) {
};
let floors = [];
let logFloors = [];
json && json.map((item, i) => {
let templateName = item.template_name;
if (!templateName) {
... ... @@ -158,22 +160,54 @@ function parseFloors(json) {
}
let data;
let logData = [];
if (templateName == 'carousel_banner') {
data = carousel_banner(item.data);
data.map((item, i) => {
logData.push({
I_INDEX: i,
IMAGE_URL: item.url,
ACTION_URL: item.src,
});
});
} else if (templateName == 'focus') {
data = focus(item.data);
data.map((item, i) => {
logData.push({
I_INDEX: i,
IMAGE_URL: item.url,
ACTION_URL: item.src,
});
});
} else if (templateName == 'text') {
data = text(item.data);
logData.push({
I_INDEX: 0,
TEXT: data,
});
} else if (templateName == 'single_image') {
data = single_image(item.data);
logData.push({
I_INDEX: 0,
IMAGE_URL: data.url,
ACTION_URL: data.src,
});
} else if (templateName == 'getCoupon') {
data = getCoupon(item.data);
if(!data.couponID){
if(floors.length>1){
if(floors[floors.length-1].templateName=='text'){
floors.pop();
logFloors.pop();
}
}
} else {
logData.push({
I_INDEX: 0,
IMAGE_URL: data.image.url,
ACTION_URL: data.image.src,
COUPON_ID: data.couponID,
});
}
}
... ... @@ -183,9 +217,29 @@ function parseFloors(json) {
templateId,
};
floors.push(floor);
let logFloor = {
"F_NAME" : templateName,
"F_ID" : templateId,
"LIST" : logData,
};
logFloors.push(logFloor);
});
return floors;
return {
floors,
logFloors,
};
}
function dataExposure(data) {
return (dispatch, getState) => {
let params = {
DATA: data,
};
console.log(params)
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_SHOW_COUPON_CENTER', params);
};
}
export function getCouponRequest() {
... ...