Authored by 周少峰

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

@@ -34,7 +34,7 @@ class BrandData @@ -34,7 +34,7 @@ class BrandData
34 // 构建必传参数 34 // 构建必传参数
35 $param = Yohobuy::param(); 35 $param = Yohobuy::param();
36 $param['brand_id'] = $brandId; 36 $param['brand_id'] = $brandId;
37 - $param['uid'] = '10267443'; 37 + $param['uid'] = $uid;
38 $param['method'] = 'app.brand.getBrandIntro'; 38 $param['method'] = 'app.brand.getBrandIntro';
39 $param['client_secret'] = Sign::getSign($param); 39 $param['client_secret'] = Sign::getSign($param);
40 40
  1 +<?php
  2 +namespace LibModels\Web\Product;
  3 +
  4 +use Api\Yohobuy;
  5 +
  6 +/**
  7 + * sale操作类
  8 + * @name SaleData
  9 + * @package
  10 + * @copyright yoho.inc
  11 + * @version 1.0 (2016-01-07)
  12 + * @author
  13 + */
  14 +class SaleData
  15 +{
  16 + const URL_SALE_SPECIAL = '/operating/service/v1/special';
  17 +
  18 + /**
  19 + * 获取专区信息
  20 + * @param $specialId 专区ID
  21 + */
  22 + public static function getSpecial($specialsaleId) {
  23 +
  24 + return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_SALE_SPECIAL, 'getOneSpecial', array($specialsaleId));
  25 + }
  26 +
  27 +}
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace Plugin; 3 namespace Plugin;
4 use Plugin\Paging; 4 use Plugin\Paging;
  5 +use LibModels\Web\Product\BrandData;
5 /** 6 /**
6 * 搜索辅助类 7 * 搜索辅助类
7 */ 8 */
@@ -946,4 +947,25 @@ class HelperSearch @@ -946,4 +947,25 @@ class HelperSearch
946 $Paging = new Paging('Yoho'); 947 $Paging = new Paging('Yoho');
947 return $Paging->setTotal($total)->setSize($viewNum)->view(0); 948 return $Paging->setTotal($total)->setSize($viewNum)->view(0);
948 } 949 }
  950 +
  951 + //组织静态资源数据格式
  952 + public static function formatNodeContent($code){
  953 + $nodeContent = BrandData::getByNodeContent($code);
  954 + if (isset($nodeContent['code']) && $nodeContent['code'] === 200) {
  955 + $result = array();
  956 +
  957 + $string = $nodeContent['data'];
  958 + $hrefPatten="/<a href=[\'\"]?([^\'\" ]+).*?>/";
  959 + preg_match_all($hrefPatten, $string, $href);
  960 +
  961 + $pattern = "/[img|IMG].*?src=['|\"](.*?(?:[.gif|.jpg]))['|\"].*?[\/]?>/";
  962 + preg_match_all($pattern,$string,$img);
  963 +
  964 + foreach($href[1] as $key=>$vo){
  965 + $result[$key]['href'] = $vo;
  966 + $result[$key]['src'] = $img[1][$key];
  967 + }
  968 + return $result;
  969 + }
  970 + }
