IndexController.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. namespace app\index\controller;
  3. use app\index\service\AdvertService;
  4. use app\index\service\CategoryService;
  5. use app\index\service\IpService;
  6. use app\index\service\JiamengService;
  7. use app\index\service\LinkService;
  8. use app\index\service\MessageService;
  9. use app\index\service\NewsCategoryService;
  10. use app\index\service\NewsService;
  11. use cmf\controller\HomeBaseController;
  12. use think\Db;
  13. class IndexController extends HomeBaseController
  14. {
  15. public function index()
  16. {
  17. // 分类列表
  18. $catearr = CategoryService::getCateList();
  19. // 热门分类
  20. $recCates = CategoryService::getRecCates(6);
  21. $recCates = $recCates? $recCates->toArray() : [];
  22. $recCates = $recCates? array_chunk($recCates, 3) : [];
  23. // 最新招商
  24. $brandNews = JiamengService::getNewList(10);
  25. /* 轮播广告 */
  26. //横幅广告位
  27. $banner = AdvertService::getListBySlide(1, 6);
  28. // 小图
  29. $bannerMin = AdvertService::getListBySlide(2, 5);
  30. // 特许加盟
  31. $banner1 = AdvertService::getListBySlide(3, 1);
  32. // 严选品牌上方广告
  33. $banner2 = AdvertService::getListBySlide(4, 1);
  34. // 品牌排行榜下方广告
  35. $banner3 = AdvertService::getListBySlide(6, 1);
  36. // 加盟动态下方广告
  37. $banner4 = AdvertService::getListBySlide(5, 1);
  38. /* 品牌栏位列表数据 */
  39. // 今日之星
  40. $brand1 = JiamengService::getListByLevel(1,3);
  41. // 匹配精选
  42. $brand2 = JiamengService::getListByLevel(2);
  43. // 品牌推荐
  44. $brand3 = JiamengService::getListByLevel(3);
  45. // 品牌严选
  46. $brand4 = JiamengService::getListByLevel(4, 21);
  47. // 专题品牌
  48. $brand6 = JiamengService::getListByLevel(6, 10);
  49. // 品牌聚焦
  50. $brand7 = JiamengService::getListByLevel(7, 42);
  51. $brand7 = $brand7? array_chunk($brand7->toArray(), 21, true) : [];
  52. // 最新品牌
  53. $brand8 = JiamengService::getListByLevel(8, 12);
  54. /* 人气排行榜1 */
  55. $phb1 = JiamengService::getTopList('touzi_level <= 2');
  56. $phb2 = JiamengService::getTopList('touzi_level = 3');
  57. $phb3 = JiamengService::getTopList('touzi_level >= 4');
  58. /* 新闻资讯 */
  59. // 分类1
  60. $cateNews1 = $cateNews2 = [];
  61. $newsCates = NewsCategoryService::getCates(6);
  62. $newsCates1 = NewsCategoryService::getCatesListByIds([17,18,19]);
  63. $newsCates2 = NewsCategoryService::getCatesListByIds([1,4,20]);
  64. if($newsCates1){
  65. foreach($newsCates1 as $k=>$v){
  66. $catid = isset($v['id'])? intval($v['id']): 0;
  67. if($catid){
  68. $dataList = NewsService::getListByCate($catid, 6);
  69. $cateNews1[] = $dataList? $dataList->toArray() : [];
  70. }
  71. }
  72. }
  73. if($newsCates2){
  74. foreach($newsCates2 as $k=>$v){
  75. $catid = isset($v['id'])? intval($v['id']): 0;
  76. if($catid){
  77. $dataList = NewsService::getListByCate($catid, 6);
  78. $cateNews2[] = $dataList? $dataList->toArray() : [];
  79. }
  80. }
  81. }
  82. // 热点新闻
  83. $newsHot = NewsService::getHotList();
  84. // 加盟问答
  85. $answerList = NewsService::getListByLevel(1, 13);
  86. // 课堂列表
  87. $courseList = NewsService::getListByLevel(2, 7);
  88. // 参数
  89. $cateList = CategoryService::getCates();
  90. $cateList = $cateList? $cateList->toArray() : [];
  91. $touziarr = config('params.touziLevels');
  92. // 分类品牌
  93. $cateBrands = [];
  94. $hotCates = $cateList? array_slice($cateList, 0, 6) : [];
  95. if($hotCates){
  96. foreach ($hotCates as $k => $cate){
  97. $catid = isset($cate['id'])? $cate['id'] : '';
  98. if($catid){
  99. $dataList = JiamengService::getList(['pcid'=> $catid], '',16);
  100. $cateBrands[] = $dataList? $dataList : [];
  101. }
  102. }
  103. }
  104. // 热门品牌
  105. $brandHot = JiamengService::getTopList([], 16);
  106. // 加盟动态
  107. $jmMessages = MessageService::getList(['type'=> 1], 10);
  108. // 友情链接
  109. $links = LinkService::getList([], 24);
  110. // 新增
  111. $this->assign('banner',$banner);
  112. $this->assign('banner1',$banner1);
  113. $this->assign('banner2',$banner2);
  114. $this->assign('banner3',$banner3);
  115. $this->assign('banner4',$banner4);
  116. $this->assign('bannerMin',$bannerMin);
  117. $this->assign('brandNews',$brandNews);
  118. $this->assign('cateList',$cateList);
  119. $this->assign('touziarr',$touziarr);
  120. $this->assign('hotCates',$hotCates);
  121. $this->assign('cateBrands',$cateBrands);
  122. $this->assign('brandHot',$brandHot);
  123. $this->assign('newsCates1',$newsCates1);
  124. $this->assign('newsCates2',$newsCates2);
  125. $this->assign('cateNews1',$cateNews1);
  126. $this->assign('cateNews2',$cateNews2);
  127. $this->assign('cateNews2',$cateNews2);
  128. $this->assign('newsCates',$newsCates);
  129. $this->assign('newsHot',$newsHot);
  130. $this->assign('answerList',$answerList);
  131. $this->assign('jmMessages',$jmMessages);
  132. $this->assign('courseList',$courseList);
  133. $this->assign('recCates',$recCates);
  134. $this->assign('links',$links);
  135. // 品牌
  136. $this->assign('brand1',$brand1);
  137. $this->assign('brand2',$brand2);
  138. $this->assign('brand3',$brand3);
  139. $this->assign('brand4',$brand4);
  140. // $this->assign('brand5',$brand5);
  141. $this->assign('brand6',$brand6);
  142. $this->assign('brand7',$brand7);
  143. $this->assign('brand8',$brand8);
  144. // 品牌排行榜
  145. $this->assign('phb1',$phb1);
  146. $this->assign('phb2',$phb2);
  147. $this->assign('phb3',$phb3);
  148. // end
  149. $this->assign('catearr',$catearr);
  150. $this->assign('link_cate_name','index');
  151. return $this->fetch();
  152. }
  153. public function ws()
  154. {
  155. return $this->fetch(':ws');
  156. }
  157. /**
  158. * 投诉
  159. */
  160. public function complaint(){
  161. $param = $this->request->param();
  162. isset($param['mobile'])&&$param['mobile']!='' or $this->error('请填写手机号');
  163. $param['create_time'] = time();
  164. $param['ip'] = get_client_ip();
  165. $param['address'] = IpService::getAddress(get_client_ip());
  166. if(strlen($param['content'])>200){
  167. $this->error('字符长度不超过300个');
  168. }
  169. $param['content'] = strFilter($param['content']);
  170. $param['name'] = strFilter($param['name']);
  171. $param['mobile'] = strFilter($param['mobile']);
  172. $param['type'] = 2;
  173. //判断是否已超过10次 今天这个ip是否投诉过
  174. $sum = MessageService::getTodyCount(['ip'=> $param['ip'],'type'=> 2]);
  175. if($sum>0){
  176. $this->error('今日投诉已超过1次,明天再来吧!');
  177. }
  178. $res = Db::name('message')->insert($param);
  179. if($res){
  180. $this->success('投诉提交成功');
  181. }else{
  182. $this->error('投诉提交失败');
  183. }
  184. }
  185. }
  186. ?>