| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- <?php
- namespace app\index\controller;
- use app\index\service\AdvertService;
- use app\index\service\CategoryService;
- use app\index\service\IpService;
- use app\index\service\JiamengService;
- use app\index\service\LinkService;
- use app\index\service\MessageService;
- use app\index\service\NewsCategoryService;
- use app\index\service\NewsService;
- use cmf\controller\HomeBaseController;
- use think\Db;
- class IndexController extends HomeBaseController
- {
- public function index()
- {
- // 分类列表
- $catearr = CategoryService::getCateList();
- // 热门分类
- $recCates = CategoryService::getRecCates(6);
- $recCates = $recCates? $recCates->toArray() : [];
- $recCates = $recCates? array_chunk($recCates, 3) : [];
- // 最新招商
- $brandNews = JiamengService::getNewList(10);
- /* 轮播广告 */
- //横幅广告位
- $banner = AdvertService::getListBySlide(1, 6);
- // 小图
- $bannerMin = AdvertService::getListBySlide(2, 5);
- // 特许加盟
- $banner1 = AdvertService::getListBySlide(3, 1);
- // 严选品牌上方广告
- $banner2 = AdvertService::getListBySlide(4, 1);
- // 品牌排行榜下方广告
- $banner3 = AdvertService::getListBySlide(6, 1);
- // 加盟动态下方广告
- $banner4 = AdvertService::getListBySlide(5, 1);
- /* 品牌栏位列表数据 */
- // 今日之星
- $brand1 = JiamengService::getListByLevel(1,3);
- // 匹配精选
- $brand2 = JiamengService::getListByLevel(2);
- // 品牌推荐
- $brand3 = JiamengService::getListByLevel(3);
- // 品牌严选
- $brand4 = JiamengService::getListByLevel(4, 21);
- // 专题品牌
- $brand6 = JiamengService::getListByLevel(6, 10);
- // 品牌聚焦
- $brand7 = JiamengService::getListByLevel(7, 42);
- $brand7 = $brand7? array_chunk($brand7->toArray(), 21, true) : [];
- // 最新品牌
- $brand8 = JiamengService::getListByLevel(8, 12);
- /* 人气排行榜1 */
- $phb1 = JiamengService::getTopList('touzi_level <= 2');
- $phb2 = JiamengService::getTopList('touzi_level = 3');
- $phb3 = JiamengService::getTopList('touzi_level >= 4');
- /* 新闻资讯 */
- // 分类1
- $cateNews1 = $cateNews2 = [];
- $newsCates = NewsCategoryService::getCates(6);
- $newsCates1 = NewsCategoryService::getCatesListByIds([17,18,19]);
- $newsCates2 = NewsCategoryService::getCatesListByIds([1,4,20]);
- if($newsCates1){
- foreach($newsCates1 as $k=>$v){
- $catid = isset($v['id'])? intval($v['id']): 0;
- if($catid){
- $dataList = NewsService::getListByCate($catid, 6);
- $cateNews1[] = $dataList? $dataList->toArray() : [];
- }
- }
- }
- if($newsCates2){
- foreach($newsCates2 as $k=>$v){
- $catid = isset($v['id'])? intval($v['id']): 0;
- if($catid){
- $dataList = NewsService::getListByCate($catid, 6);
- $cateNews2[] = $dataList? $dataList->toArray() : [];
- }
- }
- }
- // 热点新闻
- $newsHot = NewsService::getHotList();
- // 加盟问答
- $answerList = NewsService::getListByLevel(1, 13);
- // 课堂列表
- $courseList = NewsService::getListByLevel(2, 7);
- // 参数
- $cateList = CategoryService::getCates();
- $cateList = $cateList? $cateList->toArray() : [];
- $touziarr = config('params.touziLevels');
- // 分类品牌
- $cateBrands = [];
- $hotCates = $cateList? array_slice($cateList, 0, 6) : [];
- if($hotCates){
- foreach ($hotCates as $k => $cate){
- $catid = isset($cate['id'])? $cate['id'] : '';
- if($catid){
- $dataList = JiamengService::getList(['pcid'=> $catid], '',16);
- $cateBrands[] = $dataList? $dataList : [];
- }
- }
- }
- // 热门品牌
- $brandHot = JiamengService::getTopList([], 16);
- // 加盟动态
- $jmMessages = MessageService::getList(['type'=> 1], 10);
- // 友情链接
- $links = LinkService::getList([], 24);
- // 新增
- $this->assign('banner',$banner);
- $this->assign('banner1',$banner1);
- $this->assign('banner2',$banner2);
- $this->assign('banner3',$banner3);
- $this->assign('banner4',$banner4);
- $this->assign('bannerMin',$bannerMin);
- $this->assign('brandNews',$brandNews);
- $this->assign('cateList',$cateList);
- $this->assign('touziarr',$touziarr);
- $this->assign('hotCates',$hotCates);
- $this->assign('cateBrands',$cateBrands);
- $this->assign('brandHot',$brandHot);
- $this->assign('newsCates1',$newsCates1);
- $this->assign('newsCates2',$newsCates2);
- $this->assign('cateNews1',$cateNews1);
- $this->assign('cateNews2',$cateNews2);
- $this->assign('cateNews2',$cateNews2);
- $this->assign('newsCates',$newsCates);
- $this->assign('newsHot',$newsHot);
- $this->assign('answerList',$answerList);
- $this->assign('jmMessages',$jmMessages);
- $this->assign('courseList',$courseList);
- $this->assign('recCates',$recCates);
- $this->assign('links',$links);
- // 品牌
- $this->assign('brand1',$brand1);
- $this->assign('brand2',$brand2);
- $this->assign('brand3',$brand3);
- $this->assign('brand4',$brand4);
- // $this->assign('brand5',$brand5);
- $this->assign('brand6',$brand6);
- $this->assign('brand7',$brand7);
- $this->assign('brand8',$brand8);
- // 品牌排行榜
- $this->assign('phb1',$phb1);
- $this->assign('phb2',$phb2);
- $this->assign('phb3',$phb3);
- // end
- $this->assign('catearr',$catearr);
- $this->assign('link_cate_name','index');
- return $this->fetch();
- }
- public function ws()
- {
- return $this->fetch(':ws');
- }
- /**
- * 投诉
- */
- public function complaint(){
- $param = $this->request->param();
- isset($param['mobile'])&&$param['mobile']!='' or $this->error('请填写手机号');
- $param['create_time'] = time();
- $param['ip'] = get_client_ip();
- $param['address'] = IpService::getAddress(get_client_ip());
- if(strlen($param['content'])>200){
- $this->error('字符长度不超过300个');
- }
- $param['content'] = strFilter($param['content']);
- $param['name'] = strFilter($param['name']);
- $param['mobile'] = strFilter($param['mobile']);
- $param['type'] = 2;
- //判断是否已超过10次 今天这个ip是否投诉过
- $sum = MessageService::getTodyCount(['ip'=> $param['ip'],'type'=> 2]);
- if($sum>0){
- $this->error('今日投诉已超过1次,明天再来吧!');
- }
- $res = Db::name('message')->insert($param);
- if($res){
- $this->success('投诉提交成功');
- }else{
- $this->error('投诉提交失败');
- }
- }
- }
- ?>
|