Authored by runner

filter-age update

... ... @@ -109,7 +109,7 @@ class HelperSearch
/**
* 将接口返回的数据($data)组合成模板需要的格式
*
*
* @param array $data array(
* 'product' => array (接口得到的商品数据)
* 'sort' => array (接口返回的分类数据)
... ... @@ -131,11 +131,11 @@ class HelperSearch
self::$options = $options;
$result = array();
self::$filter = isset($data['product']['filter']) ? $data['product']['filter'] : array();
//当前页
$result['page'] = isset($data['product']['page']) ? $data['product']['page'] : '';
self::$page = $result['page'];
//产品列表
$result['goods'] = isset($data['product']['product_list']) ? self::getProductList($data['product']['product_list'], $options) : array();
//总页数
... ... @@ -184,7 +184,7 @@ class HelperSearch
if (empty($shopSort)) {
continue;
}
$result['shopEntry'][] = $shopSort;
$result['shopEntry'][] = $shopSort;
}
}
//分页
... ... @@ -319,7 +319,7 @@ class HelperSearch
$isNew = false;
$isSale = false;
}
if (isset($options['isNew']) && $options['isNew']) {
$isNew = true;
}
... ... @@ -453,6 +453,47 @@ class HelperSearch
}
return $result;
}
/**
* 年龄
* $filter 搜索接口返回的商品筛选条件数据 $data['product']['filter']
* @return array
*/
public static function ageLevel($filter)
{
$result = array();
if (empty($filter) || !isset($filter['ageLevel']) || empty($filter['ageLevel'])) {
return $result;
}
$params = self::$params;
$ageLevel = isset($params['ageLevel']) ? $params['ageLevel'] : '';
if (isset($params['ageLevel'])) {
unset($params['ageLevel']);
}
if (self::$total == 0) {
return $result;
}
sort($filter['ageLevel']);
foreach ($filter['ageLevel'] as $key => $val) {
if ($val['id'] == $params['ageLevel']) {
self::$selected['ageLevel'] = array(
'name' => $val['name'],
'href' => self::buildUrl($params)
);
}
$href = $val[id];
$result[] = array(
'name' => $val[name],
'href' => self::buildUrl(array_merge($params, array(
'ageLevel' => $href
))),
'checked' => isset(self::$params['ageLevel']) && self::$params['ageLevel'] == $href ? true : false
);
}
return $result;
}
/**
* 组织搜索列表页面的左侧分类
* @param array $sort
... ... @@ -1454,7 +1495,7 @@ class HelperSearch
if (self::$total == 0) {
return $shopEntry;
}
if (empty($shopSort)) {
$shopSort = array();
}
... ... @@ -1542,6 +1583,8 @@ class HelperSearch
$result = array();
//性别
$result['gender'] = self::gender(self::$filter);
//年龄
$result['ageLevel'] = self::ageLevel(self::$filter);
//品牌
$result['brand'] = self::brand(self::$filter);
//价格
... ...
... ... @@ -48,6 +48,20 @@
</div>
{{/if}}
{{#if ageLevel}}
<div class="channel section">
<span class="title">年龄:</span>
<div class="attr-content clearfix">
{{#each ageLevel}}
<a class="attr {{#if checked}}checked{{/if}}" href="{{href}}">
{{name}}
</a>
{{/each}}
</div>
</div>
{{/if}}
{{#if sort}}
<div class="sort section">
<span class="title">分类:</span>
... ...
... ... @@ -72,7 +72,8 @@ class SearchModel
'series_id' => FILTER_VALIDATE_INT,
'series' => FILTER_VALIDATE_INT,
'folder_id' => FILTER_VALIDATE_INT,
'page' => FILTER_VALIDATE_INT), false);
'page' => FILTER_VALIDATE_INT,
'ageLevel' => FILTER_VALIDATE_INT), false);
//接收高级选项
foreach ($_GET as $key =>$val) {
if (strpos($key, 'parameter_') !== false) {
... ...