Authored by Rock Zhang

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

@@ -52,10 +52,11 @@ class SearchData @@ -52,10 +52,11 @@ class SearchData
52 * p_d_asc表示按折扣正序排列, 52 * p_d_asc表示按折扣正序排列,
53 * p_d_desc表示按折扣倒序排列 53 * p_d_desc表示按折扣倒序排列
54 * @param integer $page 指定查询是多少页,默认为第一页 54 * @param integer $page 指定查询是多少页,默认为第一页
55 - * @param integer $limit 指定查询多少个,默认是60哥 55 + * @param integer $limit 指定查询多少个,默认是60个
  56 + * @param integer $channel表示哪个频道,1表示男生,2表示女生,3表示潮童,4表示创意生活
56 * @return array 搜索到的数据 57 * @return array 搜索到的数据
57 */ 58 */
58 - 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) 59 + 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)
59 { 60 {
60 // 构建必传参数 61 // 构建必传参数
61 $param = Yohobuy::param(); 62 $param = Yohobuy::param();
@@ -68,6 +69,7 @@ class SearchData @@ -68,6 +69,7 @@ class SearchData
68 is_null($price) || $param['price'] = $price; 69 is_null($price) || $param['price'] = $price;
69 is_null($p_d) || $param['p_d'] = $p_d; 70 is_null($p_d) || $param['p_d'] = $p_d;
70 is_null($sort) || $param['sort'] = $sort; 71 is_null($sort) || $param['sort'] = $sort;
  72 + is_null($channel) || $param['channel'] = $channel;
71 $param['method'] = 'app.search.li'; 73 $param['method'] = 'app.search.li';
72 $param['order'] = $order; 74 $param['order'] = $order;
73 $param['page'] = $page; 75 $param['page'] = $page;
@@ -20,7 +20,7 @@ class ListController extends AbstractAction @@ -20,7 +20,7 @@ class ListController extends AbstractAction
20 { 20 {
21 $query = $this->get('query', null); 21 $query = $this->get('query', null);
22 $brand = $this->get('brand', null); 22 $brand = $this->get('brand', null);
23 - $gender = $this->get('gender', null); 23 + $gender = $this->getCookie('_Channel', 'boys');
24 $p_d = $this->get('p_d', null); 24 $p_d = $this->get('p_d', null);
25 $misort = $this->get('misort', null); 25 $misort = $this->get('misort', null);
26 $msort = $this->get('msort', null); 26 $msort = $this->get('msort', null);
@@ -35,7 +35,7 @@ class ListController extends AbstractAction @@ -35,7 +35,7 @@ class ListController extends AbstractAction
35 'goodList' => array( 35 'goodList' => array(
36 'brand' => 0, 36 'brand' => 0,
37 'msort' => 0, 37 'msort' => 0,
38 - 'gender' => $this->getCookie('_Channel', 'boys'), 38 + 'gender' => $gender,
39 'price' => 0, 39 'price' => 0,
40 'size' => 0, 40 'size' => 0,
41 'discount' => '' 41 'discount' => ''
@@ -58,6 +58,9 @@ class ListController extends AbstractAction @@ -58,6 +58,9 @@ class ListController extends AbstractAction
58 ); 58 );
59 } 59 }
60 60
  61 + // 转换性别
  62 + $this->genderTrans($gender);
  63 +
61 // 查询数据 64 // 查询数据
62 $listData = SearchData::searchLiDatas($query, $brand, $gender, $p_d, $misort, $msort); 65 $listData = SearchData::searchLiDatas($query, $brand, $gender, $p_d, $misort, $msort);
63 // 处理返回的数据 66 // 处理返回的数据
@@ -102,18 +105,7 @@ class ListController extends AbstractAction @@ -102,18 +105,7 @@ class ListController extends AbstractAction
102 $sort = $this->get('msort', null); 105 $sort = $this->get('msort', null);
103 106
104 // 转换性别 107 // 转换性别
105 - if($gender === 'boys')  
106 - {  
107 - $gender = '1,3';  
108 - }  
109 - elseif($gender === 'girls')  
110 - {  
111 - $gender = '2,3';  
112 - }  
113 - else  
114 - {  
115 - $gender = '1,2,3';  
116 - } 108 + $this->genderTrans($gender);
117 109
118 // 转换排序方式 110 // 转换排序方式
119 $order = $this->get('order', null); 111 $order = $this->get('order', null);
@@ -160,7 +152,7 @@ class ListController extends AbstractAction @@ -160,7 +152,7 @@ class ListController extends AbstractAction
160 public function brandAction() 152 public function brandAction()
161 { 153 {
162 $brand = $this->get('brand', null); 154 $brand = $this->get('brand', null);
163 - $gender = $this->get('gender', null); 155 + $gender = $this->getCookie('_Channel', 'boys');
164 $sort = $this->get('sort', null); 156 $sort = $this->get('sort', null);
165 $color = $this->get('color', null); 157 $color = $this->get('color', null);
166 $size = $this->get('size', null); 158 $size = $this->get('size', null);
@@ -179,7 +171,7 @@ class ListController extends AbstractAction @@ -179,7 +171,7 @@ class ListController extends AbstractAction
179 ), 171 ),
180 'brand' => $brand, 172 'brand' => $brand,
181 'msort' => 0, 173 'msort' => 0,
182 - 'gender' => $this->getCookie('_Channel', 'boys'), 174 + 'gender' => $gender,
183 'sort' => 0, 175 'sort' => 0,
184 'price' => 0, 176 'price' => 0,
185 'size' => 0, 177 'size' => 0,
@@ -204,6 +196,8 @@ class ListController extends AbstractAction @@ -204,6 +196,8 @@ class ListController extends AbstractAction
204 } 196 }
205 197
206 // 查询数据 198 // 查询数据
  199 + // 转换性别
  200 + $this->genderTrans($gender);
