Authored by 张丽霞

筛选数据组装,review by 孙凯

@@ -341,6 +341,13 @@ export function productListFailure(error) { @@ -341,6 +341,13 @@ export function productListFailure(error) {
341 } 341 }
342 342
343 /* 343 /*
  344 + * 筛选
  345 + */
  346 +export function setProductFilterFactors(categort, deatil){
  347 +
  348 +}
  349 +
  350 +/*
344 * 底部产品列表 351 * 底部产品列表
345 */ 352 */
346 export function getProductList(reload=false) { 353 export function getProductList(reload=false) {
@@ -363,17 +370,16 @@ export function getProductList(reload=false) { @@ -363,17 +370,16 @@ export function getProductList(reload=false) {
363 370
364 let bSelectedFilterFactor,allFilterFactors; 371 let bSelectedFilterFactor,allFilterFactors;
365 allFilterFactors = filterFactors.toJS(); 372 allFilterFactors = filterFactors.toJS();
  373 +
366 for (var pactor in allFilterFactors) { 374 for (var pactor in allFilterFactors) {
367 if (allFilterFactors.hasOwnProperty(pactor)) { 375 if (allFilterFactors.hasOwnProperty(pactor)) {
368 - if (allFilterFactors[pactor]) {  
369 - bSelectedFilterFactor.push(pactor);  
370 - bSelectedFilterFactor[pactor] = allFilterFactors[pactor]; 376 + if (allFilterFactors[pactor] === '') {
  377 + delete allFilterFactors[pactor];
371 } 378 }
372 } 379 }
373 } 380 }
374 -  
375 dispatch(productListRequest()); 381 dispatch(productListRequest());
376 - return new BrandStoreService().productList(shopId, channel, order, page, pageSize, bSelectedFilterFactor) 382 + return new BrandStoreService().productList(shopId, channel, order, page, pageSize, allFilterFactors)
377 .then(json => { 383 .then(json => {
378 let payload = parseProductList(json); 384 let payload = parseProductList(json);
379 payload.endReached = payload.currentPage == payload.pageCount; 385 payload.endReached = payload.currentPage == payload.pageCount;
@@ -398,10 +404,164 @@ function parseProductList(json) { @@ -398,10 +404,164 @@ function parseProductList(json) {
398 404
399 let filter = json && json.filter ? json.filter : {}; 405 let filter = json && json.filter ? json.filter : {};
400 let list = json && json.product_list ? json.product_list : []; 406 let list = json && json.product_list ? json.product_list : [];
  407 + let filterCategoryDetailFilterList = {};
  408 + let categoryFilterList = [];
  409 +
  410 + if (filter['gender']) {
  411 + categoryFilterList.push({
  412 + key: 'gender',
  413 + name: '性别',
  414 + isSelect: false,
  415 + });
  416 + let genderList = filter['gender'];
  417 + let newGenderList =[];
  418 + newGenderList.push({
  419 + key:'',
  420 + name: '所有性别',
  421 + isSelect: true,
  422 + });
  423 + for (let gender in genderList) {
  424 + if (genderList.hasOwnProperty(gender)) {
  425 + newGenderList.push({
  426 + key: gender,
  427 + name: genderList[gender],
  428 + isSelect: false,
  429 + });
  430 + }
  431 + }
  432 + filterCategoryDetailFilterList.gender;
  433 + filterCategoryDetailFilterList.gender = newGenderList;
  434 + }
  435 +
  436 + if (filter['group_sort']) {
  437 + categoryFilterList.push({
  438 + key: 'sort',
  439 + name: '品类',
  440 + isSelect: false,
  441 + });
  442 + let sortList = filter['group_sort'];
  443 + let newSortList = [];
  444 + newSortList.push({
  445 + key: '',
  446 + name: '所有品类',
  447 + isSelect: true,
  448 + });
  449 + sortList.map((item, i) => {
  450 + newSortList.push({
  451 + key: item.relation_parameter.sort ? item.relation_parameter.sort : '',
  452 + name: item.category_name,
  453 + isSelect: false,
  454 + })
  455 + });
  456 + filterCategoryDetailFilterList.sort;
  457 + filterCategoryDetailFilterList.sort = newSortList;
  458 + }
  459 +
  460 + if (filter['color']) {
  461 + categoryFilterList.push({
  462 + key: 'color',
  463 + name: '颜色',
  464 + isSelect: false,
  465 + });
  466 + let colorList = filter['color'];
  467 + let newColorList = [];
  468 + newColorList.push({
  469 + key: '',
  470 + name: '所有颜色',
  471 + isSelect: true,
  472 + });
  473 + colorList.map((item, i) => {
  474 + newColorList.push({
  475 + key: item.color_id,
  476 + name: item.color_name,
  477 + isSelect: false,
  478 + });
  479 + });
  480 + filterCategoryDetailFilterList.color;
  481 + filterCategoryDetailFilterList.color = newColorList;
  482 + }
  483 +
  484 + if (filter['size']) {
  485 + categoryFilterList.push({
  486 + key: 'size',
  487 + name: '尺码',
  488 + isSelect: false,
  489 + });
  490 + let sizeList = filter['size'];
  491 + let newSizeList = [];
  492 + newSizeList.push({
  493 + key: '',
  494 + name: '所有尺码',
  495 + isSelect: true,
  496 + });
  497 + sizeList.map((item, i) => {
  498 + newSizeList.push({
  499 + key: item.size_id,
  500 + name: item.size_name,
  501 + isSelect: false,
  502 + });
  503 + });
  504 + filterCategoryDetailFilterList.size;
  505 + filterCategoryDetailFilterList.size = newSizeList;
  506 + }
  507 +
  508 + if (filter['priceRange']) {
  509 + categoryFilterList.push({
  510 + key: 'price',
  511 + name: '价格',
  512 + isSelect: false,
  513 + });
  514 + let priceObject = filter['priceRange'];
  515 + let newPriceList = [];
  516 + newPriceList.push({
  517 + key: '',
  518 + name: '所有价格',
  519 + isSelect: true,
  520 + });
  521 + for (var price in priceObject) {
  522 + if (priceObject.hasOwnProperty(price)) {
  523 + newPriceList.push({
  524 + key: price,
  525 + name: priceObject[price],
  526 + isSelect: false,
  527 + });
  528 + }
  529 + }
  530 + filterCategoryDetailFilterList.price;
  531 + filterCategoryDetailFilterList.price = newPriceList;
  532 + }
  533 +
  534 + if (filter['discount']) {
  535 + categoryFilterList.push({
  536 + key: 'p_d',
  537 + name: '折扣',
  538 + isSelect: false,
  539 + });
  540 + let p_dObject = filter['discount'];
  541 + let newP_dList = [];
  542 + newP_dList.push({
  543 + key: '',
  544 + name: '所有折扣',
  545 + isSelect: true,
  546 + });
  547 + for (var p_d in p_dObject) {
  548 + if (p_dObject.hasOwnProperty(p_d)) {
  549 + newP_dList.push({
  550 + key: p_d,
  551 + name: p_dObject[p_d].name,
  552 + isSelect: false,
  553 + });
  554 + }
  555 + }
  556 + filterCategoryDetailFilterList.p_d;
  557 + filterCategoryDetailFilterList.p_d = newP_dList;
  558 + }
401 559
402 return { 560 return {
403 list, 561 list,
404 filter, 562 filter,
  563 + categoryFilterList,
  564 + filterCategoryDetailFilterList,
405 currentPage, 565 currentPage,
406 pageCount, 566 pageCount,
407 total, 567 total,
@@ -63,18 +63,20 @@ let InitialState = Record({ @@ -63,18 +63,20 @@ let InitialState = Record({
63 })), 63 })),
64 storeFilter: 0, 64 storeFilter: 0,
65 filterFactors: new (Record({ 65 filterFactors: new (Record({
66 - gender: null, //性别  
67 - color: null, //颜色  
68 - price: null, //价格  
69 - sizePara: null, //尺码  
70 - p_d: null, //折扣  
71 - sort: null, //品类 66 + gender: '', //性别
  67 + color: '', //颜色
  68 + price: '', //价格
  69 + sizePara: '', //尺码
  70 + p_d: '', //折扣
  71 + sort: '', //品类
72 })), 72 })),
73 73
74 isCollection: false, 74 isCollection: false,
75 hasBuy : false, 75 hasBuy : false,
76 touchBrandItem : false, 76 touchBrandItem : false,
77 shopsBrands:List(), 77 shopsBrands:List(),
  78 + categoryFilterList:List(),
  79 + filterCategoryDetailFilterList:List(),
78 80
79 }); 81 });
80 82
@@ -175,6 +175,8 @@ export default function brandStoreReducer(state=initialState, action) { @@ -175,6 +175,8 @@ export default function brandStoreReducer(state=initialState, action) {
175 let { 175 let {
176 list, 176 list,
177 filter, 177 filter,
  178 + categoryFilterList,
  179 + filterCategoryDetailFilterList,
178 currentPage, 180 currentPage,
179 pageCount, 181 pageCount,
180 total, 182 total,
@@ -187,7 +189,9 @@ export default function brandStoreReducer(state=initialState, action) { @@ -187,7 +189,9 @@ export default function brandStoreReducer(state=initialState, action) {
187 .setIn(['productList', 'currentPage'], currentPage) 189 .setIn(['productList', 'currentPage'], currentPage)
188 .setIn(['productList', 'pageCount'], pageCount) 190 .setIn(['productList', 'pageCount'], pageCount)
189 .setIn(['productList', 'total'], total) 191 .setIn(['productList', 'total'], total)
190 - .setIn(['productList', 'endReached'], endReached); 192 + .setIn(['productList', 'endReached'], endReached)
  193 + .setIn('categoryFilterList', categoryFilterList)
  194 + .setIn('filterCategoryDetailFilterList', filterCategoryDetailFilterList);
191 if (currentPage == 1) { 195 if (currentPage == 1) {
192 newState = newState.setIn(['productList', 'filter'], Immutable.fromJS(filter)); 196 newState = newState.setIn(['productList', 'filter'], Immutable.fromJS(filter));
193 } 197 }