Authored by 梁志锋

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

framework @ 75bbc3b0
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
... ... @@ -47,8 +47,11 @@ class ClassData
* @param integer $channel 表示频道号,1位男生,2为女生
* @return array 品类商品数据
*/
public static function selectBrandDetail($gender, $brand, $sort, $color, $size, $price, $p_d, $channel = 1, $order = 's_t_desc', $limit = 60, $page = 1)
public static function selectClassDetail($gender, $brand, $sort, $color, $size, $price, $p_d, $channel = 1, $order = 's_t_desc', $limit = 60, $page = 1)
{
// 构建必传参数
$param = Yohobuy::param();
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
... ... @@ -60,9 +63,7 @@ class ClassData
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {return $v !== null;});
// 构建必传参数
$param = Yohobuy::param();
$param += $queriedParams;
$param['method'] = 'app.search.category';
$param['page'] = $page;
... ...
... ... @@ -63,6 +63,7 @@ class ListProcess
// 过滤条件数据
$filters = array('classify'=>array());
$num = 1;
foreach ($data as $key => $val) {
if(empty($val))
{
... ... @@ -72,6 +73,12 @@ class ListProcess
continue;
}
$build = self::$key($val);
if($num === 1)
{
$build['active'] = true;
}
$num++;
$filters['classify'][] = $build;
}
... ...
{{# new}}
{{> good}}
{{/ new}}
\ No newline at end of file
... ...
... ... @@ -3,6 +3,7 @@
use Action\AbstractAction;
use LibModels\Wap\Product\SearchData;
use LibModels\Wap\Category\BrandData;
use LibModels\Wap\Category\ClassData;
use Plugin\DataProcess\ListProcess;
use Plugin\Helpers;
... ... @@ -11,33 +12,115 @@ use Plugin\Helpers;
*/
class ListController extends AbstractAction
{
/**
* 搜索列表页
*/
public function indexAction()
{
$data = array(
'goodListPage' => true,
'goodList' => array(
)
);
$query = $this->get('query', null);
$brand = $this->get('brand', null);
$gender = $this->get('gender', null);
$p_d = $this->get('p_d', null);
$misort = $this->get('misort', null);
$msort = $this->get('msort', null);
$data = array(
'pageHeader' => array(
'navBack' => true,
'navTitle' => '搜索',
'navHome' => '/'
),
'goodListPage' => true,
'goodList' => array()
);
// 如果存在搜索字符串就显示搜索栏
if(!is_null($query))
{
$data['search'] = array(
'default' => $query
);
}
// 查询数据
$listData = SearchData::searchLiDatas(null, $brand, $gender, $p_d, $misort, $msort);
$listData = SearchData::searchLiDatas($query, $brand, $gender, $p_d, $misort, $msort);
// 处理返回的数据
if (isset($listData['code']) && $listData['code'] === 200) {
$tmpData = $listData['data'];
// 如果存在品牌信息就显示品牌字段
if(isset($tmpData['brand']) && !empty($tmpData['brand']))
{
$brandData = $tmpData['brand'];
$data['brandWay'] = array(
'url' => '/product/list/brand?brand='.$brandData['id'],
'thumb' => Helpers::getImageUrl($brandData['brand_ico'], 75, 40),
'name' => $brandData['brand_name']
);
}
$data['goodList'] = ListProcess::getListData($tmpData);
}
$this->_view->display('index', $data);
}
/**
* Ajax异步筛选请求
*/
public function searchAction()
{
if($this->isAjax())
{
$query = $this->get('query', null);
$brand = $this->get('brand', null);
$gender = $this->get('gender', null);
$p_d = $this->get('p_d', null);
$misort = $this->get('misort', null);
$msort = $this->get('msort', null);
$order = $this->get('order', null);
$type = $this->get('type', '');
switch ($type) {
case 'price':
$order = ($order == 0) ? 's_p_desc' : 's_p_asc';
break;
case 'discount':
$order = ($order == 0) ? 'p_d_desc' : 'p_d_asc';
break;
case 'newest':
default:
$order = ($order == 0) ? 's_t_desc' : 's_t_asc';
break;
}
$data = array();
// 查询数据
$listData = SearchData::searchLiDatas($query, $brand, $gender, $p_d, $misort, $msort, $order);
// 处理返回的数据
if (isset($listData['code']) && $listData['code'] === 200) {
$tmpData = $listData['data'];
unset($tmpData['filter']);// 不要筛选条件的数据
$data = ListProcess::getListData($tmpData);
}
if(empty($data))
{
echo ' ';
}
else
{
$this->_view->display('list', $data);
}
}
}
/**
* 品牌商品列表页
*/
public function brandAction()
{
$brand = $this->get('brand', null);
... ... @@ -50,6 +133,7 @@ class ListController extends AbstractAction
$data = array(
'pageHeader' => array(
'navBack' => true,
'navHome' => '/'
),
'goodListPage' => true,
... ... @@ -88,5 +172,39 @@ class ListController extends AbstractAction
$this->_view->display('index', $data);
}
/**
* 品类商品列表页
*/
public function classAction()
{
$brand = $this->get('brand', null);
$gender = $this->get('gender', null);
$sort = $this->get('sort', null);
$color = $this->get('color', null);
$size = $this->get('size', null);
$price = $this->get('price', null);
$p_d = $this->get('p_d', null);
$data = array(
'pageHeader' => array(
'navBack' => true,
'navHome' => '/'
),
'goodListPage' => true,
'goodList' => array()
);
// 查询数据
$listData = ClassData::selectClassDetail($gender, $brand, $sort, $color, $size, $price, $p_d);
// 处理返回的数据
if (isset($listData['code']) && $listData['code'] === 200) {
$tmpData = $listData['data'];
$data['goodList'] = ListProcess::getListData($tmpData);
}
$this->_view->display('index', $data);
}
}
... ...