= 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){ $cateNews1[] = NewsService::getListByCate($catid, 6); } } } if($newsCates2){ foreach($newsCates2 as $k=>$v){ $catid = isset($v['id'])? intval($v['id']): 0; if($catid){ $cateNews2[] = NewsService::getListByCate($catid, 7); } } } // 热点新闻 $recNews = NewsService::getNewList(6); // 加盟问答 $answerList = Db::name('know')->whereIn('status',[1,2]) ->field('id,title,description') ->order('create_time desc') ->limit(13) ->select(); // 课堂列表 $courseList = NewsService::getListByLevel(1, 8); // 参数 $cateList = CategoryService::getCates(); $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 = NewsService::getRandList(10); // 友情链接 $links = LinkService::getList(['catname'=> 'index'], 50); // 新增 $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('recNews',$recNews); $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 $pageHtml = $this->fetch(); // 页面缓存 $pageHtml = filterHtmlUrl($pageHtml); // RedisService::set($cacheKey, $pageHtml, 3*24*3600); // file_put_contents($cacheFile, $pageHtml); return $pageHtml; } /** * 投诉 */ 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('投诉提交失败'); } } /** * 网站地图 * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function sitemap(){ $page = input('p', 1); $cacheKey = 'cache:sitemap:list_'; $datas = RedisService::get($cacheKey.$page); if(empty($datas) ){ $dataList = CategoryService::getCates(1000, -1, "enname as id, catname as title, '1' as 'type'", 'create_time desc,list_order'); $brands = JiamengService::getList(['status'=> 1], "j.id,j.title, '2' as 'type'", 3000); $brands = $brands? $brands->toArray() : []; $news = NewsService::getList(['status'=> 1], 3000,"id,title, '3' as 'type'"); $news = $news? $news->toArray() : []; $dataList = isset($brands['data']) && $brands['data']? array_merge($dataList, $brands['data']) : $dataList; $dataList = isset($news['data']) && $news['data']? array_merge($dataList, $news['data']) : $dataList; // 生成XML文件 if($dataList){ $domain = request()->domain(); $urls = [ 0=> "".$domain."".date('Y-m-d')."daily1.0", ]; foreach ($dataList as $item){ $type = isset($item['type'])? intval($item['type']) : 0; switch($type){ case 1: $url = $domain.'/xm'.$item['id'].'/'; break; case 2: $url = $domain.'/b'.$item['id'].'/'; break; default: $url = $domain.'/news'.$item['id'].'/'; break; } $urls[] = "{$url}daily0.9"; } if($urls){ $strUrls = ''.implode('',$urls).''; file_put_contents('./sitemap.xml', $strUrls); } } $result = $dataList? array_chunk(array_values($dataList), 500) : []; if($result){ foreach ($result as $k => $list){ RedisService::set($cacheKey.($k+1), $list, 30*3600); } $datas = isset($result[$page-1])? $result[$page-1] : []; } } $nextPage = $page+1; $this->assign('datas', $datas); $this->assign('lastPage', $page-1>0? ($page-1) : 1); $this->assign('nextPage', RedisService::get($cacheKey.$nextPage)? $nextPage : 0); return $this->fetch('../sitemap'); } public function clearCache(){ // 清楚Redis缓存 RedisService::delByKeys('cache:*'); cmf_clear_cache(); exit('清除成功'); // end } } ?>