Authored by Rock Zhang

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

Code Reveiw By Rock Zhang
... ... @@ -53,9 +53,10 @@ class ListProcess
*
* @param $data
* @param string | integer $gender 默认选择的性别,默认1,2,3表示所有
* @param null|string $exclude 需要排除的字段
* @return array 处理之后的筛选数据
*/
public static function getFilterData($data, $gender = '1,2,3')
public static function getFilterData($data, $gender = '1,2,3', $exclude = null)
{
// 过滤条件数据
$filters = array('classify' => array());
... ... @@ -65,12 +66,10 @@ class ListProcess
$num = 1;
foreach ($data as $key => $val) {
if (empty($val)) {
continue;
}
if (!is_callable("self::$key")) {
if ($key === $exclude || empty($val) || !is_callable("self::$key")) {
continue;
}
$build = self::$key($val, $gender);
if ($num === 1) {
$build['active'] = true;
... ...
... ... @@ -87,17 +87,26 @@ class SearchModel
}
}
// 设置选定的gender
$gender = '1,2,3';
if (isset($condition['gender'])) {
$gender = $condition['gender'];
}
// 区别各种列表页面的筛选数据
if (isset($condition['brand'])) {
$listData = BrandData::filterBrandData($condition);
$exclude = 'brand';
} else if (isset($condition['sort'])) {
$listData = ClassData::filterClassData($condition);
$exclude = 'group_sort';
} else {
$listData = SearchData::searchByCondition($condition);
$exclude = null;
}
if (isset($listData['data']['filter'])) {
$result['filter'] = ListProcess::getFilterData($listData['data']['filter']);
$result['filter'] = ListProcess::getFilterData($listData['data']['filter'], $gender, $exclude);
}
if (USE_CACHE) {
... ...