Authored by Rock Zhang

修复列表筛选数据错误的bug,目前品牌页面没有加brand参数

Code Reveiw By Rock Zhang
@@ -53,9 +53,10 @@ class ListProcess @@ -53,9 +53,10 @@ class ListProcess
53 * 53 *
54 * @param $data 54 * @param $data
55 * @param string | integer $gender 默认选择的性别,默认1,2,3表示所有 55 * @param string | integer $gender 默认选择的性别,默认1,2,3表示所有
  56 + * @param null|string $exclude 需要排除的字段
56 * @return array 处理之后的筛选数据 57 * @return array 处理之后的筛选数据
57 */ 58 */
58 - public static function getFilterData($data, $gender = '1,2,3') 59 + public static function getFilterData($data, $gender = '1,2,3', $exclude = null)
59 { 60 {
60 // 过滤条件数据 61 // 过滤条件数据
61 $filters = array('classify' => array()); 62 $filters = array('classify' => array());
@@ -65,12 +66,10 @@ class ListProcess @@ -65,12 +66,10 @@ class ListProcess
65 66
66 $num = 1; 67 $num = 1;
67 foreach ($data as $key => $val) { 68 foreach ($data as $key => $val) {
68 - if (empty($val)) {  
69 - continue;  
70 - }  
71 - if (!is_callable("self::$key")) { 69 + if ($key === $exclude || empty($val) || !is_callable("self::$key")) {
72 continue; 70 continue;
73 } 71 }
  72 +
74 $build = self::$key($val, $gender); 73 $build = self::$key($val, $gender);
75 if ($num === 1) { 74 if ($num === 1) {
76 $build['active'] = true; 75 $build['active'] = true;
@@ -87,17 +87,26 @@ class SearchModel @@ -87,17 +87,26 @@ class SearchModel
87 } 87 }
88 } 88 }
89 89
  90 + // 设置选定的gender
  91 + $gender = '1,2,3';
  92 + if (isset($condition['gender'])) {
  93 + $gender = $condition['gender'];
  94 + }
  95 +
90 // 区别各种列表页面的筛选数据 96 // 区别各种列表页面的筛选数据
91 if (isset($condition['brand'])) { 97 if (isset($condition['brand'])) {
92 $listData = BrandData::filterBrandData($condition); 98 $listData = BrandData::filterBrandData($condition);
  99 + $exclude = 'brand';
93 } else if (isset($condition['sort'])) { 100 } else if (isset($condition['sort'])) {
94 $listData = ClassData::filterClassData($condition); 101 $listData = ClassData::filterClassData($condition);
  102 + $exclude = 'group_sort';
95 } else { 103 } else {
96 $listData = SearchData::searchByCondition($condition); 104 $listData = SearchData::searchByCondition($condition);
  105 + $exclude = null;
97 } 106 }
98 107
99 if (isset($listData['data']['filter'])) { 108 if (isset($listData['data']['filter'])) {
100 - $result['filter'] = ListProcess::getFilterData($listData['data']['filter']); 109 + $result['filter'] = ListProcess::getFilterData($listData['data']['filter'], $gender, $exclude);
101 } 110 }
102 111
103 if (USE_CACHE) { 112 if (USE_CACHE) {