Authored by 周少峰

form shop index data

... ... @@ -9,50 +9,79 @@ use Plugin\Helpers;
*/
class ShopProcess
{
private static $shopData = array();
/**
* 组织店铺页面数据
* @param array $data 接口返回的店铺页所需数据
* @param int $type 店铺模板id
* @author sefon 2016-4-26 21:56:32
* @return array
*/
public static function formShopData($data)
public static function formShopData($data, $type = 2)
{
$result = array();
foreach ($data as $key => $val) {
if (empty($val) || !is_callable("self::$key")) {
continue;
}
$result[] = self::$key($val);
self::$key($val);
}
return $result;
// print_r($data);
// exit;
return self::$shopData;
}
/**
* 店铺介绍
* 组织店铺装修
* @param array $data
* @author sefon 2016-4-26 22:06:44
* @author sefon 2016-4-26 22:04:04
* @return array
*/
private static function shopInfo($data)
private static function decorator($data)
{
return $data;
if (!isset($data['code']) || $data['code'] != 200 || !isset($data['data']['list']) || empty($data['data']['list'])) {
return;
}
foreach ($data['data']['list'] as $val) {
if (empty($val['resource_data']) || !is_callable("self::$val[resource_name]")) {
continue;
}
self::$val['resource_name'](json_decode($val['resource_data'], true));
}
// print_r($data); exit;
}
/**
* 组织店铺装修
* 店铺Banner
* @param array $data
* @author sefon 2016-4-26 22:04:04
* @author sefon 2016-4-27 08:40:05
* @return array
*/
private static function decretion($data)
private static function shopTopBanner($data)
{
//优惠券
//广告图
//热门分类
foreach ($data as $val) {
self::$shopData['bannerTop']['list'][] = array('url' => '', 'img' => $val['shopSrc']);
}
}
//人气单品
/**
* 资源位小图
* @param array $data
* @author sefon 2016-4-27 08:37:30
* @return array
*/
private static function oneRowTwoColImages($data)
{
foreach ($data as $key => $val) {
if (empty($val['data'])) {
continue;
}
foreach ($val['data'] as $val) {
self::$shopData['spring'][] = array(
'url' => $val['url'],
'springType' => $val['src']
);
}
}
return $data;
}
... ... @@ -62,17 +91,47 @@ class ShopProcess
* @author sefon 2016-4-26 22:04:04
* @return array
*/
private static function shopBrands($data)
private static function brandBrowse($data)
{
foreach ($data as $val) {
self::$shopData['multi-list'][] = array(
'url' => '',
'img' => $val['brandIco'],
'brandName' => $val['brandName']
);
}
}
/**
* 热门分类
* @param array $data
* @author sefon 2016-4-27 08:38:36
* @return array
*/
private static function hotRecommend($data)
{
return $data;
}
/**
* 店铺商品列表 可能不需要
* 人气单品
* @param array $data
* @author sefon 2016-4-27 08:38:36
* @return array
*/
private static function products($data)
private static function hotProducts($data)
{
// print_r($data);
foreach ($data as $val) {
echo $val['src'];
self::$shopData['hotList'][] = array(
'url' => $val['url'],
'img' => $val['src'],
'salesPrice' => '¥'.$val['salesPrice'],
'presentPrice' => '¥'.$val['salesPrice']
);
}
return $data;
}
... ...
{{> layout/header}}
{{# shopIndex}}
<div class="shop-index yoho-page" id="wrapper">
<div id="scroller">
<div id="nav-top">
{{# headerBanner}}
{{> product/banner-swipe-and-single}}
{{/ headerBanner}}
<div class="search-area">
<div id="search-input" class="search-input">
<form id="search-form" action={{url}} method="get">
<i class="search-icon iconfont">&#xe60f;</i>
<input type="text" placeholder="搜索店铺内潮品" name="query">
<input type="hidden" name="from" value="search">
<i class="clear-input iconfont hide">&#xe626;</i>
<span id="search" class="search" type="submit">搜索</span>
</form>
</div>
</div>
<div class="branner-top">
<img src="{{branerImg}}">
<div class="collect"></div>
</div>
</div>
<ul id="nav" class="nav">
<li class="active color">首页</li>
<li>上新</li>
<li>人气</li>
<li>
<a href="#" target="_blank">全部商品</a>
</li>
</ul>
<div id="nav-main" class="main">
{{#unless brands}}
<div class="multi-brands">
<h2>品牌一览</h2>
<!-- {{#each brandImg}}
<div class="brand-img">
<img src="{{brandType}}">
<p>{{brandName}}</p>
</div>
{{/each}} -->
<div class="multi-browse swiper-container">
<ul class="swiper-wrapper">
{{#each multi-list}}
<li class="swiper-slide brand-img">
<a href="{{url}}">
<img src="{{img}}">
</a>
<p>{{brandName}}</p>
</li>
{{/each}}
</ul>
</div>
</div>
{{/unless}}
<div class="banner-area">
{{# bannerTop}}
{{> home/banner_top}}
{{/ bannerTop}}
</div>
<ul class="spring">
{{#each spring}}
<li>
<img src="{{springType}}">
</li>
{{/each}}
</ul>
{{! 热门品类}}
{{# hotCategory}}
{{> home/hot_category}}
{{/ hotCategory}}
<div class="title">
人气单品
<a class="more" href="{{more_url}}">&#xe618;</a>
</div>
<ul class="product-list">
{{#each hotList}}
<li>
<img src="{{listUrl}}">
<div class="list-price">
<p>VANS AP M BERZE</p>
<p><span class="red">{{originalPrice}}</span>
<span>{{presentPrice}}</span>
</p>
</div>
</li>
{{/each}}
</ul>
</div>
<div class="discount-area">
{{> product/goods-nav-top}}
</div>
</div>
<ul id="pos-nav" class="nav hide">
<li class="active color">首页</li>
<li>上新</li>
<li>人气</li>
<li>
<a href="#" target="_blank">全部商品</a>
</li>
</ul>
<ul id="pos-list" class="nav hide">
<li>最新</li>
<li>价格</li>
<li>折扣</li>
<li>筛选</li>
</ul>
</div>
{{/ shopIndex}}
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -399,14 +399,13 @@ class ListModel
}
//店铺信息
$data['shopInfo'] = ListData::getShopInfo($shopId);
// $data['shopInfo'] = ListData::getShopInfo($shopId);
//店铺装修资源数据
$data['decorator'] = ListData::getShopDecorator($shopId);
//品牌一览
$data['shopBrands'] = ListData::getShopBrands($shopId);
//$data['shopBrands'] = ListData::getShopBrands($shopId);
//商品列表
$data['products'] = array();
//组织楼层数据
$result = ShopProcess::formShopData($data);
return $result;
... ...
... ... @@ -322,14 +322,19 @@ class IndexController extends AbstractAction
public function shopAction()
{
$title = '';
$domain = 'vans';
//TODO
$brandLogo = Product\ListModel::getBrandLogoByDomain($domain, $title);
$shopId = 0;
$shopId = 323;
$uid = $this->getUid(true);
$data = ListModel::shopData($shopId, $uid);
$this->setTitle($title);
$this->setNavHeader($title, true, SITE_MAIN);
$this->_view->display('shop', $data);
$this->_view->display('shop', array(
'shopIndex' => $data,
'shopPage' => true
));
}
/**
... ...