2022-10-08 17:31:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								namespace  app\controller ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-14 16:14:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								use  app\model\ { Article  as  MArticle ,  CasesModel ,  Category ,  Block ,  Message ,  Article ,  Slide };  
						 
					
						
							
								
									
										
										
										
											2022-10-08 17:31:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								use  Exception ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								use  think\exception\ValidateException ;  
						 
					
						
							
								
									
										
										
										
											2022-10-14 16:14:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								use  think\facade\Db ;  
						 
					
						
							
								
									
										
										
										
											2022-10-08 17:31:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								use  think\facade\View ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								use  app\service\Tool ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class  Index  extends  Base  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    public  function  index () 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $category    =  Category :: getIndex (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $categoryId  =  $category [ 'id' ]  ? ?  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $blocks      =  Block :: getByCategoryId ( $categoryId ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-14 16:14:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $this -> news (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> cases (); 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-11 10:23:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $this -> companyHistory ( $blocks [ 'company_history_list' ][ 'value' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-14 16:14:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $this -> data [ 'categoryId' ]     =  $categoryId ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> data [ 'blocks' ]         =  Block :: convertValue ( $blocks ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> data [ 'category' ]       =  $category ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> data [ 'topCategoryId' ]  =  Category :: firstGradeById ( $category [ 'id' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> data [ 'isIndex' ]        =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> data [ 'slide' ]          =  Slide :: getList (); 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 17:31:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        $this -> setSeo ( $this -> system [ 'seo_title' ],  $this -> system [ 'seo_keywords' ],  $this -> system [ 'seo_description' ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  $this -> view (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-14 16:14:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 新闻
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    private  function  news () 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 17:31:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-14 16:14:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $newsCategory  =  Category :: where ( 'parent_id' ,  Category :: CATEGORY_NEWS ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            -> order ( 'sort' ,  'asc' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            -> column ( 'id,title,route,url' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $sql  =  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        foreach  ( $newsCategory  as  $cate )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  empty ( $sql )  ?  ''  :  ' union ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $sql  .=  '(select `id`,`title`,`summary`,`category_id`,`src`,`src_mobile`,`create_time` from bee_article where `category_id` = ' . $cate [ 'id' ] . ' order by `top` desc, `sort` desc limit 5)' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $res   =  Db :: query ( $sql ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $list  =  []; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        foreach  ( array_column ( $newsCategory ,  'id' )  as  $categoryId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ! isset ( $list [ $categoryId ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                $list [ $categoryId ]  =  []; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            foreach  ( $res  as  $re )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( $re [ 'category_id' ]  ==  $categoryId )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    $list [ $categoryId ][]  =  $re ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> data [ 'newsCategory' ]  =  $newsCategory ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> data [ 'newsList' ]      =  $list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 案例
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    private  function  cases () 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-17 15:03:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $casesList  =  CasesModel :: where ( 'home' ,  1 ) -> order ( 'sort' ,  'desc' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            -> order ( 'id' ,  'desc' ) -> limit ( 4 ) -> select (); 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-14 16:14:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> data [ 'casesList' ]  =  $casesList ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 17:31:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-11 10:23:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    private  function  companyHistory ( string  $companyHistory ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-14 16:14:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $companyHistory      =  nl2br ( $companyHistory ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $companyHistory      =  explode ( '<br />' ,  $companyHistory ); 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-11 10:23:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $companyHistoryList  =  []; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        foreach  ( $companyHistory  as  $v )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-14 16:14:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $arr                   =  explode ( ';' ,  $v ); 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-11 10:23:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $companyHistoryList []  =  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'year'  =>  $arr [ 0 ]  ? ?  '' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'desc'  =>  $arr [ 1 ]  ? ?  '' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        $this -> data [ 'companyHistoryList' ]  =  $companyHistoryList ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 17:31:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    /** 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  留言 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     *  @ throws  Exception 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    public  function  message () 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( $this -> request -> isPost ())  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $item      =  input ( 'item/a' ,  [],  'strip_tags' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $validate  =  $this -> validateByApi ( $item ,  [ 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-14 16:14:35 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                'code|验证码'      =>  'require' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'name|姓名'       =>  'require' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'email|邮箱'      =>  'email' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'tel|联系方式'      =>  'require|mobile' , 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-08 17:31:39 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								                'content|留言内容'  =>  'require' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( $validate  !==  true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  $validate ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ! captcha_check ( $item [ 'code' ]))  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  $this -> json ( 4001 ,  '验证码错误' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            Message :: create ([ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'name'         =>  $item [ 'name' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'tel'          =>  $item [ 'tel' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'email'        =>  $item [ 'email' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'content'      =>  $item [ 'content' ], 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'ip'           =>  request () -> ip (), 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                'create_time'  =>  time (), 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ]); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  $this -> json (); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  $this -> json ( '请求错误' ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}