提交 d643212c authored 作者: 邓奇's avatar 邓奇

搜索页面处理

上级 99341240
...@@ -468,38 +468,39 @@ class IndexController extends Controller ...@@ -468,38 +468,39 @@ class IndexController extends Controller
public function site_search(Request $request) public function site_search(Request $request)
{ {
$search = $request->search; $search = $request->search;
if( empty($search) ){ if( $search || $search == '0' ){
$result = array('msg' => '请输入搜索关键字!','code'=>400); //产品搜索
return response()->json($result); $product = new Pack();
$packs = $product->where('title',$search )->orWhere('title','like','%'.$search.'%')->orderBy('add_time','desc')->get();
$packs_num = $product->where('title',$search )->orWhere('title','like','%'.$search.'%')->orderBy('add_time','desc')->count();
//视频
$content = new Content();
$videos = $content->getContentListByTypeId(20,$search);
$videos_num = $content->countContentListByTypeId(20,$search);
//新闻
$news = $content->getContentListByTypeId(21,$search);
$news_num = $content->countContentListByTypeId(21,$search);
//媒体资讯
$infomations = $content->getContentListByTypeId(33,$search);
$infomations_num = $content->countContentListByTypeId(33,$search);
//$a = [
// 'packs'=>$packs,'packs_num'=>$packs_num,'videos'=>$videos,'videos_num'=>$videos_num,
// 'news'=>$news,'news_num'=>$news_num,'infomations'=>$infomations,'infomations_num'=>$infomations_num
//];
$total_num = intval($packs_num + $videos_num + $news_num + $infomations_num);
return view('index.index_search',[
'packs'=>$packs,'packs_num'=>$packs_num,'videos'=>$videos,'videos_num'=>$videos_num,
'news'=>$news,'news_num'=>$news_num,'infomations'=>$infomations,'infomations_num'=>$infomations_num,
'total_num'=>$total_num,'showType'=>$this->showType,'showType_b'=>$this->showType_b
]);
}else{
return view('index.index_search',[
'msg' => '搜索内容不能为空!','showType'=>$this->showType,'showType_b'=>$this->showType_b
]);
} }
//产品搜索
$product = new Pack();
$packs = $product->where('title',$search )->orWhere('title','like','%'.$search.'%')->orderBy('add_time','desc')->get();
$packs_num = $product->where('title',$search )->orWhere('title','like','%'.$search.'%')->orderBy('add_time','desc')->count();
//视频
$content = new Content();
$videos = $content->getContentListByTypeId(20,$search);
$videos_num = $content->countContentListByTypeId(20,$search);
//新闻
$news = $content->getContentListByTypeId(21,$search);
$news_num = $content->countContentListByTypeId(21,$search);
//媒体资讯
$infomations = $content->getContentListByTypeId(33,$search);
$infomations_num = $content->countContentListByTypeId(33,$search);
//$a = [
// 'packs'=>$packs,'packs_num'=>$packs_num,'videos'=>$videos,'videos_num'=>$videos_num,
// 'news'=>$news,'news_num'=>$news_num,'infomations'=>$infomations,'infomations_num'=>$infomations_num
//];
return view('index.index_search',[
'packs'=>$packs,'packs_num'=>$packs_num,'videos'=>$videos,'videos_num'=>$videos_num,
'news'=>$news,'news_num'=>$news_num,'infomations'=>$infomations,'infomations_num'=>$infomations_num,
'showType'=>$this->showType,'showType_b'=>$this->showType_b
]);
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
</div> </div>
<header class="am-show-lg-only pc_header" id="head-navbar" > <header class="am-show-lg-only pc_header" id="head-navbar" >
<div class="width1400 am-cf"> <div class="width1400 am-cf">
<div class="logo am-fl"><img src="{{asset('msk/img/logo.png')}}"></div> <div class="logo am-fl"><a href="/"><img src="{{asset('msk/img/logo.png')}}"></a></div>
<form action="{{url('search')}}" method="get"> <form action="{{url('search')}}" method="get">
<div class="search am-fr"> <div class="search am-fr">
<input name="search" type="text" placeholder="请输入关键字"> <input name="search" type="text" placeholder="请输入关键字">
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论