<?php
namespace app\index\controller;
use think\facade\View;
use think\facade\Request;
use think\facade\Session;

class Index extends Base{
	
    public function index(){
		return View::fetch();
    }
    
	//搜索
    public function search(){
		$tdata=Request::param();
		
		$cate[]=['model_id','>',1];
		$cate[]=['is_info','=',0];
		$cate[]=['is_effect','=',1];
		
		$cates=\app\admin\model\Cate::where($cate)->field('id')->select()->toArray();
		foreach($cates as $c){
			$cates_array[]=$c['id'];	
		}
		
		$limit=30;

		$map[]=['is_effect','=',1];
		$map[]=['is_delete','=',1];
		$map[]=['pid','in',$cates_array];
		$map[]=['title','like','%'.$tdata['title'].'%'];
		$list=\app\index\model\Article::where($map)->order('sort desc,create_time desc')->paginate(['list_rows' =>$limit,'query' => request()->param(),]);
		$page = $list->render();
		$list=$list->items();
		foreach($list as $k=>$c){
			if($c['link']!=''){
				$list[$k]['url']=$c['link'];
			}else{
				$list[$k]['url']=info_seo_url($c['pid'],$c['id']);
			}
		}
		
        View::assign(['keywords'=>$tdata['keywords'],'list'=>$list,'page'=>$page]);
		return View::fetch();
    }

	//清理表
	public function qingli(){
		$tdata=Request::param();
		
		
		dump($tdata);
    }
}