...
|
...
|
@@ -10,13 +10,10 @@ import * as _ from 'lodash'; |
|
|
const {
|
|
|
SET_CHANNEL,
|
|
|
|
|
|
RECOMMEND_SHOP_REQUEST,
|
|
|
RECOMMEND_SHOP_SUCCESS,
|
|
|
RECOMMEND_SHOP_FAILURE,
|
|
|
|
|
|
RECOMMEND_BRAND_REQUEST,
|
|
|
RECOMMEND_BRAND_SUCCESS,
|
|
|
RECOMMEND_BRAND_FAILURE,
|
|
|
|
|
|
GET_SHOPCARTCOUNT_REQUEST,
|
|
|
GET_SHOPCARTCOUNT_SUCCESS,
|
|
|
GET_SHOPCARTCOUNT_FAILURE,
|
...
|
...
|
@@ -31,9 +28,16 @@ const { |
|
|
PRODUCT_FILTER_ACTION,
|
|
|
SET_SIMILAR_PRODUCT_INDEX,
|
|
|
SET_SHOW_SIMILAR_GUIDER,
|
|
|
UPDATE_MORE_FILTER_SELECTED_ORDER,
|
|
|
UPDATE_MORE_FILTER_SELECTED_ORDER,
|
|
|
|
|
|
FILTER_DATA_SUCCESS,
|
|
|
|
|
|
STORE_CURRENT_TAB_VALUE,
|
|
|
SET_PRODUCT_PARAMS,
|
|
|
|
|
|
FILTER_DATA_SUCCESS,
|
|
|
RESOURCE_INFO_REQUEST,
|
|
|
RESOURCE_INFO_SUCCESS,
|
|
|
RESOURCE_INFO_FAILURE,
|
|
|
} = require('../../constants/actionTypes').default;
|
|
|
|
|
|
|
...
|
...
|
@@ -64,201 +68,170 @@ export function setShowSimilarGuider(requestNative, show=false) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
export function getTopInfo() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app} = getState();
|
|
|
dispatch(topInfoRequest());
|
|
|
return new NewArrivalService(app.host).fetchRecommendShop(app.channel)
|
|
|
.then(json => {
|
|
|
let {
|
|
|
shop_list,
|
|
|
ads,
|
|
|
} = json;
|
|
|
let first_part = [];
|
|
|
let second_part = [];
|
|
|
if (ads&&ads.length) {
|
|
|
for (var i = 0; i < ads.length; i++) {
|
|
|
let {
|
|
|
data,
|
|
|
template_name,
|
|
|
} = ads[i];
|
|
|
|
|
|
if (data.length && template_name == 'focus') {
|
|
|
first_part = data;
|
|
|
}
|
|
|
if (data.length && template_name == 'single_image') {
|
|
|
second_part = data;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
export function storeCurrentTabValue(index, tabName, queryList) {
|
|
|
return (dispatch, getState) => {
|
|
|
dispatch({
|
|
|
type: STORE_CURRENT_TAB_VALUE,
|
|
|
payload: {index, tabName, queryList},
|
|
|
});
|
|
|
|
|
|
try {
|
|
|
first_part = exposeBannerData(first_part,'first_part',app.channel);
|
|
|
} catch (e) {
|
|
|
let paramsDic={};
|
|
|
queryList && queryList.map((item, index) => {
|
|
|
let res = {
|
|
|
...paramsDic,
|
|
|
...item,
|
|
|
}
|
|
|
paramsDic = res;
|
|
|
})
|
|
|
dispatch(getProductList(paramsDic));
|
|
|
};
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
export function getResourceInfoRequest() {
|
|
|
return {
|
|
|
type: RESOURCE_INFO_REQUEST,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
}
|
|
|
export function getResourceInfoSuccess(json) {
|
|
|
return {
|
|
|
type: RESOURCE_INFO_SUCCESS,
|
|
|
payload: json
|
|
|
};
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
shop_list = exposeBannerData(shop_list,'shop_list',app.channel)
|
|
|
} catch (e) {
|
|
|
export function getResourceInfoFailure(error) {
|
|
|
return {
|
|
|
type: RESOURCE_INFO_FAILURE,
|
|
|
payload: error
|
|
|
};
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
export function getResourceInfo(callback) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app} = getState();
|
|
|
dispatch(getResourceInfoRequest());
|
|
|
return new NewArrivalService(app.host).fetchResourceInfo('1f2e07cb63811680154ba693c954dd62')
|
|
|
.then(json => {
|
|
|
let newJson = exposeResourceInfoData(json);
|
|
|
|
|
|
for (let i = 0; i< json.length; i++) {
|
|
|
let item = json[i]
|
|
|
let floorname = item.template_name
|
|
|
let floorid = item.template_id
|
|
|
if (floorname === 'guessLike') {
|
|
|
dispatch(setProductParams(floorid, floorname, i + 1));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
callback && typeof callback === 'function' && callback(newJson)
|
|
|
dispatch(getResourceInfoSuccess(newJson));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(getResourceInfoFailure(error));
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
}
|
|
|
try {
|
|
|
second_part = exposeBannerData(second_part,'second_part',app.channel)
|
|
|
} catch (e) {
|
|
|
function exposeResourceInfoData(json) {
|
|
|
|
|
|
} finally {
|
|
|
if (!json) return json;
|
|
|
|
|
|
try {
|
|
|
let pageName = Platform.OS === 'android' ? 'aFP_NewArrival': 'iFP_NewArrival';
|
|
|
|
|
|
for (let i = 0; i< json.length; i++) {
|
|
|
let item = json[i]
|
|
|
|
|
|
let floorname = item.template_name
|
|
|
let floorid = item.template_id
|
|
|
|
|
|
if (floorname === 'newFocus') {
|
|
|
let list = item.data;
|
|
|
for (let j = 0; j< list.length; j ++) {
|
|
|
let subitem = list[j]
|
|
|
subitem.yh_exposureData = {
|
|
|
F_ID: floorid,
|
|
|
F_NAME: floorname,
|
|
|
F_INDEX: i + 1,
|
|
|
I_INDEX: parseInt(j) + 1 + "",
|
|
|
P_NAME: pageName,
|
|
|
F_URL: subitem.url,
|
|
|
exposureEnd: 1,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let newJson = {
|
|
|
first_part,
|
|
|
shop_list,
|
|
|
second_part,
|
|
|
}
|
|
|
dispatch(topInfoSuccess(newJson));
|
|
|
/**
|
|
|
数据曝光
|
|
|
*/
|
|
|
dispatch(topInfoExpose(newJson));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(topInfoFailure(error));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
if (floorname === 'newProductShopListFloor') {
|
|
|
let list = item.list;
|
|
|
for (let j = 0; j< list.length; j ++) {
|
|
|
let subitem = list[j]
|
|
|
subitem.yh_exposureData = {
|
|
|
F_ID: floorid,
|
|
|
F_NAME: floorname,
|
|
|
P_NAME: pageName,
|
|
|
F_INDEX: i + 1,
|
|
|
I_INDEX: parseInt(j) + 1 + "",
|
|
|
SHOP_ID: subitem.shops_id,
|
|
|
exposureEnd: 1,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} catch(error){ }
|
|
|
|
|
|
return json;
|
|
|
}
|
|
|
|
|
|
export function setProductParams(floorid, floorname, floorindex) {
|
|
|
return {
|
|
|
type: SET_PRODUCT_PARAMS,
|
|
|
payload: {floorid, floorname, floorindex},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function topInfoRequest() {
|
|
|
export function productListRequest() {
|
|
|
return {
|
|
|
type: RECOMMEND_SHOP_REQUEST,
|
|
|
type: PRODUCT_LIST_REQUEST,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function topInfoSuccess(json) {
|
|
|
export function productListSuccess(json) {
|
|
|
return {
|
|
|
type: RECOMMEND_SHOP_SUCCESS,
|
|
|
type: PRODUCT_LIST_SUCCESS,
|
|
|
payload: json
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function topInfoFailure(error) {
|
|
|
export function productListFailure(error) {
|
|
|
return {
|
|
|
type: RECOMMEND_SHOP_FAILURE,
|
|
|
type: PRODUCT_LIST_FAILURE,
|
|
|
payload: error
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function topInfoExpose(data) {
|
|
|
return (dispatch, getState) => {
|
|
|
try {
|
|
|
let {
|
|
|
first_part,
|
|
|
shop_list,
|
|
|
second_part,
|
|
|
} = data;
|
|
|
|
|
|
let logData = [];
|
|
|
let F_INDEX = 1;
|
|
|
if (first_part&&first_part.length) {
|
|
|
let LIST = [];
|
|
|
let I_INDEX = 1;
|
|
|
for (var i = 0; i < first_part.length; i++) {
|
|
|
let IMAGE_URL = first_part[i].src;
|
|
|
let ACTION_URL = first_part[i].url;
|
|
|
LIST.push({
|
|
|
I_INDEX,
|
|
|
IMAGE_URL,
|
|
|
ACTION_URL,
|
|
|
});
|
|
|
I_INDEX ++;
|
|
|
}
|
|
|
logData.push({
|
|
|
F_ID: 1001,
|
|
|
F_NM: 'BANNER',
|
|
|
F_INDEX,
|
|
|
LIST,
|
|
|
});
|
|
|
F_INDEX ++;
|
|
|
}
|
|
|
|
|
|
if (shop_list&&shop_list.length) {
|
|
|
let LIST = [];
|
|
|
let I_INDEX = 1;
|
|
|
for (var i = 0; i < shop_list.length; i++) {
|
|
|
let BRAND_ID = shop_list[i].brand_id;
|
|
|
let SHOP_ID = shop_list[i].shops_id;
|
|
|
LIST.push({
|
|
|
I_INDEX,
|
|
|
BRAND_ID,
|
|
|
SHOP_ID,
|
|
|
});
|
|
|
I_INDEX ++;
|
|
|
}
|
|
|
logData.push({
|
|
|
F_ID: 1002,
|
|
|
F_NM: '为您推荐',
|
|
|
F_INDEX,
|
|
|
LIST,
|
|
|
});
|
|
|
F_INDEX ++;
|
|
|
}
|
|
|
|
|
|
if (second_part&&second_part.length) {
|
|
|
let LIST = [];
|
|
|
let I_INDEX = 1;
|
|
|
for (var i = 0; i < second_part.length; i++) {
|
|
|
let IMAGE_URL = second_part[i].src;
|
|
|
let ACTION_URL = second_part[i].url;
|
|
|
LIST.push({
|
|
|
I_INDEX,
|
|
|
IMAGE_URL,
|
|
|
ACTION_URL,
|
|
|
});
|
|
|
I_INDEX ++;
|
|
|
}
|
|
|
logData.push({
|
|
|
F_ID: 1003,
|
|
|
F_NM: '精选抢先看',
|
|
|
F_INDEX,
|
|
|
LIST,
|
|
|
});
|
|
|
F_INDEX ++;
|
|
|
}
|
|
|
|
|
|
let params = {
|
|
|
DATA: logData,
|
|
|
};
|
|
|
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_SHOW_NEW_ARRIVAL', params);
|
|
|
} catch (e) {
|
|
|
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 底部产品列表
|
|
|
*/
|
|
|
export function getProductList(reload=false) {
|
|
|
export function getProductList(paramsDic) {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, newArrival} = getState();
|
|
|
let { productList, filterFactors, topPart} = newArrival;
|
|
|
let { productList, filterFactors, searchResourceList, prdFloorId, prdFloorName, prdFloorIndex} = newArrival;
|
|
|
|
|
|
if (reload) {
|
|
|
|
|
|
} else {
|
|
|
if (productList.isFetching || productList.endReached || productList.error) {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
if (productList.isFetching || productList.endReached || productList.error) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
dispatch(productListRequest());
|
|
|
|
|
|
let order = productList.order;
|
|
|
let page = productList.currentPage + 1;
|
|
|
let pageSize = productList.pageSize;
|
|
|
|
|
|
let tabId = newArrival.selectedTabIndex;
|
|
|
let tabName = newArrival.selectedTabName;
|
|
|
|
|
|
let channel = app.channel;
|
|
|
let bSelectedFilterFactor,allFilterFactors;
|
|
|
allFilterFactors = filterFactors.toJS();
|
...
|
...
|
@@ -275,114 +248,82 @@ export function getProductList(reload=false) { |
|
|
}
|
|
|
}
|
|
|
|
|
|
return new NewArrivalService(app.host).fetchProductList(channel, order, page, pageSize, allFilterFactors)
|
|
|
return new NewArrivalService(app.host).fetchProductList(channel, order, page, pageSize, allFilterFactors, paramsDic)
|
|
|
.then(json => {
|
|
|
let payload = parseProductList(json,order,channel,pageSize);
|
|
|
payload.endReached = payload.currentPage == payload.pageCount;
|
|
|
|
|
|
if (payload.currentPage > 1) {
|
|
|
let oldList = productList.list.toJS();
|
|
|
let list = [...oldList, ...payload.list];
|
|
|
payload.list = list;
|
|
|
}
|
|
|
dispatch(productListSuccess(payload));
|
|
|
let payload = exposeProductListData(json, order, channel, pageSize, tabId, tabName, prdFloorId, prdFloorName, prdFloorIndex);
|
|
|
payload.endReached = payload.currentPage == payload.pageCount;
|
|
|
|
|
|
if (payload.currentPage > 1) {
|
|
|
let oldList = productList.list.toJS();
|
|
|
let oldsearchlist = searchResourceList.toJS()
|
|
|
let list = [...oldList, ...payload.product_list];
|
|
|
payload.list = list;
|
|
|
payload.search_resource_list = [...oldsearchlist, ...reShuffleJumpList(payload.search_resource_list, parseInt(payload.currentPage), parseInt(pageSize)) ]
|
|
|
} else {
|
|
|
payload.list = payload.product_list
|
|
|
payload.search_resource_list = reShuffleJumpList(payload.search_resource_list, parseInt(payload.currentPage), parseInt(pageSize))
|
|
|
}
|
|
|
|
|
|
dispatch(productListExpose(payload, productList, topPart, allFilterFactors));
|
|
|
dispatch(productListSuccess(payload));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(productListFailure(error));
|
|
|
});
|
|
|
.catch(error => {
|
|
|
dispatch(productListFailure(error));
|
|
|
});
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function productListExpose(payload, productList, topPart, allFilterFactors) {
|
|
|
return (dispatch, getState) => {
|
|
|
try {
|
|
|
let LIST = [];
|
|
|
let length = payload.list.length;
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
let item = payload.list[i]
|
|
|
let ListItem = {
|
|
|
I_INDEX: productList.list.size + i + 1,
|
|
|
RECOMMEND_TYPE: item.recommend_type,
|
|
|
};
|
|
|
let KEYWORD = '';
|
|
|
if (item.recommend_type == 'hotSearchTerm'&&item.data.length) {
|
|
|
KEYWORD = item.data.join(',');
|
|
|
}
|
|
|
let SHOP_ID = 0;
|
|
|
if (item.recommend_type == 'hotShop' && item.data.shops_id) {
|
|
|
SHOP_ID = item.data.shops_id;
|
|
|
}
|
|
|
let ARTICLE_ID = 0;
|
|
|
if (item.recommend_type == 'fashionArticle' && item.data.id) {
|
|
|
ARTICLE_ID = item.data.id;
|
|
|
}
|
|
|
let CATE_ID = '';
|
|
|
if (item.recommend_type == 'seasonSort' && item.data.length) {
|
|
|
let tempAry = [];
|
|
|
let itemLength = item.data.length;
|
|
|
for (var i = 0; i < itemLength; i++) {
|
|
|
let {categoryId} = item.data[i];
|
|
|
categoryId = categoryId.toString();
|
|
|
tempAry.push(categoryId);
|
|
|
}
|
|
|
CATE_ID = tempAry.join(',');
|
|
|
ListItem.CATE_ID = CATE_ID;
|
|
|
}
|
|
|
if (item.product_skn) {
|
|
|
ListItem.PRD_SKN = item.product_skn;
|
|
|
}
|
|
|
if (item.brand_id) {
|
|
|
ListItem.BRAND_ID = item.brand_id;
|
|
|
}
|
|
|
if (ARTICLE_ID && ARTICLE_ID != 0) {
|
|
|
ListItem.ARTICLE_ID = ARTICLE_ID;
|
|
|
}
|
|
|
if (SHOP_ID && SHOP_ID != 0) {
|
|
|
ListItem.SHOP_ID = SHOP_ID;
|
|
|
} else if (KEYWORD && KEYWORD != '') {
|
|
|
ListItem.KEYWORD = KEYWORD;
|
|
|
}
|
|
|
LIST.push(ListItem);
|
|
|
}
|
|
|
let F_INDEX = 1;
|
|
|
if (topPart.topList.size) {
|
|
|
F_INDEX ++;
|
|
|
}
|
|
|
if (topPart.brandList.size) {
|
|
|
F_INDEX ++;
|
|
|
}
|
|
|
if (topPart.featuredList.size) {
|
|
|
F_INDEX ++;
|
|
|
}
|
|
|
let SORT_NM = '新品';
|
|
|
if (productList.order == 's_t_desc') {
|
|
|
SORT_NM = '新品';
|
|
|
}
|
|
|
if (productList.order == 's_p_asc' || productList.order == 's_p_desc') {
|
|
|
SORT_NM = '价格';
|
|
|
}
|
|
|
if (productList.order == 'p_d_asc' || productList.order == 'p_d_desc') {
|
|
|
SORT_NM = '折扣';
|
|
|
}
|
|
|
let FILTER_VALUE = JSON.stringify(allFilterFactors);
|
|
|
let data = [{
|
|
|
F_ID: 1004,
|
|
|
F_NM: '最新上架',
|
|
|
F_INDEX,
|
|
|
SORT_NM,
|
|
|
FILTER_VALUE,
|
|
|
LIST,
|
|
|
}];
|
|
|
let params = {
|
|
|
DATA: data,
|
|
|
};
|
|
|
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_SHOW_NEW_ARRIVAL', params);
|
|
|
} catch(e) {
|
|
|
function reShuffleJumpList(jumplist,pageindex, pagesize) {
|
|
|
return jumplist.map((item, index) => {
|
|
|
item.rowType = 1
|
|
|
item.index = (pageindex -1)*pagesize + parseInt(item.index)
|
|
|
return item
|
|
|
} )
|
|
|
}
|
|
|
|
|
|
}
|
|
|
};
|
|
|
function exposeProductListData(json, order, channel, pageSize, tabId, tabName, prdFloorId, prdFloorName, prdFloorIndex) {
|
|
|
let res = json;
|
|
|
try {
|
|
|
let list = json ? json.product_list : [];
|
|
|
if (!list) {
|
|
|
return json;
|
|
|
}
|
|
|
let pageName = Platform.OS === 'android' ? 'aFP_NewArrival' : 'iFP_NewArrival';
|
|
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
|
let item = list[i];
|
|
|
let skn = item.product_skn;
|
|
|
let prdChannel = item.is_ufo === 'N' ? '' : 'UFO';
|
|
|
let inFloorIndex = parseInt(i) + 1 + json.page_size * (json.page - 1) + '';
|
|
|
let recallType = item.recall_type ? item.recall_type : '';
|
|
|
|
|
|
let productTag = item.product_tag ? item.product_tag : '';
|
|
|
let tagItem = productTag && productTag[0];
|
|
|
let prdType = tagItem ? tagItem.name : '';
|
|
|
item.yh_exposureData = {
|
|
|
P_NAME: pageName,
|
|
|
TAB_ID: tabId,
|
|
|
TAB_NAME: tabName,
|
|
|
I_INDEX: inFloorIndex,
|
|
|
PRD_SKN: skn,
|
|
|
PRD_CHANNEL: prdChannel,
|
|
|
RECALL_TYPE: recallType,
|
|
|
PRD_TYPE: prdType,
|
|
|
|
|
|
F_NAME: prdFloorName,
|
|
|
F_INDEX: prdFloorIndex,
|
|
|
F_ID:prdFloorId,
|
|
|
exposureEnd: 1,
|
|
|
};
|
|
|
}
|
|
|
res.product_list = list;
|
|
|
res.search_resource_list = json.search_resource_list.length> 0 ? json.search_resource_list : []
|
|
|
res.currentPage = json && json.page ? json.page : 1;
|
|
|
res.pageCount = json && json.page_total ? json.page_total : 0;
|
|
|
res.total = json && json.total ? json.total : 0;
|
|
|
|
|
|
} catch(error){ }
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
export function setFilterData(payload) {
|
...
|
...
|
@@ -393,9 +334,7 @@ export function setFilterData(payload) { |
|
|
}
|
|
|
|
|
|
export function setFilterView(show) {
|
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
|
|
let {app, newArrival} = getState();
|
|
|
let {filterDataReady} = newArrival;
|
|
|
if (!filterDataReady && show) {
|
...
|
...
|
@@ -410,10 +349,8 @@ export function setFilterView(show) { |
|
|
});
|
|
|
})
|
|
|
.catch(error => {
|
|
|
|
|
|
});
|
|
|
} else {
|
|
|
|
|
|
dispatch({
|
|
|
type: FILTER_LIST_VIEW,
|
|
|
payload: show
|
...
|
...
|
@@ -421,6 +358,7 @@ export function setFilterView(show) { |
|
|
}
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function setFilterMoreView(show) {
|
|
|
return {
|
|
|
type: FILTER_MORE_VIEW,
|
...
|
...
|
@@ -483,26 +421,6 @@ export function setProductFilterFactors(category={key: 'gender', name: '性别', |
|
|
};
|
|
|
}
|
|
|
|
|
|
export function productListRequest() {
|
|
|
return {
|
|
|
type: PRODUCT_LIST_REQUEST,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
export function productListSuccess(json) {
|
|
|
return {
|
|
|
type: PRODUCT_LIST_SUCCESS,
|
|
|
payload: json
|
|
|
}
|
|
|
}
|
|
|
|
|
|
export function productListFailure(error) {
|
|
|
return {
|
|
|
type: PRODUCT_LIST_FAILURE,
|
|
|
payload: error
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//为您推荐
|
|
|
export function recommendBrandRequest() {
|
|
|
return {
|
...
|
...
|
@@ -527,21 +445,21 @@ export function recommendBrandFailure(error) { |
|
|
export function getRecommendBrand() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, newArrival} = getState();
|
|
|
let { productList, filterFactors} = newArrival;
|
|
|
let { productList, filterFactors} = newArrival;
|
|
|
let channel = app.channel;
|
|
|
|
|
|
dispatch(recommendBrandRequest());
|
|
|
return new NewArrivalService(app.host).fetchRecommendBrand(channel)
|
|
|
.then(json => {
|
|
|
let browseBrandList = json.browse_brand_list;
|
|
|
let hotBrandList = json.hot_brand_list;
|
|
|
let newBrandList = json.new_brand_list;
|
|
|
let browseBrandList = json.browse_brand_list;
|
|
|
let hotBrandList = json.hot_brand_list;
|
|
|
let newBrandList = json.new_brand_list;
|
|
|
|
|
|
dispatch(recommendBrandSuccess({hotBrandList, browseBrandList, newBrandList}));
|
|
|
dispatch(recommendBrandExpose({hotBrandList, browseBrandList, newBrandList}))
|
|
|
dispatch(recommendBrandSuccess({hotBrandList, browseBrandList, newBrandList}));
|
|
|
dispatch(recommendBrandExpose({hotBrandList, browseBrandList, newBrandList}))
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(recommendBrandFailure(error));
|
|
|
dispatch(recommendBrandFailure(error));
|
|
|
});
|
|
|
};
|
|
|
}
|
...
|
...
|
@@ -578,12 +496,12 @@ export function getShopCartCount() { |
|
|
|
|
|
new NewArrivalService(app.globalHost).getGlobalShopCartCount(uid,'NewArrival')
|
|
|
.then(json => {
|
|
|
let count = json ? json.cart_goods_count: 0;
|
|
|
cart_goods_count = cart_goods_count + count;
|
|
|
dispatch(getShopCartCountSuccess(cart_goods_count));
|
|
|
let count = json ? json.cart_goods_count: 0;
|
|
|
cart_goods_count = cart_goods_count + count;
|
|
|
dispatch(getShopCartCountSuccess(cart_goods_count));
|
|
|
})
|
|
|
.catch(error => {
|
|
|
dispatch(getShopCartCountSuccess(cart_goods_count));
|
|
|
dispatch(getShopCartCountSuccess(cart_goods_count));
|
|
|
});
|
|
|
|
|
|
})
|
...
|
...
|
@@ -702,248 +620,7 @@ function recommendBrandExpose(data) { |
|
|
|
|
|
export function goToRecommendForYou() {
|
|
|
return (dispatch, getState) => {
|
|
|
let {app, newArrival} = getState();
|
|
|
let { productList, filterFactors, topPart} = newArrival;
|
|
|
|
|
|
let I_INDEX = "0";
|
|
|
let F_INDEX = 1;
|
|
|
if (newArrival.topPart.topList.size) {
|
|
|
F_INDEX = 2;
|
|
|
}
|
|
|
F_INDEX = F_INDEX.toString();
|
|
|
let param = {
|
|
|
F_ID: "1002",
|
|
|
F_NM: '为您推荐',
|
|
|
F_INDEX,
|
|
|
I_INDEX,
|
|
|
}
|
|
|
ReactNative.NativeModules.YH_CommonHelper.logEvent('YB_NEW_ARRIVAL_FLR_C', param);
|
|
|
|
|
|
ReactNative.NativeModules.YH_NewArrivalHelper.goToRecommendForYou();
|
|
|
|
|
|
};
|
|
|
}
|
|
|
|
|
|
function parseProductList(json,order,channel,pageSize) {
|
|
|
let list = json && json.product_list ? json.product_list : [];
|
|
|
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;
|
|
|
|
|
|
try {
|
|
|
list = exposePruductListData(list,order,channel,currentPage,pageSize);
|
|
|
} catch (e) {
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
}
|
|
|
|
|
|
if (currentPage > 1) {
|
|
|
return {
|
|
|
list,
|
|
|
currentPage,
|
|
|
pageCount,
|
|
|
total,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
let filter = json && json.filter ? json.filter : {};
|
|
|
let filterCategoryDetailFilterList = {};
|
|
|
let categoryFilterList = [];
|
|
|
|
|
|
if (filter['gender']) {
|
|
|
categoryFilterList.push({
|
|
|
key: 'gender',
|
|
|
name: '性别',
|
|
|
isSelect: true,
|
|
|
});
|
|
|
let genderList = filter['gender'];
|
|
|
let newGenderList =[];
|
|
|
newGenderList.push({
|
|
|
key:'1,2,3',
|
|
|
name: '所有性别',
|
|
|
isSelect: true,
|
|
|
});
|
|
|
for (let gender in genderList) {
|
|
|
if (genderList.hasOwnProperty(gender)) {
|
|
|
newGenderList.push({
|
|
|
key: gender,
|
|
|
name: genderList[gender],
|
|
|
isSelect: false,
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
filterCategoryDetailFilterList.gender;
|
|
|
filterCategoryDetailFilterList.gender = newGenderList;
|
|
|
}
|
|
|
|
|
|
if (filter['group_sort']) {
|
|
|
categoryFilterList.push({
|
|
|
key: 'sort',
|
|
|
name: '品类',
|
|
|
isSelect: false,
|
|
|
});
|
|
|
let sortList = filter['group_sort'];
|
|
|
let newSortList = [];
|
|
|
newSortList.push({
|
|
|
key: '',
|
|
|
name: '所有品类',
|
|
|
isSelect: true,
|
|
|
});
|
|
|
sortList.map((item, i) => {
|
|
|
newSortList.push({
|
|
|
key: item.relation_parameter.sort ? item.relation_parameter.sort : '',
|
|
|
name: item.category_name,
|
|
|
isSelect: false,
|
|
|
})
|
|
|
});
|
|
|
filterCategoryDetailFilterList.sort;
|
|
|
filterCategoryDetailFilterList.sort = newSortList;
|
|
|
}
|
|
|
|
|
|
if (filter['brand']) {
|
|
|
categoryFilterList.push({
|
|
|
key: 'brand',
|
|
|
name: '品牌',
|
|
|
isSelect: false,
|
|
|
});
|
|
|
let brandList = filter['brand'];
|
|
|
brandList = brandList.sort(function(a, b) {
|
|
|
return a.brand_alif - b.brand_alif;
|
|
|
});
|
|
|
|
|
|
let templet = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
|
|
|
let bList = [];
|
|
|
|
|
|
for (var j = 0; j < templet.length; j++) {
|
|
|
for (var i = 0; i <brandList.length; i++) {
|
|
|
if (brandList[i].brand_alif == templet[j]) {
|
|
|
bList.push(brandList[i]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
let newBrandList = [];
|
|
|
newBrandList.push({
|
|
|
key: '',
|
|
|
name: '所有品牌',
|
|
|
isSelect: true,
|
|
|
});
|
|
|
bList.map((item, i) => {
|
|
|
newBrandList.push({
|
|
|
key: item.id,
|
|
|
name: item.brand_name,
|
|
|
isSelect: false,
|
|
|
})
|
|
|
});
|
|
|
filterCategoryDetailFilterList.brand;
|
|
|
filterCategoryDetailFilterList.brand = newBrandList;
|
|
|
}
|
|
|
|
|
|
if (filter['color']) {
|
|
|
categoryFilterList.push({
|
|
|
key: 'color',
|
|
|
name: '颜色',
|
|
|
isSelect: false,
|
|
|
});
|
|
|
let colorList = filter['color'];
|
|
|
let newColorList = [];
|
|
|
newColorList.push({
|
|
|
key: '',
|
|
|
name: '所有颜色',
|
|
|
isSelect: true,
|
|
|
});
|
|
|
colorList.map((item, i) => {
|
|
|
newColorList.push({
|
|
|
key: item.color_id,
|
|
|
name: item.color_name,
|
|
|
isSelect: false,
|
|
|
});
|
|
|
});
|
|
|
filterCategoryDetailFilterList.color;
|
|
|
filterCategoryDetailFilterList.color = newColorList;
|
|
|
}
|
|
|
|
|
|
if (filter['size']) {
|
|
|
categoryFilterList.push({
|
|
|
key: 'sizeKey',
|
|
|
name: '尺码',
|
|
|
isSelect: false,
|
|
|
});
|
|
|
let sizeList = filter['size'];
|
|
|
let newSizeList = [];
|
|
|
newSizeList.push({
|
|
|
key: '',
|
|
|
name: '所有尺码',
|
|
|
isSelect: true,
|
|
|
});
|
|
|
sizeList.map((item, i) => {
|
|
|
newSizeList.push({
|
|
|
key: item.size_id,
|
|
|
name: item.size_name,
|
|
|
isSelect: false,
|
|
|
});
|
|
|
});
|
|
|
filterCategoryDetailFilterList.sizeKey;
|
|
|
filterCategoryDetailFilterList.sizeKey = newSizeList;
|
|
|
}
|
|
|
|
|
|
if (filter['priceRange']) {
|
|
|
categoryFilterList.push({
|
|
|
key: 'price',
|
|
|
name: '价格',
|
|
|
isSelect: false,
|
|
|
});
|
|
|
let priceObject = filter['priceRange'];
|
|
|
priceObject = sortListByField(priceObject, 'name'); // 折扣,价格区间,需要排序
|
|
|
let newPriceList = [];
|
|
|
newPriceList.push({
|
|
|
key: '',
|
|
|
name: '所有价格',
|
|
|
isSelect: true,
|
|
|
});
|
|
|
_.forEach(priceObject, (v, k) => {
|
|
|
newPriceList.push({
|
|
|
key: v._key,
|
|
|
name: v._value,
|
|
|
isSelect: false,
|
|
|
});
|
|
|
});
|
|
|
filterCategoryDetailFilterList.price;
|
|
|
filterCategoryDetailFilterList.price = newPriceList;
|
|
|
}
|
|
|
|
|
|
if (filter['discount']) {
|
|
|
categoryFilterList.push({
|
|
|
key: 'p_d',
|
|
|
name: '折扣',
|
|
|
isSelect: false,
|
|
|
});
|
|
|
let p_dObject = filter['discount'];
|
|
|
p_dObject = sortListByField(p_dObject, 'name'); // 折扣,价格区间,需要排序
|
|
|
let newP_dList = [];
|
|
|
newP_dList.push({
|
|
|
key: '',
|
|
|
name: '所有折扣',
|
|
|
isSelect: true,
|
|
|
});
|
|
|
_.forEach(p_dObject, (v, k) => {
|
|
|
newP_dList.push({
|
|
|
key: v._key,
|
|
|
name: v.name,
|
|
|
isSelect: false,
|
|
|
});
|
|
|
});
|
|
|
filterCategoryDetailFilterList.p_d;
|
|
|
filterCategoryDetailFilterList.p_d = newP_dList;
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
list,
|
|
|
categoryFilterList,
|
|
|
filterCategoryDetailFilterList,
|
|
|
currentPage,
|
|
|
pageCount,
|
|
|
total,
|
|
|
};
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1004,135 +681,9 @@ function exposeBannerData(data,type,channel) { |
|
|
item.yh_exposureData = params;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
function exposePruductListData(list,order,channel,currentPage,pageSize) {
|
|
|
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 inFloorIndex = parseInt(i) + 1 + parseInt(currentPage - 1) * parseInt(pageSize) + '';
|
|
|
|
|
|
let recommend_type = item.recommend_type;
|
|
|
if (recommend_type == 'hotSearchTerm') {
|
|
|
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') {
|
|
|
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 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 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 params = {
|
|
|
P_NAME : pageName,
|
|
|
I_INDEX : inFloorIndex,
|
|
|
PRD_SKN : skn,
|
|
|
TAB_NAME : tab_name,
|
|
|
TAB_ID : tab_num,
|
|
|
P_PARAM : channelStr,
|
|
|
C_ID: channel,
|
|
|
exposureEnd : 1,
|
|
|
};
|
|
|
item.yh_exposureData = params;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|