Authored by 梁志锋

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

framework @ 75bbc3b0
1 -Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05 1 +Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
@@ -47,8 +47,11 @@ class ClassData @@ -47,8 +47,11 @@ class ClassData
47 * @param integer $channel 表示频道号,1位男生,2为女生 47 * @param integer $channel 表示频道号,1位男生,2为女生
48 * @return array 品类商品数据 48 * @return array 品类商品数据
49 */ 49 */
50 - public static function selectBrandDetail($gender, $brand, $sort, $color, $size, $price, $p_d, $channel = 1, $order = 's_t_desc', $limit = 60, $page = 1) 50 + public static function selectClassDetail($gender, $brand, $sort, $color, $size, $price, $p_d, $channel = 1, $order = 's_t_desc', $limit = 60, $page = 1)
51 { 51 {
  52 + // 构建必传参数
  53 + $param = Yohobuy::param();
  54 +
52 $selectItems = array( 55 $selectItems = array(
53 'gender' => $gender, 56 'gender' => $gender,
54 'brand' => $brand, 57 'brand' => $brand,
@@ -60,9 +63,7 @@ class ClassData @@ -60,9 +63,7 @@ class ClassData
60 ); 63 );
61 // 拉取筛选参数 64 // 拉取筛选参数
62 $queriedParams = array_filter($selectItems, function($v) {return $v !== null;}); 65 $queriedParams = array_filter($selectItems, function($v) {return $v !== null;});
63 -  
64 - // 构建必传参数  
65 - $param = Yohobuy::param(); 66 + $param += $queriedParams;
66 67
67 $param['method'] = 'app.search.category'; 68 $param['method'] = 'app.search.category';
68 $param['page'] = $page; 69 $param['page'] = $page;
@@ -63,6 +63,7 @@ class ListProcess @@ -63,6 +63,7 @@ class ListProcess
63 // 过滤条件数据 63 // 过滤条件数据
64 $filters = array('classify'=>array()); 64 $filters = array('classify'=>array());
65 65
  66 + $num = 1;
66 foreach ($data as $key => $val) { 67 foreach ($data as $key => $val) {
67 if(empty($val)) 68 if(empty($val))
68 { 69 {
@@ -72,6 +73,12 @@ class ListProcess @@ -72,6 +73,12 @@ class ListProcess
72 continue; 73 continue;
73 } 74 }
74 $build = self::$key($val); 75 $build = self::$key($val);
  76 + if($num === 1)
  77 + {
  78 + $build['active'] = true;
  79 + }
  80 +
  81 + $num++;
75 $filters['classify'][] = $build; 82 $filters['classify'][] = $build;
76 } 83 }
77 84
  1 +{{# new}}
  2 + {{> good}}
  3 +{{/ new}}
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 use LibModels\Wap\Product\SearchData; 4 use LibModels\Wap\Product\SearchData;
5 use LibModels\Wap\Category\BrandData; 5 use LibModels\Wap\Category\BrandData;
  6 +use LibModels\Wap\Category\ClassData;
6 use Plugin\DataProcess\ListProcess; 7 use Plugin\DataProcess\ListProcess;
7 use Plugin\Helpers; 8 use Plugin\Helpers;
8 9
@@ -11,33 +12,115 @@ use Plugin\Helpers; @@ -11,33 +12,115 @@ use Plugin\Helpers;
11 */ 12 */
12 class ListController extends AbstractAction 13 class ListController extends AbstractAction
13 { 14 {
  15 + /**
  16 + * 搜索列表页
  17 + */
14 public function indexAction() 18 public function indexAction()
15 { 19 {
16 - $data = array(  
17 - 'goodListPage' => true,  
18 - 'goodList' => array(  
19 - )  
20 - );  
21 - 20 + $query = $this->get('query', null);
22 $brand = $this->get('brand', null); 21 $brand = $this->get('brand', null);
23 $gender = $this->get('gender', null); 22 $gender = $this->get('gender', null);
24 $p_d = $this->get('p_d', null); 23 $p_d = $this->get('p_d', null);
25 $misort = $this->get('misort', null); 24 $misort = $this->get('misort', null);
26 $msort = $this->get('msort', null); 25 $msort = $this->get('msort', null);
27 26
  27 + $data = array(
  28 + 'pageHeader' => array(
  29 + 'navBack' => true,
  30 + 'navTitle' => '搜索',
  31 + 'navHome' => '/'
  32 + ),
  33 + 'goodListPage' => true,
  34 + 'goodList' => array()
  35 + );
  36 +
  37 + // 如果存在搜索字符串就显示搜索栏
  38 + if(!is_null($query))
  39 + {
  40 + $data['search'] = array(
  41 + 'default' => $query
  42 + );
  43 + }
  44 +
28 // 查询数据 45 // 查询数据
29 - $listData = SearchData::searchLiDatas(null, $brand, $gender, $p_d, $misort, $msort); 46 + $listData = SearchData::searchLiDatas($query, $brand, $gender, $p_d, $misort, $msort);
30 // 处理返回的数据 47 // 处理返回的数据
31 if (isset($listData['code']) && $listData['code'] === 200) { 48 if (isset($listData['code']) && $listData['code'] === 200) {
32 $tmpData = $listData['data']; 49 $tmpData = $listData['data'];
33 50
  51 + // 如果存在品牌信息就显示品牌字段
  52 + if(isset($tmpData['brand']) && !empty($tmpData['brand']))
  53 + {
  54 + $brandData = $tmpData['brand'];
  55 + $data['brandWay'] = array(
  56 + 'url' => '/product/list/brand?brand='.$brandData['id'],
  57 + 'thumb' => Helpers::getImageUrl($brandData['brand_ico'], 75, 40),
  58 + 'name' => $brandData['brand_name']
  59 + );
  60 + }
  61 +
34 $data['goodList'] = ListProcess::getListData($tmpData); 62 $data['goodList'] = ListProcess::getListData($tmpData);
35 } 63 }
36 64
37 $this->_view->display('index', $data); 65 $this->_view->display('index', $data);
38 } 66 }
39 67
  68 +
  69 + /**
  70 + * Ajax异步筛选请求
  71 + */
  72 + public function searchAction()
  73 + {
  74 + if($this->isAjax())
  75 + {
  76 + $query = $this->get('query', null);
  77 + $brand = $this->get('brand', null);
  78 + $gender = $this->get('gender', null);
  79 + $p_d = $this->get('p_d', null);
  80 + $misort = $this->get('misort', null);
  81 + $msort = $this->get('msort', null);
  82 +
  83 + $order = $this->get('order', null);
  84 + $type = $this->get('type', '');
  85 + switch ($type) {
  86 + case 'price':
  87 + $order = ($order == 0) ? 's_p_desc' : 's_p_asc';
  88 + break;
  89 + case 'discount':
  90 + $order = ($order == 0) ? 'p_d_desc' : 'p_d_asc';
  91 + break;
  92 + case 'newest':
  93 + default:
  94 + $order = ($order == 0) ? 's_t_desc' : 's_t_asc';
  95 + break;
  96 + }
  97 +
  98 + $data = array();
  99 + // 查询数据
  100 + $listData = SearchData::searchLiDatas($query, $brand, $gender, $p_d, $misort, $msort, $order);
  101 + // 处理返回的数据
  102 + if (isset($listData['code']) && $listData['code'] === 200) {
  103 + $tmpData = $listData['data'];
  104 +
  105 + unset($tmpData['filter']);// 不要筛选条件的数据
  106 + $data = ListProcess::getListData($tmpData);
  107 + }
  108 +
  109 + if(empty($data))
  110 + {
  111 + echo ' ';
  112 + }
  113 + else
  114 + {
  115 + $this->_view->display('list', $data);
  116 + }
  117 + }
  118 + }
  119 +
40 120
  121 + /**
  122 + * 品牌商品列表页
  123 + */
41 public function brandAction() 124 public function brandAction()
42 { 125 {
43 $brand = $this->get('brand', null); 126 $brand = $this->get('brand', null);
@@ -50,6 +133,7 @@ class ListController extends AbstractAction @@ -50,6 +133,7 @@ class ListController extends AbstractAction
50 133
51 $data = array( 134 $data = array(
52 'pageHeader' => array( 135 'pageHeader' => array(
  136 + 'navBack' => true,
53 'navHome' => '/' 137 'navHome' => '/'
54 ), 138 ),
55 'goodListPage' => true, 139 'goodListPage' => true,
@@ -88,5 +172,39 @@ class ListController extends AbstractAction @@ -88,5 +172,39 @@ class ListController extends AbstractAction
88 $this->_view->display('index', $data); 172 $this->_view->display('index', $data);
89 } 173 }
90 174
  175 +
  176 + /**
  177 + * 品类商品列表页
  178 + */
  179 + public function classAction()
  180 + {
  181 + $brand = $this->get('brand', null);
  182 + $gender = $this->get('gender', null);
  183 + $sort = $this->get('sort', null);
  184 + $color = $this->get('color', null);
  185 + $size = $this->get('size', null);
  186 + $price = $this->get('price', null);
  187 + $p_d = $this->get('p_d', null);
  188 +
  189 + $data = array(
  190 + 'pageHeader' => array(
  191 + 'navBack' => true,
  192 + 'navHome' => '/'
  193 + ),
  194 + 'goodListPage' => true,
  195 + 'goodList' => array()
  196 + );
  197 +
  198 + // 查询数据
  199 + $listData = ClassData::selectClassDetail($gender, $brand, $sort, $color, $size, $price, $p_d);
  200 + // 处理返回的数据
  201 + if (isset($listData['code']) && $listData['code'] === 200) {
  202 + $tmpData = $listData['data'];
  203 +
  204 + $data['goodList'] = ListProcess::getListData($tmpData);
  205 + }
  206 +
  207 + $this->_view->display('index', $data);
  208 + }
91 209
92 } 210 }