| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 | 
							- <?php
 
- namespace Cas\Controller;
 
- use Cas\Dao\LotteryEvents;
 
- use KIF\Core\Request;
 
- use KIF\Verify;
 
- use Cas\Module\LotteryLog;
 
- use Cas\Dao\UserInfo;
 
- use Cas\Module\Count;
 
- use Cas\Module\Lottery;
 
- use Cas\Dao\LotteryEventsForms;
 
- use KIF\String\Filter;
 
- /**
 
-  * "切屏专题" 活动
 
-  */
 
- class EventsCutScreen extends EventsController {
 
- 	
 
- 	public function doDefault() {
 
- 		
 
- 		$thisTime = time();
 
- 		//$events_id = Request::g('events_id');
 
- 		$events_id = $this->getEventsCreateTimeToId();
 
- 		if (!Verify::unsignedInt($events_id)) {
 
- 			self::fail_exit('无效id');
 
- 		}
 
- 		
 
- 		# 获取"切屏专题"信息
 
- 		$objDLotteryEvents = new LotteryEvents(); 
 
- 		$cutScreenInfo = $objDLotteryEvents -> get($events_id);
 
- 		
 
- 		# 检查是否移动端
 
- 		$title = $cutScreenInfo['weixinShare']['title'] ? $cutScreenInfo['weixinShare']['title']: $cutScreenInfo['events_name'];
 
- 		$this->checkIsFromMobile($title);
 
- 		
 
- 		# 获取登录地址
 
- 		$url = Request::g('url');
 
- 		$plat_form_id = $this->getPlatFormId();
 
- 		$objMLottery  = new Lottery();
 
- 		$thisUrl  = $objMLottery -> getEventsUrl($cutScreenInfo['type'],$cutScreenInfo['create_time'],$url);
 
- 		$loginUrl = $this -> getLoginUrl($thisUrl);
 
- 		$this->setOutput('loginUrl', $loginUrl);
 
- 		# 判断是否需要登录
 
- 		$ckLogin = $this->ckLogin();
 
- 		$this->setOutput('ckLogin', $ckLogin);
 
- 		
 
- 		# 获取用户信息
 
- 		$objUserData = new UserInfo();
 
- 		$uid = $this->getRunTimeUid();
 
- 		$userData = $objUserData -> get($uid);
 
- 		$this->setOutput('userData', $userData);
 
- 		
 
- 		# 检查当前活动是否需要登录
 
- 		
 
- 		$authorize = $cutScreenInfo['authorize'];
 
- 		if ($authorize && $loginUrl) {
 
- 				if($ckLogin==true){
 
- 					self::redirect($loginUrl);
 
- 				}
 
- 		}
 
- 		
 
- 		$objMLotteryLog = new LotteryLog($uid,$events_id);
 
- 		$other = array(
 
- 			'访问页面:' => '成功'
 
- 		);
 
- 		$objMLotteryLog ->addUserParticipateLog($other);
 
- 		
 
- 		$this->tpl = 'events_cutscreen';
 
- 		$this->setOutput('title', $cutScreenInfo['weixinShare']['title'] ? $cutScreenInfo['weixinShare']['title']: $cutScreenInfo['events_name']);
 
- 		$this->setOutput('cutScreenInfo', $cutScreenInfo);
 
- 		
 
- 		$pageData = $cutScreenInfo['pageData'];
 
- 		$waitLoadingImgs = array();
 
- 		
 
- 		# 构造下页面图片的位置
 
- 		foreach ($pageData as $tmpkey => $tmpData) {
 
- 			if ($tmpData['input_page']) {
 
- 				continue;
 
- 			}
 
- 			
 
- 			foreach ($tmpData['layers'] as $key => $tmpLayer) {
 
- 				$new_layer = $pageData[$tmpkey]['layers'][$key];
 
- 				
 
- 				if ($new_layer['url']) {
 
- 					$new_layer['width'] = $tmpLayer['width'] / 2;
 
- 					$new_layer['height'] = $tmpLayer['height'] / 2;
 
- 					
 
- 					$waitLoadingImgs[] = $new_layer['url'];
 
- 				}
 
- 				if ($new_layer['video_url']) {
 
- 					$new_layer['width'] = $new_layer['video_width'] =  $tmpLayer['video_width'];
 
- 					$new_layer['height'] = $new_layer['video_height'] = $tmpLayer['video_height'];
 
- 				}
 
- 				
 
- 				$style = '';
 
- 				switch ($tmpLayer['position']) {
 
- 					case 'center':
 
- 						$margin_left = $new_layer['width'] / 2;
 
- 						$margin_top = $new_layer['height'] / 2;
 
- 						$style = "left:50%;top:50%;margin-left:-{$margin_left}px;margin-top:-{$margin_top}px;";
 
- 						break;
 
- 					case 'up';
 
- 					$margin_left = $new_layer['width'] / 2;
 
- 					$style = "left:50%;top:0%;margin-left:-{$margin_left}px;";
 
- 					break;
 
- 					case 'down':
 
- 						$margin_left = $new_layer['width'] / 2;
 
- 						$style = "left:50%;bottom:6%;margin-left:-{$margin_left}px;";
 
- 						break;
 
- 					case 'leftup':
 
- 						$style = "left:0%;top:0%;";
 
- 						break;
 
- 					case 'leftdown':
 
- 						$style = "left:0%;bottom:0%;";
 
- 						break;
 
- 					case 'rightup':
 
- 						$style = "right:0%;top:0%;";
 
- 						break;
 
- 					case 'rightdown':
 
- 						$style = "right:0%;bottom:0%;";
 
- 						break;
 
- 				}
 
- 				$new_layer['style'] = $style;
 
- 				$pageData[$tmpkey]['layers'][$key] = $new_layer;
 
- 				
 
- 			}
 
- 			
 
- 			if ($tmpData['bgimage_url']) {
 
- 				$waitLoadingImgs[] = $tmpData['bgimage_url'];
 
- 			}
 
- 		}
 
- 		
 
- 		# 记录PV UV日志 访问
 
- 		$objCount = new Count();
 
- 		$objCount->setPassLog( $events_id,$plat_form_id);
 
- 		$this->setOutput('weixinShare', $cutScreenInfo['weixinShare']);
 
- 		$this->setOutput('pageData', $pageData);
 
- 		$this->setOutput('waitLoadingImgs', json_encode($waitLoadingImgs));
 
- 		$this->setOutput('forms', $cutScreenInfo['forms']);
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 表单提交
 
- 	 */
 
- 	public function doSubmitForm() {
 
- 		$events_id = Request::g('events_id');
 
- 		if (!Verify::unsignedInt($events_id)) {
 
- 			self::ajax_fail_exit('无效id');
 
- 		}
 
- 		
 
- 		$uid = $this->getRunTimeUid();
 
- 		
 
- 		$objDLotteryEvents = new LotteryEvents();
 
- 		$cutScreenInfo = $objDLotteryEvents -> get($events_id);
 
- 		
 
- 		$forms = $cutScreenInfo['forms'];
 
- 		$formData = Filter::arrayfilter($_POST, true);
 
- 		$objLotteryEventsForms = new LotteryEventsForms();
 
- 		$tmpVerifyResult = $objLotteryEventsForms->verifyFormData($forms, $formData);
 
- 		if (!$tmpVerifyResult->isSuccess()) {
 
- 			self::ajax_fail_exit($tmpVerifyResult->getData());
 
- 		}
 
- 		
 
- 		$info = array_merge($formData, array('uid' => $uid, 'events_id' => $events_id));
 
- 		if (!$objLotteryEventsForms->add($info)) {
 
- 			self::ajax_fail_exit('数据库操作失败');
 
- 		}
 
- 		
 
- 		self::ajax_success_exit();
 
- 	}
 
- 	
 
- 	/**
 
- 	 * 
 
- 	 */
 
- 	public function display() {
 
- 		return $this->render();
 
- 	}
 
- }
 
 
  |