返回 完成企业官网前...... 登陆

完成企业官网前后台小案例

҈果҈果҈果҈ ҈ ҈ 2019-07-23 01:48:39 386

2019-07-23_013922.jpg2019-07-23_014007.jpg2019-07-23_014050.jpg2019-07-23_014134.jpg2019-07-23_013823.jpg

<?php
namespace app\index\controller;
use app\admin\model\NewModel;
use app\admin\model\ProductModel;
use app\admin\model\SlideModel;
use app\admin\model\SystemModel;
use think\Controller;
use think\Facade\Request;

class Index extends Controller
{
    public function index()
    {
//        轮播图查询
        $slide= new SlideModel();
        $slides=$slide->select()->toArray();
        $this->view->slides=$slides;

//        最新产品查询

        $product=new ProductModel();
        $products=$product->where('sort','1')->select()->toArray();
        $this->view->products = $products;

//        新上花魁
        $NewProducts=$product->where('sort','2')->limit(1)->select()->toArray();
        $this->view->NewProducts = $NewProducts;

//        最新资讯

        $new = new NewModel();
        $news=$new->limit(4)->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()
    {
//        产品列表
        $product=new ProductModel();
        $products=$product->order('id','desc')->paginate(4);
        $this->view->products=$products;
        return $this->fetch();
    }

    public function news()
    {
        $new = new NewModel();
        $news=$new->order('id','desc')->paginate(4);
        $this->view->news=$news;
//        新闻列表

        $hotNews=$new->limit(1)->select()->toArray();
        $this->view->hotNews=$hotNews;


        $newNews=$new->limit(6)->select()->toArray();
        $this->view->newNews=$newNews;
        return $this->fetch();
    }

    public function ConNew()
    {
        $newId=Request::param('id');
        $new=NewModel::get($newId);
        $this->view->new=$new;

        $hotNew = $new->limit(1)->select()->toArray();
        $this->view->hotNews=$hotNew;

        $newNews=$new->limit(6)->select()->toArray();
        $this->view->newNews=$newNews;
        return $this->fetch();
    }

    public function ConPro()
    {
        $proId=Request::param('id');
        $product=ProductModel::get($proId);
        $this->view->product=$product;
        return $this->fetch();
    }
}


经过本章节的练习,熟练掌握了thinkphp前端渲染技术。强大的框架大大方便了平时项目开发效率。后续不断加强练习让更加巩固php开发技能

最新手记推荐

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

全部回复(0)我要回复

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