CutScreenPreview.class.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. namespace Cas\Controller;
  3. use KIF\Core\Request;
  4. use Cas\Dao\LotteryEvents;
  5. /**
  6. * 切屏专题预览页
  7. * @author lishumingoo@gmail.com
  8. */
  9. class CutScreenPreview extends Controller {
  10. public function doDefault() {
  11. $memKey = Request::g('key');
  12. $objMemcached = new \KIF\Cache\Memcached();
  13. $info = $objMemcached->get($memKey);
  14. $pageData = $info['pageData'];
  15. $events_id = $info['events_id'];
  16. $objDLotteryEvents = new LotteryEvents();
  17. $cutScreenInfo = $objDLotteryEvents -> get($events_id);
  18. $waitLoadingImgs = array();
  19. # 构造下页面图片的位置
  20. foreach ($pageData as $tmpkey => $tmpData) {
  21. // 上层图片、按钮图片 宽高压缩一半。
  22. if (isset($tmpData['upper_image']['width'])) {
  23. $pageData[$tmpkey]['upper_image']['width'] = $tmpData['upper_image']['width'] / 2;
  24. }
  25. if (isset($tmpData['upper_image']['height'])) {
  26. $pageData[$tmpkey]['upper_image']['height'] = $tmpData['upper_image']['height'] / 2;
  27. }
  28. if (isset($tmpData['button_image']['width'])) {
  29. $pageData[$tmpkey]['button_image']['width'] = $tmpData['button_image']['width'] / 2;
  30. }
  31. if (isset($tmpData['button_image']['height'])) {
  32. $pageData[$tmpkey]['button_image']['height'] = $tmpData['button_image']['height'] / 2;
  33. }
  34. // 上层图片位置
  35. if (isset($tmpData['position'])) {
  36. $position_style = '';
  37. switch ($tmpData['position']) {
  38. case 'center':
  39. $margin_left = $pageData[$tmpkey]['upper_image']['width'] / 2;
  40. $margin_top = $pageData[$tmpkey]['upper_image']['height'] / 2;
  41. $position_style = "left:50%;top:50%;margin-left:-{$margin_left}px;margin-top:-{$margin_top}px;";
  42. break;
  43. case 'leftup':
  44. $margin_left = 0;
  45. $margin_top = 0;
  46. $position_style = "left:0%;top:0%;";
  47. break;
  48. case 'leftdown':
  49. $position_style = "left:0%;bottom:0%;";
  50. break;
  51. case 'rightup':
  52. $position_style = "right:0%;top:0%;";
  53. break;
  54. case 'rightdown':
  55. $position_style = "right:0%;bottom:0%;";
  56. break;
  57. }
  58. $pageData[$tmpkey]['upper_image']['position_style'] = $position_style;
  59. }
  60. // 按钮图片位置
  61. if (isset($tmpData['button_position'])) {
  62. $button_position_style = '';
  63. switch ($tmpData['button_position']) {
  64. case 'up':
  65. $margin_left = $pageData[$tmpkey]['button_image']['width'] / 2;
  66. $button_position_style = "left:50%;top:20%;margin-left:-{$margin_left}px;";
  67. break;
  68. case 'center':
  69. $margin_left = $pageData[$tmpkey]['button_image']['width'] / 2;
  70. $button_position_style = "left:50%;top:50%;margin-left:-{$margin_left}px;";
  71. break;
  72. case 'down':
  73. $margin_left = $pageData[$tmpkey]['button_image']['width'] / 2;
  74. $button_position_style = "left:50%;bottom:20%;margin-left:-{$margin_left}px;";
  75. break;
  76. }
  77. $pageData[$tmpkey]['button_image']['position_style'] = $button_position_style;
  78. }
  79. if ($tmpData['upper_image']['url']) {
  80. $waitLoadingImgs[] = $tmpData['upper_image']['url'];
  81. }
  82. if ($tmpData['button_image']['url']) {
  83. $waitLoadingImgs[] = $tmpData['button_image']['url'];
  84. }
  85. if ($tmpData['background_image']) {
  86. $waitLoadingImgs[] = $tmpData['background_image'];
  87. }
  88. }
  89. $this->tpl = 'cutscreen_preview';
  90. $this->setOutput('title', '专题预览');
  91. $this->setOutput('pageData', $pageData);
  92. $this->setOutput('waitLoadingImgs', json_encode($waitLoadingImgs));
  93. $this->setOutput('cutScreenInfo', $cutScreenInfo);
  94. }
  95. public function display() {
  96. return $this->render();
  97. }
  98. }