Index.php 1.6 KB
<?php

namespace app\index\controller;

use app\common\controller\Frontend;
use app\common\library\Token;
use function GuzzleHttp\uri_template;
use think\Db;
class Index extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';
    protected $limit = 10;
    protected $page = 1;

    public function _initialize()
    {
        parent::_initialize();
    }

    public function index()
    {
        return $this->view->fetch();
    }

    public function news()
    {
        //新闻列表
        $news = Db::name('news')
            ->page($this->page,$this->limit)
            ->order('weigh','desc')
            ->select();
        $hot = Db::name('news')
            ->where(['flag'=>'hot'])
            ->limit($this->limit)
            ->order('weigh','desc')
            ->select();
        $this->assign('hot',$hot);
        $this->assign('list',$news);
        return $this->fetch();
    }

    public function loadNews(){
        $data = Db::name('news')
            ->order('weigh','desc')
            ->select();
        foreach($data as &$v){
            $v['createtime'] = date('Y-m-d',$v['createtime']);
        }
        echo json_encode($data);
    }

    public function map()
    {
        return $this->view->fetch();
    }

    public function course()
    {
        return $this->view->fetch();
    }

    public function contact()
    {
        return $this->view->fetch();
    }

    public function business()
    {
        return $this->view->fetch();
    }

    public function about()
    {
        return $this->view->fetch();
    }

}