949 } 971 }
  1 +{{> layout/header}}
  2 +<div class="new-sale-page product-page yoho-page">
  3 + {{# newSale}}
  4 + {{# saleBanner}}
  5 + <div class="banner-img" style="height: {{bannerHeight}}px;background:url({{img}}) no-repeat top center;"></div>
  6 + {{/ saleBanner}}
  7 +
  8 + <div class="center-content clearfix">
  9 + {{> layout/path-nav}}
  10 +
  11 + {{# saleTitle}}
  12 + <div class="header-title">
  13 + {{name}}
  14 + <p class="line-through"></p>
  15 + <p class="count-wrap">
  16 + <span class="count">共{{count}}个结果</span>
  17 + </p>
  18 + </div>
  19 + {{/ saleTitle}}
  20 +
  21 + <div class="list-left pull-left">
  22 + {{> product/left-content}}
  23 + </div>
  24 +
  25 + <div class="list-right pull-right">
  26 + {{# newMain}}
  27 + <div class="new-banner">
  28 + <a href="{{bannerHref}}">
  29 + <img src="{{banner}}">
  30 + </a>
  31 + </div>
  32 + <div class="new-brands clearfix">
  33 + <span class="iconfont pre">&#xe607;</span>
  34 + <div class="brands-wrap">
  35 + <ul class="brands">
  36 + {{# brands}}
  37 + <li>
  38 + <a href="{{href}}">
  39 + <img src="{{logo}}">
  40 + </a>
  41 + </li>
  42 + {{/ brands}}
  43 + </ul>
  44 + </div>
  45 + <span class="iconfont next">&#xe608;</span>
  46 + </div>
  47 + <div class="new-floor-title">
  48 + <span class="date">{{date}}</span>
  49 + <span class="title">{{title}}</span>
  50 + </div>
  51 + {{/ newMain}}
  52 +
  53 + {{> product/standard-content}}
  54 + </div>
  55 + </div>
  56 + {{/ newSale}}
  57 +</div>
  58 +{{> layout/footer}}
@@ -28,8 +28,7 @@ class BrandsModel { @@ -28,8 +28,7 @@ class BrandsModel {
28 * @param $options array 28 * @param $options array
29 * @return array 29 * @return array
30 */ 30 */
31 - public static function getBrandSearchData($condition, $options, $domain, $uid, $brandId) {  
32 - 31 + public static function getBrandSearchData($condition, $options, $domain, $uid, $brandId,$node) {
33 // 调用商品搜索接口 32 // 调用商品搜索接口
34 $data = SearchData::searchElasticByCondition($condition); 33 $data = SearchData::searchElasticByCondition($condition);
35 34
@@ -68,10 +67,21 @@ class BrandsModel { @@ -68,10 +67,21 @@ class BrandsModel {
68 //获取品牌系列数据 67 //获取品牌系列数据
69 $adNav = self::getAdNav($condition['brand']); 68 $adNav = self::getAdNav($condition['brand']);
70 $data['list']['leftContent'][] = array('picLink' => $adNav); 69 $data['list']['leftContent'][] = array('picLink' => $adNav);
71 - 70 +
  71 + //获取静态内容(20141219-100447)
  72 + if($node){
  73 + $nodeContent = BrandData::getByNodeContent($node);
  74 + if(isset($nodeContent['code']) && $nodeContent['code'] === 200){
  75 + $result = $nodeContent['data'];
  76 + //接口返回html格式,非前端需要格式。
  77 + }
  78 + }
  79 +
72 return $data; 80 return $data;
73 } 81 }
  82 +
74 83
  84 +
75 /** 85 /**
76 * 获取品牌首页banner条 86 * 获取品牌首页banner条
77 * @string $domain 品牌域名 87 * @string $domain 品牌域名
  1 +<?php
  2 +
  3 +namespace Product;
  4 +
  5 +use LibModels\Wap\Product\SearchData;
  6 +use LibModels\Web\Product\SearchData as WebProduct;
  7 +use Plugin\HelperSearch;
  8 +use Plugin\Images;
  9 +/**
  10 + * sale首页模板数据模型
  11 + *
  12 + */
  13 +class SaleModel
  14 +{
  15 +
  16 + public static function getSaleSearchData($params, $options, $specialInfo)
  17 + {
  18 + $data = SearchData::searchElasticByCondition($params);
  19 +
  20 + if (isset($data['code']) && $data['code'] === 200) {
  21 + //获取分类列表数据
  22 + $classes = WebProduct::getClassesData();
  23 + if (isset($classes['code']) && $classes['code'] === 200) {
  24 + $data['data']['filter']['group_sort'] = $classes['data']['sort'];
  25 + }
  26 +
  27 + //用户浏览记录
  28 +
  29 + // 组织模板数据
  30 + $list = HelperSearch::getList($data, $options);
  31 +
  32 + //删除面包屑导航数据
  33 + unset($list['pathNav']);
  34 +
  35 + $data = array(
  36 + //初始化js
  37 + 'productListPage' => true,
  38 + 'newSale' => $list
  39 + );
  40 + } else {
  41 + $data = array();
  42 + }
  43 +
  44 + //组织sale数据
  45 + if (isset($specialInfo['data']) && !empty($specialInfo['data']['banner_img'])) {
  46 + $banner = json_decode($specialInfo['data']['banner_img'], true);
  47 + foreach ($banner as $k => $v) {
  48 + $v['img'] = Images::getSourceUrl($v['img'], 'couponImg');
  49 + $specialInfo['data']['banner'][] = $v;
  50 + }
  51 + $special = $specialInfo['data'];
  52 + }
  53 +
  54 + //Sale首页 banner数据
  55 + $data['newSale']['saleBanner']['bannerHeight'] = $special['banner'][0]['height'];
  56 + $data['newSale']['saleBanner']['img'] = $special['banner'][0]['img'];
  57 + $data['newSale']['saleTitle']['name'] = '全部商品';
  58 + $data['newSale']['saleTitle']['count'] = $data['newSale']['totalCount'];
  59 +
  60 +
  61 + //获取广告位
  62 + $nodeContent = HelperSearch::formatNodeContent($special['left_ad_code']);
  63 + $data['newSale']['leftContent'][]['picLink'][] = $nodeContent;
  64 +
  65 +
  66 + return $data;
  67 + }
  68 +
  69 +}
@@ -20,6 +20,7 @@ class IndexController extends WebAction @@ -20,6 +20,7 @@ class IndexController extends WebAction
20 $brandInfo = BrandData::getBrandLogoByDomain($domain); 20 $brandInfo = BrandData::getBrandLogoByDomain($domain);
21 if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){ 21 if(!empty($brandInfo['data']) && $brandInfo['code'] === 200){
22 $brandId = $brandInfo['data']['id']; 22 $brandId = $brandInfo['data']['id'];
  23 + $node = isset($brandInfo['static_content_code']) ? $brandInfo['static_content_code'] : false;
23 }else{ 24 }else{
24 $this->go(SITE_MAIN); 25 $this->go(SITE_MAIN);
25 } 26 }
@@ -92,7 +93,7 @@ class IndexController extends WebAction @@ -92,7 +93,7 @@ class IndexController extends WebAction
92 93
93 $params = $condition + $_GET; 94 $params = $condition + $_GET;
94 $params = array_filter($params); 95 $params = array_filter($params);
95 - $data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId); 96 + $data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId,$node);
96 $cate = array('boys','girls','kids','lifestyle'); 97 $cate = array('boys','girls','kids','lifestyle');
97 $this->setWebNavHeader($cate[$gender-1]); 98 $this->setWebNavHeader($cate[$gender-1]);
98 //渲染模板 99 //渲染模板
@@ -858,17 +858,29 @@ class Index1Controller extends AbstractAction @@ -858,17 +858,29 @@ class Index1Controller extends AbstractAction
858 ), 858 ),
859 array( 859 array(
860 'picLink' => array( 860 'picLink' => array(
861 - 'title' => 'AAAA',  
862 - 'list' => array(  
863 - array(  
864 - 'href' => 'http://adidas.yohobuy.com/?folder=1366',  
865 - 'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'  
866 - ),  
867 - array(  
868 - 'href' => 'http://adidas.yohobuy.com/?folder=1366',  
869 - 'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg' 861 + array(
  862 + 'title' => 'AAAA',
  863 + 'list' => array(
  864 + array(
  865 + 'href' => 'http://adidas.yohobuy.com/?folder=1366',
  866 + 'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'
  867 + ),
  868 + array(
  869 + 'href' => 'http://adidas.yohobuy.com/?folder=1366',
  870 + 'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'
  871 + )
  872 + )
  873 + ),
  874 + array(
  875 + array(
  876 + 'href' => 'http://adidas.yohobuy.com/?folder=1366',
  877 + 'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'
  878 + ),
  879 + array(
  880 + 'href' => 'http://adidas.yohobuy.com/?folder=1366',
  881 + 'src' => 'http://img12.static.yhbimg.com/brandBanner/2015/02/04/06/0216e9a4c1c1edb0c8fe6b4347cc5a8035.jpg'
  882 + )
870 ) 883 )
871 - )  
872 ) 884 )
873 ), 885 ),
874 array( 886 array(
  1 +<?php
  2 +
  3 +use Action\WebAction;
  4 +use LibModels\Web\Product\SaleData;
  5 +
  6 +/**
  7 + * sale页
  8 + *
  9 + */
  10 +class SaleController extends WebAction
  11 +{
  12 +
  13 + public function indexAction()
  14 + {
  15 + //获取专区ID
  16 + $specialsaleId = $this->Param('specialsaleId');
  17 + $specialsaleId = 1; //测试数据
  18 + $specialInfo = SaleData::getSpecial($specialsaleId);
  19 + $special = $specialInfo['data'];
  20 +// if (empty($specialsale_id)) {
  21 +// $specialsale_id = str_replace('specialsale', '', explode('.', $_SERVER['HTTP_HOST'])[0]);
  22 +// }
  23 + //获取促销ID
  24 + $promotion = $this->Param('promotion');
  25 +
  26 + //专区ID和促销ID都为空时,跳转到主页
  27 + if (empty($specialsaleId) && empty($promotion)) {
  28 + $this->go(SITE_MAIN);
  29 + }
  30 +
  31 + /* 过滤请求参数 */
  32 + $condition = array();
  33 + $condition = filter_input_array(INPUT_GET, array(
  34 + //'query' => FILTER_SANITIZE_STRING,
  35 + 'sort' => FILTER_VALIDATE_INT,
  36 + 'msort' => FILTER_VALIDATE_INT,
  37 + 'misort' => FILTER_VALIDATE_INT,
  38 + 'color' => FILTER_VALIDATE_INT,
  39 + 'size' => FILTER_VALIDATE_INT,
  40 + 'style' => FILTER_DEFAULT,
  41 + 'price' => FILTER_DEFAULT,
  42 + 'gender' => FILTER_DEFAULT,
  43 + 'p_d' => FILTER_DEFAULT,
  44 + 'shelve_time' => FILTER_DEFAULT,
  45 + 'isNew' => FILTER_DEFAULT,
  46 + 'specialoffer' => FILTER_DEFAULT,
  47 + 'limited' => FILTER_DEFAULT,
  48 + 'order' => FILTER_DEFAULT,
  49 + 'viewNum' => FILTER_VALIDATE_INT,
  50 + 'rowNum' => FILTER_VALIDATE_INT,
  51 + 'page' => FILTER_VALIDATE_INT,), false);
  52 +
  53 + //字符转码
  54 + if (!empty($condition)) {
  55 + foreach ($condition as &$value) {
  56 + $value = rawurldecode($value);
  57 + }
  58 + }
  59 + //传品牌ID参数
  60 + if(!empty($special['brand_id'])){
  61 + $condition['brand'] = $special['brand_id'];
  62 + }
  63 +
  64 + //传促销id
  65 + if(!empty($special['ispromotion'])){
  66 + //$condition['promotion'] = $special['ispromotion'];
  67 + }
  68 +
  69 + //获取性别数据
  70 + $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender'] == '2,3' ? 2 : 1));
  71 + $condition['gender'] = $gender;
  72 +
  73 + //每页显示商品数
  74 + if (!isset($condition['viewNum']) || empty($condition['viewNum'])) {
  75 + $condition['viewNum'] = 59;
  76 + }
  77 + $view_num_arr = array(60, 100, 200);
  78 + if (!in_array($condition['viewNum'], $view_num_arr)) {
  79 + $condition['viewNum'] = 59;
  80 + }
  81 + //每行显示的商品数量
  82 + if (!isset($condition['rowNum']) || empty($condition['rowNum'])) {
  83 + $condition['rowNum'] = 5;
  84 + }
  85 + if ($condition['rowNum'] == 6) {
  86 + $imgSize = array(195, 260);
  87 + $minImgSize = array(50, 67);
  88 + } else {
  89 + $condition['rowNum'] = 5;
  90 + $imgSize = array(235, 314);
  91 + $minImgSize = array(60, 80);
  92 + }
  93 + //搜索词
  94 + //$query = $this->get('query');
  95 + $condition['needFilter'] = 1;
  96 + $options = array(
  97 + 'imgSize' => $imgSize,
  98 + 'minImgSize' => $minImgSize,
  99 + 'gender' => $gender,
  100 + 'needPd' => 'Y',
  101 + 'rowNum' => $condition['rowNum'],
  102 + 'viewNum' => $condition['viewNum'] - 1,
  103 + 'specialsale_id' => 'Y'
  104 + );
  105 +
  106 + $params = $condition + $_GET;
  107 + $params['attribute_not'] = 2;
  108 + $params = array_filter($params);
  109 +
  110 + $data = Product\SaleModel::getSaleSearchData($params, $options, $specialInfo);
  111 +
  112 + $cate = array('boys', 'girls', 'kids', 'lifestyle');
  113 + $this->setWebNavHeader($cate[$gender - 1]);
  114 + //渲染模板
  115 + $this->_view->display('new-sale', $data);
  116 + }
  117 +
  118 +}