Index.php 19.3 KB
<?php 
use Action\WebAction;
use LibModels\Web\Product\BrandData;

use \LibModels\Web\Product\HotrankData;
use product\HotrankModel;
use LibModels\Web\Home\IndexData;

class IndexController extends WebAction
{
    public $channel;
    public $gender;
    public $road;//频道
    public $code;
    /**
     * 品牌首页
     */
    public function brandAction()
    {
        //品牌域名
        $domain = $this->param('named');
        if (empty($domain)) {
            $this->go(SITE_MAIN);
        }    
        $uid = $this->getUid();
        //根据品牌域名获取品牌id(同时判断品牌域名是否有效)
        $brandInfo = BrandData::getBrandLogoByDomain($domain);
        if (!empty($brandInfo['data']) && $brandInfo['code'] === 200) {
            $brandId = $brandInfo['data']['id'];
            $node = isset($brandInfo['static_content_code']) ? $brandInfo['static_content_code'] : false;
        } else {
            $this->go(SITE_MAIN);
        }
        
        //品牌ID参数
        $condition = array();
        $condition['brand'] = $brandId;
        
        //$options参数数组
        $options = array();
        $options['brandName'] = $domain;
        $options['uid'] = $uid;
        $options['brandId'] = $brandId;
        $options['node'] = $node;
        
        //调用模型获得数据
        $data = Product\BrandsModel::getBrandSearchData($condition, $options);
        $data = array(
            //初始化js
            'searchListPage' => true,
            'list' => $data
        );
        
        $this->setWebNavHeader();
        //渲染模板
        $this->_view->display('list',$data);
    }
    
