返回前台模块控制器...登陆

前台模块控制器

会上树的猪2019-06-21 11:29:5370

<?php
namespace app\index\controller;
//use think\facade\View;  //view创建静态代理
use app\admin\model\SlideModel;
use app\admin\model\PorModel;
use app\admin\model\NewsModel;
use app\admin\model\SystemModel;
use think\facade\Request;//系统控制器
use think\Controller;

class Index extends Controller
{
    public function index()
    {
     //轮播图-实例化模型
     $slide = new SlideModel();
     //查询所有轮播图
     $slides = $slide->select()->toArray();
     //
     $this->view->slides = $slides;
        
     //头牌人选-实例化模型
     $porduct = new PorModel();
        //查询模型
        $porducts = $porduct->where('sort',1)->select()->toArray();
        //赋值给模板
        $this->view->porducts = $porducts;
        //新上花魁
        $newporducts = $porduct->where('sort',15)->limit(1)->select()->toArray();
        $this->view->newporducts = $newporducts;
        //最新资讯-实例化模型
        $new = new NewsModel();
        $news = $new->order('id', 'desc')->limit(3)->select()->toArray();
        $this->view->news = $news;

        //渲染首页模板
        return $this->fetch();
    }
    public function about()
    {
        //实例化模型
        $system = new SystemModel();
        //查询数据
        $systems = $system->select()->toArray();
        //给模板赋值
        $this->view->systems = $systems;

     //渲染关于我们界面
     return $this->fetch();
    }

    public function product()
    {
        //实例化模型
        $por = new PorModel();
        //查询数据
        $pors = $por->order('id', 'desc')->paginate(4);
        $this->view->pors = $pors;
        //渲染产品页界面
        return $this->fetch();
    }

    public function ConPro()
    {
        //获取产品id
        $porId = Request::param('id');
        //实例化模型
        $pors = PorModel::get($porId);
        //将数据赋值给模板
        $this->view->pors = $pors;
        //渲染产品详情页界面
        return $this->fetch();
    }

    public function news()
    {
        //实例化模型
        $news = new NewsModel();
        //查询所有新闻
        $new = $news->order('id','desc')->paginate(4);
        //渲染到模板
        $this->view->new = $new;
        //热门新闻
        $hosnews = $news->limit(1)->select()->toArray();
        $this->view->hosnews = $hosnews;
        //最新发布
        $nsnew = $news->order('id','desc')->limit(6)->select()->toArray();
        $this->view->nsnew = $nsnew;
        //渲染新闻中心
        return $this->fetch();
    }

    public function ConNew()
    {
        //获取新闻id
        $newsId = Request::param('id');
        $new =  NewsModel::get($newsId);
        $this->view->new = $new;
        //实例化模型
        $news = new NewsModel();
        //热门新闻
        $hosnews = $news->limit(1)->select()->toArray();
        $this->view->hosnews = $hosnews;
        //最新发布
        $nsnew = $news->order('id','desc')->limit(4)->select()->toArray();
        $this->view->nsnew = $nsnew;
        //渲染新闻中心
        return $this->fetch();
    }
}


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送
  • PHP中文网