|
|
@@ -1,5 +1,7 @@
|
|
|
<?php
|
|
|
+
|
|
|
namespace app\index\controller;
|
|
|
+
|
|
|
use app\index\service\CategoryService;
|
|
|
use app\index\service\IpService;
|
|
|
use app\index\service\JiamengService;
|
|
|
@@ -10,6 +12,7 @@ use app\index\service\PageService;
|
|
|
use app\index\service\RedisService;
|
|
|
use cmf\controller\HomeBaseController;
|
|
|
use think\Db;
|
|
|
+
|
|
|
class JiamengController extends HomeBaseController
|
|
|
{
|
|
|
public function index()
|
|
|
@@ -17,21 +20,23 @@ class JiamengController extends HomeBaseController
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
- public function home(){
|
|
|
+ public function home()
|
|
|
+ {
|
|
|
//二级分类
|
|
|
$param = $this->request->param();
|
|
|
isset($param['enname']) or $this->error('需要父分类');
|
|
|
- $curarr = Db::name('category')->where('enname',$param['enname'])->find();
|
|
|
- if($curarr['parent_id']>0){
|
|
|
- header("Location:".url('/404'));
|
|
|
+ $curarr = Db::name('category')->where('enname', $param['enname'])->find();
|
|
|
+ if ($curarr['parent_id'] > 0) {
|
|
|
+ header("Location:" . url('/404'));
|
|
|
exit;
|
|
|
}
|
|
|
- $sonarr = Db::name('category')->where('parent_id',$curarr['id'])->order('list_order')->limit(10)->select();
|
|
|
- $this->assign('sonarr',$sonarr);
|
|
|
+ $sonarr = Db::name('category')->where('parent_id', $curarr['id'])->order('list_order')->limit(10)->select();
|
|
|
+ $this->assign('sonarr', $sonarr);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
- public function category(){
|
|
|
+ public function category()
|
|
|
+ {
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
@@ -42,51 +47,58 @@ class JiamengController extends HomeBaseController
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
- public function lists(){
|
|
|
- $param = $this->request->param();
|
|
|
+ public function lists()
|
|
|
+ {
|
|
|
+ $param = $this->request->param();
|
|
|
+ $cacheKey = 'cache:jiameng_pages:list:' . md5(json_encode($param));
|
|
|
+ $pageHtml = RedisService::get($cacheKey);
|
|
|
+ if ($pageHtml) {
|
|
|
+ return $pageHtml;
|
|
|
+ }
|
|
|
+
|
|
|
//var_dump($param);die();
|
|
|
- $enname = isset($param['enname'])? trim($param['enname']) : '';
|
|
|
- $pcid = isset($param['pcid'])? intval($param['pcid']) : 0;
|
|
|
-
|
|
|
+ $enname = isset($param['enname']) ? trim($param['enname']) : '';
|
|
|
+ $pcid = isset($param['pcid']) ? intval($param['pcid']) : 0;
|
|
|
+
|
|
|
$param = [
|
|
|
- 'kw'=> isset($param['kw'])? trim($param['kw']) : '',
|
|
|
- 'enname'=> isset($param['enname'])? trim($param['enname']) : '',
|
|
|
- 'catid'=> isset($param['catid'])? intval($param['catid']) : 0,
|
|
|
- 'pcid'=> isset($param['pcid'])? intval($param['pcid']) : 0,
|
|
|
- 'lv'=> isset($param['lv'])? intval($param['lv']) : '-1',
|
|
|
- 'aid'=> isset($param['aid'])? intval($param['aid']) : 0,
|
|
|
+ 'kw' => isset($param['kw']) ? trim($param['kw']) : '',
|
|
|
+ 'enname' => isset($param['enname']) ? trim($param['enname']) : '',
|
|
|
+ 'catid' => isset($param['catid']) ? intval($param['catid']) : 0,
|
|
|
+ 'pcid' => isset($param['pcid']) ? intval($param['pcid']) : 0,
|
|
|
+ 'lv' => isset($param['lv']) ? intval($param['lv']) : '-1',
|
|
|
+ 'aid' => isset($param['aid']) ? intval($param['aid']) : 0,
|
|
|
];
|
|
|
- $sonid = 0;
|
|
|
- if($enname || $pcid){
|
|
|
+ $sonid = 0;
|
|
|
+ if ($enname || $pcid) {
|
|
|
$where = [];
|
|
|
- if($enname){
|
|
|
+ if ($enname) {
|
|
|
$where['enname'] = $enname;
|
|
|
}
|
|
|
- if($pcid){
|
|
|
+ if ($pcid) {
|
|
|
$where['id'] = $pcid;
|
|
|
}
|
|
|
- $cateData = Db::name('category')->where($where)->find();
|
|
|
- $this->assign('hangye',$cateData['catname']);
|
|
|
- $enname = isset($cateData['enname'])? $cateData['enname'] : '';
|
|
|
- $param['sid'] = $cateData['parent_id']? $cateData['id'] : 0;
|
|
|
- $param['pid'] = $cateData['parent_id']? $cateData['parent_id'] : $cateData['id'];
|
|
|
- $seo_title = str_replace('|',$cateData['catname'],$cateData['seo_title']);
|
|
|
- $seo_keywords = str_replace('|',$cateData['catname'],$cateData['seo_keywords']);
|
|
|
- $seo_desc = str_replace('|',$cateData['catname'],$cateData['seo_desc']);
|
|
|
- $this->assign('catname',$cateData['catname']);
|
|
|
- $this->assign('seo_title',$seo_title);
|
|
|
- $this->assign('seo_keywords',$seo_keywords);
|
|
|
- $this->assign('seo_desc',$seo_desc);
|
|
|
- }else{
|
|
|
+ $cateData = Db::name('category')->where($where)->find();
|
|
|
+ $this->assign('hangye', $cateData['catname']);
|
|
|
+ $enname = isset($cateData['enname']) ? $cateData['enname'] : '';
|
|
|
+ $param['sid'] = $cateData['parent_id'] ? $cateData['id'] : 0;
|
|
|
+ $param['pid'] = $cateData['parent_id'] ? $cateData['parent_id'] : $cateData['id'];
|
|
|
+ $seo_title = str_replace('|', $cateData['catname'], $cateData['seo_title']);
|
|
|
+ $seo_keywords = str_replace('|', $cateData['catname'], $cateData['seo_keywords']);
|
|
|
+ $seo_desc = str_replace('|', $cateData['catname'], $cateData['seo_desc']);
|
|
|
+ $this->assign('catname', $cateData['catname']);
|
|
|
+ $this->assign('seo_title', $seo_title);
|
|
|
+ $this->assign('seo_keywords', $seo_keywords);
|
|
|
+ $this->assign('seo_desc', $seo_desc);
|
|
|
+ } else {
|
|
|
$param['sid'] = 0;
|
|
|
$param['pid'] = 0;
|
|
|
}
|
|
|
- // echo $seo_title;die();
|
|
|
+ // echo $seo_title;die();
|
|
|
|
|
|
- if($param['pid']){
|
|
|
- $sonlist = Db::name('category')->where('parent_id',$param['pid'])->select();
|
|
|
- }else{
|
|
|
- $sonlist = Db::name('category')->where('parent_id','gt',0)->order('list_order')->limit(20)->select();
|
|
|
+ if ($param['pid']) {
|
|
|
+ $sonlist = Db::name('category')->where('parent_id', $param['pid'])->select();
|
|
|
+ } else {
|
|
|
+ $sonlist = Db::name('category')->where('parent_id', 'gt', 0)->order('list_order')->limit(20)->select();
|
|
|
}
|
|
|
|
|
|
$param['pageType'] = 1;
|
|
|
@@ -100,47 +112,48 @@ class JiamengController extends HomeBaseController
|
|
|
$cateList = CategoryService::getCates();
|
|
|
|
|
|
|
|
|
-
|
|
|
// 获取最新品牌
|
|
|
- $brandNews = JiamengService::getNewList(cmf_is_mobile()? 5: 10);
|
|
|
+ $brandNews = JiamengService::getNewList(cmf_is_mobile() ? 5 : 10);
|
|
|
|
|
|
//阅读排行
|
|
|
- // $paihang = JiamengService::getHotList(cmf_is_mobile()? 5: 18);
|
|
|
- $paihang = NewsService::getRankList(cmf_is_mobile()? 5: 18);
|
|
|
+ $paihang = JiamengService::getHotList(cmf_is_mobile() ? 5 : 18);
|
|
|
+// $paihang = NewsService::getRankList(cmf_is_mobile()? 5: 18);
|
|
|
|
|
|
- $result = $result? $result->toArray() : [];
|
|
|
- $lists = isset($result['data'])? $result['data'] : [];
|
|
|
- foreach ($lists as &$item){
|
|
|
+ $result = $result ? $result->toArray() : [];
|
|
|
+ $lists = isset($result['data']) ? $result['data'] : [];
|
|
|
+ foreach ($lists as &$item) {
|
|
|
$touziLevel = isset($item['touzi_level']) ? $item['touzi_level'] : '-1';
|
|
|
$item['touzi_level_name'] = isset($touziarr[$touziLevel]) ? $touziarr[$touziLevel] : '';
|
|
|
- $areaId = isset($item['area_id']) && $item['area_id']>0? intval($item['area_id']) : '-1';
|
|
|
+ $areaId = isset($item['area_id']) && $item['area_id'] > 0 ? intval($item['area_id']) : '-1';
|
|
|
|
|
|
$item['area_name'] = isset($areaList[$areaId]) ? $areaList[$areaId] : '';
|
|
|
}
|
|
|
|
|
|
// 友情链接
|
|
|
$links = [];
|
|
|
- if($enname){
|
|
|
- $links = LinkService::getList(['catname'=> $enname], 50);
|
|
|
+ if ($enname) {
|
|
|
+ $links = LinkService::getList(['catname' => $enname], 50);
|
|
|
}
|
|
|
|
|
|
//通过传入的参数获取中文
|
|
|
- $this->assign('dtite',$page);
|
|
|
+ $this->assign('dtite', $page);
|
|
|
|
|
|
- // var_dump($param);die();
|
|
|
- $this->assign('page',$page);
|
|
|
- $this->assign('data',$result);
|
|
|
+ // var_dump($param);die();
|
|
|
+ $this->assign('page', $page);
|
|
|
+ $this->assign('data', $result);
|
|
|
$this->assign('lists', $lists);
|
|
|
- $this->assign('paihang',$paihang);
|
|
|
- $this->assign('param',$param);
|
|
|
-
|
|
|
- $this->assign('brandNews',$brandNews);
|
|
|
- $this->assign('touziarr',$touziarr);
|
|
|
- $this->assign('areaList',$areaList);
|
|
|
- $this->assign('cateList',$cateList);
|
|
|
- $this->assign('sonlist',$sonlist);
|
|
|
- $this->assign('links',$links);
|
|
|
- return $this->fetch('list');
|
|
|
+ $this->assign('paihang', $paihang);
|
|
|
+ $this->assign('param', $param);
|
|
|
+
|
|
|
+ $this->assign('brandNews', $brandNews);
|
|
|
+ $this->assign('touziarr', $touziarr);
|
|
|
+ $this->assign('areaList', $areaList);
|
|
|
+ $this->assign('cateList', $cateList);
|
|
|
+ $this->assign('sonlist', $sonlist);
|
|
|
+ $this->assign('links', $links);
|
|
|
+ $pageHtml = $this->fetch('list');
|
|
|
+ RedisService::set($cacheKey, $pageHtml, 24*3600);
|
|
|
+ return $pageHtml;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -150,10 +163,18 @@ class JiamengController extends HomeBaseController
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
- public function search(){
|
|
|
- $param = $this->request->param();
|
|
|
- $result = JiamengService::getList($param);
|
|
|
- $page = $result->render();
|
|
|
+ public function search()
|
|
|
+ {
|
|
|
+ $param = $this->request->param();
|
|
|
+ $cacheKey = 'cache:jiameng_pages:search:' . md5(json_encode($param));
|
|
|
+ $pageHtml = RedisService::get($cacheKey);
|
|
|
+ if ($pageHtml) {
|
|
|
+ return $pageHtml;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $result = JiamengService::getList($param);
|
|
|
+ $page = $result->render();
|
|
|
|
|
|
// 参数
|
|
|
$touziarr = config('params.touziLevels');
|
|
|
@@ -161,81 +182,84 @@ class JiamengController extends HomeBaseController
|
|
|
$cateList = CategoryService::getCates();
|
|
|
|
|
|
|
|
|
- // 获取最新品牌
|
|
|
- $brandNews = JiamengService::getNewList(10);
|
|
|
+ // 获取最新品牌
|
|
|
+ $brandNews = JiamengService::getNewList(10);
|
|
|
|
|
|
- //加盟排行
|
|
|
+ //加盟排行
|
|
|
//$paihang = JiamengService::getHotList(18);
|
|
|
- $paihang = NewsService::getRankList(cmf_is_mobile()? 5: 18);
|
|
|
+ $paihang = NewsService::getRankList(cmf_is_mobile() ? 5 : 18);
|
|
|
|
|
|
$param = [
|
|
|
- 'kw'=> isset($param['kw'])? trim($param['kw']) : '',
|
|
|
- 'enname'=> isset($param['enname'])? trim($param['enname']) : '',
|
|
|
- 'catid'=> isset($param['catid'])? intval($param['catid']) : 0,
|
|
|
- 'pcid'=> isset($param['pcid'])? intval($param['pcid']) : 0,
|
|
|
- 'lv'=> isset($param['lv'])? intval($param['lv']) : '-1',
|
|
|
- 'aid'=> isset($param['aid'])? intval($param['aid']) : 0,
|
|
|
+ 'kw' => isset($param['kw']) ? trim($param['kw']) : '',
|
|
|
+ 'enname' => isset($param['enname']) ? trim($param['enname']) : '',
|
|
|
+ 'catid' => isset($param['catid']) ? intval($param['catid']) : 0,
|
|
|
+ 'pcid' => isset($param['pcid']) ? intval($param['pcid']) : 0,
|
|
|
+ 'lv' => isset($param['lv']) ? intval($param['lv']) : '-1',
|
|
|
+ 'aid' => isset($param['aid']) ? intval($param['aid']) : 0,
|
|
|
];
|
|
|
|
|
|
- $result = $result? $result->toArray() : [];
|
|
|
- $lists = isset($result['data'])? $result['data'] : [];
|
|
|
- foreach ($lists as &$item){
|
|
|
+ $result = $result ? $result->toArray() : [];
|
|
|
+ $lists = isset($result['data']) ? $result['data'] : [];
|
|
|
+ foreach ($lists as &$item) {
|
|
|
$touziLevel = isset($item['touzi_level']) ? $item['touzi_level'] : '-1';
|
|
|
$areaId = isset($item['area_id']) ? $item['area_id'] : '-1';
|
|
|
$item['touzi_level_name'] = isset($touziarr[$touziLevel]) ? $touziarr[$touziLevel] : '';
|
|
|
- $item['area_name'] = isset($areaList[$areaId]) && $item['area_id']>0? $areaList[$areaId] : '';
|
|
|
+ $item['area_name'] = isset($areaList[$areaId]) && $item['area_id'] > 0 ? $areaList[$areaId] : '';
|
|
|
}
|
|
|
|
|
|
- $enname = isset($param['enname'])? trim($param['enname']) : '';
|
|
|
- if($enname){
|
|
|
+ $enname = isset($param['enname']) ? trim($param['enname']) : '';
|
|
|
+ if ($enname) {
|
|
|
$pcatid = Db::name('category')->where('enname', $enname)->value('id');
|
|
|
}
|
|
|
|
|
|
$pcid = isset($param['pcid']) ? intval($param['pcid']) : 0;
|
|
|
- $pcid = $pcid>0? $pcid : $pcatid;
|
|
|
- if($pcid){
|
|
|
+ $pcid = $pcid > 0 ? $pcid : $pcatid;
|
|
|
+ if ($pcid) {
|
|
|
$cateData = Db::name('category')->where('id', $pcid)->find();
|
|
|
- $enname = isset($cateData['enname'])? $cateData['enname'] : '';
|
|
|
- $param['sid'] = $cateData['parent_id']? $cateData['id'] : 0;
|
|
|
- $param['pid'] = $cateData['parent_id']? $cateData['parent_id'] : $cateData['id'];
|
|
|
- $seo_title = str_replace('|',$cateData['catname'],$cateData['seo_title']);
|
|
|
- $seo_keywords = str_replace('|',$cateData['catname'],$cateData['seo_keywords']);
|
|
|
- $seo_desc = str_replace('|',$cateData['catname'],$cateData['seo_desc']);
|
|
|
- $this->assign('seo_title',$seo_title);
|
|
|
- $this->assign('seo_keywords',$seo_keywords);
|
|
|
- $this->assign('seo_desc',$seo_desc);
|
|
|
- }else{
|
|
|
+ $enname = isset($cateData['enname']) ? $cateData['enname'] : '';
|
|
|
+ $param['sid'] = $cateData['parent_id'] ? $cateData['id'] : 0;
|
|
|
+ $param['pid'] = $cateData['parent_id'] ? $cateData['parent_id'] : $cateData['id'];
|
|
|
+ $seo_title = str_replace('|', $cateData['catname'], $cateData['seo_title']);
|
|
|
+ $seo_keywords = str_replace('|', $cateData['catname'], $cateData['seo_keywords']);
|
|
|
+ $seo_desc = str_replace('|', $cateData['catname'], $cateData['seo_desc']);
|
|
|
+ $this->assign('seo_title', $seo_title);
|
|
|
+ $this->assign('seo_keywords', $seo_keywords);
|
|
|
+ $this->assign('seo_desc', $seo_desc);
|
|
|
+ } else {
|
|
|
$param['sid'] = 0;
|
|
|
$param['pid'] = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
- if($param['pid']){
|
|
|
- $sonlist = Db::name('category')->where('parent_id',$param['pid'])->select();
|
|
|
- }else{
|
|
|
- $sonlist = Db::name('category')->where('parent_id','gt',0)->order('list_order')->limit(20)->select();
|
|
|
+ if ($param['pid']) {
|
|
|
+ $sonlist = Db::name('category')->where('parent_id', $param['pid'])->select();
|
|
|
+ } else {
|
|
|
+ $sonlist = Db::name('category')->where('parent_id', 'gt', 0)->order('list_order')->limit(20)->select();
|
|
|
}
|
|
|
|
|
|
// 友情链接
|
|
|
$links = [];
|
|
|
- if($enname){
|
|
|
- $links = LinkService::getList(['catname'=> $enname], 50);
|
|
|
+ if ($enname) {
|
|
|
+ $links = LinkService::getList(['catname' => $enname], 50);
|
|
|
}
|
|
|
|
|
|
- $this->assign('page',$page);
|
|
|
- $this->assign('data',$result);
|
|
|
- $this->assign('lists', $lists);
|
|
|
- $this->assign('paihang',$paihang);
|
|
|
- $this->assign('param',$param);
|
|
|
-
|
|
|
- $this->assign('brandNews',$brandNews);
|
|
|
- $this->assign('touziarr',$touziarr);
|
|
|
- $this->assign('areaList',$areaList);
|
|
|
- $this->assign('cateList',$cateList);
|
|
|
- $this->assign('sonlist',$sonlist);
|
|
|
- $this->assign('links',$links);
|
|
|
- return $this->fetch();
|
|
|
- }
|
|
|
+ $this->assign('page', $page);
|
|
|
+ $this->assign('data', $result);
|
|
|
+ $this->assign('lists', $lists);
|
|
|
+ $this->assign('paihang', $paihang);
|
|
|
+ $this->assign('param', $param);
|
|
|
+
|
|
|
+ $this->assign('brandNews', $brandNews);
|
|
|
+ $this->assign('touziarr', $touziarr);
|
|
|
+ $this->assign('areaList', $areaList);
|
|
|
+ $this->assign('cateList', $cateList);
|
|
|
+ $this->assign('sonlist', $sonlist);
|
|
|
+ $this->assign('links', $links);
|
|
|
+ $pageHtml = $this->fetch();
|
|
|
+
|
|
|
+ RedisService::set($cacheKey, $pageHtml, 24*3600);
|
|
|
+ return $pageHtml;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 详情
|
|
|
@@ -244,136 +268,119 @@ class JiamengController extends HomeBaseController
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
* @throws \think\exception\DbException
|
|
|
*/
|
|
|
- public function show(){
|
|
|
- $param = $this->request->param();
|
|
|
+ public function show()
|
|
|
+ {
|
|
|
+ $param = $this->request->param();
|
|
|
isset($param['id']) or $this->error('需要id');
|
|
|
- $cacheKey = "cache:jiameng:show:id_".intval($param['id']);
|
|
|
- $datas = RedisService::get($cacheKey);
|
|
|
- $info = isset($datas['info'])? $datas['info'] : [];
|
|
|
- $touziarr = config('params.touziLevels');
|
|
|
- if(empty($info) || empty($datas)){
|
|
|
- $info = Db::name('jiameng')
|
|
|
- ->where('id',$param['id'])
|
|
|
- ->where('status', 1)
|
|
|
- ->find();
|
|
|
- if(empty($info)){
|
|
|
- header("Location:".url('/404'));
|
|
|
- exit;
|
|
|
- }
|
|
|
- //内容
|
|
|
- $content = Db::name('jiameng_data')->where('id',$param['id'])->find();
|
|
|
- $info['content'] = $content['content'];
|
|
|
- $info['youshi'] = $content['youshi'];
|
|
|
- $info['tiaojian'] = $content['tiaojian'];
|
|
|
- $info['liucheng'] = $content['liucheng'];
|
|
|
- $jmSupport = [];
|
|
|
- $supports = config('params.supports');
|
|
|
- $support = isset($info['jm_support']) && $info['jm_support']? explode(',', $info['jm_support']) : [];
|
|
|
- foreach ($support as $val){
|
|
|
- $name = isset($supports[$val])? $supports[$val] : '';
|
|
|
- if($name){
|
|
|
- $jmSupport[] = $name;
|
|
|
- }
|
|
|
- }
|
|
|
+ $cacheKey = 'cache:jiameng_pages:show_' . $param['id'];
|
|
|
+ $pageHtml = RedisService::get($cacheKey);
|
|
|
+ //更新点击次数
|
|
|
+ Db::name('jiameng')->where('id', $param['id'])->setInc('hits', 1);
|
|
|
+
|
|
|
+ if ($pageHtml) {
|
|
|
+ return $pageHtml;
|
|
|
+ }
|
|
|
+
|
|
|
+ $touziarr = config('params.touziLevels');
|
|
|
|
|
|
- unset($supports[0]);
|
|
|
- $info['jm_support'] = $jmSupport? $jmSupport : $supports;
|
|
|
- $areaList = config('params.areaList');
|
|
|
- $areaId = isset($info['area_id']) && $info['area_id']? intval($info['area_id']) : '-1';
|
|
|
- $area = isset($areaList[$areaId])? $areaList[$areaId] : '不限';
|
|
|
- $info['area'] = $info['area']? $info['area'] : $area;
|
|
|
-
|
|
|
- $catinfo = Db::name('category')->where('id',$info['catid'])->find();
|
|
|
-
|
|
|
- $parinfo = Db::name('category')->where('id',$catinfo['parent_id'])->find();
|
|
|
-
|
|
|
- //热门行业
|
|
|
- $hot_cate = Db::name('category')->where('parent_id',$parinfo['id'])->order('list_order')->limit(12)->select();
|
|
|
- //排行
|
|
|
- $paihang = Db::name('jiameng')->field('id,title,logo,touzi_level,mendian,hits')->where('catid',$info['catid'])->where('status', 1)->order('hits desc')->limit(5)->select();
|
|
|
- //动态
|
|
|
- $about_news = Db::name('news')->field('id,title,thumb,create_time')->where(['ncatid'=>1,'status'=> 1])->order('id desc')->limit(6)->select();
|
|
|
- $brand_news = Db::name('news')->field('id,title,thumb,create_time')->where(['catid'=>$info['catid'],'status'=> 1])->order('id desc')->limit(6)->select();
|
|
|
- //热门加盟
|
|
|
- $hot_jm = Db::name('jiameng')->field('id,title,hits')->where('catid',$info['catid'])->where('status', 1)->order('hits desc')->limit(20)->select();
|
|
|
- //最新加盟
|
|
|
- $zx_jm = $brand8 = JiamengService::getNewList(20);
|
|
|
- //精选加盟
|
|
|
- $jx_jm = Db::name('jiameng')
|
|
|
- ->field('id,title')
|
|
|
- ->where('catid',$info['catid'])
|
|
|
- ->where('status', 1)
|
|
|
- ->orderRaw('rand()')->limit(20)->select();
|
|
|
-
|
|
|
-
|
|
|
- $datas = [
|
|
|
- 'info'=> $info,
|
|
|
- 'catinfo'=> $catinfo,
|
|
|
- 'hot_jm'=> $hot_jm,
|
|
|
- 'zx_jm'=> $zx_jm,
|
|
|
- 'jx_jm'=> $jx_jm,
|
|
|
- 'about_news'=> $about_news,
|
|
|
- 'brand_news'=> $brand_news,
|
|
|
- 'paihang'=> $paihang,
|
|
|
- 'hot_cate'=> $hot_cate,
|
|
|
- 'parinfo'=> $parinfo,
|
|
|
- ];
|
|
|
-
|
|
|
- // 缓存
|
|
|
- RedisService::set($cacheKey, $datas, 2*3600);
|
|
|
- }else{
|
|
|
-
|
|
|
- $catinfo = isset($datas['catinfo'])? $datas['catinfo'] : [];
|
|
|
- $hot_jm = isset($datas['hot_jm'])? $datas['hot_jm'] : [];
|
|
|
- $zx_jm = isset($datas['zx_jm'])? $datas['zx_jm'] : [];
|
|
|
- $jx_jm = isset($datas['jx_jm'])? $datas['jx_jm'] : [];
|
|
|
- $about_news = isset($datas['about_news'])? $datas['about_news'] : [];
|
|
|
- $brand_news = isset($datas['brand_news'])? $datas['brand_news'] : [];
|
|
|
- $paihang = isset($datas['paihang'])? $datas['paihang'] : [];
|
|
|
- $hot_cate = isset($datas['hot_cate'])? $datas['hot_cate'] : [];
|
|
|
- $parinfo = isset($datas['parinfo'])? $datas['parinfo'] : [];
|
|
|
+ $info = Db::name('jiameng')
|
|
|
+ ->where('id', $param['id'])
|
|
|
+ ->where('status', 1)
|
|
|
+ ->find();
|
|
|
+ if (empty($info)) {
|
|
|
+ header("Location:" . url('/404'));
|
|
|
+ exit;
|
|
|
}
|
|
|
|
|
|
+ //内容
|
|
|
+ $content = Db::name('jiameng_data')->where('id', $param['id'])->find();
|
|
|
+ $info['content'] = $content['content'];
|
|
|
+ $info['youshi'] = $content['youshi'];
|
|
|
+ $info['tiaojian'] = $content['tiaojian'];
|
|
|
+ $info['liucheng'] = $content['liucheng'];
|
|
|
+ $jmSupport = [];
|
|
|
+ $supports = config('params.supports');
|
|
|
+ $support = isset($info['jm_support']) && $info['jm_support'] ? explode(',', $info['jm_support']) : [];
|
|
|
+ foreach ($support as $val) {
|
|
|
+ $name = isset($supports[$val]) ? $supports[$val] : '';
|
|
|
+ if ($name) {
|
|
|
+ $jmSupport[] = $name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ unset($supports[0]);
|
|
|
+ $info['jm_support'] = $jmSupport ? $jmSupport : $supports;
|
|
|
+ $areaList = config('params.areaList');
|
|
|
+ $areaId = isset($info['area_id']) && $info['area_id'] ? intval($info['area_id']) : '-1';
|
|
|
+ $area = isset($areaList[$areaId]) ? $areaList[$areaId] : '不限';
|
|
|
+ $info['area'] = $info['area'] ? $info['area'] : $area;
|
|
|
+
|
|
|
+ $catinfo = Db::name('category')->where('id', $info['catid'])->find();
|
|
|
+
|
|
|
+ $parinfo = Db::name('category')->where('id', $catinfo['parent_id'])->find();
|
|
|
+
|
|
|
+ //热门行业
|
|
|
+ $hot_cate = Db::name('category')->where('parent_id', $parinfo['id'])->order('list_order')->limit(12)->select();
|
|
|
+ //排行
|
|
|
+ $paihang = Db::name('jiameng')->field('id,title,logo,touzi_level,mendian,hits')->where('catid', $info['catid'])->where('status', 1)->order('hits desc')->limit(5)->select();
|
|
|
+ //动态
|
|
|
+ $about_news = Db::name('news')->field('id,title,thumb,create_time')->where(['ncatid' => 1, 'status' => 1])->order('id desc')->limit(6)->select();
|
|
|
+ $brand_news = Db::name('news')->field('id,title,thumb,create_time')->where(['catid' => $info['catid'], 'status' => 1])->order('id desc')->limit(6)->select();
|
|
|
+ //热门加盟
|
|
|
+ $hot_jm = Db::name('jiameng')->field('id,title,hits')->where('catid', $info['catid'])->where('status', 1)->order('hits desc')->limit(20)->select();
|
|
|
+ //最新加盟
|
|
|
+ $zx_jm = $brand8 = JiamengService::getNewList(20);
|
|
|
+ //精选加盟
|
|
|
+ $jx_jm = Db::name('jiameng')
|
|
|
+ ->field('id,title')
|
|
|
+ ->where('catid', $info['catid'])
|
|
|
+ ->where('status', 1)
|
|
|
+ ->orderRaw('rand()')->limit(20)->select();
|
|
|
+
|
|
|
|
|
|
//seo
|
|
|
- $seo_title = str_replace('|',$info['title'],$catinfo['seo_title']);
|
|
|
- $seo_keywords = str_replace('|',$info['title'],$catinfo['seo_keywords']);
|
|
|
+ $seo_title = str_replace('|', $info['title'], $catinfo['seo_title']);
|
|
|
+ $seo_keywords = str_replace('|', $info['title'], $catinfo['seo_keywords']);
|
|
|
$seo_desc = trim(strip_tags($info['content']));
|
|
|
- $seo_desc = mb_substr($seo_desc,0,200,'utf8');
|
|
|
-
|
|
|
-
|
|
|
- $this->assign('seo_title',$seo_title);
|
|
|
- $this->assign('seo_keywords',$seo_keywords);
|
|
|
- $this->assign('seo_desc',$seo_desc);
|
|
|
- $this->assign('hot_jm',$hot_jm);
|
|
|
- $this->assign('zx_jm',$zx_jm);
|
|
|
- $this->assign('jx_jm',$jx_jm);
|
|
|
- $this->assign('about_news',$about_news);
|
|
|
- $this->assign('brand_news',$brand_news);
|
|
|
- $this->assign('paihang',$paihang);
|
|
|
- $this->assign('hot_cate',$hot_cate);
|
|
|
- $this->assign('touziarr',$touziarr);
|
|
|
- $this->assign('catinfo',$catinfo);
|
|
|
- $this->assign('parinfo',$parinfo);
|
|
|
- $this->assign('info',$info);
|
|
|
- return $this->fetch();
|
|
|
+ $seo_desc = mb_substr($seo_desc, 0, 200, 'utf8');
|
|
|
+
|
|
|
+
|
|
|
+ $this->assign('seo_title', $seo_title);
|
|
|
+ $this->assign('seo_keywords', $seo_keywords);
|
|
|
+ $this->assign('seo_desc', $seo_desc);
|
|
|
+ $this->assign('hot_jm', $hot_jm);
|
|
|
+ $this->assign('zx_jm', $zx_jm);
|
|
|
+ $this->assign('jx_jm', $jx_jm);
|
|
|
+ $this->assign('about_news', $about_news);
|
|
|
+ $this->assign('brand_news', $brand_news);
|
|
|
+ $this->assign('paihang', $paihang);
|
|
|
+ $this->assign('hot_cate', $hot_cate);
|
|
|
+ $this->assign('touziarr', $touziarr);
|
|
|
+ $this->assign('catinfo', $catinfo);
|
|
|
+ $this->assign('parinfo', $parinfo);
|
|
|
+ $this->assign('info', $info);
|
|
|
+ $pageHtml = $this->fetch();
|
|
|
+
|
|
|
+ RedisService::set($cacheKey, $pageHtml, 24*3600);
|
|
|
+ return $pageHtml;
|
|
|
}
|
|
|
|
|
|
- public function message(){
|
|
|
+ public function message()
|
|
|
+ {
|
|
|
$param = $this->request->param();
|
|
|
$orignUrl = $this->request->header('origin');
|
|
|
// isset($param['name'])&&$param['name']!='' or $this->error('请填写姓名');
|
|
|
- isset($param['mobile'])&&$param['mobile']!='' or $this->error('请填写手机号');
|
|
|
+ isset($param['mobile']) && $param['mobile'] != '' or $this->error('请填写手机号');
|
|
|
$param['create_time'] = time();
|
|
|
$param['ip'] = get_client_ip();
|
|
|
$param['address'] = IpService::getAddress(get_client_ip());
|
|
|
$todaytime = strtotime(date('Y-m-d'));
|
|
|
- if(strlen($param['content'])>300){
|
|
|
- $this->error('字符长度不超过300个');
|
|
|
+ if (strlen($param['content']) > 300) {
|
|
|
+ $this->error('字符长度不超过300个');
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
- if(isset($param['tzed']) && $param['tzed']<=0){
|
|
|
+ if (isset($param['tzed']) && $param['tzed'] <= 0) {
|
|
|
$this->error('请选择投资额度');
|
|
|
exit;
|
|
|
}
|
|
|
@@ -388,36 +395,35 @@ class JiamengController extends HomeBaseController
|
|
|
|
|
|
// print_r($param);exit;
|
|
|
//判断是否已超过10次 今天这个ip是否留言过
|
|
|
- /* $sum = MessageService::getTodyCount(['ip'=> $param['ip'],'type'=> 1]);
|
|
|
- if($sum>0){
|
|
|
- $this->error('今日留言已超过1次,明天再来吧!');
|
|
|
- }
|
|
|
- //判断手机号本周内是否留过
|
|
|
- $sum = MessageService::getWeekCount(['mobile'=> $param['mobile'],'type'=> 1]);
|
|
|
- if($sum>0){
|
|
|
- $this->error('您的手机号在本周内已预留过,下周再来吧!');
|
|
|
- }*/
|
|
|
- $week_time=time()-604800;
|
|
|
-
|
|
|
- $res_mobile=Db::name('message')->where('mobile',$param['mobile'])->where('create_time','>',$week_time)->find();
|
|
|
- if($res_mobile)
|
|
|
- {
|
|
|
+ /* $sum = MessageService::getTodyCount(['ip'=> $param['ip'],'type'=> 1]);
|
|
|
+ if($sum>0){
|
|
|
+ $this->error('今日留言已超过1次,明天再来吧!');
|
|
|
+ }
|
|
|
+ //判断手机号本周内是否留过
|
|
|
+ $sum = MessageService::getWeekCount(['mobile'=> $param['mobile'],'type'=> 1]);
|
|
|
+ if($sum>0){
|
|
|
+ $this->error('您的手机号在本周内已预留过,下周再来吧!');
|
|
|
+ }*/
|
|
|
+ $week_time = time() - 604800;
|
|
|
+
|
|
|
+ $res_mobile = Db::name('message')->where('mobile', $param['mobile'])->where('create_time', '>', $week_time)->find();
|
|
|
+ if ($res_mobile) {
|
|
|
$this->error('手机号码一个周内只能留一次');
|
|
|
}
|
|
|
- $ip=get_client_ip();
|
|
|
- $start_time=strtotime(date('Y-m-d') );
|
|
|
- $ip_count=Db::name('message')->where('ip',$ip)->where('create_time','>',$start_time)->count();
|
|
|
- if($ip_count>1)
|
|
|
- {
|
|
|
+ $ip = get_client_ip();
|
|
|
+ $start_time = strtotime(date('Y-m-d'));
|
|
|
+ $ip_count = Db::name('message')->where('ip', $ip)->where('create_time', '>', $start_time)->count();
|
|
|
+ if ($ip_count > 1) {
|
|
|
$this->error('同一个ip一天只可以留言2次');
|
|
|
}
|
|
|
$res = Db::name('message')->insert($param);
|
|
|
- if($res){
|
|
|
+ if ($res) {
|
|
|
$this->success('咨询成功');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$this->error('咨询失败');
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
?>
|