Green.php 1.7 KB
<?php


namespace app\index\controller;


use app\admin\controller\WhchList;
use app\admin\model\GreenList;
use app\common\controller\Frontend;
use think\Request;

class Green extends Frontend
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';
    public function index()
    {
        //查出最新的
        $param=Request::instance()->param();
        $list=self::$model::green($param['pid'],$param,1);

        if($list && $param['pid']==13){
            if (empty($list[0])){
                $this->error('相关内容还在补充,敬请关注');
            }
            $res=$list[0];
            $list2=GreenList::where("green_id",$res['id'])->select();

            $advice=self::$model::advice(0,2,2);


        }else{
            $res=$list[0];
            $list2=\app\admin\model\WhchList::where("green_id",$res['id'])->select();
            $advice=self::$model::advice(0,2,3);
        }

        $this->assign("list",$list2);
        $list1=self::$model::green($param['pid'],[],10);

        $this->assign("list1",$list1);
        $this->assign("pid",$param['pid']);
        $this->assign("advice",$advice);
        return view("green/green");
    }
    //查出更多
    public function getList()
    {
        $param=Request::instance()->param();
        $list=self::$model::green($param['pid'],$param,12);
        $this->assign("list",$list);
        $this->assign("pid",$param['pid']);
        return view("green/list");
    }
    //详情
    public function detail()
    {
        $param=Request::instance()->param();
        $news=self::$model::greenDetail($param['id'],$param['pid']);
        $this->assign("news",$news);
        $this->assign("pid",$param['pid']);
        return $this->view->fetch();
    }
}