Newsale.php 9.27 KB
<?php

use Action\AbstractAction;
use LibModels\wap\Product\NewsaleData as Newsale;
use Plugin\Helpers;
/**
 * 新品到着
 */
class NewsaleController extends AbstractAction
{
    public function indexAction()
    {
        $this->_view->assign('title', '新品到着');

        // 新品到着顶部焦点图
        $focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d');
        // 处理返回的数据
        $focus = array();
        if($focusData['code'] == 200)
        {
            foreach ($focusData['data'] as $single)
            {
                foreach ($single['data'] as $val) {
                    $val['src'] = Helpers::getImageUrl($val['src'], 375, 667, 1);
                    $focus[] = $val;
                }
            }
        }

        // 批量获取新品到着商品数据
        $products = Newsale::getNewProducts('1,3', 1, 60);

        echo '<pre>';
        print_r($focus);print_r($products);exit;

        $this->_view->display('new', compact('f/**/ocus', 'products'));
 
        /*$data = array(
            'headerBanner' => array(
                 'list'  => array(
                      array(
                          'url' => '',
                          'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',
                      )
                  )
             ),
             'listNav'  => array(
                 'list'  => array(
                      array(
                          'url' => '',
                          'textCn' => '5月27日',
                          'styleClass' => ''
                      ),
                      array(
                          'url' => '',
                          'textCn' => '本周上新'
                      ),
                      array(
                          'url' => '',
                          'textCn' => '销量'
                      ),
                      array(
                          'url' => '',
                          'textCn' => '筛选',
                          'styleClass' => 'screen-nav'
                      )
                  )
             )       
        );

        $this->_view->assign('title', '新品到着');
        $this->_view->display('new', $data);*/
    }


    /**
     * Ajax方式筛选新品到着、折扣专区商品
     * 
     * @return array 根据指定条件筛选之后的商品
     */
    public function selectNewAction()
    {
        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);

            $data = Newsale::selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page);

            $this->returnJson(200, '获取成功', $data);
        }
    }


    public function discountAction()
    {

        $data = array(
            'header' => array(
                 'title'  =>  'SALE'
             ),
             'headerBanner'  => array(
                 'list'  => array(
                      array(
                          'url' => '',
                          'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
                      ),
                      array(
                          'url' => '',
                          'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
                      ),
                      array(
                          'url' => '',
                          'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
                      ),
                      array(
                          'url' => '',
                          'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
                      )
                  )
             ),
             'saleSection'  => array(
                 'list'  => array(
                      array(
                          'url' => '',
                          'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
                      ),
                      array(
                          'url' => '',
                          'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
                      ),
                      array(
                          'url' => '',
                          'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
                      ),
                      array(
                          'url' => '',
                          'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
                      )
                  )
             ),  
             'latestSale'  => array(
                 'list'  => '最新降价'
             ),
             'goodsNav'  => array(
                 'newPatterns'  => true,
                 'price'  => true,
                 'salesVolume'  => true,
                 'screen'  => true,
             ), 
             'goodsContainer'  => array(
                 'goods'  => array(
                      array(
                          'id' => '',
                          'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',
                          'name'  => 'GAWS DIGI 丛林数码印花拼接卫衣',
                          'isLike'  => false,
                          'price'  => 1268,
                          'salePrice'  => 589,
                          'isSale'  => true,
                          'isFew'  => true,
                          'isNew'  => false,
                          'url'  => ''
                      ),
                      array(
                          'id' => '',
                          'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',
                          'name'  => 'GAWS DIGI 丛林数码印花拼接卫衣',
                          'isLike'  => false,
                          'price'  => 1268,
                          'salePrice'  => 589,
                          'isSale'  => true,
                          'isFew'  => true,
                          'isNew'  => false,
                          'url'  => ''
                      ),
                      array(
                          'id' => '',
                          'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',
                          'name'  => 'GAWS DIGI 丛林数码印花拼接卫衣',
                          'isLike'  => false,
                          'price'  => 1268,
                          'salePrice'  => 589,
                          'isSale'  => true,
                          'isFew'  => true,
                          'isNew'  => false,
                          'url'  => ''
                      ),
                      array(
                          'id' => '',
                          'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',
                          'name'  => 'GAWS DIGI 丛林数码印花拼接卫衣',
                          'isLike'  => false,
                          'price'  => 1268,
                          'salePrice'  => 589,
                          'isSale'  => true,
                          'isFew'  => true,
                          'isNew'  => false,
                          'url'  => ''
                      )
                  )
             ), 
        );
 
        /*$this->_view->assign('title', '折扣专区');

        // 折扣专区顶部焦点图
        $focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523');
        // 处理返回的数据
        $focus = array();
        if($focusData['code'] == 200)
        {
        	foreach ($focusData['data'] as $single)
            {
                foreach ($single['data'] as $val) {
                    $val['src'] = Helpers::getImageUrl($val['src'], 375, 667, 1);
                    $focus[] = $val;
                }
            }
        }

        // 折扣专区商品数据
        $products = Newsale::getNewProducts('1,3', 1, 60);

        echo '<pre>';
        print_r($focus);print_r($products);exit;

        $this->_view->display('new', compact('focus', 'products'));*/

        $this->_view->assign('title', '折扣专区');
        $this->_view->display('sale', $data);
    }
}