Sale.php 1.53 KB
<?php

use Action\WebAction;
use LibModels\Web\Product\SaleData;

/**
 * sale页
 *
 */
class SaleController extends WebAction 
{

    public function indexAction() 
    {
        //获取专区ID
        $specialsaleId = $this->get('specialsale_id');
        $specialInfo = SaleData::getSpecial($specialsaleId);
        if(isset($specialInfo['data'])) {
            $special = $specialInfo['data'];
        } else {
            $special = array();
        }
        //获取促销ID
        $promotion = $this->get('promotion');
        //专区ID和促销ID都为空时,跳转到主页
        if (empty($specialsaleId) && empty($promotion)) {
            $this->go(SITE_MAIN);
        }
        
        $condition = array();
        //传品牌ID参数
        if(!empty($special['brand_id'])){
            $condition['brand'] = $special['brand_id'];
        }
        //传促销id
        if(!empty($special['ispromotion'])){
            $condition['promotion'] = $special['ispromotion'];
        }else{
            $condition['promotion'] = $promotion;
        }
        
        $options = array(
            'specialsale_id' => 'Y',
            'controller' => $this->_request->controller
        );
        
        $saleData = Product\SaleModel::getSaleSearchData($condition, $options, $specialInfo);
        $data = array(
             //初始化js
            'productListPage' => true,
            'newSale' => $saleData
        );
        $this->setWebNavHeader();
        //渲染模板
        $this->_view->display('new-sale', $data);
    }

}