    public function hotrankAction() {
       
        $data = array(
            'hotrankPage' => true,
            'hotrank' => array(
                array(
                    'slide' => array(
                        'list' => array(
                            array(
                                'href' => '/?gender=1,3',
                                'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
                            ),
                            array(
                                'href' => '/?gender=1,3',
                                'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
                            ),
                            array(
                                'href' => '/?gender=1,3',
                                'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
                            ),
                            array(
                                'href' => '/?gender=1,3',
                                'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
                            ),
                            array(
                                'href' => '/?gender=1,3',
                                'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
                            ),
                            array(
                                'href' => '/?gender=1,3',
                                'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
                            ),
                            array(
                                'href' => '/?gender=1,3',
                                'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
                            ),
                            array(
                                'href' => '/?gender=1,3',
                                'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
                            )
                        )
                    )
                ),
                array(
                    'popular' => array(
                        'name' => '人气单品',
                        'list' => array(
                            array(
                                'href' => '',
                                'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
                                'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
                                'price' => '399',
                                'sPrice' => '199',
                                'rank' => '1'
                            ),
                            array(
                                'href' => '',
                                'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
                                'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
                                'price' => '399',
                                'sPrice' => '199',
                                'rank' => '2'
                            ),
                            array(
                                'href' => '',
                                'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
                                'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
                                'price' => '399',
                                'sPrice' => '199',
                                'rank' => '3'
                            ),
                            array(
                                'href' => '',
                                'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
                                'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
                                'price' => '399',
                                'sPrice' => '199',
                                'rank' => '4'
                            ),
                            array(
                                'href' => '',
                                'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
                                'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
                                'price' => '399',
                                'sPrice' => '199',
                                'rank' => '5'
                            ),
                            array(
                                'href' => '',
                                'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
                                'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
                                'price' => '399',
                                'sPrice' => '199',
                                'rank' => '6'
                            ),
                            array(
                                'href' => '',
                                'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
                                'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
                                'price' => '399',
                                'sPrice' => '199',
                                'rank' => '7'
                            ),
                            array(
                                'href' => '',
                                'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
                                'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
                                'price' => '399',
                                'sPrice' => '199',
                                'rank' => '8'
                            ),
                            array(
                                'href' => '',
                                'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
                                'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
                                'price' => '399',
                                'sPrice' => '199',
                                'rank' => '9'
                            ),
                            array(
                                'href' => '',
                                'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
                                'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
                                'price' => '399',
                                'sPrice' => '199',
                                'rank' => '10'
                            )
                        )
                        
                    )
                ),
                array(
                    'hotBrands' => array(
                        'name' => '热门品牌',
                    )
                ),
                array(
                    'hotWeek' => array(
                        'name' => '一周热卖',
                        'nav' => array(
                            array(
                                'textCn' => 'TOP100',
                                'url' => '',
                                'sid' => 1
                            ),
                            array(
                                'textCn' => '上装',
                                'url' => '',
                                'sid' => 2
                            ),
                            array(
                                'textCn' => '男生测试',
                                'url' => '',
                                'sid' => 3
                            ),
                            array(
                                'textCn' => '配饰',
                                'url' => '',
                                'sid' => 4
                            )
                        ),
                        'list' => array(
                            array(
                                'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
                                'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
                                'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
                                'marketPrice' => '109',
                                'salePrice' => '129'
                            ),
                            array(
                                'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
                                'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
                                'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
                                'marketPrice' => '109',
                                'salePrice' => '129'
                            ),
                            array(
                                'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
                                'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
                                'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
                                'marketPrice' => '109',
                                'salePrice' => '129'
                            ),
                            array(
                                'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
                                'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
                                'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
                                'marketPrice' => '109',
                                'salePrice' => '129'
                            ),
                            array(
                                'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
                                'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
                                'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
                                'marketPrice' => '109',
                                'salePrice' => '129'
                            ),
                            array(
                                'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
                                'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
                                'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
                                'marketPrice' => '109',
                                'salePrice' => '129'
                            ),
                        )
                    )
                )
            )
        );
        
 
        $cookie = $this->getCookie('_Channel');
        $cookie = 'lifestyle';
        $this->channel = isset($cookie) ? $cookie : 'boys';
        switch ($this->channel){
                case 'boys' :
                        $this->gender = '1,3';
                        $this->road = 1;
                        $this->code = '80d772d8dff25300a2a2e4c97165330c';
                        break;
                case 'girls' :
                        $this->gender = '2,3';
                        $this->road = 2;
                        $this->code = '8df64e505e94edb9881fd1e7efb702e9';
                        break;
                case 'lifestyle' :
                        $this->gender = '';
                        $this->road = 4;
                        $this->code = 'd131aba83a84a6977eee3a7403a713de';
                        break;
                case 'kids' :
                        $this->gender = '';
                        $this->road = 3;
                        $this->code = 'bd6a06a08f8ca9b0db762f78e0bc5b68';
                        break;

        }
        $this->setWebNavHeader(\Index\HomeModel::$this->channel);
        $data = array( 'hotrankPage' => true,
                        'footerTop'=> true,
                        'hotrank' => array()
                    );
        //焦点图 热门品牌
        $focus = \Index\HomeModel::getChannelResource($this->channel, $this->code);
        $data['hotrank']['slide'] = $focus[0]['slide'];
        $data['hotrank']['hotBrands'] = $focus[1]['hotBrands'];
        
        //人气单品 一周热卖
        $page = $this->get('page',1);		
        $sort_id = $this->get('sid',0);
        $viewNum = 60;
        $param = array('order'=>'s_n_desc','viewNum'=>$viewNum,'page'=>$page,'stocknumber'=>1,'status'=>1,'gender'=>$this->gender,'attribute_not'=>2);
        if($sort_id != 0){
                $param['sort'] = $sort_id;
        }
        if($this->road == 3){
                $param['msort'] = 365;
        }elseif($this->road == 4){
                $param['msort'] = 10;
        }else{
            $param['not_maxSortId'] = '10,365';
        } 
       $publiclist = \product\HotrankModel::getSearchData($param,$page,0);
       $data['hotrank']['popular'] = $publiclist['popular'];
       $data['hotrank']['hotWeek'] = $publiclist['hotWeek'];

       //分类标签
       $nav = \product\HotrankModel::getHotranktag('web',$this->road,true);
       $data['hotrank']['hotWeek']['nav'] = $nav;
       $this->_view->display('hotrank', $data);
    }
    
    /*
     * 一周热卖加载更多
     */
    public function getdataAction()
    {
        $page = $this->get('page',1);
        //加载到100个以后停止
        if($page > 2)
        {
            echo json_encode(array('code'=>201,'data'=>''));
            exit;
        }
        $sid = $this->get('sid',1);
        $sort = '';		
        //是否是默认标签
        if($sid > 1)
        {
            //通过ID获取标签信息
            $info = \LibModels\Web\Product\HotrankData::getTagById($sid, false);
            if(!empty($info['data']))
            {
                $sort = $info['data']['category_id'];
            }				
        }
        $viewNum = 60;
        //过滤掉赠品		
        $param = array('order'=>'s_n_desc','viewNum'=>$viewNum,'page'=>$page,'sort'=>$sort,'stocknumber'=>1,'status'=>1,'gender'=>$this->gender,
                'attribute_not'=>2);
        if(empty($param['sort']))
        {
            if($this->road == 3)
            {
                $param['msort'] = 365;
            }elseif($this->road == 4){
                $param['msort'] = 10;
            }else{
                $param['not_maxSortId'] = '10,365';
            }
        }
        
        $list = \product\HotrankModel::getSearchData($param, $page, 1);
        $lister = $list['hotWeek']['list'];
        $lister = array_values($lister);
        if($sid == 1 && $page == 1)
        {
            $lister = array_slice($lister, 10, 50);
        }else{
            $lister = array_slice($lister, 0, 50);
        }
        $data = array(
                'code'=>200,
                'data'=>$lister,
        );
        echo json_encode($data);
        exit;   
    }
}
?>