Favorite.php 13 KB
<?php

use Action\WebAction;
use WebPlugin\Helpers;
use Home\UserModel;
use LibModels\Web\Product\FavoriteData;
use LibModels\Wap\Home\UserData;

/**
 * 商品收藏
 */
class FavoriteController extends WebAction
{

    /**
     * 我的收藏
     */
    public function indexAction()
    {
        //判断是否登录
        $uid = $this->auditJumpLogin();
        $page = 1;
        $result = FavoriteData::favoriteProductData($uid, $page, 10);
//        print_r($result);
        $all = array();
        
        if($result['data']){
           $all[0]['name'] = '全部';
           $all[0]['url'] = Helpers::url('/product/favorite');
           $all[0]['count'] = $result['data']['total'];
            foreach ($result['data']['category_list'] as $catekey => $cateval){
                $all[$catekey + 1]['name'] = $cateval['category_name'];
                $all[$catekey + 1]['url'] = Helpers::url('/product/favorite', array('middle_sort_id' => $cateval['category_id']));
                $all[$catekey + 1]['count'] = 0;
            }
            
        }
        $data = array(
            'path' => UserModel::getCenterCrumb('我的收藏'),
            'userThumb' => UserModel::getUserHeadImg($uid),
            'homeNav' => UserModel::getCenterLeftNav('我的收藏'),
            'tabs' => array(
                array(
                    'active' => true,
                    'url' => '',
                    'name' => '商品收藏'
                ),
                array(
                    'url' => '',
                    'name' => '品牌收藏'
                ),
                array(
                    'url' => '',
                    'name' => '文章收藏'
                )
            ),
            'favProducts' => array(
                'sort' => array(
                    'default' => array(
                        array(
                            'name' => '全部',
                            'count' => 140,
                            'focus' => true,
                            'url' => ''
                        )
                    ),
                    'all' => $all
//                    'all' => array(
//                        array(
//                            'name' => '全部',
//                            'count' => 140,
//                            'focus' => true,
//                            'url' => ''
//                        ),
//                        array(
//                            'name' => 'T恤',
//                            'count' => 5,
//                            'url' => ''
//                        ),
//                        array(
//                            'name' => '衬衫',
//                            'count' => 40,
//                            'url' => ''
//                        )
//                    )
                ),
                'reduction' => array(
                    'count' => 0,
                    'url' => ''
                ),
                'filter' => array(
                    'reductionUrl' => '',
                    'reductionChecked' => true,
                    'activityUrl' => '',
                    'activityChecked' => true
                ),
                'goods' => array(
                    array(
                        'skn' => '239557',
                        'img' => 'http://img12.static.yhbimg.com/goodsimg/2016/01/14/07/02b9ce4acb9374022cf645634574902f1a.jpg?imageMogr2/thumbnail/100x100/extent/100x100/background/d2hpdGU=/position/center/quality/90',
                        'name' => 'VEIL  ADVOCATED CHAOS Snapback 熔岩体刺绣棒球帽',
                        'url' => '',
                        'activites' => array(
                            'count' => 1,
                            'list' => array(
                                array(
                                    'type' => '现金折扣',
                                    'name' => '冬装季末特享',
                                    'desc' => '折上满¥599再减¥100'
                                ),
                                array(
                                    'type' => '满送礼品',
                                    'name' => '全场99元加价购'
                                ),
                                array(
                                    'type' => '满送礼品',
                                    'name' => '全场59元加价购'
                                )
                            )
                        ),
                        'price' => '239.00',
                        'priceDown' => '30.00',
                        'buyNow' => '/path/to/buy',
                        // 'buyAgain' => '/path/to/buy', //再次购买链接
                        // 'soldOut' => true,
                        // 'hadNoticed' => true, //已经订阅通知
                        'delUrl' => ''
                    )
                ),
                'pager' => array(
                    'hasCheckAll' => true,
                    'count' => 24,
                    'curPage' => 1,
                    'totalPages' => 4,
                    'pagerHtml' => '<a href="?page=2&amp;type=3"><span class="iconfont">&#xe634;</span>上一页</a><a href="?page=1&amp;type=3">1</a><a class="cur" href="?page=2&amp;type=3">2</a><a href="?page=3&amp;type=3">3</a><a href="?page=2&amp;type=3">下一页<span class="iconfont">&#xe601;</span></a>'
                )
            )
                // 'favBrands' => array(
                //     'brands' => array(
                //         array(
                //             'img' => 'http://img13.static.yhbimg.com/brandLogo/2015/12/07/11/02ad8c091053e36261ac4eace80ba40c54.jpg?imageMogr2/thumbnail/100x100/extent/100x100/background/d2hpdGU=/position/center/quality/90',
                //             'url' => '',
                //             'name' => 'ACROSS!',
                //             'naCount' => 1,
                //             'colCount' => 2300,
                //             'delUrl' => ''
                //         )
                //     ),
                //     'pager' => array(
                //         'hasCheckAll' => true,
                //         'count' => 24,
                //         'curPage' => 1,
                //         'totalPages' => 4,
                //         'pagerHtml' => '<a href="?page=2&amp;type=3"><span class="iconfont">&#xe634;</span>上一页</a><a href="?page=1&amp;type=3">1</a><a class="cur" href="?page=2&amp;type=3">2</a><a href="?page=3&amp;type=3">3</a><a href="?page=2&amp;type=3">下一页<span class="iconfont">&#xe601;</span></a>'
                //     )
                // )
                // 'favArticles' => array(
                //     'articles' => array(
                //         array(
                //             'img' => 'http://img12.static.yhbimg.com/yhb-img01/2016/02/17/06/02f6d182974252df932839932b1f2f8b9c.jpg?imageView/2/w/600/h/200',
                //             'url' => '',
                //             'name' => ' 趁着好天气,换上一身轻松的装备,骑车去郊游吧',
                //             'desc' => '看着外面天气这么好,春节假期的欢乐应该延续一下,马上周末,快约上三五好友去郊游吧!'
                //         )
                //     ),
                //     'pager' => array(
                //         'hasCheckAll' => true,
                //         'count' => 24,
                //         'curPage' => 1,
                //         'totalPages' => 4,
                //         'pagerHtml' => '<a href="?page=2&amp;type=3"><span class="iconfont">&#xe634;</span>上一页</a><a href="?page=1&amp;type=3">1</a><a class="cur" href="?page=2&amp;type=3">2</a><a href="?page=3&amp;type=3">3</a><a href="?page=2&amp;type=3">下一页<span class="iconfont">&#xe601;</span></a>'
                //     )
                // )
        );

        $this->_view->display('favorite', array('meFavoritePage' => true, 'meFavorite' => $data));
    }

