Authored by 郭成尧

代码布局调整

... ... @@ -70,6 +70,21 @@ class ShopData
}
/**
* 获取店铺下所有商品
*
* @param null $shop
* @return mixed
*/
public static function getAllProducts($shop = null)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.li';
$param['shop'] = $shop;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
*
* 辅助方法 Debug 数据输出
*
... ...
{{> layout/header}}
{{# brands}}
<a class="brand-list" href="{{url}}">
{{brandname}}
</a>
{{/ brands}}
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -8,6 +8,7 @@ use LibModels\Wap\Category\BrandData;
use Plugin\DataProcess\ListProcess;
use Plugin\Helpers;
use Plugin\Cache;
use Plugin\Images;
/**
* 商品列表相关的模板数据模型
... ... @@ -344,4 +345,33 @@ class ListModel
return $result;
}
/**
* @param $data 传入的从接口传来的数据
* @return array 返回的处理好的数据
* @author chengyao.guo
*/
public static function categoryData($data)
{
$result = array();
$result['class'] = array();
$result['category'] = array();
foreach ($data as &$item) {
array_push($result['class'], array('name' => $item['category_name']));
foreach ($item['sub'] as &$item2) {
$item2['url'] = Helpers::url(''); // tar mark 还不知道链接是啥样的
}
array_push($result['category'], array('subcategory' => $item['sub']));
}
return $result;
}
public static function brandData($data)
{
// 处理图片链接
foreach ($data as &$item) {
$item['brand_ico'] = Images::getImageUrl($item['brand_ico'], 0, 0);
}
return $data;
}
}
... ...
... ... @@ -3,6 +3,7 @@
use Action\AbstractAction;
use Plugin\Helpers;
use LibModels\Wap\Product\ShopData;
use Product\ListModel;
/**
* 商品列表相关的控制器
... ... @@ -14,13 +15,13 @@ class IndexController extends AbstractAction
/**
* 品类商品列表页
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $brand 品牌Id
* @param integer $sort 品类查询sort参数
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $brand 品牌Id
* @param integer $sort 品类查询sort参数
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
*/
public function indexAction()
{
... ... @@ -110,12 +111,12 @@ class IndexController extends AbstractAction
/**
* 品牌商品列表页
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $sort 品类查询sort参数
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $sort 品类查询sort参数
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
*/
public function brandAction()
{
... ... @@ -209,8 +210,7 @@ class IndexController extends AbstractAction
$data['goodList']['brandWay'] = $brandLogo;
$data['goodList']['search']['default'] = $query;
$data['goodList']['search']['url'] = Helpers::url('', null, 'search');
}
// 品牌一览过来的展示品牌介绍和LOGO
} // 品牌一览过来的展示品牌介绍和LOGO
elseif ($brandId !== 0) {
$data['brandHome'] = \Product\ListModel::getBrandIntro($brandId, $uid, $title);
$data['goodList'] = array();
... ... @@ -231,11 +231,11 @@ class IndexController extends AbstractAction
}
/**
* 店铺品牌品类页,需要判断单品店还是多品店
*
* 店铺券全部品牌页面
* @author chengyao.guo
* @return mixed
*/
public function categoryAction()
public function allBrandAction()
{
$requestData = filter_input_array(INPUT_GET, array(
'shop_id' => FILTER_DEFAULT,
... ... @@ -244,32 +244,34 @@ class IndexController extends AbstractAction
$this->go(SITE_MAIN);
}
$result = array();
$resource = array();
$resource['category'] = ShopData::getShopCategory($requestData['shop_id'], Helpers::getChannelByCookie(), Helpers::getGenderByCookie());
$resource['brands'] = ShopData::getShopBrands($requestData['shop_id']);
if ($resource['category']['code'] === 200) {
$class = array();
$category = array();
foreach ($resource['category']['data'] as &$item) {
array_push($class, array('name' => $item['category_name']));
foreach ($item['sub'] as &$item2) {
$item2['url'] = Helpers::url(''); // tar mark 还不知道链接是啥样的
}
array_push($category, array('subcategory' => $item['sub']));
}
$result['class'] = $class;
$result['category'] = $category;
$resource = ShopData::getShopBrands($requestData['shop_id']);
if($resource['code'] === 200){
$result = ListModel::brandData($resource['data']);
}
return $this->_view->display('brand', array(
'content' => $result,
));
}
if ($resource['brands']['code'] === 200) {
$result['brands'] = $resource['brands']['data'];
/**
*
* 店铺品类页面
* @author chengyao.guo
* @return mixed
*/
public function categoryAction()
{
$requestData = filter_input_array(INPUT_GET, array(
'shop_id' => FILTER_DEFAULT,
));
if (empty($requestData['shop_id'])) {
$this->go(SITE_MAIN);
}
// 处理图片链接
foreach ($result['brands'] as &$item) {
$item['brand_ico'] = \Plugin\Images::getImageUrl($item['brand_ico'], 0, 0);
$result = array();
$resource = ShopData::getShopCategory($requestData['shop_id'], Helpers::getChannelByCookie(), Helpers::getGenderByCookie());
if ($resource['code'] === 200) {
$result = ListModel::categoryData($resource['data']);
}
// $result = $this->getCategoryContent();
ShopData::debugOut($result,false);
return $this->_view->display('category', array(
'productCategoryPage' => true,
'content' => $result,
... ... @@ -278,7 +280,7 @@ class IndexController extends AbstractAction
/**
* 店铺简介页面
*
* @author chengyao.guo
* @return mixed
*/
public function introAction()
... ... @@ -300,6 +302,18 @@ class IndexController extends AbstractAction
}
/**
* 店铺内全部商品页面
* @author chengyao.guo
* @return mixed
*/
public function allProductAction()
{
$result = array();
return $this->_view->display('allproduct', array(
'content' => $result,
));
}
/**
* 店铺分类品类页数据模拟
... ...