ActivitiesController.php 3.27 KB
<?php

class ActivitiesController extends QLib_Controller_Default_Action {
	
	public function init() {
		$this->QLayoutLink()->appendStylesheet($this->_css('promotion'));
		$this->QLayoutScript()->offsetSetFile(61, $this->_js('activities'));
		$this->QLayoutTitle()->headTitle('促销活动|YOHO!有货 100%正品保证');
	}
	
	/**
	 * 当前执行的活动
	 */
	public function indexAction() {
		//获取全场活动
		$this->view->globalActList = QINOperations_Models_Activities_Client::getCurActivities(1);
		//获取当前品牌的活动
		$this->view->brandActList = QINOperations_Models_Activities_Client::getCurActivities(2);
		if(!empty($this->view->brandActList)) {
			//获取所有的品牌
			$brandList = QINProduct_Models_Brand_Client::getAllBrand();
			foreach ($this->view->brandActList as $k => $v) {
				$this->view->brandActList[$k]['brand_logo'] = $brandList[$v['brand_id']]['brand_ico'];
				$this->view->brandActList[$k]['brand_name'] = $brandList[$v['brand_id']]['brand_name'];
			}
		}
	}
	
	
	/**
	 * 过往全场活动
	 */
	public function oldAction(){
		$count = QINOperations_Models_Activities_Client::getOldActivitiesCount(1);
		$this->view->page = $page = $this->helpPaging()->setTotal($count)->setSize(10);
		$this->view->actList = QINOperations_Models_Activities_Client::getOldActivitiesList(1, $page->getOffset(), $page->getSize());
		
	}
	
	/**
	 * 过往品牌活动
	 */
	public function brandoldAction() {
		$count = QINOperations_Models_Activities_Client::getOldActivitiesCount(2);
		$this->view->page = $page = $this->helpPaging()->setTotal($count)->setSize(10);
		$this->view->actList = QINOperations_Models_Activities_Client::getOldActivitiesList(2, $page->getOffset(), $page->getSize());
		if(!empty($this->view->actList)) {
			$brandList = QINProduct_Models_Brand_Client::getAllBrand();
			foreach ($this->view->actList as $k => $v) {
				$this->view->actList[$k]['brand_logo'] = $brandList[$v['brand_id']]['brand_ico'];
				$this->view->actList[$k]['brand_name'] = $brandList[$v['brand_id']]['brand_name'];
			}
		}
	}
	
	/**
	 * 加载活动资讯
	 */
	public function actinfoAction() {
		
		$this->_helper->layout()->disableLayout();
		$total = QINOperations_Models_Activities_Info_Client::getCountInfo();
		$this->view->page = $page = $this->helpPaging('buymini')->setFJs('QActivities.getInfos')->setTotal($total)->setSize(8);
		$this->view->infoList = QINOperations_Models_Activities_Info_Client::getInfoList($page);
		//print_r($this->view->infoList);exit;
	}
	
	public function detailAction() {
			
		$id = $this->helpGparam('id');		
		$this->view->detail = $detail = QINOperations_Models_Activities_Info_Client::getInfoById($id);
	}
	
	/**
	 * 推荐商品
	 */
	public function recommendproductAction() {
		$this->_helper->layout()->disableLayout();
		$size = 6;
		$getUserParams = $this->getRequest()->getParams();
		$userParams['isrecommend'] = 1;
		$userParams['ishot'] = 1;
		$paging = $this->helpPaging('yohomini')->setSize($size);
		$parans = array();
		$result = QModels_Search_Source_Client::getSourceIds($getUserParams, $paging->getNewCurrent(), $size, $parans);
		$total = $result['total'];
		$this->view->paging = $paging->setFJs('QRecommend.recommend')->setTotal($total);
		$this->view->productData = $productData = QModels_Product_Client::getProductAllByIds($result['ids']);
	}
	
}