...
|
...
|
@@ -97,11 +97,8 @@ class HelperSearch |
|
|
$result['opts']['pageCounts'] = self::viewNum();
|
|
|
$result['opts']['curPage'] = self::$page;
|
|
|
$result['opts']['pageCount'] = $data['data']['page_total'];
|
|
|
$result['opts']['nextHref'] = self::next($data['data']['page_total'],$data['data']['filter']);
|
|
|
$result['hasNextPage'] = array(
|
|
|
'href' => self::next($data['data']['page_total'],$data['data']['filter']),
|
|
|
'src' => 'http://img10.static.yhbimg.com/product/2014/01/15/11/01fa01614784f6239760f1b749663016f1.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90'
|
|
|
);
|
|
|
$result['opts']['nextHref'] = ($next = self::next($data['data']['page_total'],$data['data']['filter'])) ? $next['href'] : '';
|
|
|
$result['hasNextPage'] = self::next($data['data']['page_total']);
|
|
|
//分类
|
|
|
$result['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array();
|
|
|
//一周新品上架
|
...
|
...
|
@@ -168,12 +165,6 @@ class HelperSearch |
|
|
public static function standard($filter) {
|
|
|
$params = self::$params;
|
|
|
$result = array();
|
|
|
if (empty(self::$params)) {
|
|
|
return $result;
|
|
|
}
|
|
|
if (empty($filter) || !is_array($filter)) {
|
|
|
return array();
|
|
|
}
|
|
|
foreach ($filter as $key => $val) {
|
|
|
if (substr_compare($key, 'parameter', 0, 9) != 0) {
|
|
|
continue;
|
...
|
...
|
@@ -181,7 +172,6 @@ class HelperSearch |
|
|
if (!isset($val['sub']) || empty($val['sub'])) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
$sub = array();
|
|
|
foreach ($val['sub'] as $pval) {
|
|
|
if (isset(self::$params['parameter_' . $val['standard_id']]) && self::$params['parameter_' . $val['standard_id']] == $pval['standard_id']) {
|
...
|
...
|
@@ -189,12 +179,12 @@ class HelperSearch |
|
|
unset($tmpParams['parameter_' . $val['standard_id']]);
|
|
|
self::$selected['parameter_' . $val['standard_id']] = array(
|
|
|
'name' => $pval['standard_name'],
|
|
|
'href' => self::buildurl($tmpParams)
|
|
|
'href' => self::buildUrl($tmpParams)
|
|
|
);
|
|
|
}
|
|
|
$sub[] = array(
|
|
|
'name' => $pval['standard_name'],
|
|
|
'href' => self::buildurl(array_merge($params, array(
|
|
|
'href' => self::buildUrl(array_merge($params, array(
|
|
|
'parameter_' . $val['standard_id'] => $pval['standard_id']
|
|
|
))) ,
|
|
|
'selected' => isset(self::$params['parameter_' . $val['standard_id']]) && self::$params['parameter_' . $val['standard_id']] == $pval['standard_id'] ? true : false
|
...
|
...
|
@@ -223,21 +213,20 @@ class HelperSearch |
|
|
if (isset($params['gender'])) {
|
|
|
unset($params['gender']);
|
|
|
}
|
|
|
|
|
|
//设置选中
|
|
|
if ($gender == '1,3' || $gender == '2,3') {
|
|
|
self::$selected['gender'] = array(
|
|
|
'name' => $gender == '1,3' ? 'BOYS' : 'GIRLS',
|
|
|
'href' => self::buildurl($params)
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
}
|
|
|
$result = array();
|
|
|
foreach ($filter['gender'] as $key => $val) {
|
|
|
$result[] = array(
|
|
|
'name' => $val,
|
|
|
'href' => self::buildurl(array_merge($params, array(
|
|
|
'href' => self::buildUrl(array_merge($params, array(
|
|
|
'gender' => $key
|
|
|
))) ,
|
|
|
'selected' => $gender == $key ? true : false
|
|
|
);
|
|
|
}
|
|
|
return $result;
|
...
|
...
|
@@ -249,105 +238,50 @@ class HelperSearch |
|
|
* @param array $option
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function groupSort($sort, $option = array()) {
|
|
|
|
|
|
public static function groupSort($sort, $option = array())
|
|
|
{
|
|
|
//设置导航
|
|
|
self::setListNav($option);
|
|
|
$params = self::$params;
|
|
|
$gender = isset($params['gender']) ? $params['gender'] : '';
|
|
|
|
|
|
$query = array();
|
|
|
if (isset($option['needKeyword']) && $option['needKeyword'] == 'Y') {
|
|
|
if (isset($params['query']) && !empty($params['query'])) {
|
|
|
$query['query'] = $params['query'];
|
|
|
}
|
|
|
|
|
|
if (isset($params['keyword']) && !empty($params['keyword'])) {
|
|
|
$query['keyword'] = $params['keyword'];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (isset($params['gender']) && !empty($params['gender'])) {
|
|
|
$query['gender'] = $params['gender'];
|
|
|
}
|
|
|
if (isset($option['needDay']) && !empty($option['needDay']) && isset($params['day']) && !empty($params['day'])) {
|
|
|
$query['day'] = $params['day'];
|
|
|
}
|
|
|
if (isset($option['needPd']) && !empty($option['needPd']) && isset($params['p_d']) && !empty($params['p_d'])) {
|
|
|
$query['p_d'] = $params['p_d'];
|
|
|
}
|
|
|
if (isset($option['specialsale_id']) && !empty($option['specialsale_id']) && isset($params['specialsale_id']) && !empty($params['specialsale_id'])) {
|
|
|
$query['specialsale_id'] = $params['specialsale_id'];
|
|
|
}
|
|
|
|
|
|
$result = array(
|
|
|
'all' => array(
|
|
|
'sort_id' => 0,
|
|
|
'name' => '全部品类',
|
|
|
'href' => self::buildurl($query) ,
|
|
|
// 'num' => 0,
|
|
|
'active' => ''
|
|
|
'href' => self::buildUrl() ,
|
|
|
'active' => isset($params['msort']) ? false : true,
|
|
|
) ,
|
|
|
'list' => array()
|
|
|
);
|
|
|
foreach ($sort as $val) {
|
|
|
$sortList = array();
|
|
|
foreach ($sort as $key => $val) {
|
|
|
//若参数有分类,设置导航
|
|
|
if (isset($params['msort']) && $params['msort'] == $val['sort_id']) {
|
|
|
$nav_index = isset($option['brandName']) && $option['brandName'] ? 2 : 1;
|
|
|
self::$listnav[$nav_index] = array(
|
|
|
'sort_id' => $val['sort_id'],
|
|
|
//是否有品牌
|
|
|
$navIndex = isset($option['brandName']) && $option['brandName'] ? 2 : 1;
|
|
|
self::$listnav[$navIndex] = array(
|
|
|
'name' => $val['sort_name'],
|
|
|
'href' => self::buildurl(array(
|
|
|
'href' => self::buildUrl(array(
|
|
|
'msort' => $val['sort_id'],
|
|
|
'gender' => $gender
|
|
|
))
|
|
|
);
|
|
|
}
|
|
|
//$result['all']['num']+= $val['count'];
|
|
|
$msort = array(
|
|
|
'sort_id' => $val['sort_id'],
|
|
|
'name' => $val['sort_name'],
|
|
|
// 'num' => $val['count'],
|
|
|
'active' => isset($params['msort']) && $params['msort'] == $val['sort_id'] ? true : false,
|
|
|
'href' => self::buildurl(array_merge($query, array(
|
|
|
'msort' => $val['sort_id']
|
|
|
))) ,
|
|
|
'childList' => array()
|
|
|
);
|
|
|
$sub = array();
|
|
|
if (!empty($val['sub'])) {
|
|
|
|
|
|
$sub[] = array(
|
|
|
'sort_id' => $val['sort_id'],
|
|
|
'name' => '全部' . $val['sort_name'],
|
|
|
// 'num' => $val['count'],
|
|
|
'childActive' => !isset($params['misort']) && isset($params['msort']) && $params['msort'] == $val['sort_id'] ? true : false,
|
|
|
'href' => self::buildurl(array_merge($query, array(
|
|
|
'msort' => $val['sort_id']
|
|
|
))) ,
|
|
|
);
|
|
|
foreach ($val['sub'] as $mval) {
|
|
|
if (isset($params['misort']) && $params['misort'] == $mval['sort_id']) {
|
|
|
$nav_index = isset($option['brandName']) && $option['brandName'] ? 3 : 2;
|
|
|
self::$listnav[$nav_index] = array(
|
|
|
'sort_id' => $mval['sort_id'],
|
|
|
'name' => $mval['sort_name'],
|
|
|
'href' => ''
|
|
|
);
|
|
|
}
|
|
|
|
|
|
$sub[] = array(
|
|
|
'sort_id' => $mval['sort_id'],
|
|
|
'name' => $mval['sort_name'],
|
|
|
// 'num' => $mval['count'],
|
|
|
'childActive' => isset($params['misort']) && $params['misort'] == $mval['sort_id'] ? true : false,
|
|
|
'href' => self::buildurl(array_merge($query, array(
|
|
|
'msort' => $val['sort_id'],
|
|
|
'misort' => $mval['sort_id']
|
|
|
))) ,
|
|
|
unset($params['msort']);
|
|
|
unset($params['misort']);
|
|
|
$sortList[$key]['name'] = $val['sort_name'];
|
|
|
$sortList[$key]['active'] = isset(self::$params['msort']) && self::$params['msort'] == $val['sort_id'] ? true : false;
|
|
|
$sortList[$key]['childList'][] = array(
|
|
|
'name' => '全部分类',
|
|
|
'href' => self::buildUrl(array_merge($params, array('msort'=>$val['sort_id'])))
|
|
|
);
|
|
|
if (isset($val['sub']) && !empty($val['sub'])) {
|
|
|
foreach ($val['sub'] as $k => $v) {
|
|
|
$sortList[$key]['childList'][$k+1]['name'] = $v['sort_name'];
|
|
|
$sortList[$key]['childList'][$k+1]['href'] = self::buildUrl(array_merge($params, array('msort' => $val['sort_id'], 'misort' => $v['sort_id'])));
|
|
|
$sortList[$key]['childList'][$k+1]['childActive'] = isset(self::$params['misort']) && self::$params['misort'] == $v['sort_id'] ? true : false;
|
|
|
}
|
|
|
$msort['childList'] = $sub;
|
|
|
}
|
|
|
$result['list'][] = $msort;
|
|
|
}
|
|
|
$result['list'] = $sortList;
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -358,14 +292,10 @@ class HelperSearch |
|
|
* @return array
|
|
|
*/
|
|
|
public static function brand($filter, $options = array()) {
|
|
|
//品牌列表返回空
|
|
|
if (isset($options['brandName'])) {
|
|
|
return array();
|
|
|
}
|
|
|
$params = self::$params;
|
|
|
$brand_ids = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
|
|
if (isset($params['brand'])) {
|
|
|
unset($params['brand']);
|
|
|
}
|
|
|
$result = array(
|
|
|
'default' => array() ,
|
|
|
'brandIndex' => array(
|
...
|
...
|
@@ -374,58 +304,28 @@ class HelperSearch |
|
|
'H~N',
|
|
|
'O~T',
|
|
|
'U~Z') ,
|
|
|
'brandsShow' => array() ,
|
|
|
'list' => array(
|
|
|
'0~9' => array() ,
|
|
|
'A~G' => array() ,
|
|
|
'H~N' => array() ,
|
|
|
'O~T' => array() ,
|
|
|
'U~Z' => array() ,
|
|
|
)
|
|
|
'brandsShow' => array()
|
|
|
);
|
|
|
$brand_keys = array_reverse(array_keys($result['list']));
|
|
|
$params = self::$params;
|
|
|
//url中的品牌ids
|
|
|
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
|
|
if (isset($filter['brand']) && !empty($filter['brand'])) {
|
|
|
//有商品结果时
|
|
|
$brand = $filter['brand'];
|
|
|
foreach ($brand as $v) {
|
|
|
if (!isset($v['brand_alif']) && isset($v['brand_name_en'])) {
|
|
|
$v['brand_alif'] = substr($v['brand_name_en'], 0, 1);
|
|
|
}
|
|
|
else if (!isset($v['brand_alif'])) {
|
|
|
$v['brand_alif'] = '';
|
|
|
}
|
|
|
if (!isset($v['brand_domain'])) {
|
|
|
$v['brand_domain'] = '';
|
|
|
}
|
|
|
//选中的筛选条件
|
|
|
if (in_array($v['id'], $brand_ids)) {
|
|
|
$selected_brand = explode(',', self::$params['brand']);
|
|
|
$selected_key = array_search($v['id'], $selected_brand);
|
|
|
unset($selected_brand[$selected_key]);
|
|
|
$selected_params = $params;
|
|
|
$selected_params['brand'] = implode(',', $selected_brand);
|
|
|
self::$selected['brand'][] = array(
|
|
|
'name' => $v['brand_name'],
|
|
|
'href' => self::buildurl($selected_params)
|
|
|
);
|
|
|
}
|
|
|
$selected_brand = isset(self::$params['brand']) && !empty(self::$params['brand']) ? explode(',', self::$params['brand']) : array();
|
|
|
if (empty($selected_brand)) {
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
'brand' => $v['id']
|
|
|
)));
|
|
|
}
|
|
|
else if (in_array($v['id'], $brand_ids)) {
|
|
|
$tk = array_search($v['id'], $selected_brand);
|
|
|
unset($selected_brand[$tk]);
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
'brand' => implode(',', $selected_brand)
|
|
|
foreach ($brand as $key => $v) {
|
|
|
$selectBrandIds = $brandIds;
|
|
|
//品牌id在提交的参数中,构造url参数去除该品牌id
|
|
|
if (in_array($v['id'], $brandIds)) {
|
|
|
$filterKey = array_search($v['id'], $selectBrandIds);
|
|
|
unset($selectBrandIds[$filterKey]);
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'brand' => implode(',', $selectBrandIds)
|
|
|
)));
|
|
|
}
|
|
|
//该品牌url参数中添加该品牌的id
|
|
|
else {
|
|
|
$selected_brand[] = $v['id'];
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
'brand' => implode(',', $selected_brand)
|
|
|
$selectBrandIds[] = $v['id'];
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'brand' => implode(',', $selectBrandIds)
|
|
|
)));
|
|
|
}
|
|
|
$this_brand = array(
|
...
|
...
|
@@ -433,53 +333,41 @@ class HelperSearch |
|
|
'name' => $v['brand_name'],
|
|
|
'alif' => $v['brand_alif'],
|
|
|
'href' => $url,
|
|
|
'active' => in_array($v['id'], $brand_ids) ? true : false
|
|
|
'active' => in_array($v['id'], $brandIds) ? true : false
|
|
|
);
|
|
|
//默认品牌
|
|
|
if (count($result['default']) < 10) {
|
|
|
$result['default'][] = $this_brand;
|
|
|
}
|
|
|
$result['brandsShow'][] = $this_brand;
|
|
|
foreach ($brand_keys as $range) {
|
|
|
if (ord($v['brand_alif']) >= ord($range)) {
|
|
|
$_order_key = $v['brand_alif'] . $v['brand_name'];
|
|
|
$result['list'][$range][$_order_key] = $this_brand;
|
|
|
break;
|
|
|
//品牌列表
|
|
|
$brandList[$v['brand_alif']][] = $this_brand;
|
|
|
$brandAll[$v['id']] = $v['brand_name'];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
foreach ($result['list'] as $key => $value) {
|
|
|
ksort($result['list'][$key]);
|
|
|
$result['list'][$key] = array_values($result['list'][$key]);
|
|
|
if (empty($value)) {
|
|
|
unset($result['list'][$key]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (isset($filter['paramNames']) && isset($filter['paramNames']['brand'])) {
|
|
|
//无商品结果时且选择了品牌
|
|
|
$brand = $filter['paramNames']['brand'];
|
|
|
foreach ($brand as $v) {
|
|
|
//选中的筛选条件
|
|
|
if (in_array($v['id'], $brand_ids)) {
|
|
|
$selected_brand = explode(',', self::$params['brand']);
|
|
|
$selected_key = array_search($v['id'], $selected_brand);
|
|
|
unset($selected_brand[$selected_key]);
|
|
|
$selected_params = $params;
|
|
|
$selected_params['brand'] = implode(',', $selected_brand);
|
|
|
//清空品牌参数
|
|
|
unset($params['brand']);
|
|
|
//设置已选中的品牌
|
|
|
foreach ($brandIds as $key => $val) {
|
|
|
$brandParam = $brandIds;
|
|
|
unset($brandParam[$key]);
|
|
|
$params['brand'] = implode(',', $brandParam);
|
|
|
self::$selected['brand'][] = array(
|
|
|
'name' => $v['name'],
|
|
|
'href' => self::buildurl($selected_params)
|
|
|
'name' => $brandAll[$val],
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
}
|
|
|
//品牌列表排序
|
|
|
ksort($brandList);
|
|
|
foreach ($brandList as $key => $val) {
|
|
|
if (is_array($val)) {
|
|
|
foreach ($val as $v) {
|
|
|
$result['brandsShow'][] = $v;
|
|
|
}
|
|
|
$result['list'] = array();
|
|
|
}
|
|
|
else {
|
|
|
$result['list'] = array();
|
|
|
}
|
|
|
unset($brandList);
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 尺码的链接,不能多选
|
|
|
* @param array $filter
|
...
|
...
|
@@ -487,7 +375,7 @@ class HelperSearch |
|
|
*/
|
|
|
public static function size($filter) {
|
|
|
$params = self::$params;
|
|
|
$size_id = isset($params['size']) && !empty($params['size']) ? $params['size'] : '';
|
|
|
$sizeId = isset($params['size']) && !empty($params['size']) ? $params['size'] : '';
|
|
|
if (isset($params['size'])) {
|
|
|
unset($params['size']);
|
|
|
}
|
...
|
...
|
@@ -495,32 +383,21 @@ class HelperSearch |
|
|
if (isset($filter['size']) && !empty($filter['size'])) {
|
|
|
$size = $filter['size'];
|
|
|
foreach ($size as $v) {
|
|
|
if ($v['size_id'] == $size_id) {
|
|
|
//设置选中
|
|
|
if ($v['size_id'] == $sizeId) {
|
|
|
self::$selected['size'] = array(
|
|
|
'name' => $v['size_name'],
|
|
|
'href' => self::buildurl($params)
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
}
|
|
|
$result[] = array(
|
|
|
'size_id' => $v['size_id'],
|
|
|
'name' => $v['size_name'],
|
|
|
'href' => self::buildurl(array_merge($params, array(
|
|
|
'href' => self::buildUrl(array_merge($params, array(
|
|
|
'size' => $v['size_id']
|
|
|
))) ,
|
|
|
'selected' => $size_id == $v['size_id'] ? true : false
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
else if (isset($filter['paramNames']) && isset($filter['paramNames']['size'])) {
|
|
|
$size = $filter['paramNames']['size'];
|
|
|
foreach ($size as $val) {
|
|
|
self::$selected['size'] = array(
|
|
|
'name' => $val['name'],
|
|
|
'href' => self::buildurl($params)
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -531,51 +408,29 @@ class HelperSearch |
|
|
*/
|
|
|
public static function color($filter) {
|
|
|
$params = self::$params;
|
|
|
$color_id = isset($params['color']) && !empty(self::$params['color']) ? self::$params['color'] : '';
|
|
|
$colorId = isset($params['color']) && !empty(self::$params['color']) ? self::$params['color'] : '';
|
|
|
if (isset($params['color'])) {
|
|
|
unset($params['color']);
|
|
|
}
|
|
|
|
|
|
$result = array();
|
|
|
if (isset($filter['color']) && !empty($filter['color'])) {
|
|
|
|
|
|
//有商品结果时的颜色
|
|
|
$color = $filter['color'];
|
|
|
foreach ($color as $v) {
|
|
|
if ($v['color_id'] == $color_id) {
|
|
|
//设置已选中
|
|
|
if ($v['color_id'] == $colorId) {
|
|
|
$background = empty($v['color_value']) ? '#' . $v['color_code'] : "url(" . $v['color_value'] . ")";
|
|
|
self::$selected['color'] = array(
|
|
|
'color' => $background,
|
|
|
'href' => self::buildurl($params)
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
}
|
|
|
|
|
|
$result[] = array(
|
|
|
'color_id' => $v['color_id'],
|
|
|
'name' => $v['color_name'],
|
|
|
'rgb' => empty($v['color_value']) ? '#' . $v['color_code'] : "url({$v['color_value']})",
|
|
|
'href' => self::buildurl(array_merge($params, array(
|
|
|
'href' => self::buildUrl(array_merge($params, array(
|
|
|
'color' => $v['color_id']
|
|
|
))) ,
|
|
|
'selected' => $color_id == $v['color_id'] ? true : false
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
else if (isset($filter['paramNames']) && isset($filter['paramNames']['color'])) {
|
|
|
|
|
|
//无商品结果时的颜色
|
|
|
$color = $filter['paramNames']['color'];
|
|
|
foreach ($color as $v) {
|
|
|
if ($v['id'] == $color_id) {
|
|
|
$background = empty($v['value']) ? '#' . $v['code'] : "url(" . $v['value'] . ")";
|
|
|
self::$selected['color'] = array(
|
|
|
'name' => '<em style="background:' . $background . ';"> </em>',
|
|
|
'href' => self::buildurl($params)
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -586,54 +441,28 @@ class HelperSearch |
|
|
*/
|
|
|
public static function price($filter) {
|
|
|
$params = self::$params;
|
|
|
$price_id = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
|
|
|
$priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
|
|
|
if (isset($params['price'])) {
|
|
|
unset($params['price']);
|
|
|
}
|
|
|
|
|
|
$result = array();
|
|
|
|
|
|
if (isset($filter['price']) && !empty($filter['price'])) {
|
|
|
|
|
|
//有商品时
|
|
|
if (!empty($price_id) && isset($filter['price'][$price_id])) {
|
|
|
//设置已选中价格
|
|
|
if (!empty($priceId) && isset($filter['price'][$priceId])) {
|
|
|
self::$selected['price'] = array(
|
|
|
'name' => $filter['price'][$price_id],
|
|
|
'href' => self::buildurl($params)
|
|
|
'name' => $filter['price'][$priceId],
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
}
|
|
|
else if (!empty($price_id)) {
|
|
|
$_price = explode(',', $price_id);
|
|
|
if (count($_price) == 2) {
|
|
|
self::$selected['price'] = array(
|
|
|
'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$_price[0] . '-' . (int)$_price[1],
|
|
|
'href' => self::buildurl($params)
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//返回价格条件
|
|
|
foreach ($filter['price'] as $key => $val) {
|
|
|
$val = trim($val,'¥');
|
|
|
$result[] = array(
|
|
|
'name' => $val,
|
|
|
'href' => self::buildurl(array_merge($params, array(
|
|
|
'href' => self::buildUrl(array_merge($params, array(
|
|
|
'price' => $key
|
|
|
))) ,
|
|
|
'selected' => isset(self::$params['price']) && $key == self::$params['price'] ? true : false
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
else if (!empty($price_id)) {
|
|
|
|
|
|
//无商品结果时
|
|
|
$_price = explode(',', $price_id);
|
|
|
if (count($_price) == 2) {
|
|
|
self::$selected['price'] = array(
|
|
|
'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$_price[0] . '-' . (int)$_price[1],
|
|
|
'href' => self::buildurl($params)
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -644,76 +473,47 @@ class HelperSearch |
|
|
*/
|
|
|
public static function style($filter) {
|
|
|
$params = self::$params;
|
|
|
$style_ids = isset($params['style']) && !empty($params['style']) ? explode(',', $params['style']) : array();
|
|
|
$styleIds = isset($params['style']) && !empty($params['style']) ? explode(',', $params['style']) : array();
|
|
|
if (isset($params['style'])) {
|
|
|
unset($params['style']);
|
|
|
}
|
|
|
$result = array();
|
|
|
if (isset($filter['style']) && !empty($filter['style'])) {
|
|
|
//有商品结果时
|
|
|
$style = $filter['style'];
|
|
|
foreach ($style as $v) {
|
|
|
//选中的筛选条件
|
|
|
if (in_array($v['style_id'], $style_ids)) {
|
|
|
$selected_style = explode(',', self::$params['style']);
|
|
|
$selected_key = array_search($v['style_id'], $selected_style);
|
|
|
unset($selected_style[$selected_key]);
|
|
|
$selected_params = $params;
|
|
|
$selected_params['style'] = implode(',', $selected_style);
|
|
|
if (in_array($v['style_id'], $styleIds)) {
|
|
|
$selectedStyle = explode(',', self::$params['style']);
|
|
|
$selectedKey = array_search($v['style_id'], $selectedStyle);
|
|
|
unset($selectedStyle[$selectedKey]);
|
|
|
$selectedParams = $params;
|
|
|
$selectedParams['style'] = implode(',', $selectedStyle);
|
|
|
self::$selected['style'][] = array(
|
|
|
'name' => $v['style_name'],
|
|
|
'href' => self::buildurl($selected_params)
|
|
|
'href' => self::buildUrl($selectedParams)
|
|
|
);
|
|
|
}
|
|
|
|
|
|
$selected_style = isset(self::$params['style']) && !empty(self::$params['style']) ? explode(',', self::$params['style']) : array();
|
|
|
|
|
|
if (empty($selected_style)) {
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
'style' => $v['style_id']
|
|
|
)));
|
|
|
}
|
|
|
else if (in_array($v['style_id'], $selected_style)) {
|
|
|
$tk = array_search($v['style_id'], $selected_style);
|
|
|
unset($selected_style[$tk]);
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
'style' => implode(',', $selected_style)
|
|
|
$selectedStyle = isset(self::$params['style']) && !empty(self::$params['style']) ? explode(',', self::$params['style']) : array();
|
|
|
//风格id在提交的参数中,构造url参数去除该风格id
|
|
|
if (in_array($v['style_id'], $selectedStyle)) {
|
|
|
$filterKey = array_search($v['style_id'], $selectedStyle);
|
|
|
unset($selectedStyle[$filterKey]);
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'style' => implode(',', $selectedStyle)
|
|
|
)));
|
|
|
}
|
|
|
//该风格url参数中添加该风格的id
|
|
|
else {
|
|
|
$selected_style[] = $v['style_id'];
|
|
|
$url = self::buildurl($params + array(
|
|
|
'style' => implode(',', $selected_style)
|
|
|
));
|
|
|
$selectedStyle[] = $v['style_id'];
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'style' => implode(',', $selectedStyle)
|
|
|
)));
|
|
|
}
|
|
|
$result[] = array(
|
|
|
'style_id' => $v['style_id'],
|
|
|
'id' => $v['style_id'],
|
|
|
'name' => $v['style_name'],
|
|
|
'href' => $url,
|
|
|
'selected' => in_array($v['style_id'], $style_ids) ? true : false
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
else if (isset($filter['paramNames']) && isset($filter['paramNames']['style'])) {
|
|
|
|
|
|
//无商品结果时
|
|
|
$style = $filter['paramNames']['style'];
|
|
|
foreach ($style as $v) {
|
|
|
|
|
|
//选中的筛选条件
|
|
|
if (in_array($v['id'], $style_ids)) {
|
|
|
$selected_style = explode(',', self::$params['style']);
|
|
|
$selected_key = array_search($v['id'], $selected_style);
|
|
|
unset($selected_style[$selected_key]);
|
|
|
$selected_params = $params;
|
|
|
$selected_params['style'] = implode(',', $selected_style);
|
|
|
self::$selected['style'][] = array(
|
|
|
'name' => $v['name'],
|
|
|
'href' => self::buildurl($selected_params)
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
$data[0] = array(
|
|
|
'attr' => 'style',
|
|
|
'name' => '风格',
|
...
|
...
|
@@ -739,18 +539,14 @@ class HelperSearch |
|
|
public static function viewNum()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
$view_num = array(
|
|
|
60,
|
|
|
100,
|
|
|
200
|
|
|
);
|
|
|
$viewNum = array(60, 100, 200);
|
|
|
$result = array();
|
|
|
foreach ($view_num as $value) {
|
|
|
foreach ($viewNum as $value) {
|
|
|
$params['viewNum'] = $value;
|
|
|
$params['page'] = 1;
|
|
|
$result[] = array(
|
|
|
'count' => $value,
|
|
|
'href' => self::buildurl($params)
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
}
|
|
|
return $result;
|
...
|
...
|
@@ -762,10 +558,8 @@ class HelperSearch |
|
|
public static function rowNum($num = 5)
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
|
|
|
$params['rowNum'] = $num;
|
|
|
|
|
|
return self::buildurl($params);
|
|
|
return self::buildUrl($params);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -773,6 +567,7 @@ class HelperSearch |
|
|
*/
|
|
|
public static function specialoffer()
|
|
|
{
|
|
|
$selected = '';
|
|
|
$params = self::$params;
|
|
|
if (isset($params['specialoffer']) && !empty($params['specialoffer'])) {
|
|
|
unset($params['specialoffer']);
|
...
|
...
|
@@ -780,12 +575,10 @@ class HelperSearch |
|
|
}
|
|
|
else {
|
|
|
$params['specialoffer'] = 1;
|
|
|
$selected = '';
|
|
|
}
|
|
|
|
|
|
return array(
|
|
|
'name' => '打折',
|
|
|
'href' => self::buildurl($params) ,
|
|
|
'href' => self::buildUrl($params) ,
|
|
|
'checked' => $selected
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -795,6 +588,7 @@ class HelperSearch |
|
|
*/
|
|
|
public static function limited()
|
|
|
{
|
|
|
$selected = '';
|
|
|
$params = self::$params;
|
|
|
if (isset($params['limited']) && !empty($params['limited'])) {
|
|
|
unset($params['limited']);
|
...
|
...
|
@@ -802,11 +596,10 @@ class HelperSearch |
|
|
}
|
|
|
else {
|
|
|
$params['limited'] = 'Y';
|
|
|
$selected = '';
|
|
|
}
|
|
|
return array(
|
|
|
'name' => '限量',
|
|
|
'href' => self::buildurl($params) ,
|
|
|
'href' => self::buildUrl($params) ,
|
|
|
'checked' => $selected
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -817,18 +610,17 @@ class HelperSearch |
|
|
public static function isnew()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
|
|
|
$selected = '';
|
|
|
if (isset($params['isNew']) && !empty($params['isNew'])) {
|
|
|
unset($params['isNew']);
|
|
|
$selected = true;
|
|
|
}
|
|
|
else {
|
|
|
$params['isNew'] = 'Y';
|
|
|
$selected = false;
|
|
|
}
|
|
|
return array(
|
|
|
'name' => '新品',
|
|
|
'href' => self::buildurl($params) ,
|
|
|
'href' => self::buildUrl($params) ,
|
|
|
'checked' => $selected
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -844,10 +636,10 @@ class HelperSearch |
|
|
}
|
|
|
$result = array(
|
|
|
'name' => '最新',
|
|
|
'href' => isset(self::$params['order']) && self::$params['order'] == 's_t_desc' ? self::buildurl($params) : self::buildurl(array_merge($params, array(
|
|
|
'order' => 's_t_desc'
|
|
|
'href' => isset(self::$params['order']) && self::$params['order'] == 's_t_desc' ? self::buildUrl($params) : self::buildUrl(array_merge($params, array(
|
|
|
'order' => 's_t_asc'
|
|
|
))) ,
|
|
|
'selected' => isset(self::$params['order']) && self::$params['order'] == 's_t_desc' ? true : ''
|
|
|
'active' => isset(self::$params['order']) && self::$params['order'] == 's_t_asc' ? true : ''
|
|
|
);
|
|
|
return $result;
|
|
|
}
|
...
|
...
|
@@ -863,8 +655,8 @@ class HelperSearch |
|
|
}
|
|
|
$result = array(
|
|
|
'name' => '默认',
|
|
|
'href' => self::buildurl($params) ,
|
|
|
'selected' => !isset(self::$params['order']) || empty(self::$params['order']) ? true : ''
|
|
|
'href' => self::buildUrl($params) ,
|
|
|
'active' => !isset(self::$params['order']) || empty(self::$params['order']) ? true : ''
|
|
|
);
|
|
|
return $result;
|
|
|
}
|
...
|
...
|
@@ -882,33 +674,34 @@ class HelperSearch |
|
|
's_p_asc',
|
|
|
's_p_desc'
|
|
|
))) {
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'order' => 's_p_asc'
|
|
|
)));
|
|
|
$asc = '';
|
|
|
$desc = '';
|
|
|
$active = '';
|
|
|
$desc = true;
|
|
|
}
|
|
|
else if (self::$params['order'] == 's_p_asc') {
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'order' => 's_p_desc'
|
|
|
)));
|
|
|
$asc = true;
|
|
|
$desc = '';
|
|
|
$active = true;
|
|
|
$desc = true;
|
|
|
|
|
|
}
|
|
|
else {
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'order' => 's_p_asc'
|
|
|
)));
|
|
|
$asc = '';
|
|
|
$desc = true;
|
|
|
$desc = '';
|
|
|
$active = '';
|
|
|
}
|
|
|
$result = array(
|
|
|
'name' => '价格',
|
|
|
'href' => $url,
|
|
|
'asc' => $asc,
|
|
|
'hasSortOrient' => true,
|
|
|
'active' => $active,
|
|
|
'desc' => $desc
|
|
|
);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -925,21 +718,21 @@ class HelperSearch |
|
|
'p_d_asc',
|
|
|
'p_d_desc'
|
|
|
))) {
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'order' => 'p_d_asc'
|
|
|
)));
|
|
|
$asc = '';
|
|
|
$desc = '';
|
|
|
}
|
|
|
else if (self::$params['order'] == 'p_d_asc') {
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'order' => 'p_d_desc'
|
|
|
)));
|
|
|
$asc = true;
|
|
|
$desc = '';
|
|
|
}
|
|
|
else {
|
|
|
$url = self::buildurl(array_merge($params, array(
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'order' => 'p_d_asc'
|
|
|
)));
|
|
|
$asc = '';
|
...
|
...
|
@@ -947,6 +740,7 @@ class HelperSearch |
|
|
}
|
|
|
$result = array(
|
|
|
'name' => '折扣',
|
|
|
'hasSortOrient' => true,
|
|
|
'href' => $url,
|
|
|
'asc' => $asc,
|
|
|
'desc' => $desc
|
...
|
...
|
@@ -956,58 +750,16 @@ class HelperSearch |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取自定义价格要提交的地址
|
|
|
*/
|
|
|
public static function priceSubmit()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
$price = array();
|
|
|
if (isset($params['price'])) {
|
|
|
$price = explode(',', $params['price']);
|
|
|
unset($params['price']);
|
|
|
}
|
|
|
|
|
|
$result = array();
|
|
|
foreach ($params as $key => $value) {
|
|
|
$result[] = '<input type="hidden" name="' . $key . '" value="' . $value . '">';
|
|
|
}
|
|
|
|
|
|
if (count($price) == 2 && !in_array(self::$params['price'], array(
|
|
|
'0,300',
|
|
|
'300,600',
|
|
|
'600,1000',
|
|
|
'1000,2000',
|
|
|
'2000,99999'
|
|
|
))) {
|
|
|
return array(
|
|
|
'start' => $price[0],
|
|
|
'end' => $price[1],
|
|
|
'selected' => true,
|
|
|
'form' => implode('', $result)
|
|
|
);
|
|
|
}
|
|
|
else {
|
|
|
return array(
|
|
|
'start' => '',
|
|
|
'end' => '',
|
|
|
'selected' => false,
|
|
|
'form' => implode('', $result)
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 组织参数
|
|
|
* @param array $params
|
|
|
* @return string
|
|
|
*/
|
|
|
private static function buildurl($params)
|
|
|
private static function buildUrl($params = array())
|
|
|
{
|
|
|
if (empty($params)) {
|
|
|
return self::current();
|
|
|
}
|
|
|
$queryPath = explode('?', $_SERVER['REQUEST_URI']);
|
|
|
|
|
|
$params_arr = array();
|
|
|
foreach ($params as $key => $val) {
|
|
|
if (is_array($val) || $val === '') {
|
...
|
...
|
@@ -1054,31 +806,18 @@ class HelperSearch |
|
|
public static function getDiscount(array $list = array())
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
|
|
|
if (empty($list)) {
|
|
|
return array();
|
|
|
}
|
|
|
$params = $_GET;
|
|
|
$query = array();
|
|
|
if (isset($params['gender'])) {
|
|
|
$query['gender'] = $params['gender'];
|
|
|
}
|
|
|
if (isset($params['msort'])) {
|
|
|
$query['msort'] = $params['msort'];
|
|
|
}
|
|
|
if (isset($params['misort'])) {
|
|
|
$query['misort'] = $params['misort'];
|
|
|
}
|
|
|
$total = 0;
|
|
|
foreach ($list as $k => $v) {
|
|
|
$total+= $v['count'];
|
|
|
$total += $v['count'];
|
|
|
$query['p_d'] = $k;
|
|
|
$list[$k]['href'] = self::buildurl($query);
|
|
|
//$list[$k]['num'] = $total;
|
|
|
$list[$k]['href'] = self::buildUrl($query);
|
|
|
$list[$k]['active'] = isset($params['p_d']) && $params['p_d'] == $k ? true : false;
|
|
|
}
|
|
|
$result = array(
|
|
|
//'updateNum' => $total,
|
|
|
'list' => array_values($list)
|
|
|
);
|
|
|
return $result;
|
...
|
...
|
@@ -1094,15 +833,6 @@ class HelperSearch |
|
|
}
|
|
|
$params = self::$params;
|
|
|
$query = array();
|
|
|
if (isset($params['gender'])) {
|
|
|
$query['gender'] = $params['gender'];
|
|
|
}
|
|
|
if (isset($params['msort'])) {
|
|
|
$query['msort'] = $params['msort'];
|
|
|
}
|
|
|
if (isset($params['misort'])) {
|
|
|
$query['misort'] = $params['misort'];
|
|
|
}
|
|
|
$data = array();
|
|
|
$i = 0;
|
|
|
foreach ($list as $k => $v) {
|
...
|
...
|
@@ -1113,7 +843,7 @@ class HelperSearch |
|
|
if (isset($params['shelve_time']) && $query['shelve_time'] == $params['shelve_time']) {
|
|
|
$data[$i]['active'] = true;
|
|
|
}
|
|
|
@$data[$i]['href'] = self::buildurl($query);
|
|
|
$data[$i]['href'] = self::buildUrl($query);
|
|
|
$data[$i]['name'] = $k;
|
|
|
$i++;
|
|
|
}
|
...
|
...
|
@@ -1121,6 +851,8 @@ class HelperSearch |
|
|
//'updateNum' => $total,
|
|
|
'list' => $data
|
|
|
);
|
|
|
unset($data);
|
|
|
unset($query);
|
|
|
return $result;
|
|
|
}
|
|
|
/**
|
...
|
...
|
@@ -1132,17 +864,22 @@ class HelperSearch |
|
|
return $url[0];
|
|
|
}
|
|
|
/**
|
|
|
* 下一页地址
|
|
|
* 下一页
|
|
|
*/
|
|
|
public static function next($total,$filter){
|
|
|
$page = 1;
|
|
|
public static function next($total){
|
|
|
$param = self::$params;
|
|
|
$page = self::$page;
|
|
|
if($page < $total){
|
|
|
$next = array();
|
|
|
if ($page < $total) {
|
|
|
$page ++;
|
|
|
$param['page'] = $page;
|
|
|
$nextUrl = self::buildUrl($param);
|
|
|
$next = array(
|
|
|
'href' => $nextUrl,
|
|
|
'src' => 'http://img10.static.yhbimg.com/product/2014/01/15/11/01fa01614784f6239760f1b749663016f1.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90'
|
|
|
);
|
|
|
}
|
|
|
return self::buildurl($param);
|
|
|
return $next;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1164,8 +901,8 @@ class HelperSearch |
|
|
return $result;
|
|
|
}
|
|
|
//分页
|
|
|
public static function pager($total,$view_num){
|
|
|
public static function pager($total,$viewNum){
|
|
|
$Paging = new Paging('Yoho');
|
|
|
return $Paging->setTotal($total)->setSize($view_num)->view(0);
|
|
|
return $Paging->setTotal($total)->setSize($viewNum)->view(0);
|
|
|
}
|
|
|
} |
...
|
...
|
|