| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 | 
							- <?php
 
- namespace Cas\Controller;
 
- use KIF\Core\Request;
 
- use Cas\Dao\LotteryEvents;
 
- /**
 
-  * 切屏专题预览页
 
-  * @author lishumingoo@gmail.com
 
-  */
 
- class CutScreenPreview extends Controller {
 
- 	
 
- 	public function doDefault() {
 
- 		$memKey = Request::g('key');
 
- 		
 
- 		$objMemcached = new \KIF\Cache\Memcached();
 
- 		$info = $objMemcached->get($memKey);
 
- 		
 
- 		$pageData = $info['pageData'];
 
- 		$events_id = $info['events_id'];
 
- 		
 
- 		$objDLotteryEvents = new LotteryEvents();
 
- 		$cutScreenInfo = $objDLotteryEvents -> get($events_id);
 
- 		
 
- 		$waitLoadingImgs = array();
 
- 		
 
- 		# 构造下页面图片的位置
 
- 		foreach ($pageData as $tmpkey => $tmpData) {
 
- 			// 上层图片、按钮图片 宽高压缩一半。
 
- 			if (isset($tmpData['upper_image']['width'])) {
 
- 				$pageData[$tmpkey]['upper_image']['width'] = $tmpData['upper_image']['width'] / 2;
 
- 			}
 
- 			if (isset($tmpData['upper_image']['height'])) {
 
- 				$pageData[$tmpkey]['upper_image']['height'] = $tmpData['upper_image']['height'] / 2;
 
- 			}
 
- 				
 
- 			if (isset($tmpData['button_image']['width'])) {
 
- 				$pageData[$tmpkey]['button_image']['width'] = $tmpData['button_image']['width'] / 2;
 
- 			}
 
- 			if (isset($tmpData['button_image']['height'])) {
 
- 				$pageData[$tmpkey]['button_image']['height'] = $tmpData['button_image']['height'] / 2;
 
- 			}
 
- 				
 
- 			// 上层图片位置
 
- 			if (isset($tmpData['position'])) {
 
- 				$position_style = '';
 
- 				switch ($tmpData['position']) {
 
- 					case 'center':
 
- 						$margin_left = $pageData[$tmpkey]['upper_image']['width'] / 2;
 
- 						$margin_top = $pageData[$tmpkey]['upper_image']['height'] / 2;
 
- 						$position_style = "left:50%;top:50%;margin-left:-{$margin_left}px;margin-top:-{$margin_top}px;";
 
- 						break;
 
- 					case 'leftup':
 
- 						$margin_left = 0;
 
- 						$margin_top = 0;
 
- 						$position_style = "left:0%;top:0%;";
 
- 						break;
 
- 					case 'leftdown':
 
- 						$position_style = "left:0%;bottom:0%;";
 
- 						break;
 
- 					case 'rightup':
 
- 						$position_style = "right:0%;top:0%;";
 
- 						break;
 
- 					case 'rightdown':
 
- 						$position_style = "right:0%;bottom:0%;";
 
- 						break;
 
- 				}
 
- 				$pageData[$tmpkey]['upper_image']['position_style'] = $position_style;
 
- 			}
 
- 				
 
- 			// 按钮图片位置
 
- 			if (isset($tmpData['button_position'])) {
 
- 				$button_position_style = '';
 
- 				switch ($tmpData['button_position']) {
 
- 					case 'up':
 
- 						$margin_left = $pageData[$tmpkey]['button_image']['width'] / 2;
 
- 						$button_position_style = "left:50%;top:20%;margin-left:-{$margin_left}px;";
 
- 						break;
 
- 					case 'center':
 
- 						$margin_left = $pageData[$tmpkey]['button_image']['width'] / 2;
 
- 						$button_position_style = "left:50%;top:50%;margin-left:-{$margin_left}px;";
 
- 						break;
 
- 					case 'down':
 
- 						$margin_left = $pageData[$tmpkey]['button_image']['width'] / 2;
 
- 						$button_position_style = "left:50%;bottom:20%;margin-left:-{$margin_left}px;";
 
- 						break;
 
- 				}
 
- 				$pageData[$tmpkey]['button_image']['position_style'] = $button_position_style;
 
- 			}
 
- 			
 
- 			if ($tmpData['upper_image']['url']) {
 
- 				$waitLoadingImgs[] = $tmpData['upper_image']['url'];
 
- 			}
 
- 			if ($tmpData['button_image']['url']) {
 
- 				$waitLoadingImgs[] = $tmpData['button_image']['url'];
 
- 			}
 
- 			if ($tmpData['background_image']) {
 
- 				$waitLoadingImgs[] = $tmpData['background_image'];
 
- 			}
 
- 		}
 
- 		
 
- 		$this->tpl = 'cutscreen_preview';
 
- 		$this->setOutput('title', '专题预览');
 
- 		$this->setOutput('pageData', $pageData);
 
- 		$this->setOutput('waitLoadingImgs', json_encode($waitLoadingImgs));
 
- 		$this->setOutput('cutScreenInfo', $cutScreenInfo);
 
- 	}
 
- 	
 
- 	public function display() {
 
- 		return $this->render();
 
- 	}
 
- }
 
 
  |