Newsale.php 2.73 KB
<?php

use Action\AbstractAction;
use LibModels\wap\Product\NewsaleData as Newsale;
use Plugin\DataProcess\NewSaleProcess;
/**
 * 新品到着
 */
class NewsaleController extends AbstractAction
{
	public function indexAction()
	{

		$data = array(
			'newArrival' => true,             
			'header' => array(       
				'title'  =>  '新品到着' 
			)
		);

		// 新品到着顶部焦点图
		$focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d');
		// 处理返回的数据
		$focus = array();
		if($focusData['code'] == 200)
		{
			$focus = $focusData['data'];
		}

		// 批量获取新品到着商品数据
		$products = Newsale::getNewProducts('1,3', 1, 60);
		// 添加商品数据
		$data += NewSaleProcess::newSaleData($focus, $products);

		/*echo '<pre>';
		print_r($data);exit;*/

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

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

			$result = NewSaleProcess::selectData($data);

			$this->_view->display('product', $result);
			// $this->returnJson(200, '获取成功', $data);
		// }
	}

	/**
	 * 折扣专区
	 */
	public function discountAction()
	{
		$data = array(
			'discount' => true,             
			'header' => array(       
				'title'  =>  'SALE' 
			)
		);

		// 折扣专区顶部焦点图
		$focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523');
		// 处理返回的数据
		$focus = array();
		if($focusData['code'] == 200)
		{
			$focus = $focusData['data'];
		}

		// 折扣专区商品数据
		$products = Newsale::getSaleProducts('1,3', 1);
		// 更新tabs
		$tabs = array();
		foreach (array_keys($products) as $key => $value) {
			$tabItem = array();
			$tabItem['title'] = $value;
			if($key === 0)
			{
				$tabItem['focus'] = true;
			}
			$tabs[] = $tabItem;
		}
		$data += array('tabs' => $tabs);
		// 添加商品数据
		$data += NewSaleProcess::newSaleData($focus, $products);

		/*echo '<pre>';
		print_r($data);exit;*/

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