Authored by 郭成尧

店铺分类和品牌数据调取

@@ -17,7 +17,7 @@ class ShopData @@ -17,7 +17,7 @@ class ShopData
17 /** 17 /**
18 * 调取店铺简介数据 18 * 调取店铺简介数据
19 * 19 *
20 - * @param $shopId 20 + * @param int|店铺ID $shopId 店铺ID
21 * @return mixed 21 * @return mixed
22 */ 22 */
23 public static function getShopIntro($shopId = 0) 23 public static function getShopIntro($shopId = 0)
@@ -29,11 +29,36 @@ class ShopData @@ -29,11 +29,36 @@ class ShopData
29 return Yohobuy::get(Yohobuy::API_URL, $param); 29 return Yohobuy::get(Yohobuy::API_URL, $param);
30 } 30 }
31 31
32 - public static function getShopCategory($shopId = 0) 32 + /**
  33 + * 获取店铺下的所有品类
  34 + *
  35 + * @param int $shopId 店铺ID
  36 + * @param $yhChannel 频道
  37 + * @param $gender 性别
  38 + * @return mixed
  39 + */
  40 + public static function getShopCategory($shopId, $yhChannel, $gender)
33 { 41 {
34 $param = Yohobuy::param(); 42 $param = Yohobuy::param();
35 $param['method'] = 'app.shop.getSortInfo'; 43 $param['method'] = 'app.shop.getSortInfo';
36 $param['shops_id'] = $shopId; 44 $param['shops_id'] = $shopId;
  45 + $param['yh_channel'] = $yhChannel;
  46 + $param['gender'] = $gender;
  47 + $param['client_secret'] = Sign::getSign($param);
  48 + return Yohobuy::get(Yohobuy::API_URL, $param);
  49 + }
  50 +
  51 + /**
  52 + * 获取店铺下的所有品牌
  53 + *
  54 + * @param int $shopId 店铺ID
  55 + * @return mixed
  56 + */
  57 + public static function getShopBrands($shopId = 0)
  58 + {
  59 + $param = Yohobuy::param();
  60 + $param['method'] = 'app.shops.getShopsBrands';
  61 + $param['shops_id'] = $shopId;
37 $param['client_secret'] = Sign::getSign($param); 62 $param['client_secret'] = Sign::getSign($param);
38 return Yohobuy::get(Yohobuy::API_URL, $param); 63 return Yohobuy::get(Yohobuy::API_URL, $param);
39 } 64 }
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 9
10 use Action\AbstractAction; 10 use Action\AbstractAction;
11 use LibModels\Wap\Shop\ShopData; 11 use LibModels\Wap\Shop\ShopData;
  12 +use Plugin\Helpers;
12 13
13 class IndexController extends AbstractAction 14 class IndexController extends AbstractAction
14 { 15 {
@@ -36,11 +37,23 @@ class IndexController extends AbstractAction @@ -36,11 +37,23 @@ class IndexController extends AbstractAction
36 */ 37 */
37 public function categoryAction() 38 public function categoryAction()
38 { 39 {
  40 + $requestData = filter_input_array(INPUT_GET, array(
  41 + 'shopId' => FILTER_DEFAULT,
  42 + ));
  43 + if (empty($requestData['shopId'])) {
  44 + $this->go(SITE_MAIN);
  45 + }
39 $result = array(); 46 $result = array();
40 - // 假数据  
41 - $result = $this->getCategoryContent();  
42 - $result2 = ShopData::getShopIntro(356);  
43 - 47 + $resource = array();
  48 + $resource['category'] = ShopData::getShopCategory($requestData['shopId'], Helpers::getChannelByCookie(), Helpers::getGenderByCookie());
  49 + $resource['brands'] = ShopData::getShopBrands($requestData['shopId']);
  50 + if($resource['category']['code'] === 200){
  51 + $result['category'] = $resource['category']['data'];
  52 + }
  53 + if($resource['brands']['code'] === 200){
  54 + $result['brands'] = $resource['brands']['data'];
  55 + }
  56 + ShopData::debugOut($result);
44 return $this->_view->display('category', array( 57 return $this->_view->display('category', array(
45 'content' => $result, 58 'content' => $result,
46 )); 59 ));
@@ -61,7 +74,7 @@ class IndexController extends AbstractAction @@ -61,7 +74,7 @@ class IndexController extends AbstractAction
61 } 74 }
62 $result = array(); 75 $result = array();
63 $resource = ShopData::getShopIntro($requestData['shopId']); 76 $resource = ShopData::getShopIntro($requestData['shopId']);
64 - if($resource['code'] === 200){ 77 + if ($resource['code'] === 200) {
65 $result = $resource['data']; 78 $result = $resource['data'];
66 } 79 }
67 return $this->_view->display('intro', array( 80 return $this->_view->display('intro', array(
@@ -78,8 +91,7 @@ class IndexController extends AbstractAction @@ -78,8 +91,7 @@ class IndexController extends AbstractAction
78 */ 91 */
79 public function getCategoryContent() 92 public function getCategoryContent()
80 { 93 {
81 - return array(  
82 - // 数据模拟 94 + return array(// 数据模拟
83 ); 95 );
84 } 96 }
85 97
@@ -90,8 +102,7 @@ class IndexController extends AbstractAction @@ -90,8 +102,7 @@ class IndexController extends AbstractAction
90 */ 102 */
91 public function getIntroContent() 103 public function getIntroContent()
92 { 104 {
93 - return array(  
94 - // 数据模拟 105 + return array(// 数据模拟
95 ); 106 );
96 } 107 }
97 108