222.png
_menu.html
<aside class="Hui-aside">
<div class="menu_dropdown bk_2">
<dl id="menu-article">
<dt><i class="Hui-iconfont"></i> 娱乐新闻管理<i class="Hui-iconfont menu_dropdown-arrow"></i></dt>
<dd>
<ul>
<li><a data-href="{:url('news/add')}" data-title="添加管理" href="javascript:void(0)">添加管理</a></li>
<li><a data-href="{:url('news/index')}" data-title="内容管理" href="javascript:void(0)">内容管理</a></li>
</ul>
</dd>
</dl>
<dl id="menu-article">
<dt><i class="Hui-iconfont"></i> 用户管理<i class="Hui-iconfont menu_dropdown-arrow"></i></dt>
<dd>
<ul>
<li><a data-href="{:url('admin/add')}" data-title="添加用户" href="javascript:void(0)">添加用户</a></li>
</ul>
</dd>
</dl>
</div>
</aside>
<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a>
</div>
News.php(Model)
<?php
/**
* Created by PhpStorm.
* User: tong
* Date: 2017/11/7
* Time: 15:28
*/
namespace app\common\model;
class News extends Base
{
/**
* 后台自动化分页
* @param array $data
* @return array
*/
public function getNews($data = [])
{
$data['status'] = [
'neq', config('code.status_delete')
];
$order = ['id' => 'desc'];
$result = $this->where($data)
->order($order)
->paginate();
return $result;
}
}
config.php
'paginate' => [
'type' => 'bootstrap',
'var_page' => 'page',
'list_rows' => 3,
],
News.php(Controller)
<?php
/**
* Created by PhpStorm.
* User: tong
* Date: 2017/11/6
* Time: 17:42
*/
namespace app\admin\controller;
use function Sodium\add;
class News extends Base
{
public function index()
{
//获取数据 然后把数据填充到模板
$news = model('News')->getNews();
return $this->fetch('', [
'news' => $news,
]);
}
public function add()
{
if (request()->isPost()) {
$data = input('post.');
/**
* array (size=9)
* 'title' => string 'sdsdsd' (length=6)
* 'small_title' => string 'dfdfd' (length=5)
* 'catid' => string '1' (length=1)
* 'description' => string 'fdfdfdfd' (length=8)
* 'is_allowcomments' => string '' (length=0)
* 'is_head_figure' => string '' (length=0)
* 'is_position' => string '' (length=0)
* 'image' => string '' (length=0)
* 'content' => string '<p>dfdfdfdfdfd</p>dfdfdfdfd_ueditor_page_break_tag_<p><br/></p>' (length=63)
*/
//halt($data);
//数据检验 自行完成
try {
$id = model('News')->add($data);
} catch (\Exception $e) {
return $this->result('', 0, '新增失败:' . $e->getMessage());
}
if ($id) {
return $this->result(['jump_url' => url('news/index')], 1, 'OK');
} else {
return $this->result('', 0, '新增失败');
}
} else {
return $this->fetch('', [
'cats' => config('cat.list')
]);
}
}
}
common.php
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
// 应用公共文件
function pagination($obj)
{
if (!$obj) {
return '';
}
$params = request()->param();
return '<div class="imooc-app">' . $obj->appends($params)->render() . '</div>';
}
/**
* 获取栏目名称
* @param $catId
*/
function getCatName($catId)
{
if (!$catId) {
return '';
}
$cats = config('cat.list');
return !empty($cats[$catId]) ? $cats[$catId] : '';
}
function isYesNo($str)
{
return $str ? '<span style="color:red">是</span>' : '<span >否</span>';
}
index.php
<!--header-->
{include file="public/_meta" title="娱乐资讯"/}
<nav class="breadcrumb"><i class="Hui-iconfont"></i> 首页 <span class="c-gray en">></span> 资讯管理 <span class="c-gray en">></span> 资讯列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont"></i></a></nav>
<div class="page-container">
<div class="text-c">
<form action="" method="get">
<span class="select-box inline">
<select name="catid" class="select">
<option value="0">全部分类</option>
<option value="" ></option>
</select>
</span> 日期范围:
<input type="text" name="start_time" class="input-text" id="countTimestart" onfocus="selecttime(1)" value="" style="width:120px;" >
-
<input type="text" name="end_time" class="input-text" id="countTimestart" onfocus="selecttime(1)" value="" style="width:120px;">
<input type="text" name="title" id="" value="" placeholder=" 资讯名称" style="width:250px" class="input-text">
<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont"></i> 搜资讯</button>
</form>
</div>
<div class="mt-20">
<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive" >
<thead>
<tr class="text-c">
<th width="25"><input type="checkbox" name="" value=""></th>
<th width="80">ID</th>
<th>标题</th>
<th width="80">分类</th>
<th width="80">缩图</th>
<th width="120">更新时间</th>
<th width="40">是否推荐</th>
<th width="60">发布状态</th>
<th width="120">操作</th>
</tr>
</thead>
<tbody>
{volist name="news" id="vo"}
<tr class="text-c">
<td><input type="checkbox" value="" name=""></td>
<td>{$vo.id}</td>
<td class="text-l"><u style="cursor:pointer" class="text-primary" title="查看">{$vo.title}</u></td>
<td>{$vo.catid|getCatName}</td>
<td><img width="60" height="60" class="picture-thumb" src="{$vo.image}"></td>
<td>{$vo.update_time}</td>
<td>{$vo.is_position|isYesNo}</td>
<td class="td-status">{$vo.is_position}</td>
<td class="f-14 td-manage"> <a style="text-decoration:none" class="ml-5" onClick="article_edit('资讯编辑','article-add.html','10001')" href="javascript:;" title="编辑"><i class="Hui-iconfont"></i></a> <a style="text-decoration:none" class="ml-5" onClick="" href="javascript:;" title="删除" del_url=""><i class="Hui-iconfont"></i></a></td>
</tr>
{/volist}
</tbody>
</table>
<div id="laypage"></div>
</div>
{:pagination($news)}
</div>
<!--header-->
{include file="public/_footer" /}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/hadmin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/hadmin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
</script>
<style>
.imooc-app .pagination li{display:inline; padding-left:10px;}
.pagination .active{color:red}
.pagination .disabled{color:#888888}
</style>
</body>
</html>
{volist name="news" id="vo"}
<tr class="text-c">
<td><input type="checkbox" value="" name=""></td>
<td>{$vo.id}</td>
<td class="text-l"><u style="cursor:pointer" class="text-primary" title="查看">{$vo.title}</u></td>
<td>{$vo.catid|getCatName}</td>
<td><img width="60" height="60" class="picture-thumb" src="{$vo.image}"></td>
<td>{$vo.update_time}</td>
<td>{$vo.is_position|isYesNo}</td>
<td class="td-status">{$vo.is_position}</td>
<td class="f-14 td-manage"> <a style="text-decoration:none" class="ml-5" onClick="article_edit('资讯编辑','article-add.html','10001')" href="javascript:;" title="编辑"><i class="Hui-iconfont"></i></a> <a style="text-decoration:none" class="ml-5" onClick="" href="javascript:;" title="删除" del_url=""><i class="Hui-iconfont"></i></a></td>
</tr>
{/volist}
{:pagination($news)}
222.png
网友评论