Authored by Rock Zhang

添加sale.m.yohobuy.com页面(专区活动)

Code Review By Rock Zhang
@@ -34,6 +34,14 @@ @@ -34,6 +34,14 @@
34 <input class="query-param" type="hidden" data-attr="discount" value="{{discount}}"> 34 <input class="query-param" type="hidden" data-attr="discount" value="{{discount}}">
35 {{/if}} 35 {{/if}}
36 36
  37 +{{#if specialsale_id}}
  38 + <input class="query-param" type="hidden" data-attr="specialsale_id" value="{{specialsale_id}}">
  39 +{{/if}}
  40 +
  41 +{{#if promotion}}
  42 + <input class="query-param" type="hidden" data-attr="promotion" value="{{promotion}}">
  43 +{{/if}}
  44 +
37 {{#if query}} 45 {{#if query}}
38 <input class="query-param" type="hidden" data-attr="query" value="{{query}}"> 46 <input class="query-param" type="hidden" data-attr="query" value="{{query}}">
39 {{/if}} 47 {{/if}}
@@ -96,10 +96,10 @@ class Bootstrap extends Bootstrap_Abstract @@ -96,10 +96,10 @@ class Bootstrap extends Bootstrap_Abstract
96 case 'cart': // 购物车 96 case 'cart': // 购物车
97 $module = 'Cart'; 97 $module = 'Cart';
98 break; 98 break;
99 -// case 'sale': // 专区活动  
100 -// $module = 'Product';  
101 -// $action = 'Sale';  
102 -// break; 99 + case 'sale': // 专区活动
  100 + $module = 'Product';
  101 + $action = 'Sale';
  102 + break;
103 default: // 其它(识别为品牌) 103 default: // 其它(识别为品牌)
104 $module = 'Product'; 104 $module = 'Product';
105 $action = 'Brand'; 105 $action = 'Brand';
@@ -210,6 +210,8 @@ class SearchController extends AbstractAction @@ -210,6 +210,8 @@ class SearchController extends AbstractAction
210 /* 过滤请求参数 */ 210 /* 过滤请求参数 */
211 $condition = filter_input_array(INPUT_GET, array( 211 $condition = filter_input_array(INPUT_GET, array(
212 'query' => FILTER_DEFAULT, 212 'query' => FILTER_DEFAULT,
  213 + 'specialsale_id' => FILTER_DEFAULT,
  214 + 'promotion' => FILTER_DEFAULT,
213 'brand' => FILTER_DEFAULT, 215 'brand' => FILTER_DEFAULT,
214 'sort' => FILTER_DEFAULT, 216 'sort' => FILTER_DEFAULT,
215 'msort' => FILTER_DEFAULT, 217 'msort' => FILTER_DEFAULT,
@@ -234,6 +236,13 @@ class SearchController extends AbstractAction @@ -234,6 +236,13 @@ class SearchController extends AbstractAction
234 if (isset($condition['misort'])) { 236 if (isset($condition['misort'])) {
235 $condition['misort'] = rawurldecode($condition['misort']); 237 $condition['misort'] = rawurldecode($condition['misort']);
236 } 238 }
  239 + // 转义活动ID
  240 + if (isset($condition['specialsale_id'])) {
  241 + $condition['specialsale_id'] = rawurldecode($condition['specialsale_id']);
  242 + }
  243 + if (isset($condition['promotion'])) {
  244 + $condition['promotion'] = rawurldecode($condition['promotion']);
  245 + }
237 // 转义颜色 246 // 转义颜色
238 if (isset($condition['color'])) { 247 if (isset($condition['color'])) {
239 $condition['color'] = rawurldecode($condition['color']); 248 $condition['color'] = rawurldecode($condition['color']);
1 <?php 1 <?php
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
  4 +use LibModels\Web\Product\SaleData;
4 use Plugin\Helpers; 5 use Plugin\Helpers;
5 6
6 /** 7 /**
@@ -228,4 +229,121 @@ class IndexController extends AbstractAction @@ -228,4 +229,121 @@ class IndexController extends AbstractAction
228 229
229 $this->_view->display('index', $data); 230 $this->_view->display('index', $data);
230 } 231 }
  232 +
  233 + /**
  234 + * 活动专区
  235 + *
  236 + * @param int channel 1:男生,2:女生,3:潮童,4:创意生活
  237 + */
  238 + public function saleAction()
  239 + {
  240 + // 过滤请求参数
  241 + $condition = filter_input_array(INPUT_GET, array(
  242 + 'brand' => FILTER_DEFAULT,
  243 + 'specialsale_id' => FILTER_DEFAULT,
  244 + 'promotion' => FILTER_DEFAULT,
  245 + 'sort' => FILTER_DEFAULT,
  246 + 'msort' => FILTER_DEFAULT,
  247 + 'misort' => FILTER_DEFAULT,
  248 + 'color' => FILTER_DEFAULT,
  249 + 'size' => FILTER_DEFAULT,
  250 + 'style' => FILTER_DEFAULT,
  251 + 'price' => FILTER_DEFAULT,
  252 + 'discount' => FILTER_DEFAULT,
  253 + 'gender' => FILTER_DEFAULT,
  254 + 'p_d' => FILTER_DEFAULT,), false);
  255 +
  256 + //专区ID和促销ID都为空时,跳转到主页
  257 + if (!isset($condition['specialsale_id']) && isset($condition['promotion'])) {
  258 + $this->go(SITE_MAIN);
  259 + }
  260 +
  261 + // 转义活动ID
  262 + if (isset($condition['specialsale_id'])) {
  263 + $condition['specialsale_id'] = rawurldecode($condition['specialsale_id']);
  264 + }
  265 + if (isset($condition['promotion'])) {
  266 + $condition['promotion'] = rawurldecode($condition['promotion']);
  267 + }
  268 +
  269 + // 获取促销信息
  270 + $special = array();
  271 + $specialInfo = SaleData::getSpecial($condition['specialsale_id']);
  272 + if(isset($specialInfo['data'])) {
  273 + $special = $specialInfo['data'];
  274 + }
  275 + //传促销id,促销id为空时传专区id
  276 + if(!empty($special['ispromotion'])){
  277 + $condition['promotion'] = $special['ispromotion'];
  278 + }
  279 +
  280 + // 转义品牌
  281 + if (isset($condition['brand'])) {
  282 + $condition['brand'] = rawurldecode($condition['brand']);
  283 + } else {
  284 + //传品牌ID参数
  285 + if(!empty($special['brand_id'])){
  286 + $condition['brand'] = $special['brand_id'];
  287 + }
  288 + }
  289 +
  290 + // 转义分类
  291 + if (isset($condition['sort'])) {
  292 + $condition['sort'] = rawurldecode($condition['sort']);
  293 + }
  294 + // 转义一级分类
  295 + if (isset($condition['msort'])) {
  296 + $condition['msort'] = rawurldecode($condition['msort']);
  297 + }
  298 + // 转义二级分类
  299 + if (isset($condition['misort'])) {
  300 + $condition['misort'] = rawurldecode($condition['misort']);
  301 + }
  302 + // 转义颜色
  303 + if (isset($condition['color'])) {
  304 + $condition['color'] = rawurldecode($condition['color']);
  305 + }
  306 + // 转义尺码
  307 + if (isset($condition['size'])) {
  308 + $condition['size'] = rawurldecode($condition['size']);
  309 + }
  310 + // 转义风格
  311 + if (isset($condition['style'])) {
  312 + $condition['style'] = rawurldecode($condition['style']);
  313 + }
  314 + // 转义价格
  315 + if (isset($condition['price'])) {
  316 + $condition['price'] = rawurldecode($condition['price']);
  317 + }
  318 + // 转换折扣
  319 + if (isset($condition['discount'])) {
  320 + $condition['p_d'] = rawurldecode($condition['discount']);
  321 + }
  322 + // 为了兼容现在运营在用的p_d
  323 + if (isset($condition['p_d'])) {
  324 + $condition['discount'] = rawurldecode($condition['p_d']);
  325 + }
  326 + // 性别参数,不传则从COOKIE获取
  327 + if (!isset($condition['gender'])) {
  328 + $condition['gender'] = Helpers::getGenderByCookie();
  329 + } else {
  330 + $condition['gender'] = rawurldecode($condition['gender']);
  331 + }
  332 +
  333 + if (!$condition) {
  334 + $condition = array();
  335 + }
  336 + $goodList = $condition;
  337 + $goodList['cartUrl'] = Helpers::url('/cart/index/index', null);
  338 +
  339 + $this->setTitle('专区活动');
  340 + $this->setNavHeader('专区活动', true, SITE_MAIN);
  341 +
  342 + $this->_view->display('index', array(
  343 + 'goodListPage' => true,
  344 + 'showDownloadApp' => true,
  345 + 'goodList' => $goodList,
  346 + 'pageFooter' => true,
  347 + ));
  348 + }
231 } 349 }