内容模块前端完善

This commit is contained in:
2020-04-16 16:53:44 +08:00
parent 521a678a22
commit c005714ea8
6 changed files with 239 additions and 8 deletions

View File

@@ -8,17 +8,39 @@
// +----------------------------------------------------------------------
namespace app\controller\front;
use think\facade\Db;
use \app\model\Category;
use \app\model\Model;
use \app\model\Content as ContentModel;
class Content extends Base {
public $modelInfo = [];
public $model = null;
/**
* @title 内容频道页
* @return [type] [description]
*/
public function index() {
$param = $this->request->param();
$this->setModel();
$order = "id desc";
$map = [];
if (isset($param['keyword']) && $param['keyword'] != '') {
$map[] = ['title', 'LIKE', '%'.$param['keyword'].'%'];
}
$category = Category::where('model_id', $this->modelInfo['id'])->column("*", "id");
$list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig);
$this->data = [
'model' => $this->modelInfo,
'category' => $category,
'list' => $list,
'page' => $list->render()
];
return $this->fetch();
}
@@ -27,6 +49,60 @@ class Content extends Base {
* @return [type] [description]
*/
public function lists() {
$param = $this->request->param();
$this->setModel();
$order = "id desc";
$map = [];
$category = Category::where('model_id', $this->modelInfo['id'])->column("*", "id");
$ids = (new \sent\tree\Tree())->getChilds($category, (int) $param['id']);
array_push($ids, (int) $param['id']);
$map[] = ['category_id', "IN", $ids];
if (isset($param['keyword']) && $param['keyword'] != '') {
$map[] = ['title', 'LIKE', '%'.$param['keyword'].'%'];
}
$list = $this->model->where($map)->order($order)->paginate($this->request->pageConfig);
$this->data = [
'model' => $this->modelInfo,
'id' => (int) $param['id'],
'category' => $category,
'list' => $list,
'page' => $list->render()
];
return $this->fetch();
}
/**
* @title 内容详情
* @return [type] [description]
*/
public function detail() {
$param = $this->request->param();
$this->setModel();
$map[] = ['id', "=", $param['id']];
$detail = $this->model->where($map)->find();
$pmap = [
['category_id', '=', $detail['category_id']],
['id', '<', $param['id']]
];
$prev = Db::name(ucfirst($this->modelInfo['name']))->where($pmap)->order('id desc')->find();
$nmap = [
['category_id', '=', $detail['category_id']],
['id', '>', $param['id']]
];
$next = Db::name(ucfirst($this->modelInfo['name']))->where($nmap)->order('id asc')->find();
$this->data = [
'model' => $this->modelInfo,
'info' => $detail,
'prev' => $prev,
'next' => $next
];
return $this->fetch();
}
@@ -43,15 +119,21 @@ class Content extends Base {
* @return [type] [description]
*/
public function search() {
return $this->fetch();
}
$param = $this->request->param();
$list = [];
if (isset($param['keyword']) && $param['keyword'] != '') {
$map[] = ['title', 'LIKE', '%'.$param['keyword'].'%'];
}
/**
* @title 内容详情
* @return [type] [description]
*/
public function detail() {
$this->data = [
"list" => $list
];
return $this->fetch();
}
protected function setModel(){
$this->modelInfo = Model::where('name', $this->request->param('name'))->find()->append(['grid_list', 'attr_group'])->toArray();
$this->model = Db::name($this->modelInfo['name']);
}
}

View File

@@ -0,0 +1,37 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SentCMS网站管理系统</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<style>
html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0;}
.top{text-align: right; line-height: 35px; padding: 0 20px;}
.top a{color: #333333; padding: 0 10px}
.full-height {height: 90vh;}
.flex-center {align-items: center;display: flex;justify-content: center;}
.position-ref {position: relative;}
.top-right {position: absolute;right: 10px;top: 18px;}
.content {text-align: center;}
.title {font-size: 84px;}
.links > a {color: #636b6f;padding: 0 25px; font-size: 12px;font-weight: 600;letter-spacing: .1rem;text-decoration: none;text-transform: uppercase;}
.m-b-md {margin-bottom: 30px;}
</style>
</head>
<body>
<div class="top">
<a href="{:url('/user/index/register')}">注册</a>
<a href="{:url('/user/index/login')}">登录</a>
</div>
<div class="flex-center position-ref full-height">
<div class="content">
{$info['title']}
<p>{$info['create_time']|time_format}</p>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,37 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SentCMS网站管理系统</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<style>
html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0;}
.top{text-align: right; line-height: 35px; padding: 0 20px;}
.top a{color: #333333; padding: 0 10px}
.full-height {height: 90vh;}
.flex-center {align-items: center;display: flex;justify-content: center;}
.position-ref {position: relative;}
.top-right {position: absolute;right: 10px;top: 18px;}
.content {text-align: center;}
.title {font-size: 84px;}
.links > a {color: #636b6f;padding: 0 25px; font-size: 12px;font-weight: 600;letter-spacing: .1rem;text-decoration: none;text-transform: uppercase;}
.m-b-md {margin-bottom: 30px;}
</style>
</head>
<body>
<div class="top">
<a href="{:url('/user/index/register')}">注册</a>
<a href="{:url('/user/index/login')}">登录</a>
</div>
<div class="flex-center position-ref full-height">
<div class="content">
{$model['title']}频道
<p>{:print_r($model)}</p>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,40 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SentCMS网站管理系统</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<style>
html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0;}
.top{text-align: right; line-height: 35px; padding: 0 20px;}
.top a{color: #333333; padding: 0 10px}
.full-height {height: 90vh;}
.flex-center {align-items: center;display: flex;justify-content: center;}
.position-ref {position: relative;}
.top-right {position: absolute;right: 10px;top: 18px;}
.content {text-align: center;}
.title {font-size: 84px;}
.links > a {color: #636b6f;padding: 0 25px; font-size: 12px;font-weight: 600;letter-spacing: .1rem;text-decoration: none;text-transform: uppercase;}
.m-b-md {margin-bottom: 30px;}
</style>
</head>
<body>
<div class="top">
<a href="{:url('/user/index/register')}">注册</a>
<a href="{:url('/user/index/login')}">登录</a>
</div>
<div class="flex-center position-ref full-height">
<div class="content">
<ul>
{volist name="list" id="item"}
<li><a href="{:url('/'.$model['name'].'/detail-'.$item['id'])}">{$item['title']}</a></li>
{/volist}
</ul>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,35 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SentCMS网站管理系统</title>
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">
<!-- Styles -->
<style>
html, body {background-color: #fff; color: #636b6f; font-family: 'Raleway', sans-serif; font-weight: 100; height: 100vh; margin: 0;}
.top{text-align: right; line-height: 35px; padding: 0 20px;}
.top a{color: #333333; padding: 0 10px}
.full-height {height: 90vh;}
.flex-center {align-items: center;display: flex;justify-content: center;}
.position-ref {position: relative;}
.top-right {position: absolute;right: 10px;top: 18px;}
.content {text-align: center;}
.title {font-size: 84px;}
.links > a {color: #636b6f;padding: 0 25px; font-size: 12px;font-weight: 600;letter-spacing: .1rem;text-decoration: none;text-transform: uppercase;}
.m-b-md {margin-bottom: 30px;}
</style>
</head>
<body>
<div class="top">
<a href="{:url('/user/index/register')}">注册</a>
<a href="{:url('/user/index/login')}">登录</a>
</div>
<div class="flex-center position-ref full-height">
<div class="content">
</div>
</div>
</body>
</html>

View File

@@ -16,7 +16,7 @@ $model = Model::where('status', '>', 0)->field(['id', 'name'])->select()->toArra
foreach ($model as $value) {
Route::rule('/admin/' . $value['name'] . '/:function', 'admin.content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
Route::rule($value['name'] . '/index', 'front.content/index')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
Route::rule($value['name'] . '/list/[:id]', 'front.content/lists')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
Route::rule($value['name'] . '/list/:id', 'front.content/lists')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
Route::rule($value['name'] . '/detail-:id', 'front.content/detail')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
Route::rule('/user/' . $value['name'] . '/:function', 'user.content/:function')->append(['name'=>$value['name'], 'model_id' => $value['id']]);
}