国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

前臺(tái)模塊的實(shí)現(xiàn)

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

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

控制器類:

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()
    {
        // 實(shí)例化模型
        $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查詢對(duì)應(yīng)的新聞詳細(xì)
        $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

Correcting teacher:天蓬老師Correction time:2019-06-01 14:18:13
Teacher's summary:做過了一個(gè)完整的項(xiàng)目, 就會(huì)對(duì)流程有了一個(gè)大致的了解了.............

Release Notes

Popular Entries