亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

前臺模塊的實現(xiàn)

??? 2019-05-31 16:57:52 354
????:通過本章的學習,完成了前臺模塊。學完本章后,整個企業(yè)站的項目實戰(zhàn)課程已結課,通過本套實踐課程的學習,已經(jīng)能過通過搭建后臺數(shù)據(jù)庫,并利用tp5.1作為后臺框架,通過layui作為前端框架,實現(xiàn)網(wǎng)站的前臺展示和后臺界面管理。代碼如下:控制器類:index.php:<?php namespace app\index\controller; use app\admin\mode

通過本章的學習,完成了前臺模塊。學完本章后,整個企業(yè)站的項目實戰(zhàn)課程已結課,通過本套實踐課程的學習,已經(jīng)能過通過搭建后臺數(shù)據(jù)庫,并利用tp5.1作為后臺框架,通過layui作為前端框架,實現(xiàn)網(wǎng)站的前臺展示和后臺界面管理。代碼如下:

控制器類:

index.php:

<?php
namespace app\index\controller;

use app\admin\model\news\NewsModel;
use app\admin\model\product\ProductModel;
use app\admin\model\slide\SlideModel;
use app\admin\model\system\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;
        // 查詢新上花魁
        $NewProduct = $product->where('sort','2')->limit(1)->select()->toArray();
        $this->view->NewProduct = $NewProduct;

        // 查詢最新資訊
        $new = new NewsModel();
        $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 NewsModel();
        // 查詢數(shù)據(jù)按照id的順序查詢并且每頁四條數(shù)據(jù)
        $news = $new->order('id','desc')->paginate(4);
        // 給模板繼續(xù)賦值
        $this->view->news=$news;

        $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 ConNew()
    {
        $newId = Request::param('id');
        // 通過id查詢對應的新聞詳細
        $new = NewsModel::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()
    {
        // 獲取產(chǎn)品id
        $ProId = Request::param('id');
        $product = ProductModel::get($ProId);
        $this->view->product=$product;
        // 渲染模板
        return $this->fetch();
    }

}

效果圖:

QQ截圖20190531165249.png

QQ截圖20190531165301.png

QQ截圖20190531165311.png

QQ截圖20190531165322.png

?? ???:天蓬老師?? ??:2019-06-01 14:18:13
???? ??:做過了一個完整的項目, 就會對流程有了一個大致的了解了.............

??? ??

?? ??