更新前端
This commit is contained in:
parent
3f7b87cdb5
commit
f8257144cb
@ -11,6 +11,7 @@ use think\facade\Config;
|
||||
|
||||
use think\exception\HttpResponseException;
|
||||
use think\facade\Request;
|
||||
use app\index\model\User;
|
||||
|
||||
class Base
|
||||
{
|
||||
@ -36,7 +37,7 @@ class Base
|
||||
# 获取用户信息
|
||||
$this->userId = Cookie::get('user_id');
|
||||
if (!empty($this->userId)) {
|
||||
$this->user = Db::table('yz_users')->where('uid', $this->userId)->find();
|
||||
$this->user = User::where('uid', $this->userId)->find();
|
||||
}
|
||||
|
||||
View::assign([
|
||||
|
||||
@ -8,6 +8,12 @@ use think\facade\Db;
|
||||
use think\facade\View;
|
||||
use think\facade\Env;
|
||||
use think\facade\Config;
|
||||
use app\index\model\Banner;
|
||||
use app\index\model\ResourceCategory;
|
||||
use app\index\model\ArticleCategory;
|
||||
use app\index\model\Resource;
|
||||
use app\index\model\Article;
|
||||
|
||||
|
||||
class Index extends Base
|
||||
{
|
||||
@ -17,8 +23,7 @@ class Index extends Base
|
||||
public function index()
|
||||
{
|
||||
// 获取banner列表
|
||||
$bannerList = Db::name('yz_banner')
|
||||
->where('delete_time', null)
|
||||
$bannerList = Banner::where('delete_time', null)
|
||||
->order('sort DESC, id DESC')
|
||||
->select()
|
||||
->toArray();
|
||||
@ -33,8 +38,7 @@ class Index extends Base
|
||||
public function siteNewslist()
|
||||
{
|
||||
// 获取站点资讯分类(顶级分类id为1的子分类)
|
||||
$categories = Db::name('yz_article_category')
|
||||
->where('cid', 1)
|
||||
$categories = ArticleCategory::where('cid', 1)
|
||||
->where('delete_time', null)
|
||||
->select()
|
||||
->toArray();
|
||||
@ -50,8 +54,7 @@ class Index extends Base
|
||||
];
|
||||
|
||||
// 获取该分类下的文章,限制4条
|
||||
$articles = Db::name('yz_article')
|
||||
->where('cate', $category['id'])
|
||||
$articles = Article::where('cate', $category['id'])
|
||||
->where('delete_time', null)
|
||||
->where('status', 2)
|
||||
->order('id', 'desc')
|
||||
@ -76,8 +79,7 @@ class Index extends Base
|
||||
public function technicalArticleslist()
|
||||
{
|
||||
// 获取技术文章分类(顶级分类id为3的子分类)
|
||||
$categories = Db::name('yz_article_category')
|
||||
->where('cid', 3)
|
||||
$categories = ArticleCategory::where('cid', 3)
|
||||
->where('delete_time', null)
|
||||
->select()
|
||||
->toArray();
|
||||
@ -95,8 +97,7 @@ class Index extends Base
|
||||
$categoryImageMap[$category['id']] = $category['image'] ?? '';
|
||||
|
||||
// 获取每个分类下的文章,限制12条
|
||||
$articles = Db::name('yz_article')
|
||||
->where('cate', $category['id'])
|
||||
$articles = Article::where('cate', $category['id'])
|
||||
->where('delete_time', null)
|
||||
->where('status', 2)
|
||||
->order('id', 'desc')
|
||||
@ -130,8 +131,7 @@ class Index extends Base
|
||||
public function bannerlist()
|
||||
{
|
||||
// 获取启用状态的banner列表,按排序倒序
|
||||
$bannerList = Db::name('yz_banner')
|
||||
->where('delete_time', null)
|
||||
$bannerList = Banner::where('delete_time', null)
|
||||
->order('sort DESC, id DESC')
|
||||
->select()
|
||||
->toArray();
|
||||
@ -145,8 +145,7 @@ class Index extends Base
|
||||
public function resourcesList()
|
||||
{
|
||||
// 获取资源分类(顶级分类id为2的子分类)
|
||||
$categories = Db::name('yz_resources_category')
|
||||
->where('cid', 2)
|
||||
$categories = ResourceCategory::where('cid', 2)
|
||||
->where('delete_time', null)
|
||||
->select()
|
||||
->toArray();
|
||||
@ -164,8 +163,7 @@ class Index extends Base
|
||||
$categoryImageMap[$category['id']] = $category['image'] ?? '';
|
||||
|
||||
// 获取每个分类下的资源,限制8条
|
||||
$resources = Db::name('yz_resources')
|
||||
->where('cate', $category['id'])
|
||||
$resources = Resource::where('cate', $category['id'])
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->order('id', 'desc')
|
||||
@ -213,8 +211,7 @@ class Index extends Base
|
||||
public function programList()
|
||||
{
|
||||
// 获取程序分类(顶级分类id为4的子分类)
|
||||
$categories = Db::name('yz_resources_category')
|
||||
->where('cid', 1)
|
||||
$categories = ResourceCategory::where('cid', 1)
|
||||
->where('delete_time', null)
|
||||
->select()
|
||||
->toArray();
|
||||
@ -232,8 +229,7 @@ class Index extends Base
|
||||
$categoryImageMap[$category['id']] = $category['image'] ?? '';
|
||||
|
||||
// 获取每个分类下的程序,限制8条
|
||||
$programs = Db::name('yz_resources')
|
||||
->where('cate', $category['id'])
|
||||
$programs = Resource::where('cate', $category['id'])
|
||||
->where('delete_time', null)
|
||||
->where('status', 1)
|
||||
->order('id', 'desc')
|
||||
|
||||
8
app/index/model/Article.php
Normal file
8
app/index/model/Article.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Article extends Model
|
||||
{
|
||||
}
|
||||
8
app/index/model/ArticleCategory.php
Normal file
8
app/index/model/ArticleCategory.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class ArticleCategory extends Model
|
||||
{
|
||||
}
|
||||
8
app/index/model/Banner.php
Normal file
8
app/index/model/Banner.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Banner extends Model
|
||||
{
|
||||
}
|
||||
8
app/index/model/Resource.php
Normal file
8
app/index/model/Resource.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class Resource extends Model
|
||||
{
|
||||
}
|
||||
8
app/index/model/ResourceCategory.php
Normal file
8
app/index/model/ResourceCategory.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class ResourceCategory extends Model
|
||||
{
|
||||
}
|
||||
8
app/index/model/User.php
Normal file
8
app/index/model/User.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace app\index\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user