Authored by 周少峰

Merge branch 'feature/web-list' of git.dev.yoho.cn:web/yohobuy into feature/web-list

... ... @@ -34,7 +34,7 @@ class BrandData
// 构建必传参数
$param = Yohobuy::param();
$param['brand_id'] = $brandId;
$param['uid'] = '10267443';
$param['uid'] = $uid;
$param['method'] = 'app.brand.getBrandIntro';
$param['client_secret'] = Sign::getSign($param);
... ...
<?php
namespace LibModels\Web\Product;
use Api\Yohobuy;
/**
* sale操作类
* @name SaleData
* @package
* @copyright yoho.inc
* @version 1.0 (2016-01-07)
* @author
*/
class SaleData
{
const URL_SALE_SPECIAL = '/operating/service/v1/special';
/**
* 获取专区信息
* @param $specialId 专区ID
*/
public static function getSpecial($specialsaleId) {
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_SALE_SPECIAL, 'getOneSpecial', array($specialsaleId));
}
}
... ...
... ... @@ -2,6 +2,7 @@
namespace Plugin;
use Plugin\Paging;
use LibModels\Web\Product\BrandData;
/**
* 搜索辅助类
*/
... ... @@ -946,4 +947,25 @@ class HelperSearch
$Paging = new Paging('Yoho');
return $Paging->setTotal($total)->setSize($viewNum)->view(0);
}
//组织静态资源数据格式
public static function formatNodeContent($code){
$nodeContent = BrandData::getByNodeContent($code);
if (isset($nodeContent['code']) && $nodeContent['code'] === 200) {
$result = array();
$string = $nodeContent['data'];
$hrefPatten="/<a href=[\'\"]?([^\'\" ]+).*?>/";
preg_match_all($hrefPatten, $string, $href);
$pattern = "/[img|IMG].*?src=['|\"](.*?(?:[.gif|.jpg]))['|\"].*?[\/]?>/";
preg_match_all($pattern,$string,$img);
foreach($href[1] as $key=>$vo){
$result[$key]['href'] = $vo;
$result[$key]['src'] = $img[1][$key];
}
return $result;
}
}
}
... ...
{{> layout/header}}
<div class="new-sale-page product-page yoho-page">
{{# newSale}}
{{# saleBanner}}
<div class="banner-img" style="height: {{bannerHeight}}px;background:url({{img}}) no-repeat top center;"></div>
{{/ saleBanner}}
<div class="center-content clearfix">
{{> layout/path-nav}}
{{# saleTitle}}
<div class="header-title">
{{name}}
<p class="line-through"></p>
<p class="count-wrap">
<span class="count">共{{count}}个结果</span>
</p>
</div>
{{/ saleTitle}}
<div class="list-left pull-left">
{{> product/left-content}}
</div>
<div class="list-right pull-right">
{{# newMain}}
<div class="new-banner">
<a href="{{bannerHref}}">
<img src="{{banner}}">
</a>
</div>
<div class="new-brands clearfix">
<span class="iconfont pre">&#xe607;</span>
<div class="brands-wrap">
<ul class="brands">
{{# brands}}
<li>
<a href="{{href}}">
<img src="{{logo}}">
</a>
</li>
{{/ brands}}
</ul>
</div>
<span class="iconfont next">&#xe608;</span>
</div>
<div class="new-floor-title">
<span class="date">{{date}}</span>
<span class="title">{{title}}</span>
</div>
{{/ newMain}}
{{> product/standard-content}}
</div>
</div>
{{/ newSale}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -28,8 +28,7 @@ class BrandsModel {
* @param $options array
* @return array
*/
public static function getBrandSearchData($condition, $options, $domain, $uid, $brandId) {
public static function getBrandSearchData($condition, $options, $domain, $uid, $brandId,$node) {
// 调用商品搜索接口
$data = SearchData::searchElasticByCondition($condition);
... ... @@ -69,9 +68,20 @@ class BrandsModel {
$adNav = self::getAdNav($condition['brand']);
$data['list']['leftContent'][] = array('picLink' => $adNav);
//获取静态内容(20141219-100447)
if($node){
$nodeContent = BrandData::getByNodeContent($node);
if(isset($nodeContent['code']) && $nodeContent['code'] === 200){
$result = $nodeContent['data'];
//接口返回html格式,非前端需要格式。
}
}
return $data;
}
/**
* 获取品牌首页banner条
* @string $domain 品牌域名
... ...
<?php
namespace Product;
use LibModels\Wap\Product\SearchData;
use LibModels\Web\Product\SearchData as WebProduct;
use Plugin\HelperSearch;
use Plugin\Images;
/**
* sale首页模板数据模型
*
*/
class SaleModel
{
public static function getSaleSearchData($params, $options, $specialInfo)
{
$data = SearchData::searchElasticByCondition($params);
if (isset($data['code']) && $data['code'] === 200) {
//获取分类列表数据
$classes = WebProduct::getClassesData();
if (isset($classes['code']) && $classes['code'] === 200) {
$data['data']['filter']['group_sort'] = $classes['data']['sort'];
}
//用户浏览记录
// 组织模板数据
$list = HelperSearch::getList($data, $options);
//删除面包屑导航数据
unset($list['pathNav']);
$data = array(
//初始化js
'productListPage' => true,
'newSale' => $list
);
} else {
$data = array();
}
//组织sale数据
if (isset($specialInfo['data']) && !empty($specialInfo['data']['banner_img'])) {
$banner = json_decode($specialInfo['data']['banner_img'], true);
foreach ($banner as $k => $v) {
$v['img'] = Images::getSourceUrl($v['img'], 'couponImg');
$specialInfo['data']['banner'][] = $v;
}
$special = $specialInfo['data'];
}
//Sale首页 banner数据
$data['newSale']['saleBanner']['bannerHeight'] = $special['banner'][0]['height'];
$data['newSale']['saleBanner']['img'] = $special['banner'][0]['img'];
$data['newSale']['saleTitle']['name'] = '全部商品';
$data['newSale']['saleTitle']['count'] = $data['newSale']['totalCount'];
//获取广告位
$nodeContent = HelperSearch::formatNodeContent($special['left_ad_code']);
$data['newSale']['leftContent'][]['picLink'][] = $nodeContent;
return $data;
}
}
... ...
... ... @@ -20,6 +20,7 @@ class IndexController extends WebAction
$brandInfo = BrandData::getBrandLogoByDomain($domain);
if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){
$brandId = $brandInfo['data']['id'];
$node = isset($brandInfo['static_content_code']) ? $brandInfo['static_content_code'] : false;
}else{
$this->go(SITE_MAIN);
}
... ... @@ -92,7 +93,7 @@ class IndexController extends WebAction
$params = $condition + $_GET;
$params = array_filter($params);
$data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId);
$data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId,$node);
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
//渲染模板
... ...
... ... @@ -858,6 +858,7 @@ class Index1Controller extends AbstractAction
),
array(
'picLink' => array(
array(
'title' => 'AAAA',
'list' => array(
array(
... ... @@ -869,6 +870,17 @@ class Index1Controller extends AbstractAction
'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'
)
)
),
array(
array(
'href' => 'http://adidas.yohobuy.com/?folder=1366',
'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'
),
array(
'href' => 'http://adidas.yohobuy.com/?folder=1366',
'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'
)
)
)
),
array(
... ...
<?php
use Action\WebAction;
use LibModels\Web\Product\SaleData;
/**
* sale页
*
*/
class SaleController extends WebAction
{
public function indexAction()
{
//获取专区ID
$specialsaleId = $this->Param('specialsaleId');
$specialsaleId = 1; //测试数据
$specialInfo = SaleData::getSpecial($specialsaleId);
$special = $specialInfo['data'];
// if (empty($specialsale_id)) {
// $specialsale_id = str_replace('specialsale', '', explode('.', $_SERVER['HTTP_HOST'])[0]);
// }
//获取促销ID
$promotion = $this->Param('promotion');
//专区ID和促销ID都为空时,跳转到主页
if (empty($specialsaleId) && empty($promotion)) {
$this->go(SITE_MAIN);
}
/* 过滤请求参数 */
$condition = array();
$condition = filter_input_array(INPUT_GET, array(
//'query' => FILTER_SANITIZE_STRING,
'sort' => FILTER_VALIDATE_INT,
'msort' => FILTER_VALIDATE_INT,
'misort' => FILTER_VALIDATE_INT,
'color' => FILTER_VALIDATE_INT,
'size' => FILTER_VALIDATE_INT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,
'shelve_time' => FILTER_DEFAULT,
'isNew' => FILTER_DEFAULT,
'specialoffer' => FILTER_DEFAULT,
'limited' => FILTER_DEFAULT,
'order' => FILTER_DEFAULT,
'viewNum' => FILTER_VALIDATE_INT,
'rowNum' => FILTER_VALIDATE_INT,
'page' => FILTER_VALIDATE_INT,), false);
//字符转码
if (!empty($condition)) {
foreach ($condition as &$value) {
$value = rawurldecode($value);
}
}
//传品牌ID参数
if(!empty($special['brand_id'])){
$condition['brand'] = $special['brand_id'];
}
//传促销id
if(!empty($special['ispromotion'])){
//$condition['promotion'] = $special['ispromotion'];
}
//获取性别数据
$gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender'] == '2,3' ? 2 : 1));
$condition['gender'] = $gender;
//每页显示商品数
if (!isset($condition['viewNum']) || empty($condition['viewNum'])) {
$condition['viewNum'] = 59;
}
$view_num_arr = array(60, 100, 200);
if (!in_array($condition['viewNum'], $view_num_arr)) {
$condition['viewNum'] = 59;
}
//每行显示的商品数量
if (!isset($condition['rowNum']) || empty($condition['rowNum'])) {
$condition['rowNum'] = 5;
}
if ($condition['rowNum'] == 6) {
$imgSize = array(195, 260);
$minImgSize = array(50, 67);
} else {
$condition['rowNum'] = 5;
$imgSize = array(235, 314);
$minImgSize = array(60, 80);
}
//搜索词
//$query = $this->get('query');
$condition['needFilter'] = 1;
$options = array(
'imgSize' => $imgSize,
'minImgSize' => $minImgSize,
'gender' => $gender,
'needPd' => 'Y',
'rowNum' => $condition['rowNum'],
'viewNum' => $condition['viewNum'] - 1,
'specialsale_id' => 'Y'
);
$params = $condition + $_GET;
$params['attribute_not'] = 2;
$params = array_filter($params);
$data = Product\SaleModel::getSaleSearchData($params, $options, $specialInfo);
$cate = array('boys', 'girls', 'kids', 'lifestyle');
$this->setWebNavHeader($cate[$gender - 1]);
//渲染模板
$this->_view->display('new-sale', $data);
}
}
... ...