Authored by 孙凯

add 大数据曝光 review by jianqiu

... ... @@ -81,8 +81,6 @@ export function setShowSimilarGuider(requestNative, show=false) {
if (requestNative) {
ReactNative.NativeModules.YH_CommonHelper.showSimilarGuider()
.then(data => {
console.log('showSimilarGuider')
console.log(data)
dispatch( {
type: SET_SHOW_SIMILAR_GUIDER,
payload: data,
... ...
... ... @@ -45,9 +45,9 @@ export default class MineList extends React.Component {
productListForMineCenter,
} = this.props;
let similarIndex = productListForMineCenter.similarIndex;
let showSimilarGuider = this.props.showSimilarGuider
&& this.state.scrollEnd
&& rowID == this.state.selectedVisibleIndex
let showSimilarGuider = this.props.showSimilarGuider
&& this.state.scrollEnd
&& rowID == this.state.selectedVisibleIndex
&& rowID != similarIndex;
return (
<ProductListCell
... ... @@ -101,7 +101,7 @@ export default class MineList extends React.Component {
let rowIndexs = Object.keys(visibleRows[targetSection]);
if (rowIndexs.length > 0) {
selectedIndex = rowIndexs[0];
}
}
if (rowIndexs.length > 3) {
selectedIndex = rowIndexs[2];
}
... ... @@ -132,13 +132,17 @@ export default class MineList extends React.Component {
announcement,
globalOrderData
} = this.props;
let dataSource = productListForMineCenter.list.toArray();
return (
<View style={styles.container}>
<ListView
ref={(c) => {
this.listView = c;
}}
yh_viewVisible = {true}
contentContainerStyle={styles.contentContainer}
enableEmptySections={true}
dataSource={this.dataSource.cloneWithRows(dataSource)}
... ...
... ... @@ -329,8 +329,14 @@ export function getProductListForMineCenter() {
dispatch(productListForMineCenterRequest());
return new MineService(app.host).fetchMineCenterProductList()
.then(json => {
dispatch(productListForMineCenterSuccess(json));
dispatch(reportFavoriteData(json));
let res = json;
try {
res = exposePruductListData(json,app.channel);
} catch (e) {
} finally {
}
dispatch(productListForMineCenterSuccess(res));
dispatch(reportFavoriteData(res));
})
.catch(error => {
dispatch(productListForMineCenterFailure());
... ... @@ -338,6 +344,50 @@ export function getProductListForMineCenter() {
}
}
function exposePruductListData(json,channel) {
let list = json?json.product_list:[];
let rec_id = json?json.rec_id:'';
let res = json;
if (!list) {
return list;
}
let rec_pose = '';
if (channel == '1') {
rec_pose = '100001';
}else if (channel == '2'){
rec_pose = '100002';
}else if (channel == '3'){
rec_pose = '100006';
}else if (channel == '4'){
rec_pose = '100011';
}
let pageName = 'iFP_My';
if (Platform.OS === 'android') {
pageName = 'aFP_My';
}
for (var i = 0; i < list.length; i++) {
let item = list[i];
let skn = item.product_skn;
let inFloorIndex = parseInt(i) + 1 + '';
let params = {
P_NAME : pageName,
I_INDEX : inFloorIndex,
PRD_SKN : skn,
REC_POS : rec_pose,
REC_ID : rec_id,
exposureEnd : 1,
};
item.yh_exposureData = params;
}
res.product_list = list;
return res;
}
function reportFavoriteData(payload) {
return (dispatch, getState) => {
try {
... ... @@ -747,4 +797,4 @@ export function getNewCouponInfo() {
.catch(error => {
});
}
}
\ No newline at end of file
}
... ...
... ... @@ -31,6 +31,8 @@ export default class ProductListCell extends Component {
let src = data.get('src');
let article_id = data.get('id');
let show10K = false;
let yh_exposureData = data.get('yh_exposureData')?data.get('yh_exposureData').toJS():null;
if (browse>10000) {
browse = browse/10000.0;
if (browse >= 100) {
... ... @@ -45,6 +47,7 @@ export default class ProductListCell extends Component {
return (
<TouchableOpacity
style={[styles.container, style]}
yh_exposureData={yh_exposureData}
activeOpacity={1}
onPress={() => {
this.props.onPressArticle && this.props.onPressArticle(url, index, article_id);
... ...
... ... @@ -60,11 +60,13 @@ export default class Banner extends React.Component {
let data = this.props.data.toArray();
width = Math.ceil(width);
height = Math.ceil(height);
let list = this.props.data?this.props.data.toJS():[];
if (data.length == 1) {
let yh_exposureData = list[0].yh_exposureData;
return (
<TouchableOpacity
activeOpacity={1}
yh_exposureData={yh_exposureData}
style={{width: width, height: height}}
onPress={() => {
this.props.onPress && this.props.onPress(data[0].get('url'), 0);
... ... @@ -94,9 +96,13 @@ export default class Banner extends React.Component {
if (!item.get('src')) {
return null;
}
let yh_exposureData = item.yh_exposureData?item.yh_exposureData.toJS():null;
console.log(yh_exposureData);
return (
<TouchableOpacity
key={i}
yh_exposureData={yh_exposureData}
activeOpacity={1}
onPress={() => {
this.props.onPress && this.props.onPress(item.get('url'), i);
... ...
... ... @@ -28,8 +28,9 @@ export default class BrandCell extends Component {
let shops_id = data.get('shops_id');
let new_product_num = data.get('new_product_num');
shop_logo = shop_logo?shop_logo.replace('{width}', 166).replace('{height}', 68).replace('{mode}',2):'';
let yh_exposureData = data.get('yh_exposureData');
return (
<TouchableOpacity style={styles.container} onPress={()=>{this.props.onPressShop&&this.props.onPressShop(data, index);}}>
<TouchableOpacity style={styles.container} yh_exposureData={yh_exposureData} onPress={()=>{this.props.onPressShop&&this.props.onPressShop(data, index);}}>
<View style={{flex:1}}>
<Image style={styles.image} source={{uri:shop_logo}}/>
<View style={styles.footerContainer}>
... ...
... ... @@ -99,7 +99,10 @@ export default class NewArrival extends Component {
data.push(src);
}
}
let list = rowData?rowData.toJS():[];
console.log(list);
if(data.length==1){
let yh_exposureData = list[0].yh_exposureData;
return (
<View style={{
width,
... ... @@ -111,6 +114,7 @@ export default class NewArrival extends Component {
精选抢先看
</Text>
<TouchableOpacity
yh_exposureData={yh_exposureData}
activeOpacity={0.8}
onPress={() => {
let item = rowData.get(0);
... ... @@ -128,7 +132,8 @@ export default class NewArrival extends Component {
</View>
)
}else if(data.length==2){
let yh_exposureData0 = list[0].yh_exposureData;
let yh_exposureData1 = list[1].yh_exposureData;
return (
<View style={{
width,
... ... @@ -147,6 +152,7 @@ export default class NewArrival extends Component {
}}>
<TouchableOpacity
activeOpacity={0.8}
yh_exposureData={yh_exposureData0}
onPress={() => {
let item = rowData.get(0);
let url = item.get('url');
... ... @@ -161,6 +167,7 @@ export default class NewArrival extends Component {
</TouchableOpacity>
<TouchableOpacity
activeOpacity={0.8}
yh_exposureData={yh_exposureData1}
onPress={() => {
let item = rowData.get(1);
let url = item.get('url');
... ... @@ -185,7 +192,7 @@ export default class NewArrival extends Component {
}}>
<FeaturedView
style={styles.carouselSection}
items={data}
items={list}
onClick={(info) => {
let item = rowData.get(info.index);
let url = item.get('url');
... ... @@ -206,6 +213,7 @@ export default class NewArrival extends Component {
let recommend_type = rowData.get('recommend_type');
let data = rowData.get('data');
let yh_exposureDataList = rowData.get('yh_exposureDataList');
let paddingLeft = rowID % 2 == 1 ? rowMarginHorizontal / 2 : rowMarginHorizontal;
let customStyle = rowID == 0 || rowID == 1 ? {paddingLeft} : {paddingLeft};
... ... @@ -213,12 +221,13 @@ export default class NewArrival extends Component {
if (recommend_type == 'hotSearchTerm' || recommend_type == 'seasonSort') {
return (
<TagsCell
style={[styles.listContainer, customStyle]}
recommend_type={recommend_type}
data={data}
index={rowID}
onPressCategory={this.props.onPressCategory}
onPressHotSearch={this.props.onPressHotSearch}
style={[styles.listContainer, customStyle]}
recommend_type={recommend_type}
data={data}
yh_exposureDataList={yh_exposureDataList}
index={rowID}
onPressCategory={this.props.onPressCategory}
onPressHotSearch={this.props.onPressHotSearch}
/>
)
}
... ... @@ -238,7 +247,6 @@ export default class NewArrival extends Component {
productList,
} = this.props;
let similarIndex = productList.get('similarIndex');
return (
<BrandProductListCell
style={[styles.listContainer, customStyle]}
... ... @@ -338,6 +346,7 @@ export default class NewArrival extends Component {
ref={(c) => {
this.listView = c;
}}
yh_viewVisible = {true}
contentContainerStyle={styles.contentContainer}
dataSource={this.dataSource.cloneWithRowsAndSections(dataSource)}
renderRow={this._renderRow}
... ...
... ... @@ -28,6 +28,7 @@ export default class ProductListCell extends Component {
let shop_logo = data.get('shop_logo');
let shop_name = data.get('shop_name');
let new_product_num = data.get('new_product_num');
let yh_exposureData = data.get('yh_exposureData')?data.get('yh_exposureData').toJS():null;
if (!shop_logo||!shop_name) {
return null;
... ... @@ -37,6 +38,7 @@ export default class ProductListCell extends Component {
<TouchableOpacity
style={[styles.container, style]}
activeOpacity={1}
yh_exposureData={yh_exposureData}
onPress={() => {
this.props.onPressShop && this.props.onPressShop(data, rowID);
}}
... ...
... ... @@ -38,7 +38,8 @@ export default class ProductListCell extends Component {
}
render() {
let {data, index, recommend_type, style} = this.props;
let {data, index, recommend_type, style,yh_exposureDataList} = this.props;
let yh_exposureDatas = yh_exposureDataList?yh_exposureDataList.toJS():null;
return (
<TouchableOpacity
style={[styles.container, style]}
... ... @@ -52,15 +53,18 @@ export default class ProductListCell extends Component {
return;
}
let str = '';
let yh_exposureData = null;
if (recommend_type == 'seasonSort') {
str = item.get('categoryName');
yh_exposureData = item.get('yh_exposureData')?item.get('yh_exposureData').toJS():null;
}
if (recommend_type == 'hotSearchTerm') {
str = item;
yh_exposureData = yh_exposureDatas[i];
}
return (
<View style={styles.tag} key={i}>
<TouchableOpacity style={styles.button} onPress={()=>{
<TouchableOpacity style={styles.button} yh_exposureData={yh_exposureData} onPress={()=>{
if (recommend_type == 'seasonSort') {
this.props.onPressCategory&&this.props.onPressCategory(item, i ,index);
}
... ...
... ... @@ -95,7 +95,7 @@ class NewArrivalContainer extends Component {
}
_onPressDislike() {
}
_onEndReached() {
... ...
'use strict';
import ReactNative from 'react-native';
import ReactNative, {
Platform,
} from 'react-native';
import NewArrivalService from '../../services/NewArrivalService';
import * as _ from 'lodash';
... ... @@ -73,6 +76,7 @@ export function getTopInfo() {
data,
template_name,
} = ads[i];
if (data.length && template_name == 'focus') {
first_part = data;
}
... ... @@ -81,6 +85,16 @@ export function getTopInfo() {
}
}
}
try {
first_part = exposeBannerData(first_part,'first_part',app.channel);
shop_list = exposeBannerData(shop_list,'shop_list',app.channel)
second_part = exposeBannerData(second_part,'second_part',app.channel)
} catch (e) {
} finally {
}
let newJson = {
first_part,
shop_list,
... ... @@ -221,8 +235,7 @@ export function getProductList(reload=false) {
dispatch(productListRequest());
return new NewArrivalService(app.host).fetchProductList(channel, order, page, pageSize, allFilterFactors)
.then(json => {
let payload = parseProductList(json);
let payload = parseProductList(json,order,channel);
payload.endReached = payload.currentPage == payload.pageCount;
let LIST = [];
for (var i = 0; i < payload.list.length; i++) {
... ... @@ -301,6 +314,7 @@ export function getProductList(reload=false) {
}];
// console.log(logData);
dispatch(newArrivalExposure(logData));
if (payload.currentPage > 1) {
let oldList = productList.list.toJS();
let list = [...oldList, ...payload.list];
... ... @@ -560,13 +574,21 @@ export function goToRecommendForYou() {
};
}
function parseProductList(json) {
function parseProductList(json,order,channel) {
let list = json && json.product_list ? json.product_list : [];
try {
list = exposePruductListData(list,order,channel);
} catch (e) {
} finally {
}
let currentPage = json && json.page ? json.page : 1;
let pageCount = json && json.page_total ? json.page_total : 0;
let total = json && json.total ? json.total : 0;
let filter = json && json.filter ? json.filter : {};
let list = json && json.product_list ? json.product_list : [];
let filterCategoryDetailFilterList = {};
let categoryFilterList = [];
... ... @@ -766,6 +788,198 @@ function parseProductList(json) {
};
}
function exposeBannerData(data,type,channel) {
let pageName = 'iFP_NewArrival';
if (Platform.OS === 'android') {
pageName = 'aFP_NewArrival';
}
let channelStr = 'boy';
if (channel == '1') {
channelStr = 'boy';
}else if (channel == '2') {
channelStr = 'girl';
}else if (channel == '3') {
channelStr = 'kid';
}else if (channel == '4') {
channelStr = 'leftStyle';
}
if (type == 'first_part') {
for (var i = 0; i < data.length; i++) {
let item = data[i];
let params = {
P_NAME: pageName,
P_PARAM: channelStr,
I_INDEX: parseInt(i) + 1 + '',
ACTION_URL: item.url,
C_ID: channel,
exposureEnd : 1,
};
item.yh_exposureData = params;
}
}else if (type == 'shop_list') {
for (var i = 0; i < data.length; i++) {
let item = data[i];
let params = {
P_NAME: pageName,
P_PARAM: channelStr,
I_INDEX: parseInt(i) + 1 + '',
BRAND_ID: item.brand_id,
SHOP_ID: item.shops_id,
C_ID: channel,
exposureEnd : 1,
};
item.yh_exposureData = params;
}
}else if (type == 'second_part') {
for (var i = 0; i < data.length; i++) {
let item = data[i];
let params = {
P_NAME: pageName,
P_PARAM: channelStr,
I_INDEX: parseInt(i) + 1 + '',
ACTION_URL: item.url,
C_ID: channel,
exposureEnd : 1,
};
item.yh_exposureData = params;
}
}
return data;
}
function exposePruductListData(list,order,channel) {
if (!list) {
return list;
}
let tab_name = '最新';
let tab_num = 0;
if (order == 's_t_desc') {
tab_name = '最新';
tab_num = 0;
}
if (order == 's_p_asc' || order == 's_p_desc') {
tab_name = '价格';
tab_num = 1;
}
if (order == 'p_d_asc' || order == 'p_d_desc') {
tab_name = '折扣';
tab_num = 2;
}
let pageName = 'iFP_NewArrival';
if (Platform.OS === 'android') {
pageName = 'aFP_NewArrival';
}
let channelStr = 'boy';
if (channel == '1') {
channelStr = 'boy';
}else if (channel == '2') {
channelStr = 'girl';
}else if (channel == '3') {
channelStr = 'kid';
}else if (channel == '4') {
channelStr = 'leftStyle';
}
for (var i = 0; i < list.length; i++) {
let item = list[i];
let recommend_type = item.recommend_type;
if (recommend_type == 'hotSearchTerm') {
let inFloorIndex = parseInt(i) + 1 + '';
let yh_exposureData = [];
for (var j = 0; j < item.data.length; j++) {
let f_item = item.data[j];
let keyword = f_item;
let categoryId = f_item.categoryId;
let params = {
P_NAME: pageName,
P_PARAM: channelStr,
TAB_ID: tab_num,
TAB_NAME: tab_name,
I_INDEX: inFloorIndex,
L_INDEX: parseInt(j) + 1 + '',
C_ID: channel,
KEYWORD: keyword,
exposureEnd : 1,
};
yh_exposureData.push(params);
}
item.yh_exposureDataList = yh_exposureData;
}else if (recommend_type == 'seasonSort') {
let inFloorIndex = parseInt(i) + 1 + '';
for (var j = 0; j < item.data.length; j++) {
let f_item = item.data[j];
let url = f_item.url;
let categoryId = f_item.categoryId;
let params = {
P_NAME: pageName,
P_PARAM: channelStr,
TAB_ID: tab_num,
TAB_NAME: tab_name,
I_INDEX: inFloorIndex,
L_INDEX: parseInt(j) + 1 + '',
C_ID: channel,
ACTION_URL: url,
L1_CATE_ID: categoryId,
exposureEnd : 1,
};
f_item.yh_exposureData = params;
}
}else if (recommend_type == 'hotShop') {
let inFloorIndex = parseInt(i) + 1 + '';
let brandID = item.data.brand_id;
let params = {
P_NAME: pageName,
P_PARAM: channelStr,
TAB_ID: tab_num,
TAB_NAME: tab_name,
I_INDEX: inFloorIndex,
BRAND_ID: brandID,
C_ID: channel,
exposureEnd : 1,
};
item.data.yh_exposureData = params;
}else if (recommend_type == 'fashionArticle') {
let inFloorIndex = parseInt(i) + 1 + '';
let article_id = item.data.id;
let params = {
P_NAME: pageName,
P_PARAM: channelStr,
TAB_ID: tab_num,
TAB_NAME: tab_name,
I_INDEX: inFloorIndex,
ARTICLE_ID: article_id,
C_ID: channel,
exposureEnd : 1,
};
item.data.yh_exposureData = params;
}else {
let skn = item.product_skn;
let inFloorIndex = parseInt(i) + 1 + '';
let params = {
P_NAME : pageName,
I_INDEX : inFloorIndex,
PRD_SKN : skn,
TAB_NAM : tab_name,
TAB_ID : tab_num,
P_PARAM : channelStr,
C_ID: channel,
exposureEnd : 1,
};
item.yh_exposureData = params;
}
}
return list;
}
/**
* 按照数组中指定字段排序二维数组
*
... ...