ShoppingCart.php 7.45 KB
<?php

use Action\AbstractAction;

/**
 * 购物车
 */
class ShoppingCartController extends AbstractAction
{
    public function indexAction()
    {
        $data = array(
            'cartNav' => true,
            'commonGoodsCount' => 2,
            'presellGoodsCount' => 2,
            'showLoginInfo' => true,
            'commonCart' => array(
                'goods' => array(
                    array(
                        'id' => 1,
                        'name' => '黄伟文Wyman X y yohood 联名商品YYYOHOOD圆领卫衣',
                        'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90',
                        'color' => '黄色',
                        'size' => 'F',
                        'appearDate' => '12月',
                        'price' => 399.00,
                        'count' => 8,
                        'lowStocks' => true
                    ),
                    array(
                        'id' => 2,
                        'name' => 'TYAKSHA圣诞树凭借三角领蓝色白条毛衣',
                        'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/10/03/10/01bc1878f9154e77ac4f7a6003c954f1b8.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                        'color' => '黄色',
                        'size' => 'F',
                        'price' => 553.00,
                        'count' => 1,
                        'soldOut' => true
                    )
                ),
                'freebieOrAdvanceBuy' => true,
                'freebie' => array(
                    'url' => '',
                    'count' => 2
                ),
                'advanceBuy' => array(
                    'url' => '',
                    'count' => 3
                ),
                'price' => 3192,
                'activityPrice' => 0,
                'count' => 8,
                'sumPrice' => 3192
            ),
            'preSellCart' => array(
                'goods' => array(
                    array(
                        'id' => 2,
                        'name' => 'TYAKSHA圣诞树凭借三角领蓝色白条毛衣',
                        'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/10/03/10/01bc1878f9154e77ac4f7a6003c954f1b8.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                        'color' => '黄色',
                        'size' => 'F',
                        'price' => 553.00,
                        'count' => 1,
                        'soldOut' => true
                    )
                ),
                'freebieOrAdvanceBuy' => true,
                'freebie' => array(
                    'url' => '',
                    'count' => 2
                ),
                'advanceBuy' => array(
                    'url' => '',
                    'count' => 3
                ),
                'price' => 553,
                'activityPrice' => 0,
                'count' => 1,
                'sumPrice' => 553
            )
        );
        // 渲染模板
        $this->_view->display('index', array('shoppingCartPage' => true, 'pageHeader' => array(
            'navBack' => 'http://m.yohobuy.com', 'navTitle' => '购物车'), 'shoppingCart' => $data));
    }

    public function giftAdvanceAction()
    {
        $data = array(
            'advance' => array(
                array(
                    'title' => '【izzue】加¥19购袜子',
                    'goods' => array(
                        'id' => 1,
                        'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90',
                        'name' => 'Life.After.Life纯棉短袜',
                        'salePrice' => 19,
                        'price' => 99,
                        'count' => 1
                    )
                ),
                array(
                    'title' => '【银鳞堂】加¥9购手绳',
                    'goods' => array(
                        'id' => 1,
                        'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/10/03/10/01bc1878f9154e77ac4f7a6003c954f1b8.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
                        'name' => '银鳞堂民族风牛皮手绳',
                        'salePrice' => 9,
                        'price' => 19,
                        'count' => 1
                    )
                )
            )
        );

        // $data = array(
        //     'gift' => array(
        //         'id' => 1,
        //         'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90',
        //         'name' => 'Life.After.Life纯棉短袜',
        //         'color' => '黄色',
        //         'size' => 'L',
        //         'price' => 0,
        //         'count' => 1
        //     )
        // );

        $this->_view->display('gift-advance', array('giftAdvancePage' => true, 'pageHeader' => array(
            'navBack' => true, 'navTitle' => '加价购'), 'shoppingCart' => $data));
    }
 
    /**
     * 读取chose-panel内容
     */
    public function tplAction()
    {
        if($this->isAjax()) {
            $data = file_get_contents('../../../template/m.yohobuy.com/partials/shopping-cart/chose-panel.phtml');

            echo($data);
        }
    }

    public function goodinfoAction()
    {
        if ($this->isAjax()) {
            $data = array(
                'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/09/17/03/014cacfa5c458b9732c68adf1af15d7a45.jpg?imageMogr2/thumbnail/120x120/extent/120x120/background/d2hpdGU=/position/center/quality/90',
                'name' => '黄伟文Wyman X y yohood 联名商品YYYOHOOD圆领卫衣',
                'price' => 289,
                'salePrice' => 241,
                'colors' => array(
                    array(
                        'id' => 1,
                        'name' => '黄色'
                    ),
                    array(
                        'id' => 2,
                        'chosed' => true,
                        'name' => '白色'
                    )
                ),
                'sizes' => array(
                    array(
                        'id' => 1,
                        'name' => 'XS'
                    ),
                    array(
                        'id' => 2,
                        'name' => 'S'
                    ),
                    array(
                        'id' => 3,
                        'chosed' => true,
                        'name' => 'M'
                    ),
                    array(
                        'id' => 4,
                        'name' => 'L'
                    ),
                    array(
                        'id' => 5,
                        'name' => 'XL'
                    ),
                    array(
                        'id' => 6,
                        'name' => 'XXL'
                    )
                ),
                'num' => 1
            );
            
            $this->echoJson(array('code' => 200, 'data' => $data));
        }
    }
}