Authored by 郭成尧

店铺分类和品牌数据调取

... ... @@ -17,7 +17,7 @@ class ShopData
/**
* 调取店铺简介数据
*
* @param $shopId
* @param int|店铺ID $shopId 店铺ID
* @return mixed
*/
public static function getShopIntro($shopId = 0)
... ... @@ -29,11 +29,36 @@ class ShopData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
public static function getShopCategory($shopId = 0)
/**
* 获取店铺下的所有品类
*
* @param int $shopId 店铺ID
* @param $yhChannel 频道
* @param $gender 性别
* @return mixed
*/
public static function getShopCategory($shopId, $yhChannel, $gender)
{
$param = Yohobuy::param();
$param['method'] = 'app.shop.getSortInfo';
$param['shops_id'] = $shopId;
$param['yh_channel'] = $yhChannel;
$param['gender'] = $gender;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取店铺下的所有品牌
*
* @param int $shopId 店铺ID
* @return mixed
*/
public static function getShopBrands($shopId = 0)
{
$param = Yohobuy::param();
$param['method'] = 'app.shops.getShopsBrands';
$param['shops_id'] = $shopId;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
... ...
... ... @@ -9,6 +9,7 @@
use Action\AbstractAction;
use LibModels\Wap\Shop\ShopData;
use Plugin\Helpers;
class IndexController extends AbstractAction
{
... ... @@ -36,11 +37,23 @@ class IndexController extends AbstractAction
*/
public function categoryAction()
{
$requestData = filter_input_array(INPUT_GET, array(
'shopId' => FILTER_DEFAULT,
));
if (empty($requestData['shopId'])) {
$this->go(SITE_MAIN);
}
$result = array();
// 假数据
$result = $this->getCategoryContent();
$result2 = ShopData::getShopIntro(356);
$resource = array();
$resource['category'] = ShopData::getShopCategory($requestData['shopId'], Helpers::getChannelByCookie(), Helpers::getGenderByCookie());
$resource['brands'] = ShopData::getShopBrands($requestData['shopId']);
if($resource['category']['code'] === 200){
$result['category'] = $resource['category']['data'];
}
if($resource['brands']['code'] === 200){
$result['brands'] = $resource['brands']['data'];
}
ShopData::debugOut($result);
return $this->_view->display('category', array(
'content' => $result,
));
... ... @@ -61,7 +74,7 @@ class IndexController extends AbstractAction
}
$result = array();
$resource = ShopData::getShopIntro($requestData['shopId']);
if($resource['code'] === 200){
if ($resource['code'] === 200) {
$result = $resource['data'];
}
return $this->_view->display('intro', array(
... ... @@ -78,8 +91,7 @@ class IndexController extends AbstractAction
*/
public function getCategoryContent()
{
return array(
// 数据模拟
return array(// 数据模拟
);
}
... ... @@ -90,8 +102,7 @@ class IndexController extends AbstractAction
*/
public function getIntroContent()
{
return array(
// 数据模拟
return array(// 数据模拟
);
}
... ...