SpecialController.class.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. class SpecialController extends CommonController {
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->cur_page = 'special';
  20. }
  21. public function index(){
  22. //special_id
  23. $special_id = I('get.special_id',0);
  24. $special_info = M('mb_special')->where( array('mb_special' => $special_id) )->find();
  25. $mb_special_item_list = M('mb_special_item')->where( array('special_id' =>$special_id,'item_usable' => 1) )->order('item_sort asc')->select();
  26. $item_content_html = '';
  27. foreach($mb_special_item_list as $item)
  28. {
  29. if($item['item_type'] == 'adv_list')
  30. {
  31. $adv_list_html = $this->get_adv_list_html($item);
  32. $item_content_html .= $adv_list_html;
  33. }
  34. if($item['item_type'] == 'home1')
  35. {
  36. $home1_html = $this->home1($item);
  37. $item_content_html .= $home1_html;
  38. }
  39. if($item['item_type'] == 'home2')
  40. {
  41. $home2_html = $this->home2($item);
  42. $item_content_html .= $home2_html;
  43. }
  44. //home3
  45. if($item['item_type'] == 'home3')
  46. {
  47. $home3_html = $this->home3($item);
  48. $item_content_html .= $home3_html;
  49. }
  50. //home4
  51. if( $item['item_type'] == 'home4')
  52. {
  53. $home4_html = $this->home4($item);
  54. $item_content_html .= $home4_html;
  55. }
  56. }
  57. $this->item_content_html = $item_content_html;
  58. $this->special_info = $special_info;
  59. $this->mb_special_item_list = $mb_special_item_list;
  60. $this->display();
  61. }
  62. private function home4($item)
  63. {
  64. $tmp_item_data = unserialize($item['item_data']);
  65. $home4_html = '';
  66. $home4_html .= '<div class="home4_box">';
  67. $home4_html .= '<div class="half_left">';
  68. if(!empty($tmp_item_data['rectangle1_image']))
  69. {
  70. if($tmp_item_data['rectangle1_type'] == 'goods')
  71. {
  72. $tmp_url = U('/goods/'.$tmp_item_data['rectangle1_data']);
  73. } else if($tmp_item_data['rectangle1_type'] == 'url')
  74. {
  75. $tmp_url = $tmp_item_data['rectangle1_data'];
  76. }
  77. $home4_html .= '<div class="half_half_div">';
  78. $home4_html .= ' <a href="'.$tmp_url.'"><img src="/Uploads/image/'.$tmp_item_data['rectangle1_image'].'" /></a>';
  79. $home4_html .= '</div>';
  80. }
  81. if(!empty($tmp_item_data['rectangle2_image']))
  82. {
  83. if($tmp_item_data['rectangle2_type'] == 'goods')
  84. {
  85. $tmp_url = U('/goods/'.$tmp_item_data['rectangle2_data']);
  86. } else if($tmp_item_data['rectangle2_type'] == 'url')
  87. {
  88. $tmp_url = $tmp_item_data['rectangle2_data'];
  89. }
  90. $home4_html .= '<div class="half_half_div">';
  91. $home4_html .= ' <a href="'.$tmp_url.'"><img src="/Uploads/image/'.$tmp_item_data['rectangle2_image'].'" /></a>';
  92. $home4_html .= '</div>';
  93. }
  94. $home4_html .= ' </div>';
  95. if(!empty($tmp_item_data['square_image']))
  96. {
  97. if($tmp_item_data['square_type'] == 'goods')
  98. {
  99. $tmp_url = U('/goods/'.$tmp_item_data['square_data']);
  100. } else if($tmp_item_data['square_type'] == 'url')
  101. {
  102. $tmp_url = $tmp_item_data['square_data'];
  103. }
  104. $home4_html .= '<div class="half_left">';
  105. $home4_html .= ' <a href="'.$tmp_url.'"><img src="/Uploads/image/'.$tmp_item_data['square_image'].'" /></a>';
  106. $home4_html .= '</div>';
  107. }
  108. $home4_html .= '</div>';
  109. return $home4_html;
  110. }
  111. private function home3($item)
  112. {
  113. $tmp_item_data = unserialize($item['item_data']);
  114. $home3_html = '';
  115. $home3_html .= '<div class="home_3_box">';
  116. foreach($tmp_item_data['item'] as $item_data)
  117. {
  118. if($item_data['type'] == 'goods')
  119. {
  120. $tmp_url = U('/goods/'.$item_data['data']);
  121. } else if($item_data['type'] == 'url')
  122. {
  123. $tmp_url = $item_data['data'];
  124. }
  125. $home3_html .= '<div class="home_3_div">';
  126. $home3_html .= ' <a href="'.$tmp_url.'">';
  127. $home3_html .= ' <img src="/Uploads/image/'.$item_data['image'].'" />';
  128. $home3_html .= ' </a>';
  129. $home3_html .= '</div>';
  130. }
  131. $home3_html .= '</div>';
  132. return $home3_html;
  133. }
  134. private function home2($item)
  135. {
  136. $tmp_item_data = unserialize($item['item_data']);
  137. $home2_html = '';
  138. $home2_html .= '<div class="home2_box">';
  139. if(!empty($tmp_item_data['square_image']))
  140. {
  141. if($tmp_item_data['square_type'] == 'goods')
  142. {
  143. $tmp_url = U('/goods/'.$tmp_item_data['square_data']);
  144. } else if($tmp_item_data['square_type'] == 'url')
  145. {
  146. $tmp_url = $tmp_item_data['square_data'];
  147. }
  148. $home2_html .= '<div class="half_left">';
  149. $home2_html .= ' <a href="'.$tmp_url.'"><img src="/Uploads/image/'.$tmp_item_data['square_image'].'" /></a>';
  150. $home2_html .= '</div>';
  151. }
  152. $home2_html .= '<div class="half_right">';
  153. if(!empty($tmp_item_data['rectangle1_image']))
  154. {
  155. if($tmp_item_data['rectangle1_type'] == 'goods')
  156. {
  157. $tmp_url = U('/goods/'.$tmp_item_data['rectangle1_data']);
  158. } else if($tmp_item_data['rectangle1_type'] == 'url')
  159. {
  160. $tmp_url = $tmp_item_data['rectangle1_data'];
  161. }
  162. $home2_html .= '<div class="half_half_div">';
  163. $home2_html .= ' <a href="'.$tmp_url.'"><img src="/Uploads/image/'.$tmp_item_data['rectangle1_image'].'" /></a>';
  164. $home2_html .= '</div>';
  165. }
  166. if(!empty($tmp_item_data['rectangle2_image']))
  167. {
  168. if($tmp_item_data['rectangle2_type'] == 'goods')
  169. {
  170. $tmp_url = U('/goods/'.$tmp_item_data['rectangle2_data']);
  171. } else if($tmp_item_data['rectangle2_type'] == 'url')
  172. {
  173. $tmp_url = $tmp_item_data['rectangle2_data'];
  174. }
  175. $home2_html .= '<div class="half_half_div">';
  176. $home2_html .= ' <a href="'.$tmp_url.'"><img src="/Uploads/image/'.$tmp_item_data['rectangle2_image'].'" /></a>';
  177. $home2_html .= '</div>';
  178. }
  179. $home2_html .= ' </div>';
  180. $home2_html .= '</div>';
  181. return $home2_html;
  182. }
  183. private function home1($item)
  184. {
  185. $tmp_item_data = unserialize($item['item_data']);
  186. if($tmp_item_data['type'] == 'goods')
  187. {
  188. $tmp_url = U('/goods/'.$tmp_item_data['data']);
  189. } else if($tmp_item_data['type'] == 'url')
  190. {
  191. $tmp_url = $tmp_item_data['data'];
  192. }
  193. $home1_html = '';
  194. $home1_html .= '<div class="index_ad_list">';
  195. $home1_html .= '<ul>';
  196. $home1_html .= ' <li><a href="'.$tmp_url.'"><img src="/Uploads/image/'.$tmp_item_data['image'].'" /></a></li>';
  197. $home1_html .= '</ul>';
  198. $home1_html .= '</div>';
  199. return $home1_html;
  200. }
  201. private function get_adv_list_html($item)
  202. {
  203. $tmp_item_data = unserialize($item['item_data']);
  204. $adv_list_html = '';
  205. $adv_list_html = '<div class="tuanc" id="banner">';
  206. $adv_list_html .= '<div class="bd">';
  207. $adv_list_html .= '<ul id="slider">';
  208. foreach($tmp_item_data['item'] as $adv_list_item)
  209. {
  210. if($adv_list_item['type'] == 'goods')
  211. {
  212. $tmp_url = U('/goods/'.$adv_list_item['data']);
  213. } else if($adv_list_item['type'] == 'url')
  214. {
  215. $tmp_url = $adv_list_item['data'];
  216. }
  217. $adv_list_html .= '<li><a href="'.$tmp_url.'"><img src="/Uploads/image/'.$adv_list_item['image'].'" /></a></li>';
  218. }
  219. $adv_list_html .= '</ul></div>';
  220. $adv_list_html .= '<div class="banner-focus"><div class="banner-hd"><ul>';
  221. $i = 1;
  222. foreach($tmp_item_data['item'] as $adv_list_item)
  223. {
  224. if($i == 1){
  225. $adv_list_html .= '<li class="on"></li>';
  226. } else {
  227. $adv_list_html .= '<li></li>';
  228. }
  229. $i++;
  230. }
  231. $adv_list_html .= '</ul></div></div></div>';
  232. return $adv_list_html;
  233. }
  234. }