|
|
<?php
|
|
|
|
|
|
namespace Plugin;
|
|
|
use Plugin\Images;
|
|
|
use Plugin\Paging;
|
|
|
/**
|
|
|
* 搜索辅助类
|
|
|
*/
|
...
|
...
|
@@ -10,11 +10,10 @@ class HelperSearch |
|
|
/**
|
|
|
* 请求时用的所有参数
|
|
|
*/
|
|
|
private static $params = array();
|
|
|
public static $params = array();
|
|
|
|
|
|
//当前页面
|
|
|
private static $current_url = '';
|
|
|
private static $page = 1;
|
|
|
//当前页
|
|
|
public static $page = 1;
|
|
|
|
|
|
/**
|
|
|
* 选中的条件
|
...
|
...
|
@@ -25,147 +24,142 @@ class HelperSearch |
|
|
* list分类面包屑
|
|
|
* @var array
|
|
|
*/
|
|
|
public static $listnav = array(
|
|
|
array(
|
|
|
public static $listnav = array();
|
|
|
|
|
|
|
|
|
//设置导航
|
|
|
private static function setListNav($option = array())
|
|
|
{
|
|
|
$cookieChannel = isset($_COOKIE['_Channel']) ? $_COOKIE['_Channel'] : 'boys';
|
|
|
if (isset($option['brandName']) && !empty($option['brandName'])) {
|
|
|
$initNav = $option['brandName'];
|
|
|
}else{
|
|
|
$initNav = '列表';
|
|
|
}
|
|
|
self::$listnav[0] = array(
|
|
|
'href' => '',
|
|
|
'name' => '首页'
|
|
|
),
|
|
|
array(
|
|
|
'name' => $cookieChannel
|
|
|
);
|
|
|
self::$listnav[1] = array(
|
|
|
'href' => '',
|
|
|
'name' => '列表'
|
|
|
)
|
|
|
);
|
|
|
|
|
|
'name' => $initNav
|
|
|
);
|
|
|
}
|
|
|
/**
|
|
|
* 组织搜索模板数据
|
|
|
* @param array $data
|
|
|
* @param array $options
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function getList($data = array() , $options = array()) {
|
|
|
if (empty($data)) {
|
|
|
return array();
|
|
|
}
|
|
|
public static function getList($data = array() , $options = array())
|
|
|
{
|
|
|
$result = array();
|
|
|
self::$params = $_GET;
|
|
|
unset(self::$params['/']);
|
|
|
unset(self::$params['page']);
|
|
|
unset(self::$params['/sale']);
|
|
|
unset(self::$params['sale']);
|
|
|
$result = array();
|
|
|
if (!isset($data['data']) || !isset($data['data']['product_list']) || !is_array($data['data']['product_list'])) {
|
|
|
return array();
|
|
|
}
|
|
|
$result['product_list'] = self::getProductList($data['data']['product_list'], $options['imgSize'], $options['minImgSize'], $options['gender']);
|
|
|
$filter = $data['data']['filter'];
|
|
|
//产品列表
|
|
|
$result['goods'] = self::getProductList($data['data']['product_list'], $options['imgSize']);
|
|
|
//总页数
|
|
|
$result['page_total'] = $data['data']['page_total'];
|
|
|
$result['total'] = $data['data']['total'];
|
|
|
//当前页
|
|
|
$result['page'] = $data['data']['page'];
|
|
|
//设置当前页
|
|
|
self::$page = $result['page'];
|
|
|
//搜索条件
|
|
|
if (isset($data['data']['filter']) && !empty($data['data']['filter'])) {
|
|
|
$filter = $data['data']['filter'];
|
|
|
$result['filter']['left_sort'] = isset($filter['minsort']) ? self::minsort($filter['minsort']) : array();
|
|
|
$result['filter']['group_sort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array();
|
|
|
$result['filter']['size'] = self::size($filter);
|
|
|
$result['filter']['color'] = self::color($filter);
|
|
|
$result['filter']['price'] = self::price($filter);
|
|
|
$result['filter']['brand'] = self::brand($filter);
|
|
|
$result['filter']['parameters'] = self::standard($filter);
|
|
|
$result['filter']['rowNum4'] = self::rowNum();
|
|
|
$result['filter']['rowNum6'] = self::rowNum(6);
|
|
|
$result['filter']['viewNum'] = self::viewNum();
|
|
|
$result['filter']['priceSubmit'] = self::priceSubmit();
|
|
|
$result['filter']['gender'] = self::gender($filter);
|
|
|
$result['filter']['selected'] = self::getSelected();
|
|
|
$result['filter']['checks'] = array(self::isnew(),self::specialoffer(),self::limited());
|
|
|
$result['filter']['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount());
|
|
|
$result['filter']['clear'] =self::current();
|
|
|
$result['filter']['next'] = self::next($data['data']['page_total'],$data['data']['filter']);
|
|
|
$result['filter']['listnav'] = self::$listnav;
|
|
|
$result['filter']['discount'] = self::getDiscount($filter['discount']);
|
|
|
$result['filter']['recent'] = self::recentShelve($filter['recent']);
|
|
|
$result['filter']['seniorChose'] = self::seniorChose($filter);
|
|
|
}
|
|
|
//清除选中
|
|
|
$result['filters']['checkedConditions']['clearUrl'] = self::current();
|
|
|
//频道
|
|
|
$result['filters']['channel'] = self::gender($filter);
|
|
|
//分类
|
|
|
$result['filters']['sort'] = array();
|
|
|
//品牌
|
|
|
$result['filters']['brand'] = self::brand($filter);
|
|
|
//价格
|
|
|
$result['filters']['price'] = self::price($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['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['leftContent'][]['allSort'] = isset($filter['group_sort']) ? self::groupSort($filter['group_sort'], $options) : array();
|
|
|
//一周新品上架
|
|
|
$result['leftContent'][]['newSales'] = self::recentShelve($filter['recent']);
|
|
|
//全部折扣
|
|
|
$result['leftContent'][]['allDiscount'] = self::getDiscount($filter['discount']);
|
|
|
//总记录数
|
|
|
$result['totalCount'] = $data['data']['total'];
|
|
|
//分页
|
|
|
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']);
|
|
|
//echo $result['pager']; exit;
|
|
|
//选中条件
|
|
|
$result['filters']['checkedConditions']['conditions'] = self::getSelected();
|
|
|
$result['pathNav'] = self::$listnav;
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 组织列表模板数据
|
|
|
*
|
|
|
*/
|
|
|
public static function getTemplateData($result, $options){
|
|
|
//模板数据
|
|
|
$data = array(
|
|
|
'brandBanner' => array(),
|
|
|
'pathNav' => $result['filter']['listnav'],
|
|
|
'shopEntry' => array(),
|
|
|
'filters' => array(
|
|
|
'checkedConditions' => array(
|
|
|
'conditions' => $result['filter']['selected'],
|
|
|
'clearUrl' => $result['filter']['clear']
|
|
|
),
|
|
|
'channel' => $result['filter']['gender'],
|
|
|
'sort' => array() ,
|
|
|
'brand' => $result['filter']['brand'],
|
|
|
'price' => $result['filter']['price'],
|
|
|
'color' => $result['filter']['color'],
|
|
|
'size' => $result['filter']['size'],
|
|
|
'seniorChose' => $result['filter']['seniorChose']
|
|
|
),
|
|
|
'opts' => array(
|
|
|
'sortType' => $result['filter']['sortType'],
|
|
|
'checks' => $result['filter']['checks'],
|
|
|
'fivePerLine' => true,
|
|
|
'sixPerLineHref' => '',
|
|
|
'countPerPage' => $options['viewNum'],
|
|
|
'pageCounts' => $result['filter']['viewNum'],
|
|
|
'curPage' => $result['page'],
|
|
|
'pageCount' => $result['page_total'],
|
|
|
'nextHref' => $result['filter']['next']
|
|
|
),
|
|
|
'goods' => $result['product_list'],
|
|
|
'allSort' => array(
|
|
|
'updateNum' => $result['filter']['group_sort']['all']['num'],
|
|
|
'list' => $result['filter']['group_sort']['list']
|
|
|
),
|
|
|
'advNav' => array(),
|
|
|
'advPic' => array(),
|
|
|
'newSales' => $result['filter']['recent'],
|
|
|
'allDiscount' => $result['filter']['discount']
|
|
|
);
|
|
|
return $data;
|
|
|
}
|
|
|
/**
|
|
|
* TODO 组织商品列表信息
|
|
|
* @param $product 接口返回商品列表
|
|
|
* @author sefon 2015-12-21 17:24:04
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function getProductList($product,$imgSize){
|
|
|
$result = array();
|
|
|
$goods = array();
|
|
|
foreach($product as $key => $val){
|
|
|
//NEW
|
|
|
$isNew = $val['is_new'] == 'Y' ? true : false;
|
|
|
$isFew = $val['is_soon_sold_out'] == 'Y' ? true : false;
|
|
|
$is_promotion = $val['is_promotion'];
|
|
|
//限量商品
|
|
|
$isLimit = isset($val['is_limited']) && $val['is_limited'] === 'Y';
|
|
|
//即将售罄
|
|
|
$isFew = $val['is_soon_sold_out'] === 'Y' ? true : false;
|
|
|
//SALE
|
|
|
//新品节
|
|
|
//再到着
|
|
|
//年终大促
|
|
|
// 年中大促
|
|
|
foreach($val['goods_list'] as $k => $v){
|
|
|
$goods_list[$k]['url'] = Helpers::getUrlBySkc($val['product_id'], $v['goods_id'], $val['cn_alphabet']);
|
|
|
}
|
|
|
if (!empty($val['default_images'])) {
|
|
|
$val['default_images'] = Images::getImageUrl($val['default_images'],$imgSize[0],$imgSize[1]);
|
|
|
}
|
|
|
$result[] = array(
|
|
|
$goods[] = array(
|
|
|
'tags' => array(
|
|
|
'isNew' => $isNew,
|
|
|
'isYearEndPromotion' => $is_promotion
|
|
|
'isLimit' => $isLimit
|
|
|
),
|
|
|
'url' => $goods_list[0]['url'],
|
|
|
'thumb' => $val['default_images'],
|
|
|
'name' => $val['product_name'],
|
|
|
'salePrice' => $val['sales_price'],
|
|
|
'isFew' => $isFew
|
|
|
'marketPrice' => $val['market_price'],
|
|
|
'isFew' => $isFew,
|
|
|
'skn' => $val['product_skn']
|
|
|
);
|
|
|
}
|
|
|
return $result;
|
|
|
return $goods;
|
|
|
}
|
|
|
/**
|
|
|
* 版型等其它筛选项
|
...
|
...
|
@@ -256,13 +250,8 @@ class HelperSearch |
|
|
* @param array $params
|
|
|
* @return array
|
|
|
*/
|
|
|
/**
|
|
|
* 组织搜索列表页面的左侧分类
|
|
|
* @param array $sort
|
|
|
* @param array $params
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function groupSort($sort, $option = array()) {
|
|
|
self::setListNav();
|
|
|
$params = self::$params;
|
|
|
$gender = isset($params['gender']) ? $params['gender'] : '';
|
|
|
|
...
|
...
|
@@ -295,8 +284,8 @@ class HelperSearch |
|
|
'sort_id' => 0,
|
|
|
'name' => '全部品类',
|
|
|
'href' => self::buildurl($query) ,
|
|
|
'num' => 0,
|
|
|
'selected' => ''
|
|
|
// 'num' => 0,
|
|
|
'active' => ''
|
|
|
) ,
|
|
|
'list' => array()
|
|
|
);
|
...
|
...
|
@@ -311,12 +300,12 @@ class HelperSearch |
|
|
))
|
|
|
);
|
|
|
}
|
|
|
$result['all']['num']+= $val['count'];
|
|
|
//$result['all']['num']+= $val['count'];
|
|
|
$msort = array(
|
|
|
'sort_id' => $val['sort_id'],
|
|
|
'name' => $val['sort_name'],
|
|
|
'num' => $val['count'],
|
|
|
'selected' => isset($params['msort']) && $params['msort'] == $val['sort_id'] ? true : false,
|
|
|
// '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']
|
|
|
))) ,
|
...
|
...
|
@@ -328,8 +317,8 @@ class HelperSearch |
|
|
$sub[] = array(
|
|
|
'sort_id' => $val['sort_id'],
|
|
|
'name' => '全部' . $val['sort_name'],
|
|
|
'num' => $val['count'],
|
|
|
'selected' => !isset($params['misort']) && isset($params['msort']) && $params['msort'] == $val['sort_id'] ? true : false,
|
|
|
// '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']
|
|
|
))) ,
|
...
|
...
|
@@ -346,8 +335,8 @@ class HelperSearch |
|
|
$sub[] = array(
|
|
|
'sort_id' => $mval['sort_id'],
|
|
|
'name' => $mval['sort_name'],
|
|
|
'num' => $mval['count'],
|
|
|
'selected' => isset($params['misort']) && $params['misort'] == $mval['sort_id'] ? true : false,
|
|
|
// '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']
|
...
|
...
|
@@ -364,16 +353,18 @@ class HelperSearch |
|
|
/**
|
|
|
* 品牌,可以多选
|
|
|
* @param array $brand
|
|
|
* @param array $options
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function brand($filter) {
|
|
|
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(
|
...
|
...
|
@@ -391,14 +382,11 @@ class HelperSearch |
|
|
'U~Z' => array() ,
|
|
|
)
|
|
|
);
|
|
|
|
|
|
$brand_keys = array_reverse(array_keys($result['list']));
|
|
|
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);
|
|
|
}
|
...
|
...
|
@@ -408,7 +396,6 @@ class HelperSearch |
|
|
if (!isset($v['brand_domain'])) {
|
|
|
$v['brand_domain'] = '';
|
|
|
}
|
|
|
|
|
|
//选中的筛选条件
|
|
|
if (in_array($v['id'], $brand_ids)) {
|
|
|
$selected_brand = explode(',', self::$params['brand']);
|
...
|
...
|
@@ -421,9 +408,7 @@ class HelperSearch |
|
|
'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']
|
...
|
...
|
@@ -442,15 +427,13 @@ class HelperSearch |
|
|
'brand' => implode(',', $selected_brand)
|
|
|
)));
|
|
|
}
|
|
|
|
|
|
$this_brand = array(
|
|
|
'brand_id' => $v['id'],
|
|
|
'name' => $v['brand_name'],
|
|
|
'alif' => $v['brand_alif'],
|
|
|
'href' => $url,
|
|
|
'selected' => in_array($v['id'], $brand_ids) ? true : false
|
|
|
'active' => in_array($v['id'], $brand_ids) ? true : false
|
|
|
);
|
|
|
|
|
|
if (count($result['default']) < 10) {
|
|
|
$result['default'][] = $this_brand;
|
|
|
}
|
...
|
...
|
@@ -472,11 +455,9 @@ class HelperSearch |
|
|
}
|
|
|
}
|
|
|
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']);
|
...
|
...
|
@@ -743,7 +724,8 @@ class HelperSearch |
|
|
/**
|
|
|
* 高级选项
|
|
|
*/
|
|
|
public static function seniorChose($filter){
|
|
|
public static function seniorChose($filter)
|
|
|
{
|
|
|
$style = self::style($filter);
|
|
|
$other = self::standard($filter);
|
|
|
$result = array_merge($style,$other);
|
...
|
...
|
@@ -753,9 +735,9 @@ class HelperSearch |
|
|
/**
|
|
|
* 每页显示数量
|
|
|
*/
|
|
|
public static function viewNum() {
|
|
|
public static function viewNum()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
|
|
|
$view_num = array(
|
|
|
60,
|
|
|
100,
|
...
|
...
|
@@ -776,8 +758,9 @@ class HelperSearch |
|
|
/**
|
|
|
* 显示行数
|
|
|
*/
|
|
|
public static function rowNum($num = 5) {
|
|
|
$params = self::$params;
|
|
|
public static function rowNum($num = 5)
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
|
|
|
$params['rowNum'] = $num;
|
|
|
|
...
|
...
|
@@ -787,7 +770,8 @@ class HelperSearch |
|
|
/**
|
|
|
* 是否特价
|
|
|
*/
|
|
|
public static function specialoffer() {
|
|
|
public static function specialoffer()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
if (isset($params['specialoffer']) && !empty($params['specialoffer'])) {
|
|
|
unset($params['specialoffer']);
|
...
|
...
|
@@ -808,7 +792,8 @@ class HelperSearch |
|
|
/**
|
|
|
* 是否限量
|
|
|
*/
|
|
|
public static function limited() {
|
|
|
public static function limited()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
if (isset($params['limited']) && !empty($params['limited'])) {
|
|
|
unset($params['limited']);
|
...
|
...
|
@@ -828,7 +813,8 @@ class HelperSearch |
|
|
/**
|
|
|
* 是否新品
|
|
|
*/
|
|
|
public static function isnew() {
|
|
|
public static function isnew()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
|
|
|
if (isset($params['isNew']) && !empty($params['isNew'])) {
|
...
|
...
|
@@ -849,7 +835,8 @@ class HelperSearch |
|
|
/**
|
|
|
* 排序是否最新
|
|
|
*/
|
|
|
public static function orderTime() {
|
|
|
public static function orderTime()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
if (isset($params['order'])) {
|
|
|
unset($params['order']);
|
...
|
...
|
@@ -867,7 +854,8 @@ class HelperSearch |
|
|
/**
|
|
|
* 排序是否默认
|
|
|
*/
|
|
|
public static function orderDefault() {
|
|
|
public static function orderDefault()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
if (isset($params['order'])) {
|
|
|
unset($params['order']);
|
...
|
...
|
@@ -883,7 +871,8 @@ class HelperSearch |
|
|
/**
|
|
|
* 价格排序
|
|
|
*/
|
|
|
public static function orderPrice() {
|
|
|
public static function orderPrice()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
if (isset($params['order'])) {
|
|
|
unset($params['order']);
|
...
|
...
|
@@ -925,7 +914,8 @@ class HelperSearch |
|
|
/**
|
|
|
* 折扣排序
|
|
|
*/
|
|
|
public static function orderDiscount() {
|
|
|
public static function orderDiscount()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
if (isset($params['order'])) {
|
|
|
unset($params['order']);
|
...
|
...
|
@@ -967,7 +957,8 @@ class HelperSearch |
|
|
/**
|
|
|
* 获取自定义价格要提交的地址
|
|
|
*/
|
|
|
public static function priceSubmit() {
|
|
|
public static function priceSubmit()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
$price = array();
|
|
|
if (isset($params['price'])) {
|
...
|
...
|
@@ -1009,7 +1000,8 @@ class HelperSearch |
|
|
* @param array $params
|
|
|
* @return string
|
|
|
*/
|
|
|
private static function buildurl($params) {
|
|
|
private static function buildurl($params)
|
|
|
{
|
|
|
if (empty($params)) {
|
|
|
return self::current();
|
|
|
}
|
...
|
...
|
@@ -1033,7 +1025,8 @@ class HelperSearch |
|
|
/**
|
|
|
* 获取选中的条件
|
|
|
*/
|
|
|
public static function getSelected() {
|
|
|
public static function getSelected()
|
|
|
{
|
|
|
$result = array();
|
|
|
$is_array_key = array(
|
|
|
'brand',
|
...
|
...
|
@@ -1057,7 +1050,10 @@ class HelperSearch |
|
|
* @param array $list
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function getDiscount(array $list = array()) {
|
|
|
public static function getDiscount(array $list = array())
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
|
|
|
if (empty($list)) {
|
|
|
return array();
|
|
|
}
|
...
|
...
|
@@ -1077,12 +1073,12 @@ class HelperSearch |
|
|
$total+= $v['count'];
|
|
|
$query['p_d'] = $k;
|
|
|
$list[$k]['href'] = self::buildurl($query);
|
|
|
$list[$k]['num'] = $total;
|
|
|
$list[$k]['selected'] = isset($params['p_d']) && $params['p_d'] == $k ? true : false;
|
|
|
//$list[$k]['num'] = $total;
|
|
|
$list[$k]['active'] = isset($params['p_d']) && $params['p_d'] == $k ? true : false;
|
|
|
}
|
|
|
$result = array(
|
|
|
'updateNum' => $total,
|
|
|
'list' => $list
|
|
|
//'updateNum' => $total,
|
|
|
'list' => array_values($list)
|
|
|
);
|
|
|
return $result;
|
|
|
}
|
...
|
...
|
@@ -1090,11 +1086,12 @@ class HelperSearch |
|
|
/**
|
|
|
* 最新上架
|
|
|
*/
|
|
|
public static function recentShelve($list = array()){
|
|
|
public static function recentShelve($list = array())
|
|
|
{
|
|
|
if (empty($list)) {
|
|
|
return array();
|
|
|
}
|
|
|
$params = $_GET;
|
|
|
$params = self::$params;
|
|
|
$query = array();
|
|
|
if (isset($params['gender'])) {
|
|
|
$query['gender'] = $params['gender'];
|
...
|
...
|
@@ -1106,21 +1103,21 @@ class HelperSearch |
|
|
$query['misort'] = $params['misort'];
|
|
|
}
|
|
|
$data = array();
|
|
|
$total = 0;
|
|
|
$i = 0;
|
|
|
foreach ($list as $k => $v) {
|
|
|
$total+= $v;
|
|
|
$star_time = strtotime($k);
|
|
|
$end_time = $star_time+60*60*24;
|
|
|
$query['shelve_time'] = '';
|
|
|
$query['shelve_time'] = $star_time.','.$end_time;
|
|
|
if (isset($params['shelve_time']) && $query['shelve_time'] == $params['shelve_time']) {
|
|
|
$data[$i]['active'] = true;
|
|
|
}
|
|
|
@$data[$i]['href'] = self::buildurl($query);
|
|
|
$data[$i]['num'] = $v;
|
|
|
$data[$i]['name'] = $k;
|
|
|
$i++;
|
|
|
}
|
|
|
$result = array(
|
|
|
'updateNum' => $total,
|
|
|
//'updateNum' => $total,
|
|
|
'list' => $data
|
|
|
);
|
|
|
return $result;
|
...
|
...
|
@@ -1130,11 +1127,7 @@ class HelperSearch |
|
|
*/
|
|
|
public static function current(){
|
|
|
$url = explode('?', $_SERVER['REQUEST_URI']);
|
|
|
self::$current_url = $url[0];
|
|
|
self::$listnav[0] = array(
|
|
|
'href' => '$url[0]',
|
|
|
'name' => '首页'
|
|
|
);
|
|
|
self::$listnav[0]['href'] = $url[0];
|
|
|
return $url[0];
|
|
|
}
|
|
|
/**
|
...
|
...
|
@@ -1150,4 +1143,28 @@ class HelperSearch |
|
|
}
|
|
|
return self::buildurl($param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 组织产品的图片
|
|
|
* @param $product
|
|
|
* @param $options
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function getProductPic($product, $options)
|
|
|
{
|
|
|
$result = array();
|
|
|
if (isset($product[0]['goods_list']) && !empty($product[0]['goods_list'])){
|
|
|
foreach ($product[0]['goods_list'] as $key => $val){
|
|
|
$result[$key]['coverImg'] = Images::getImageUrl($val['images_url'], $options['imgSize'][0], $options['imgSize'][1]);
|
|
|
$result[$key]['url'] = Helpers::getUrlBySkc($product[0]['product_id'], $val['goods_id'], $product[0]['cn_alphabet']);
|
|
|
$result[$key]['src'] = Images::getImageUrl($val['images_url'], $options['imgSize'][0], $options['imgSize'][1]);
|
|
|
}
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
//分页
|
|
|
public static function pager($total,$view_num){
|
|
|
$Paging = new Paging('Yoho');
|
|
|
return $Paging->setTotal($total)->setSize($view_num)->view(0);
|
|
|
}
|
|
|
} |
...
|
...
|
|