...
|
...
|
@@ -17,15 +17,16 @@ class HelperSearch |
|
|
public static $options = array();
|
|
|
//当前页
|
|
|
public static $page = 1;
|
|
|
//总页数
|
|
|
public static $pageTotal;
|
|
|
//总记录数
|
|
|
public static $total;
|
|
|
//接口返回搜索条件
|
|
|
public static $filter;
|
|
|
|
|
|
//选中的条件
|
|
|
public static $selected = array();
|
|
|
|
|
|
//list分类面包屑
|
|
|
public static $listNav = array();
|
|
|
|
|
|
//设置导航
|
|
|
private static function setListNav()
|
|
|
{
|
...
|
...
|
@@ -78,9 +79,9 @@ class HelperSearch |
|
|
//总页数
|
|
|
$result['page_total'] = isset($data['product']['page_total']) ? $data['product']['page_total'] : '';
|
|
|
self::$pageTotal = $result['page_total'];
|
|
|
self::$total = $data['product']['total'];
|
|
|
//当前页
|
|
|
$result['page'] = isset($data['product']['page']) ? $data['product']['page'] : '';
|
|
|
self::$page = $result['page'];
|
|
|
self::$page = $result['page'] = isset($data['product']['page']) ? $data['product']['page'] : '';
|
|
|
//筛选条件
|
|
|
$result['filters'] = isset($data['product']['filter']) ? self::filter() : array();
|
|
|
//排序方式、显示数量等其他选项
|
...
|
...
|
@@ -145,7 +146,7 @@ class HelperSearch |
|
|
* @author sefon 2015-12-21 17:24:04
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function getProductList($product,$imgSize)
|
|
|
public static function getProductList($product, $imgSize)
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
$goods = array();
|
...
|
...
|
@@ -160,12 +161,26 @@ class HelperSearch |
|
|
//即将售罄
|
|
|
$isFew = $val['is_soon_sold_out'] === 'Y' ? true : false;
|
|
|
//SALE
|
|
|
$isSale = ($val['is_discount'] == 'Y') ? true : false;
|
|
|
//新品节
|
|
|
//再到着
|
|
|
//年终大促
|
|
|
// 年中大促
|
|
|
$gender = 0;
|
|
|
if (isset(self::$options['gender'])) {
|
|
|
$genderArr = explode(',', self::$options['gender']);
|
|
|
$gender = $genderArr[0];
|
|
|
}
|
|
|
foreach($val['goods_list'] as $k => $v){
|
|
|
$goods_list[$k]['url'] = Helpers::getUrlBySkc($val['product_id'], $v['goods_id'], $val['cn_alphabet']);
|
|
|
//女封
|
|
|
if (isset($v['cover_1']) && $gender == 1) {
|
|
|
$val['default_images'] = $v['images_url'];
|
|
|
}
|
|
|
//男封
|
|
|
if (isset($v['cover_2']) && $gender == 2) {
|
|
|
$val['default_images'] = $v['images_url'];
|
|
|
}
|
|
|
//筛选符合颜色条件的封面图片
|
|
|
if (isset($params['color']) && $params['color'] == $v['color_id']) {
|
|
|
$val['default_images'] = $v['images_url'];
|
...
|
...
|
@@ -175,11 +190,19 @@ class HelperSearch |
|
|
if (!empty($val['default_images'])) {
|
|
|
$val['default_images'] = Images::getImageUrl($val['default_images'],$imgSize[0],$imgSize[1]);
|
|
|
}
|
|
|
|
|
|
//搜索关键字高亮
|
|
|
if (isset(self::$params['query']) && !empty(self::$params['query']) && preg_match("/".self::$params['query']."/i", $val['product_name'], $match)) {
|
|
|
foreach ($match as $k => &$v) {
|
|
|
$replace[$k] = '<span style="color: #cc0000">'.$v.'</span>';
|
|
|
$v = '/'.$v.'/';
|
|
|
}
|
|
|
$val['product_name'] = preg_replace($match, $replace, $val['product_name']);
|
|
|
}
|
|
|
$good = array(
|
|
|
'tags' => array(
|
|
|
'isNew' => $isNew,
|
|
|
'isLimit' => $isLimit
|
|
|
'isLimit' => $isLimit,
|
|
|
'isSale' => $isSale
|
|
|
),
|
|
|
'url' => self::fromPram($goods_list[0]['url'],++$key),
|
|
|
'thumb' => $val['default_images'],
|
...
|
...
|
@@ -422,7 +445,7 @@ class HelperSearch |
|
|
//已选中品牌数量
|
|
|
$existBrandNum = 0;
|
|
|
//已选中品牌标签名
|
|
|
$existName = '';
|
|
|
$existName = array();
|
|
|
foreach ($brand as $key => $v) {
|
|
|
$selectBrandIds = $brandIds;
|
|
|
//品牌已被选中
|
...
|
...
|
@@ -433,10 +456,10 @@ class HelperSearch |
|
|
'brand' => implode(',', $selectBrandIds)
|
|
|
)));
|
|
|
if ($existBrandNum === 0) {
|
|
|
$existName .= $v['brand_name'].'、';
|
|
|
$existName[] = $v['brand_name'];
|
|
|
}
|
|
|
if ($existBrandNum === 1){
|
|
|
$existName .= substr($v['brand_name'], 0, 3).'...';
|
|
|
$existName[]= substr($v['brand_name'], 0, 3).'...';
|
|
|
}
|
|
|
$existBrandNum++;
|
|
|
}
|
...
|
...
|
@@ -474,7 +497,7 @@ class HelperSearch |
|
|
//设置选中
|
|
|
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
|
|
|
self::$selected['brand'] = array(
|
|
|
'name' => rtrim($existName, '、'),
|
|
|
'name' => implode($existName,'、'),
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
}
|
...
|
...
|
@@ -487,7 +510,6 @@ class HelperSearch |
|
|
$result['brandIndex'][] = $index;
|
|
|
}
|
|
|
unset($brandList);
|
|
|
|
|
|
//搜索页已选中,返回空
|
|
|
if (self::checkSearch('brand')) {
|
|
|
return array();
|
...
|
...
|
@@ -586,12 +608,16 @@ class HelperSearch |
|
|
*/
|
|
|
public static function price($filter)
|
|
|
{
|
|
|
$result = array();
|
|
|
//商品记录小于10,不显示价格区间
|
|
|
if (self::$total < 10) {
|
|
|
return $result;
|
|
|
}
|
|
|
$params = self::$params;
|
|
|
$priceId = isset($params['price']) && !empty(self::$params['price']) ? self::$params['price'] : '';
|
|
|
if (isset($params['price'])) {
|
|
|
unset($params['price']);
|
|
|
}
|
|
|
$result = array();
|
|
|
//设置已选中价格
|
|
|
if (!empty($priceId)) {
|
|
|
$price = explode(',' ,$priceId);
|
...
|
...
|
|