Policy.php 2.1 KB
<?php


namespace app\index\controller;


use app\common\controller\Frontend;
use think\Db;

class Policy extends Frontend
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = 'default';
    public function _initialize()
    {
        parent::_initialize(); // TODO: Change the autogenerated stub
        $this->view->assign('index',$index='foot');//首页隐藏头部使用
    }

    public function index(){
        $param = $this->request->param();
        $page = null;
        $p_category_id = Db::name('news_category')->where('title','政策制度')->where('school_id',$this->school_id)->value("id");
        if(empty($param['category_id'])){
            $category = Db::name('news_category')->where('pid',$p_category_id)->order("weigh","desc")->find();
        }else{
            $category = Db::name('news_category')->where('id',$param['category_id'])->find();
        }

        $category_list = Db::name('news_category')->where('pid',$p_category_id)->order("weigh","desc")->select();
        $list = Db::name("news_content")->where("category_id",  $category['id'])->paginate(3,false,["query"=>request()->param()]);
        $page = $list->render();
        $this->assign("category_list",$category_list);
        $this->assign("list",$list);
        $this->assign("category",$category);
        $this->assign("page",$page);
        return $this->view->fetch();
    }

    public function detail(){
        $param = $this->request->param();
        Db::name("news_content")->where(["id"=>$param['id']])->setInc("visit_count");
        $p_category_id = Db::name('news_category')->where('title','政策制度')->where('school_id',$this->school_id)->value("id");
        $category_list = Db::name('news_category')->where('pid',$p_category_id)->order("weigh","desc")->select();
        $info = Db::name("news_content")->where("id", $param['id'])->find();
        $category = Db::name('news_category')->where('id',$info['category_id'])->find();
        $this->assign("category",$category);
        $this->assign("category_list",$category_list);
        $this->assign("info",$info);
        return $this->view->fetch();
    }
}