    /**
     * 品牌收藏-新品到着
     */
    public function newproductAction()
    {
        $this->_view->display('na-list', array(
            'naGoods' => array(
                // 'pre' => 'path/to/ajax',
                'goods' => array(
                    array(
                        'img' => 'http://img13.static.yhbimg.com/goodsimg/2016/02/02/08/0262ec823af3dcecc5fff8c687fc872c31.jpg?imageMogr2/thumbnail/100x100/extent/100x100/background/d2hpdGU=/position/center/quality/90',
                        'url' => '',
                        'name' => 'Master Plan PU拼接魔术贴运动鞋 ',
                        'salePrice' => '699.00',
                        'marketPrice' => '799.00'
                    )
                ),
                'next' => '/home/newproduct'
            )
        ));
    }

    /**
     * 商品收藏,降价通知
     */
    public function reductionAction()
    {
        $data = array(
            'path' => array(
                array(
                    'href' => 'www.yohobuy.com',
                    'name' => 'YOHO!有货首页'
                ),
                array(
                    'href' => 'www.yohobuy.com/home',
                    'name' => '个人中心'
                ),
                array(
                    'name' => '订单中心'
                )
            ),
            'userThumb' => 'http://img10.static.yhbimg.com/headimg/2013/11/28/09/01cae078abe5fe320c88cdf4c220212688.gif?imageView/2/w/100/h/100',
            'homeNav' => array(
                array(
                    'title' => '交易管理',
                    'subNav' => array(
                        array(
                            'name' => '我的订单',
                            'href' => '/',
                            'active' => true
                        ),
                        array(
                            'name' => '我的收藏',
                            'href' => '/'
                        ),
                        array(
                            'name' => '我的YOHO币',
                            'href' => '/'
                        ),
                        array(
                            'name' => '我的红包',
                            'href' => '/'
                        ),
                        array(
                            'name' => '我的优惠券',
                            'href' => '/'
                        ),
                        array(
                            'name' => '我的VIP',
                            'href' => '/'
                        )
                    )
                )
            ),
            'tabs' => array(
                array(
                    'active' => true,
                    'url' => '',
                    'name' => '商品收藏'
                ),
                array(
                    'url' => '',
                    'name' => '品牌收藏'
                ),
                array(
                    'url' => '',
                    'name' => '文章收藏'
                )
            ),
            //'reductionUrl' => 'xxx',
            'goods' => array(
                array(
                    'skn' => '239557',
                    'img' => 'http://img12.static.yhbimg.com/goodsimg/2016/01/14/07/02b9ce4acb9374022cf645634574902f1a.jpg?imageMogr2/thumbnail/100x100/extent/100x100/background/d2hpdGU=/position/center/quality/90',
                    'name' => 'VEIL  ADVOCATED CHAOS Snapback 熔岩体刺绣棒球帽',
                    'url' => '',
                    'activites' => array(
                        'count' => 1,
                        'list' => array(
                            array(
                                'type' => '现金折扣',
                                'name' => '冬装季末特享',
                                'desc' => '折上满¥599再减¥100'
                            ),
                            array(
                                'type' => '满送礼品',
                                'name' => '全场99元加价购'
                            ),
                            array(
                                'type' => '满送礼品',
                                'name' => '全场59元加价购'
                            )
                        )
                    ),
                    'price' => '239.00',
                    'priceDown' => '30.00',
                    'buyNow' => '/path/to/buy',
                    // 'buyAgain' => '/path/to/buy', //再次购买链接
                    // 'soldOut' => true,
                    'hadNoticed' => true, //已经订阅通知
                    'delUrl' => ''
                )
            )
        );

        $this->_view->display('../../index/home/reduction', array('meFavoritePage' => true, 'meFavorite' => $data));
    }

    /**
     * 降价通知
     */
    public function noticeAction()
    {
        $this->echoJson(array('code' => 200, 'data' => array('num' => 3)));
    }

    /**
     * 取消通知
     */
    public function cancelnoticeAction()
    {
        $this->echoJson(array('code' => 200, 'data' => array('num' => 3)));
    }

}