Authored by yangyang

合并代码

... ... @@ -123,15 +123,31 @@ class HelperSearch
'pageCount' => $result['page_total'],
'nextHref' => $result['filter']['next']
),
'hasNextPage' => array(
'href' => $result['filter']['next'],
'src' => 'http://img10.static.yhbimg.com/product/2014/01/15/11/01fa01614784f6239760f1b749663016f1.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90'
),
'goods' => $result['product_list'],
'allSort' => array(
'updateNum' => $result['filter']['group_sort']['all']['num'],
'list' => $result['filter']['group_sort']['list']
'leftContent' => array(
array(
'allSort' => array(
//'updateNum' => $result['filter']['group_sort']['all']['num'],
'list' => $result['filter']['group_sort']['list']
)
),
array(
'advNav' => array()
),
array(
'advPic' => array()
),
array(
'newSales' => $result['filter']['recent']
),
array('allDiscount' => $result['filter']['discount'])
),
'advNav' => array(),
'advPic' => array(),
'newSales' => $result['filter']['recent'],
'allDiscount' => $result['filter']['discount']
'totalCount' => $result['total'],
);
return $data;
}
... ... @@ -144,9 +160,18 @@ class HelperSearch
public static function getProductList($product,$imgSize){
$result = 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']);
}
... ... @@ -156,13 +181,15 @@ class HelperSearch
$result[] = 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;
... ... @@ -256,12 +283,6 @@ class HelperSearch
* @param array $params
* @return array
*/
/**
* 组织搜索列表页面的左侧分类
* @param array $sort
* @param array $params
* @return array
*/
public static function groupSort($sort, $option = array()) {
$params = self::$params;
$gender = isset($params['gender']) ? $params['gender'] : '';
... ... @@ -295,8 +316,8 @@ class HelperSearch
'sort_id' => 0,
'name' => '全部品类',
'href' => self::buildurl($query) ,
'num' => 0,
'selected' => ''
// 'num' => 0,
'active' => ''
) ,
'list' => array()
);
... ... @@ -311,12 +332,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 +349,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 +367,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']
... ... @@ -448,7 +469,7 @@ class HelperSearch
'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) {
... ... @@ -1058,6 +1079,8 @@ class HelperSearch
* @return array
*/
public static function getDiscount(array $list = array()) {
$params = self::$params;
if (empty($list)) {
return array();
}
... ... @@ -1077,11 +1100,11 @@ 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,
//'updateNum' => $total,
'list' => $list
);
return $result;
... ... @@ -1094,7 +1117,7 @@ class HelperSearch
if (empty($list)) {
return array();
}
$params = $_GET;
$params = self::$params;
$query = array();
if (isset($params['gender'])) {
$query['gender'] = $params['gender'];
... ... @@ -1106,21 +1129,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;
... ... @@ -1150,4 +1173,23 @@ 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;
}
}
... ...
{{> layout/header}}
<div class="product-search-page product-page yoho-page center-content">
{{# search}}
{{> layout/path-nav}}
{{> product/standard-content}}
{{> product/latest-walk}}
{{/ search}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -95,7 +95,7 @@ exports.init = function(num) {
});
$.ajax({
type: 'POST',
url: '/product/index/getProductPic',
url: '/product/list/getProductPic',
dataType: 'json',
data: {
skn: event.target.attr('data-skn')
... ...
... ... @@ -58,4 +58,27 @@ class SearchModel
}
return $data;
}
/**
* 根据product_sn查询产品图片信息
* @param $product_sn
* @param $options
* @author sefon 2015-12-28 18:09:28
* @return array
*/
public static function getProductPic($product_sn, $options)
{
$data = array();
$condition['query'] = $product_sn;
$condition['query'] = $product_sn;
//返回搜索条件
$condition['needFilter'] = 0;
//获取产品数据
$data = SearchData::searchElasticByCondition($condition);
if (isset($data['code']) && $data['code'] === 200 && isset($data['data']['product_list']) && !empty($data['data']['product_list'])) {
//组织数据结构
$data = HelperSearch::getProductPic($data['data']['product_list'], $options);
}
echo json_encode($data);
}
}
\ No newline at end of file
... ...
... ... @@ -39,10 +39,6 @@ class IndexController extends WebAction
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,
'shelve_time' => FILTER_DEFAULT,
'parameter_790' => FILTER_DEFAULT,
'parameter_824' => FILTER_DEFAULT,
'parameter_825' => FILTER_DEFAULT,
'parameter_787' => FILTER_DEFAULT,
'isNew' => FILTER_DEFAULT,
'specialoffer' => FILTER_DEFAULT,
'limited' => FILTER_DEFAULT,
... ...
<?php
use Action\WebAction;
use Product\SearchModel;
class ListController extends WebAction
{
public function indexAction()
{
}
public function newAction(){
}
/**
* list列表sale
... ... @@ -76,9 +80,41 @@ class ListController extends WebAction
);
$params = $condition + $_GET;
$params = array_filter($params);
$data = Product\SearchModel::getSearchData($params,$options);
$data = SearchModel::getSearchData($params,$options);
// print_r($data); exit;
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
$this->_view->display('list', $data);
}
/**
* 根据product_skn获取产品图片信息
* @author sefon 2015-12-28 18:35:24
* @return json
*/
public function getProductPicAction()
{
$product_skn = $this->post('skn');
if (!$product_skn) {
return ;
}
//大图
$imgSize = array();
//小图
$minImgSize = array();
$rowNum = $this->post('rowNum');
if ($rowNum == 5) {
$imgSize = array(195, 260);
$minImgSize = array(50, 67);
} else {
$condition['rowNum'] = 4;
$imgSize = array(235, 314);
$minImgSize = array(60, 80);
}
$options = array(
'imgSize' => $imgSize,
'minImgSize' => $minImgSize,
);
SearchModel::getProductPic($product_skn, $options);
}
}
\ No newline at end of file
... ...