IndexController.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. namespace app\index\controller;
  3. use app\index\service\AdvertService;
  4. use app\index\service\CategoryService;
  5. use app\index\service\JiamengService;
  6. use app\index\service\LinkService;
  7. use app\index\service\MessageService;
  8. use app\index\service\NewsCategoryService;
  9. use app\index\service\NewsService;
  10. use cmf\controller\HomeBaseController;
  11. class IndexController extends HomeBaseController
  12. {
  13. public function index()
  14. {
  15. // 分类列表
  16. $catearr = CategoryService::getCateList();
  17. // 热门分类
  18. $recCates = CategoryService::getRecCates(6);
  19. $recCates = $recCates? $recCates->toArray() : [];
  20. $recCates = $recCates? array_chunk($recCates, 3) : [];
  21. // 最新招商
  22. $brandNews = JiamengService::getNewList(10);
  23. /* 轮播广告 */
  24. //横幅广告位
  25. $banner = AdvertService::getListBySlide(1, 6);
  26. // 小图
  27. $bannerMin = AdvertService::getListBySlide(2, 5);
  28. // 特许加盟
  29. $banner1 = AdvertService::getListBySlide(3, 1);
  30. // 严选品牌上方广告
  31. $banner2 = AdvertService::getListBySlide(4, 1);
  32. // 品牌排行榜下方广告
  33. $banner3 = AdvertService::getListBySlide(6, 1);
  34. // 加盟动态下方广告
  35. $banner4 = AdvertService::getListBySlide(5, 1);
  36. /* 品牌栏位列表数据 */
  37. // 今日之星
  38. $brand1 = JiamengService::getListByLevel(1,3);
  39. // 匹配精选
  40. $brand2 = JiamengService::getListByLevel(2);
  41. // 品牌推荐
  42. $brand3 = JiamengService::getListByLevel(3);
  43. // 品牌严选
  44. $brand4 = JiamengService::getListByLevel(4, 21);
  45. // 专题品牌
  46. $brand6 = JiamengService::getListByLevel(6, 10);
  47. // 品牌聚焦
  48. $brand7 = JiamengService::getListByLevel(7, 42);
  49. $brand7 = $brand7? array_chunk($brand7->toArray(), 21, true) : [];
  50. // 最新品牌
  51. $brand8 = JiamengService::getListByLevel(8, 12);
  52. /* 人气排行榜1 */
  53. $phb1 = JiamengService::getTopList('touzi_level <= 2');
  54. $phb2 = JiamengService::getTopList('touzi_level = 3');
  55. $phb3 = JiamengService::getTopList('touzi_level >= 4');
  56. /* 新闻资讯 */
  57. // 分类1
  58. $cateNews1 = $cateNews2 = [];
  59. $newsCates = NewsCategoryService::getCates(6);
  60. $newsCates1 = NewsCategoryService::getCatesListByIds([17,18,19]);
  61. $newsCates2 = NewsCategoryService::getCatesListByIds([1,4,20]);
  62. if($newsCates1){
  63. foreach($newsCates1 as $k=>$v){
  64. $catid = isset($v['id'])? intval($v['id']): 0;
  65. if($catid){
  66. $dataList = NewsService::getListByCate($catid, 5);
  67. $cateNews1[] = $dataList? $dataList->toArray() : [];
  68. }
  69. }
  70. }
  71. if($newsCates2){
  72. foreach($newsCates2 as $k=>$v){
  73. $catid = isset($v['id'])? intval($v['id']): 0;
  74. if($catid){
  75. $dataList = NewsService::getListByCate($catid, 5);
  76. $cateNews2[] = $dataList? $dataList->toArray() : [];
  77. }
  78. }
  79. }
  80. // 热点新闻
  81. $newsHot = NewsService::getHotList();
  82. // 加盟问答
  83. $answerList = NewsService::getListByLevel(1, 12);
  84. // 课堂列表
  85. $courseList = NewsService::getListByLevel(2, 7);
  86. // 参数
  87. $cateList = CategoryService::getCates();
  88. $cateList = $cateList? $cateList->toArray() : [];
  89. $touziarr = config('params.touziLevels');
  90. // 分类品牌
  91. $cateBrands = [];
  92. $hotCates = $cateList? array_slice($cateList, 0, 6) : [];
  93. if($hotCates){
  94. foreach ($hotCates as $k => $cate){
  95. $catid = isset($cate['id'])? $cate['id'] : '';
  96. if($catid){
  97. $dataList = JiamengService::getList(['pcid'=> $catid], '',16);
  98. $cateBrands[] = $dataList? $dataList : [];
  99. }
  100. }
  101. }
  102. // 热门品牌
  103. $brandHot = JiamengService::getTopList([], 16);
  104. // 加盟动态
  105. $jmMessages = MessageService::getList([], 10);
  106. // 友情链接
  107. $links = LinkService::getList([], 24);
  108. // 新增
  109. $this->assign('banner',$banner);
  110. $this->assign('banner1',$banner1);
  111. $this->assign('banner2',$banner2);
  112. $this->assign('banner3',$banner3);
  113. $this->assign('banner4',$banner4);
  114. $this->assign('bannerMin',$bannerMin);
  115. $this->assign('brandNews',$brandNews);
  116. $this->assign('cateList',$cateList);
  117. $this->assign('touziarr',$touziarr);
  118. $this->assign('hotCates',$hotCates);
  119. $this->assign('cateBrands',$cateBrands);
  120. $this->assign('brandHot',$brandHot);
  121. $this->assign('newsCates1',$newsCates1);
  122. $this->assign('newsCates2',$newsCates2);
  123. $this->assign('cateNews1',$cateNews1);
  124. $this->assign('cateNews2',$cateNews2);
  125. $this->assign('cateNews2',$cateNews2);
  126. $this->assign('newsCates',$newsCates);
  127. $this->assign('newsHot',$newsHot);
  128. $this->assign('answerList',$answerList);
  129. $this->assign('jmMessages',$jmMessages);
  130. $this->assign('courseList',$courseList);
  131. $this->assign('recCates',$recCates);
  132. $this->assign('links',$links);
  133. // 品牌
  134. $this->assign('brand1',$brand1);
  135. $this->assign('brand2',$brand2);
  136. $this->assign('brand3',$brand3);
  137. $this->assign('brand4',$brand4);
  138. // $this->assign('brand5',$brand5);
  139. $this->assign('brand6',$brand6);
  140. $this->assign('brand7',$brand7);
  141. $this->assign('brand8',$brand8);
  142. // 品牌排行榜
  143. $this->assign('phb1',$phb1);
  144. $this->assign('phb2',$phb2);
  145. $this->assign('phb3',$phb3);
  146. // end
  147. $this->assign('catearr',$catearr);
  148. $this->assign('link_cate_name','index');
  149. return $this->fetch();
  150. }
  151. public function ws()
  152. {
  153. return $this->fetch(':ws');
  154. }
  155. }
  156. ?>