...
|
...
|
@@ -11,25 +11,20 @@ use Api\Sign; |
|
|
*/
|
|
|
class HelperSearch
|
|
|
{
|
|
|
/**
|
|
|
* 请求时用的所有参数
|
|
|
*/
|
|
|
//请求时用的所有参数
|
|
|
public static $params = array();
|
|
|
|
|
|
public static $options = array();
|
|
|
//当前页
|
|
|
public static $page = 1;
|
|
|
public static $pageTotal;
|
|
|
public static $filter;
|
|
|
|
|
|
/**
|
|
|
* 选中的条件
|
|
|
*/
|
|
|
//选中的条件
|
|
|
public static $selected = array();
|
|
|
|
|
|
/**
|
|
|
* list分类面包屑
|
|
|
* @var array
|
|
|
*/
|
|
|
public static $listnav = array();
|
|
|
//list分类面包屑
|
|
|
public static $listNav = array();
|
|
|
|
|
|
//设置导航
|
|
|
private static function setListNav()
|
...
|
...
|
@@ -41,11 +36,11 @@ class HelperSearch |
|
|
}else{
|
|
|
$initNav = '列表';
|
|
|
}
|
|
|
self::$listnav[0] = array(
|
|
|
self::$listNav[0] = array(
|
|
|
'href' => '',
|
|
|
'name' => $cookieChannel
|
|
|
);
|
|
|
self::$listnav[1] = array(
|
|
|
self::$listNav[1] = array(
|
|
|
'href' => '',
|
|
|
'name' => $initNav
|
|
|
);
|
...
|
...
|
@@ -63,46 +58,20 @@ class HelperSearch |
|
|
self::$options = $options;
|
|
|
unset(self::$params['/']);
|
|
|
unset(self::$params['page']);
|
|
|
unset(self::$params['/sale']);
|
|
|
unset(self::$params['sale']);
|
|
|
$filter = $data['product']['filter'];
|
|
|
self::$filter = $data['product']['filter'];
|
|
|
//产品列表
|
|
|
$result['goods'] = self::getProductList($data['product']['product_list'], $options['imgSize']);
|
|
|
//总页数
|
|
|
$result['page_total'] = $data['product']['page_total'];
|
|
|
self::$pageTotal = $data['product']['page_total'];
|
|
|
//当前页
|
|
|
$result['page'] = $data['product']['page'];
|
|
|
self::$page = $result['page'];
|
|
|
//清除选中
|
|
|
$result['filters']['checkedConditions']['clearUrl'] = self::current();
|
|
|
//频道
|
|
|
$result['filters']['channel'] = self::gender($filter);
|
|
|
//品牌
|
|
|
$result['filters']['brand'] = self::brand($filter);
|
|
|
//价格
|
|
|
$result['filters']['price'] = self::price($filter);
|
|
|
$result['filters']['customPrice'] = self::customPrice($filter);
|
|
|
//颜色
|
|
|
$result['filters']['color'] = self::color($filter);
|
|
|
//尺寸
|
|
|
$result['filters']['size'] = self::size($filter);
|
|
|
//高级选项
|
|
|
$result['filters']['seniorChose'] = self::seniorChose($filter);
|
|
|
//排序方式
|
|
|
$result['opts']['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount());
|
|
|
//特殊:新品、特价、限量
|
|
|
$result['opts']['checks'] = array(self::isnew(),self::specialoffer(),self::limited());
|
|
|
//每行显示5个产品
|
|
|
$result['opts']['fivePerLine'] = true;
|
|
|
//每行显示6个产品
|
|
|
$result['opts']['sixPerLineHref'] = true;
|
|
|
//每页显示的数量
|
|
|
$result['opts']['countPerPage'] = $options['viewNum'];
|
|
|
//可选每页显示数量
|
|
|
$result['opts']['pageCounts'] = self::viewNum();
|
|
|
$result['opts']['curPage'] = self::$page;
|
|
|
$result['opts']['pageCount'] = $data['product']['page_total'];
|
|
|
$result['opts']['nextHref'] = ($next = self::next($data['product']['page_total'],$data['product']['filter'])) ? $next['href'] : '';
|
|
|
//筛选条件
|
|
|
$result['filters'] = self::filter();
|
|
|
//排序方式、显示数量等其他选项
|
|
|
$result['opts'] = self::getOpts();
|
|
|
//下一页
|
|
|
$result['hasNextPage'] = self::next($data['product']['page_total']);
|
|
|
//全部折扣
|
|
|
$result['leftContent'][]['allDiscount'] = isset($data['discount']) ? self::getDiscount($data['discount']['discount']) : array();
|
...
|
...
|
@@ -121,17 +90,15 @@ class HelperSearch |
|
|
//分页
|
|
|
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
|
|
|
//选中条件
|
|
|
if (self::getSelected()) {
|
|
|
$result['filters']['checkedConditions']['conditions'] = self::getSelected();
|
|
|
}
|
|
|
//没有选中
|
|
|
else{
|
|
|
$result['filters']['checkedConditions'] = array();
|
|
|
}
|
|
|
$result['filters']['checkedConditions'] = self::getSelected();
|
|
|
if (isset($options['controller']) && $options['controller'] == 'Search') {
|
|
|
self::setSearchNav($data['product']['total']);
|
|
|
}
|
|
|
$result['pathNav'] = isset($options['controller']) && $options['controller'] == 'Sale' ? array() : self::$listnav;
|
|
|
if (empty($result['goods'])) {
|
|
|
$result['filters'] = array();
|
|
|
$result['opts'] = array();
|
|
|
}
|
|
|
$result['pathNav'] = isset($options['controller']) && $options['controller'] == 'Sale' ? array() : self::$listNav;
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -295,7 +262,7 @@ class HelperSearch |
|
|
if (isset($params['msort']) && $params['msort'] == $val['sort_id']) {
|
|
|
//是否有品牌
|
|
|
$navIndex = isset($option['brandName']) && $option['brandName'] ? 2 : 1;
|
|
|
self::$listnav[$navIndex] = array(
|
|
|
self::$listNav[$navIndex] = array(
|
|
|
'name' => $val['sort_name'],
|
|
|
'href' => self::buildUrl(array(
|
|
|
'msort' => $val['sort_id'],
|
...
|
...
|
@@ -336,13 +303,14 @@ class HelperSearch |
|
|
$result[$key]['name'] = $val['sort_name'];
|
|
|
if (isset($val['sub']) && !empty($val['sub'])) {
|
|
|
foreach ($val['sub'] as $k => $v) {
|
|
|
$result[$key]['sub'][$k]['href'] = self::buildUrl(array('msort' => $val['sort_id'], 'misort' => $v['sort_id']));
|
|
|
$result[$key]['sub'][$k]['href'] = self::buildUrl(array_merge($params,array('msort' => $val['sort_id'], 'misort' => $v['sort_id'])));
|
|
|
$result[$key]['sub'][$k]['name'] = $v['sort_name'];
|
|
|
if (isset($params['misort']) && $params['misort'] == $v['sort_id']) {
|
|
|
unset($params['msort']);
|
|
|
unset($params['misort']);
|
|
|
self::$selected['sort'] = array(
|
|
|
'name' => $v['sort_name'],
|
|
|
'href' => self::buildUrl()
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -846,8 +814,8 @@ class HelperSearch |
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'order' => 's_p_asc'
|
|
|
)));
|
|
|
$desc = '';
|
|
|
$active = '';
|
|
|
$desc = false;
|
|
|
$active = true;
|
|
|
}
|
|
|
$result = array(
|
|
|
'name' => '价格',
|
...
|
...
|
@@ -875,29 +843,29 @@ class HelperSearch |
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'order' => 'p_d_asc'
|
|
|
)));
|
|
|
$asc = '';
|
|
|
$desc = '';
|
|
|
$desc = false;
|
|
|
$active = true;
|
|
|
}
|
|
|
else if (self::$params['order'] == 'p_d_asc') {
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'order' => 'p_d_desc'
|
|
|
)));
|
|
|
$asc = true;
|
|
|
$desc = '';
|
|
|
$desc = false;
|
|
|
$active = true;
|
|
|
}
|
|
|
else {
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'order' => 'p_d_asc'
|
|
|
)));
|
|
|
$asc = '';
|
|
|
$active = true;
|
|
|
$desc = true;
|
|
|
}
|
|
|
$result = array(
|
|
|
'name' => '折扣',
|
|
|
'hasSortOrient' => true,
|
|
|
'href' => $url,
|
|
|
'asc' => $asc,
|
|
|
'desc' => $desc
|
|
|
'hasSortOrient' => true,
|
|
|
'active' => $active,
|
|
|
'desc' => $desc,
|
|
|
);
|
|
|
|
|
|
return $result;
|
...
|
...
|
@@ -935,6 +903,7 @@ class HelperSearch |
|
|
public static function getSelected()
|
|
|
{
|
|
|
$result = array();
|
|
|
$data = array();
|
|
|
$is_array_key = array(
|
|
|
'brand',
|
|
|
'style'
|
...
|
...
|
@@ -942,13 +911,16 @@ class HelperSearch |
|
|
foreach (self::$selected as $key => $val) {
|
|
|
if (in_array($key, $is_array_key)) {
|
|
|
foreach ($val as $k => $v) {
|
|
|
$result[] = $v;
|
|
|
$data[] = $v;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
$result[] = $val;
|
|
|
$data[] = $val;
|
|
|
}
|
|
|
}
|
|
|
if ($data) {
|
|
|
$result['conditions'] = $data;
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1015,7 +987,7 @@ class HelperSearch |
|
|
public static function current()
|
|
|
{
|
|
|
$url = explode('?', $_SERVER['REQUEST_URI']);
|
|
|
self::$listnav[0]['href'] = $url[0];
|
|
|
self::$listNav[0]['href'] = $url[0];
|
|
|
return $url[0];
|
|
|
}
|
|
|
/**
|
...
|
...
|
@@ -1136,19 +1108,19 @@ class HelperSearch |
|
|
*/
|
|
|
public static function setSearchNav($total)
|
|
|
{
|
|
|
self::$listnav[0] = array(
|
|
|
self::$listNav[0] = array(
|
|
|
'href' => '/',
|
|
|
'name' => '首页'
|
|
|
);
|
|
|
$param = self::$params;
|
|
|
$options = self::$options;
|
|
|
if (isset($options['controller']) && $options['controller'] == 'Search' && isset($param['query'])) {
|
|
|
self::$listnav[1] = array(
|
|
|
self::$listNav[1] = array(
|
|
|
'href' => '',
|
|
|
'name' => "‘".$param['query']."’ 共".$total."个结果"
|
|
|
);
|
|
|
}else{
|
|
|
self::$listnav[1] = array(
|
|
|
self::$listNav[1] = array(
|
|
|
'href' => '',
|
|
|
'name' => '所有商品'
|
|
|
);
|
...
|
...
|
@@ -1184,7 +1156,6 @@ class HelperSearch |
|
|
$param['status'] = 1; // 是否上架,1表示在架,2表示不在
|
|
|
$param['sales'] = 'Y'; // 只搜索销售的产品
|
|
|
$param['stocknumber'] = 1; // 过滤掉已售罄的商品
|
|
|
// $param['needFilter'] = 1; // 是否需要返回筛选条件
|
|
|
if (!isset($condition['order'])) {
|
|
|
$param['order'] = $orderMaps['s_t_desc'];
|
|
|
} else {
|
...
|
...
|
@@ -1335,7 +1306,7 @@ class HelperSearch |
|
|
elseif ($type == 'shop') {
|
|
|
return 'http://101.200.31.165/yohosearch/shops.json';
|
|
|
}
|
|
|
return 'http://101.200.31.165/yohosearch/search.json';
|
|
|
return 'http://192.168.10.64:8080/yohosearch/search-once.json';
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1370,4 +1341,50 @@ class HelperSearch |
|
|
'banner' => $bannerImg
|
|
|
);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 搜索条件
|
|
|
*/
|
|
|
public static function filter()
|
|
|
{
|
|
|
$result = array();
|
|
|
//清除选中
|
|
|
$result['checkedConditions']['clearUrl'] = self::current();
|
|
|
//频道
|
|
|
$result['channel'] = self::gender(self::$filter);
|
|
|
//品牌
|
|
|
$result['brand'] = self::brand(self::$filter);
|
|
|
//价格
|
|
|
$result['price'] = self::price(self::$filter);
|
|
|
$result['customPrice'] = self::customPrice(self::$filter);
|
|
|
//颜色
|
|
|
$result['color'] = self::color(self::$filter);
|
|
|
//尺寸
|
|
|
$result['size'] = self::size(self::$filter);
|
|
|
//高级选项
|
|
|
$result['seniorChose'] = self::seniorChose(self::$filter);
|
|
|
return $result;
|
|
|
}
|
|
|
/**
|
|
|
* 其他选项
|
|
|
*/
|
|
|
public static function getOpts()
|
|
|
{
|
|
|
//排序方式
|
|
|
$result['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount());
|
|
|
//特殊:新品、特价、限量
|
|
|
$result['checks'] = array(self::isnew(),self::specialoffer(),self::limited());
|
|
|
//每行显示5个产品
|
|
|
$result['fivePerLine'] = true;
|
|
|
//每行显示6个产品
|
|
|
$result['sixPerLineHref'] = true;
|
|
|
//每页显示的数量
|
|
|
$result['countPerPage'] = self::$options['viewNum'];
|
|
|
//可选每页显示数量
|
|
|
$result['pageCounts'] = self::viewNum();
|
|
|
$result['curPage'] = self::$page;
|
|
|
$result['pageCount'] = self::$pageTotal;
|
|
|
$result['nextHref'] = ($next = self::next(self::$pageTotal, self::$filter)) ? $next['href'] : '';
|
|
|
return $result;
|
|
|
}
|
|
|
} |
...
|
...
|
|