DiscountController.php 3.85 KB
<?php
class DiscountController extends QLib_Controller_Default_Action
{
	/**
	 *
	 * @var SphinxClient 
	 */
	private $query_opt = array();
	private $orderOptions = array();
	private $size = 59;
	/**
	 *
	 * @var QModels_Search_Factory 
	 */
	private $search;
	
	public function init() {
		$this->QLayoutLink()->offsetSetStylesheet(20, $this->_css('style_css'))->offsetSetStylesheet(21, $this->_css('jslider'))->offsetSetStylesheet(51, $this->_css('common_new'))->offsetSetStylesheet(52, $this->_css('search'));
		$this->QLayoutScript()->offsetSetFile(30, $this->_js('jquery.slider'))->offsetSetFile(31, $this->_js('search.common'))->offsetSetFile(32, $this->_js('treeview'))->offsetSetFile(33, $this->_js('jquery.dependClass'))->offsetSetFile(34, $this->_js('product_js'));
		
		$this->view->search_url = '/discount?';
		$this->view->defaultMove = array();
		$this->search = new QModels_Search_Factory();
	}
	
	public function indexAction()
	{
		$this->QLayoutScript()->offsetSetFile(2,$this->_js('jquery.lazyload.mini'));
		$this->view->discountArr = $discountArr = array(
			'0.1,0.3' => '1~3折',
			'0.4,0.6' => '4~6折',
			'0.7,0.9' => '7~9折',
			'0.1,0.9' => '1~9折'
		);
		$this->view->query = $query = trim($this->helpGparam('query'));
		$getUserParams = $this->getRequest()->getParams();
		$this->view->sort = $sort = isset($getUserParams['sort']) ? $getUserParams['sort'] : 0;
		$goodParans = array();
		
		$p_d = isset($getUserParams['p_d']) ? preg_replace('|%2c|si', ',', $getUserParams['p_d']) : '';
		$this->view->p_d = $getUserParams['p_d'] = (!empty($getUserParams['p_d']) && !empty($discountArr[$p_d])) ? $p_d : '0.1,0.9';
		
		$paging = $this->helpPaging('Yoho')->setSize($this->size);
		
		$this->search->setFilters($getUserParams, $goodParans);
		$this->search->setLimits($paging->getNewCurrent(), $this->size);

		$searchData = $this->search->query($query);
		if (isset($goodParans['query_opt']) && !empty($goodParans['query_opt'])) {
			$this->query_opt = $goodParans['query_opt'];
			foreach ($goodParans['query_opt'] as $key => $value) {
				$this->view->$key = $value;
			}
		}
		$this->view->query_opt = $this->query_opt;
		if (isset($goodParans['orderOptions']) && !empty($goodParans['orderOptions'])) {
			$this->orderOptions = $goodParans['orderOptions'];
		}
		$this->view->total = $total = $searchData['total'];
		$this->view->total = $total_found = $searchData['total_found'];
		$this->view->matches = $matches = $searchData['matches'];
		$this->view->orderOptions = $this->orderOptions;
		$this->view->goods = $searchData['ids'];
		$this->view->paging = $paging->setTotal($total);
		$this->view->pagingr = $mini = $this->helpPaging('Yhmini')->setTotal($total)->setSize($this->size);
		$this->view->getGoodsNumByFilter = $this->search->getGoodsNumByFilter(array('p_d' => $getUserParams['p_d']));
		$this->view->sortPath = QModels_Product_Sort_Client::getMMSInfoBysmallID($sort);
		$this->view->sortData = QModels_Product_Sort_Client::groupSort();
		$this->view->msort = $msort = intval($this->helpGparam('msort', 0));
		$this->view->sort_ids = $sort_ids = array(
			'msort' => $msort, 
			'misort' => intval($this->helpGparam('misort', 0)), 
			'sort' => intval($this->helpGparam('sort', 0))
		);
		$this->view->nextpage = $nextpage = $mini->getPageNum() != $mini->getCurrent() ? '/discount' . $mini->getUrl($mini->getNext()) : '';
		$title = '潮流商品搜索 | YOHO!有货';
		$keywords = 'Yoho! 有货,潮流,时尚,流行,购物,B2C,正品,购物网站,网上购物,货到付款,品牌服饰,男士护肤,黑框眼镜,匡威,板鞋,i.t,izzue,5cm,eastpak,vans,lylescott,g-shock,new balance,lacoste,melissa,casio,卡西欧手表,舒雅,jasonwood,odm,AAAA,香港购物,日本潮流';
		$description = '潮流商品搜索,上衣,衬衫,TEE,卫衣,冲锋衣,风衣,羽绒服,裤子,休闲鞋,板鞋,配饰,复古眼镜';
		
		$this->setMetaInfo($title, $keywords, $description);
	}
}