Authored by Rock Zhang

修改搜索列表页gender从cookie中获取

... ... @@ -52,10 +52,11 @@ class SearchData
* p_d_asc表示按折扣正序排列,
* p_d_desc表示按折扣倒序排列
* @param integer $page 指定查询是多少页,默认为第一页
* @param integer $limit 指定查询多少个,默认是60哥
* @param integer $limit 指定查询多少个,默认是60个
* @param integer $channel表示哪个频道,1表示男生,2表示女生,3表示潮童,4表示创意生活
* @return array 搜索到的数据
*/
public static function searchLiDatas($query = null, $brand = null, $gender = null, $color = null, $size = null, $price = null, $p_d = null, $sort = null, $order = 's_t_desc', $page = 1, $limit = 60)
public static function searchLiDatas($query = null, $brand = null, $gender = null, $color = null, $size = null, $price = null, $p_d = null, $sort = null, $order = 's_t_desc', $page = 1, $limit = 60, $channel = null)
{
// 构建必传参数
$param = Yohobuy::param();
... ... @@ -68,6 +69,7 @@ class SearchData
is_null($price) || $param['price'] = $price;
is_null($p_d) || $param['p_d'] = $p_d;
is_null($sort) || $param['sort'] = $sort;
is_null($channel) || $param['channel'] = $channel;
$param['method'] = 'app.search.li';
$param['order'] = $order;
$param['page'] = $page;
... ...
... ... @@ -20,7 +20,7 @@ class ListController extends AbstractAction
{
$query = $this->get('query', null);
$brand = $this->get('brand', null);
$gender = $this->get('gender', null);
$gender = $this->getCookie('_Channel', 'boys');
$p_d = $this->get('p_d', null);
$misort = $this->get('misort', null);
$msort = $this->get('msort', null);
... ... @@ -35,7 +35,7 @@ class ListController extends AbstractAction
'goodList' => array(
'brand' => 0,
'msort' => 0,
'gender' => $this->getCookie('_Channel', 'boys'),
'gender' => $gender,
'price' => 0,
'size' => 0,
'discount' => ''
... ... @@ -58,6 +58,9 @@ class ListController extends AbstractAction
);
}
// 转换性别
$this->genderTrans($gender);
// 查询数据
$listData = SearchData::searchLiDatas($query, $brand, $gender, $p_d, $misort, $msort);
// 处理返回的数据
... ... @@ -102,18 +105,7 @@ class ListController extends AbstractAction
$sort = $this->get('msort', null);
// 转换性别
if($gender === 'boys')
{
$gender = '1,3';
}
elseif($gender === 'girls')
{
$gender = '2,3';
}
else
{
$gender = '1,2,3';
}
$this->genderTrans($gender);
// 转换排序方式
$order = $this->get('order', null);
... ... @@ -160,7 +152,7 @@ class ListController extends AbstractAction
public function brandAction()
{
$brand = $this->get('brand', null);
$gender = $this->get('gender', null);
$gender = $this->getCookie('_Channel', 'boys');
$sort = $this->get('sort', null);
$color = $this->get('color', null);
$size = $this->get('size', null);
... ... @@ -179,7 +171,7 @@ class ListController extends AbstractAction
),
'brand' => $brand,
'msort' => 0,
'gender' => $this->getCookie('_Channel', 'boys'),
'gender' => $gender,
'sort' => 0,
'price' => 0,
'size' => 0,
... ... @@ -204,6 +196,8 @@ class ListController extends AbstractAction
}
// 查询数据
// 转换性别
$this->genderTrans($gender);
$listData = BrandData::selectBrandDetail($gender, $brand, $sort, $color, $size, $price, $p_d);
// 处理返回的数据
if (isset($listData['code']) && $listData['code'] === 200) {
... ... @@ -224,7 +218,7 @@ class ListController extends AbstractAction
public function classAction()
{
$brand = $this->get('brand', null);
$gender = $this->get('gender', null);
$gender = $this->getCookie('_Channel', 'boys');
$sort = $this->get('sort', null);
$color = $this->get('color', null);
$size = $this->get('size', null);
... ... @@ -240,7 +234,7 @@ class ListController extends AbstractAction
'goodList' => array(
'brand' => 0,
'msort' => 0,
'gender' => $this->getCookie('_Channel', '1,3'),
'gender' => $gender,
'sort' => $sort,
'price' => 0,
'size' => 0,
... ... @@ -253,6 +247,8 @@ class ListController extends AbstractAction
$data['pageHeader']['navTitle'] = isset($classes[$sort]) ? $classes[$sort] : '';
// 查询数据
// 转换性别
$this->genderTrans($gender);
$listData = ClassData::selectClassDetail($gender, $brand, $sort, $color, $size, $price, $p_d);
// 处理返回的数据
if (isset($listData['code']) && $listData['code'] === 200) {
... ... @@ -264,4 +260,26 @@ class ListController extends AbstractAction
$this->_view->display('index', $data);
}
/**
* 性别数据转换
*
* @param string &$gender 从cookie中获取的gender值,最后得到转换之后接口调用的值
*/
private function genderTrans(&$gender)
{
if($gender === 'boys')
{
$gender = '1,3';
}
elseif($gender === 'girls')
{
$gender = '2,3';
}
else
{
$gender = '1,2,3';
}
}
}
... ...