Home.php 10.8 KB
<?php

use Action\AbstractAction;
use home\GradeModel;
use home\OrderModel;
use Plugin\Helpers;

/**
 * 个人中心相关的控制器
 * 
 * @name HomeController
 * @package 
 * @copyright yoho.inc
 * @version 1.0 (2015-10-28 16:28:32)
 * @author fei.hong <fei.hong@yoho.cn>
 */
class HomeController extends AbstractAction
{
    /**
     * 个人中心入口
     */
    public function indexAction()
    {
    	// 设置网站标题
        $this->setTitle('个人中心');
	    $this->setNavHeader('个人中心', true, SITE_MAIN);

	    // $uid = $this->getUid();
	    $uid = 967016;
	    $data = \Index\UserModel::getUserProfileData($uid);
	    $data += \Index\UserModel::getInfoNumData($uid);

	    // 优选新品数据
	    $channel = Helpers::getChannelByCookie();
		$data['recommendForYou'] = \Index\UserModel::getPreferenceData($channel);
	    // print_r($data);

        $data['myIndexPage'] = true;
        $data['pageFooter'] = true;

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

	/**
	 * 用户订单
	 */
	public function ordersAction()
	{
		// $uid = $this->getUid();
		// $type = $this->get('type', 1);

		// $orders = \Index\UserModel::getUserOrderData(967016, $type);

		$order = array(
			'orders' => array(
				array(
					'orderNum' => '408539077',
					'tradingStatus' => '交易成功',
					'goods' => array(
						array(
							'id' => 1,
							'thumb' => 'http://img11.static.yhbimg.com/goodsimg/2015/11/04/05/01ce2aff32fc3c90584f516167cd526d91.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
							'name' => 'Adidas Originals ZX FLUXM22508',
							'color' => '黄',
							'size' => '43',
							'price' => '699.00',
							'count' => '2'
						),
						array(
							'id' => 1,
							'thumb' => 'http://img10.static.yhbimg.com/goodsimg/2015/11/04/05/0188f1aca49ac478a565ec029b5d2d4a6c.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90',
							'name' => 'B.Duck浴室玩伴mini浮水鸭',
							'gift' => true,
							'color' => '黄',
							'size' => '43',
							'price' => '0.00',
							'count' => '1'
						)
					),
					'count' => 2,
					'sumCost' => '699.00',
					'unpaid' => true,
				)
			)
		);

		$this->_view->display('order', array('order' => $order, 'orderPage' => true));
		// print_r($orders);
	}

	/**
	 * 用户收藏的商品
	 */
	public function favoriteAction()
	{
		$uid = $this->getUid();

		$favProducts = \Index\UserModel::getFavProductData($uid);

		//print_r($favProducts);

        $this->_view->display('favorite', array(
            'favPage' => true,
            'pageHeader' => array(
                'navBack' => true,
                'navTitle' => '我的收藏',
                'navHome' => true
            ),
            'pageFooter' => true,
            'favorite' => true,
            'hasFavProduct' => false,
            'hasFavBrand' => false
        ));
	}

	/**
	 * 用户收藏的品牌
	 */
	public function favoritebrandAction()
	{
		$uid = $this->getUid();
		$gender = Helpers::getGenderByCookie();

		$favBrands = \Index\UserModel::getFavBrandData($uid, $gender);

		print_r($favBrands);
	}

	/**
	 * 个人信息
	 */
	public function personalDetailsAction()
	{
        $this->setTitle('个人信息');
	    $this->setNavHeader('个人信息', true, SITE_MAIN);

		// $uid = $this->getUid();
		$uid = 967016;
	    $data = \Index\UserModel::getUserProfileData($uid);
	    $data['pageFooter'] = true;
        $this->_view->display('personal-details', $data);


	}

	/**
	 * YOHO币
	 */
	public function currencyAction()
	{
		// $uid = $this->getUid();
		$this->setNavHeader('YOHO币', true, false);

	    $uid = 967016;
		$currency = \Index\UserModel::getYohoCoinData($uid);

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

	/**
	 * 优惠券
	 */
	public function couponsAction()
	{

        $this->setTitle('优惠券');
	    $this->setNavHeader('优惠券', true, SITE_MAIN);
		// $uid = $this->getUid();
	    $uid = 8826435;
		$coupons  = array(
			'couponsUrl' => array(
				\Index\UserModel::getCouponData($uid, 0),
				\Index\UserModel::getCouponData($uid, 1),
			),
			'couponsPage' => true
		);
		
        $this->_view->display('coupons', $coupons);

	}

	/**
	 * 我的消息
	 */
	public function messageAction()
	{
		// $uid = $this->getUid();
		$page = $this->get('page', 0);
		$size = $this->get('size', 10);

	    $uid = 967016;
		$messages  = \Index\UserModel::getMessageData($uid, $page, $size);

		print_r($messages);

	}

	/**
	 * 地址管理
	 */
	public function addressAction()
	{
		// 设置网站标题
        $this->setTitle('地址管理');
        $this->setNavHeader('地址管理', true, SITE_MAIN);

        // $uid = $this->getUid();
        $uid = 967016;

		$address = \Index\UserModel::getAddressData($uid);

		// print_r($address);

        $this->_view->display('address', array(
            'addressPage' => true,
            'pageFooter' => true,
            'address' => $address
        ));
	}

    /**
     * 修改地址
     */
    public function editAddressAction()
    {
        // 设置网站标题
        $this->setTitle('修改地址');
        $this->setNavHeader('修改地址', true, SITE_MAIN);

        // $uid = $this->getUid();
        $uid = 967016;

        $address = \Index\UserModel::getAddressData($uid);

        // print_r($address);

        $this->_view->display('edit_address', array(
            'editAddressPage' => true,
            'pageFooter' => true,
            'address' => $address
        ));
    }

	/**
	 * 在线客服
	 */
	public function onlineServiceAction()
	{
		$service = \Index\UserModel::getOnlineServiceData();

		print_r($service);

        $this->_view->display('online_service', array(
            'onlineServicePage' => true,
            'pageFooter' => true,
            'service' => $service
        ));
	}

	/**
	 * 我的逛
	 */
	public function myGuangAction()
	{
		echo 'My Guang';
	}

	/**
	 * 意见反馈
	 */
	public function suggestAction()
	{
		$udid = $this->getUdid();
		$page = $this->get('page', 1);
		$limit = $this->get('limit', 30);

		$suggest = \Index\UserModel::getSuggestData($udid, $page, $limit);

		//print_r($suggest);
        $this->_view->display('suggest', array(
            'suggestPage' => true,
            'pageHeader' => array(
                'navBack' => true,
                'navTitle' => '意见反馈'
            ),
            'pageFooter' => true,
            'suggest' => true,
            'suggestContent' => array(
                0 => array(
                    'imgUrl' => 'http://img11.static.yhbimg.com/yhb-img01/2015/09/12/06/0115bdfeb4a7dca4b4bfdf0e850f82f2a1.jpg?imageView/2/w/640/h/240',
                    'title' => '为什么手机不能退换货?',
                    'content' => 'YOHO!有货的退换货承诺:自您签收商品7日内可以退货,15日内可以换货,在商品吊牌、标签、包装完整,不影响二次销售的情况下,YOHO!有货将为您办理退换货服务。',
                    'good' => true,
                    'bad' => false),
                1 => array(
                    'imgUrl' => 'http://img11.static.yhbimg.com/yhb-img01/2015/09/12/06/0115bdfeb4a7dca4b4bfdf0e850f82f2a1.jpg?imageView/2/w/640/h/240',
                    'title' => '为什么手机不能退换货?',
                    'content' => 'YOHO!有货的退换货承诺:自您签收商品7日内可以退货,15日内可以换货,在商品吊牌、标签、包装完整,不影响二次销售的情况下,YOHO!有货将为您办理退换货服务。',
                    'good' => false,
                    'bad' => true),
                2 => array(
                    'imgUrl' => 'http://img11.static.yhbimg.com/yhb-img01/2015/09/12/06/0115bdfeb4a7dca4b4bfdf0e850f82f2a1.jpg?imageView/2/w/640/h/240',
                    'title' => '为什么手机不能退换货?',
                    'content' => 'YOHO!有货的退换货承诺:自您签收商品7日内可以退货,15日内可以换货,在商品吊牌、标签、包装完整,不影响二次销售的情况下,YOHO!有货将为您办理退换货服务。',
                    'good' => false,
                    'bad' => false)
            )
        ));

	}

	/**
	 * 异步保存意见反馈数据
	 */
	public function savesuggestAction()
	{
		if($this->isAjax()) {
			$uid = $this->getUid();
			$content = $this->post('content', '');
			$suggest_type = $this->get('suggest_type', 2);

			$result = \Index\UserModel::saveSuggestData($uid, $content, $suggest_type);

			$this->echoJson($result);
		}

	}
        
        /**
         * 会员等级展示页
        */
            public function gradeAction(){
                //设置网站seo信息
                $this->setTitle('会员等级');
                //显示网站导航头部信息
                $this->setNavHeader('会员等级');
                
                $gender = Helpers::getGenderByCookie();
                $channel = Helpers::getChannelByCookie();
                $uid = $this -> getUid();
                $uid = '7566245';//临时测试用
                $data = GradeModel::getGrade($gender,$channel,$uid);
                $data['pageFooter'] = true;
                $this -> _view -> display('vip-grade',$data);
            }
        /*
        *会员特权查看页
        */
            public function preferentialAction(){
                //设置网站seo信息
                $this->setTitle('会员等级');
                //显示网站导航头部信息
                $this->setNavHeader('会员特权详情');
                
                $channel = Helpers::getChannelByCookie();
                $uid = $this -> getUid();               
                $data = GradeModel::getPreferential($channel,$uid);
                $data['pageFooter'] = true;
                $this -> _view -> display('privilege',$data);
            }
            
        /*
        *我的订单页面
        */
            public function orderAction(){
                
                do{
                    //判断是不是ajax请求
//                    if(!$this -> isAjax()){
//                        break;
//                    }
                    //判断参数是否有效
                    $type = $this -> get('type',1);
                    $page = $this -> get('page',1);
                    $limit = $this -> get('limit',10);
                    $gender = Helpers::getGenderByCookie();
                    $yh_channel = $this -> get('yh_channel',1);
                    $uid = $this -> getUid();
                    if(!empty($type) && !is_numeric($type)){
                        break;
                    }
                    //$data = OrderModel::getOrder();
                    $data = OrderModel::getOrder($type,$page,$limit,$gender,$yh_channel,$uid);
                    //print_r($data);
                }
                while(false);
                //$this -> _view -> display('order',$data);
            }
}