Authored by 张丽霞

筛选数据组装,review by 孙凯

... ... @@ -341,6 +341,13 @@ export function productListFailure(error) {
}
/*
* 筛选
*/
export function setProductFilterFactors(categort, deatil){
}
/*
* 底部产品列表
*/
export function getProductList(reload=false) {
... ... @@ -363,17 +370,16 @@ export function getProductList(reload=false) {
let bSelectedFilterFactor,allFilterFactors;
allFilterFactors = filterFactors.toJS();
for (var pactor in allFilterFactors) {
if (allFilterFactors.hasOwnProperty(pactor)) {
if (allFilterFactors[pactor]) {
bSelectedFilterFactor.push(pactor);
bSelectedFilterFactor[pactor] = allFilterFactors[pactor];
if (allFilterFactors[pactor] === '') {
delete allFilterFactors[pactor];
}
}
}
dispatch(productListRequest());
return new BrandStoreService().productList(shopId, channel, order, page, pageSize, bSelectedFilterFactor)
return new BrandStoreService().productList(shopId, channel, order, page, pageSize, allFilterFactors)
.then(json => {
let payload = parseProductList(json);
payload.endReached = payload.currentPage == payload.pageCount;
... ... @@ -398,10 +404,164 @@ function parseProductList(json) {
let filter = json && json.filter ? json.filter : {};
let list = json && json.product_list ? json.product_list : [];
let filterCategoryDetailFilterList = {};
let categoryFilterList = [];
if (filter['gender']) {
categoryFilterList.push({
key: 'gender',
name: '性别',
isSelect: false,
});
let genderList = filter['gender'];
let newGenderList =[];
newGenderList.push({
key:'',
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['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: 'size',
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.size;
filterCategoryDetailFilterList.size = newSizeList;
}
if (filter['priceRange']) {
categoryFilterList.push({
key: 'price',
name: '价格',
isSelect: false,
});
let priceObject = filter['priceRange'];
let newPriceList = [];
newPriceList.push({
key: '',
name: '所有价格',
isSelect: true,
});
for (var price in priceObject) {
if (priceObject.hasOwnProperty(price)) {
newPriceList.push({
key: price,
name: priceObject[price],
isSelect: false,
});
}
}
filterCategoryDetailFilterList.price;
filterCategoryDetailFilterList.price = newPriceList;
}
if (filter['discount']) {
categoryFilterList.push({
key: 'p_d',
name: '折扣',
isSelect: false,
});
let p_dObject = filter['discount'];
let newP_dList = [];
newP_dList.push({
key: '',
name: '所有折扣',
isSelect: true,
});
for (var p_d in p_dObject) {
if (p_dObject.hasOwnProperty(p_d)) {
newP_dList.push({
key: p_d,
name: p_dObject[p_d].name,
isSelect: false,
});
}
}
filterCategoryDetailFilterList.p_d;
filterCategoryDetailFilterList.p_d = newP_dList;
}
return {
list,
filter,
categoryFilterList,
filterCategoryDetailFilterList,
currentPage,
pageCount,
total,
... ...
... ... @@ -63,18 +63,20 @@ let InitialState = Record({
})),
storeFilter: 0,
filterFactors: new (Record({
gender: null, //性别
color: null, //颜色
price: null, //价格
sizePara: null, //尺码
p_d: null, //折扣
sort: null, //品类
gender: '', //性别
color: '', //颜色
price: '', //价格
sizePara: '', //尺码
p_d: '', //折扣
sort: '', //品类
})),
isCollection: false,
hasBuy : false,
touchBrandItem : false,
shopsBrands:List(),
categoryFilterList:List(),
filterCategoryDetailFilterList:List(),
});
... ...
... ... @@ -175,6 +175,8 @@ export default function brandStoreReducer(state=initialState, action) {
let {
list,
filter,
categoryFilterList,
filterCategoryDetailFilterList,
currentPage,
pageCount,
total,
... ... @@ -187,7 +189,9 @@ export default function brandStoreReducer(state=initialState, action) {
.setIn(['productList', 'currentPage'], currentPage)
.setIn(['productList', 'pageCount'], pageCount)
.setIn(['productList', 'total'], total)
.setIn(['productList', 'endReached'], endReached);
.setIn(['productList', 'endReached'], endReached)
.setIn('categoryFilterList', categoryFilterList)
.setIn('filterCategoryDetailFilterList', filterCategoryDetailFilterList);
if (currentPage == 1) {
newState = newState.setIn(['productList', 'filter'], Immutable.fromJS(filter));
}
... ...