Newsale.php 2.54 KB
<?php

use Action\AbstractAction;
use LibModels\Wap\Product\NewsaleData;
use Product\NewsaleModel;

/**
 * 新品到着
 */
class NewsaleController extends AbstractAction
{

    public function indexAction()
    {
        $this->setTitle('新品到着');

        $data = array(
            'newArrival' => true,
            'pageHeader' => array(
                'navBack' => true,
                'navTitle' => '新品到着',
                'navHome' => '/'
            )
        );

        $channel = $this->getCookie('_Channel', 'boys');
        // 添加商品数据
        $data += NewsaleModel::getNewByChannel($channel);

        $this->_view->display('new', $data);
    }

    /**
     * Ajax方式筛选新品到着、折扣专区商品
     * 
     * @return array 根据指定条件筛选之后的商品
     */
    public function selectNewSaleAction()
    {
        if ($this->isAjax()) {
            $gender = $this->get('gender', '1,3');
            $brand = $this->get('brand', null);
            $sort = $this->get('sort', null);
            $color = $this->get('color', null);
            $size = $this->get('size', null);
            $price = $this->get('price', null);
            $p_d = $this->get('p_d', null);
            $channel = $this->get('channel', '1');
            $dayLimit = $this->get('dayLimit', '1');
            $limit = $this->get('limit', 50);
            $page = $this->get('page', 1);

            $result = NewsaleModel::selectData($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page);

            $this->_view->display('product', $result);
        }
    }

    /**
     * 折扣专区
     */
    public function discountAction()
    {
        $this->setTitle('折扣专区');
        
        $data = array(
            'discount' => true,
            'pageHeader' => array(
                'navBack' => true,
                'navTitle' => 'SALE',
                'navHome' => '/'
            )
        );

        $channel = $this->getCookie('_Channel', 'boys');
        // 添加商品数据
        $data += NewsaleModel::getSaleByChannel($channel);
        
        // 更新tabs
        $tabs = array();
        foreach (array_keys($products) as $key => $value) {
            $tabItem = array();
            $tabItem['title'] = $value;
            if ($key === 0) {
                $tabItem['focus'] = true;
            }
            $tabs[] = $tabItem;
        }
        $data['tabs'] = $tabs;

        /* echo '<pre>';
          print_r($data);exit; */

        $this->_view->display('sale', $data);
    }

}