207 $listData = BrandData::selectBrandDetail($gender, $brand, $sort, $color, $size, $price, $p_d); 201 $listData = BrandData::selectBrandDetail($gender, $brand, $sort, $color, $size, $price, $p_d);
208 // 处理返回的数据 202 // 处理返回的数据
209 if (isset($listData['code']) && $listData['code'] === 200) { 203 if (isset($listData['code']) && $listData['code'] === 200) {
@@ -224,7 +218,7 @@ class ListController extends AbstractAction @@ -224,7 +218,7 @@ class ListController extends AbstractAction
224 public function classAction() 218 public function classAction()
225 { 219 {
226 $brand = $this->get('brand', null); 220 $brand = $this->get('brand', null);
227 - $gender = $this->get('gender', null); 221 + $gender = $this->getCookie('_Channel', 'boys');
228 $sort = $this->get('sort', null); 222 $sort = $this->get('sort', null);
229 $color = $this->get('color', null); 223 $color = $this->get('color', null);
230 $size = $this->get('size', null); 224 $size = $this->get('size', null);
@@ -240,7 +234,7 @@ class ListController extends AbstractAction @@ -240,7 +234,7 @@ class ListController extends AbstractAction
240 'goodList' => array( 234 'goodList' => array(
241 'brand' => 0, 235 'brand' => 0,
242 'msort' => 0, 236 'msort' => 0,
243 - 'gender' => $this->getCookie('_Channel', '1,3'), 237 + 'gender' => $gender,
244 'sort' => $sort, 238 'sort' => $sort,
245 'price' => 0, 239 'price' => 0,
246 'size' => 0, 240 'size' => 0,
@@ -253,6 +247,8 @@ class ListController extends AbstractAction @@ -253,6 +247,8 @@ class ListController extends AbstractAction
253 $data['pageHeader']['navTitle'] = isset($classes[$sort]) ? $classes[$sort] : ''; 247 $data['pageHeader']['navTitle'] = isset($classes[$sort]) ? $classes[$sort] : '';
254 248
255 // 查询数据 249 // 查询数据
  250 + // 转换性别
  251 + $this->genderTrans($gender);
256 $listData = ClassData::selectClassDetail($gender, $brand, $sort, $color, $size, $price, $p_d); 252 $listData = ClassData::selectClassDetail($gender, $brand, $sort, $color, $size, $price, $p_d);
257 // 处理返回的数据 253 // 处理返回的数据
258 if (isset($listData['code']) && $listData['code'] === 200) { 254 if (isset($listData['code']) && $listData['code'] === 200) {
@@ -264,4 +260,26 @@ class ListController extends AbstractAction @@ -264,4 +260,26 @@ class ListController extends AbstractAction
264 $this->_view->display('index', $data); 260 $this->_view->display('index', $data);
265 } 261 }
266 262
  263 +
  264 + /**
  265 + * 性别数据转换
  266 + *
  267 + * @param string &$gender 从cookie中获取的gender值,最后得到转换之后接口调用的值
  268 + */
  269 + private function genderTrans(&$gender)
  270 + {
  271 + if($gender === 'boys')
  272 + {
  273 + $gender = '1,3';
  274 + }
  275 + elseif($gender === 'girls')
  276 + {
  277 + $gender = '2,3';
  278 + }
  279 + else
  280 + {
  281 + $gender = '1,2,3';
  282 + }
  283 + }
  284 +
267 } 285 }