Green.php 1.5 KB
<?php


namespace app\api\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){
            $res=$list[0];
            $list2=GreenList::where("green_id",$res['id'])->select();
        }else{
            $res=$list[0];
            $list2=\app\admin\model\WhchList::where("green_id",$res['id'])->select();

        }
        $this->assign("list",$list2);
        $list1=self::$model::green($param['pid'],[],3);
        $this->assign("list1",$list1);
        $this->assign("pid",$param['pid']);
        return view("green/green");
    }
    //查出更多
    public function getList()
    {
        $param=Request::instance()->param();
        $list=self::$model::green($param['pid'],$param,12);
        if(Request::instance()->isAjax()){
            return self::$model::js($list,200);
        }
        $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);
        return $this->view->fetch();
    }
}