admin home
This commit is contained in:
parent
5476ebf681
commit
37967a491e
@ -43,6 +43,60 @@ class Index extends AdminController
|
||||
View::assign(['sys'=>$sys,'day'=>$days,'hos'=>$hos,'mins'=>$mins]);
|
||||
return View::fetch();
|
||||
}
|
||||
//
|
||||
public function forums()
|
||||
{
|
||||
$forumList = Db::name('article')
|
||||
->alias('a')
|
||||
->join('user u','a.user_id = u.id')
|
||||
->join('cate c','a.cate_id = c.id')
|
||||
->field('a.id as aid,title,name,catename,pv')
|
||||
->whereWeek('a.create_time')
|
||||
->order('a.create_time', 'desc')
|
||||
->paginate(10);
|
||||
$res = [];
|
||||
$count = $forumList->total();
|
||||
if($count){
|
||||
$res['code'] = 0;
|
||||
$res['msg'] = '';
|
||||
$res['count'] = $count;
|
||||
foreach($forumList as $k=>$v){
|
||||
$res['data'][]= ['id'=>$v['aid'],'title'=>$v['title'],'name'=>$v['name'],'catename'=>$v['catename'],'pv'=>$v['pv']];
|
||||
}
|
||||
} else {
|
||||
$res = ['code'=>-1,'msg'=>'本周还没有发帖!'];
|
||||
}
|
||||
return json($res);
|
||||
}
|
||||
|
||||
//帖子评论
|
||||
public function replys()
|
||||
{
|
||||
if(Request::isAjax()) {
|
||||
|
||||
$replys = Db::name('comment')
|
||||
->alias('a')
|
||||
->join('user u','a.user_id = u.id')
|
||||
->join('article c','a.article_id = c.id')
|
||||
->field('a.content as content,title,c.id as cid,name')
|
||||
->whereWeek('a.create_time')
|
||||
->order('a.create_time', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
$count = $replys->total();
|
||||
$res = [];
|
||||
if ($count) {
|
||||
$res = ['code'=>0,'msg'=>'','count'=>$count];
|
||||
foreach($replys as $k => $v){
|
||||
$res['data'][] = ['content'=>$v['content'],'title'=>$v['title'],'cid'=>$v['cid'],'name'=>$v['name']];
|
||||
}
|
||||
} else {
|
||||
$res = ['code'=>-1,'msg'=>'本周还没评论'];
|
||||
}
|
||||
return json($res);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function layout(){
|
||||
|
@ -200,8 +200,7 @@ class Article extends BaseController
|
||||
$validate = new \app\common\validate\Article(); //调用验证器
|
||||
$res = $validate->scene('Artadd')->check($data); //进行数据验证
|
||||
|
||||
if(true !==$res){
|
||||
//echo '<script>alert("'.$res.'");location.back()</script>';
|
||||
if(true !==$res){
|
||||
return $this->error($validate->getError());
|
||||
} else {
|
||||
$article = new \app\common\model\Article();
|
||||
@ -240,47 +239,13 @@ class Article extends BaseController
|
||||
return json($res);
|
||||
}
|
||||
|
||||
//添加文章和编辑页富文本编辑器图片上传
|
||||
public function lay_img_upload()
|
||||
{
|
||||
$file = Request()->file('file');
|
||||
if(empty($file)){
|
||||
$result["code"] = "1";
|
||||
$result["msg"] = "请选择图片";
|
||||
$result['data']["src"] = '';
|
||||
}else{
|
||||
// 移动到框架应用根目录/public/uploads/ 目录下
|
||||
$info = $file->move('uploads/' );
|
||||
if($info){
|
||||
$infos = $info->getInfo();
|
||||
// 源文件名
|
||||
$name = $infos['name'];
|
||||
|
||||
$name_path =str_replace('\\',"/",$info->getSaveName());
|
||||
//成功上传后 获取上传信息
|
||||
$result["code"] = '0';
|
||||
$result["msg"] = "上传成功";
|
||||
$result['data']["src"] = "/uploads/".$name_path;
|
||||
$result['data']["title"] = $name;
|
||||
}else{
|
||||
// 上传失败获取错误信息
|
||||
$result["code"] = "2";
|
||||
$result["msg"] = "上传出错";
|
||||
$result['data']["src"] ='';
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($result);
|
||||
|
||||
}
|
||||
|
||||
//文本编辑器图片上传
|
||||
public function text_img_upload()
|
||||
{
|
||||
$file = request()->file('file');
|
||||
try {
|
||||
validate(['file'=>'fileSize:2048|fileExt:jpg,png,gif'])
|
||||
->check(array($file));
|
||||
->check(['file'=>$file]);
|
||||
$savename = \think\facade\Filesystem::disk('public')->putFile('article_pic',$file);
|
||||
} catch (ValidateException $e) {
|
||||
echo $e->getMessage();
|
||||
@ -305,26 +270,22 @@ class Article extends BaseController
|
||||
//文章置顶,状态
|
||||
public function jieset(){
|
||||
$data = Request::param();
|
||||
$article = ArticleModel::find($data['id']);
|
||||
$article = ArticleModel::field('id,is_top,is_hot')->find($data['id']);
|
||||
if($data['field'] === 'top') {
|
||||
if($data['rank']==1){
|
||||
$article->save(['is_top' => 1]);
|
||||
$res['status'] = 0;
|
||||
$res['msg'] ='置顶成功';
|
||||
$res = ['status'=>0,'msg'=>'置顶成功'];
|
||||
} else {
|
||||
$article->save(['is_top' => 0]);
|
||||
$res['status'] = 0;
|
||||
$res['msg'] ='已取消置顶';
|
||||
$res = ['status'=>0,'msg'=>'已取消置顶'];
|
||||
}
|
||||
} else {
|
||||
if($data['rank']==1){
|
||||
$article->save(['is_hot' => 1]);
|
||||
$res['status'] = 0;
|
||||
$res['msg'] ='已设精贴';
|
||||
$res = ['status'=>0,'msg'=>'已设精贴'];
|
||||
} else {
|
||||
$article->save(['is_hot' => 0]);
|
||||
$res['status'] = 0;
|
||||
$res['msg'] ='精贴已取消';
|
||||
$res = ['status'=>0,'msg'=>'精贴已取消'];
|
||||
}
|
||||
}
|
||||
return json($res);
|
||||
|
@ -61,7 +61,7 @@ class Comment extends BaseController
|
||||
return json($res);
|
||||
}
|
||||
|
||||
//更新评论
|
||||
//更新评论
|
||||
public function updateDa()
|
||||
{
|
||||
$this->isLogin();
|
||||
@ -103,7 +103,7 @@ class Comment extends BaseController
|
||||
}
|
||||
|
||||
} else {
|
||||
return $res=['msg' => '你已赞过了'];
|
||||
return $res=['status'=>1,'msg' => '你已赞过了'];
|
||||
}
|
||||
}
|
||||
}
|
@ -188,32 +188,34 @@ layui.define(function(exports){
|
||||
var $ = layui.$
|
||||
,table = layui.table;
|
||||
|
||||
//今日热搜
|
||||
//本周发贴
|
||||
table.render({
|
||||
elem: '#LAY-index-topSearch'
|
||||
,url: layui.setter.base + 'json/console/top-search.js' //模拟接口
|
||||
,page: true
|
||||
,cols: [[
|
||||
{type: 'numbers', fixed: 'left'}
|
||||
,{field: 'keywords', title: '关键词', minWidth: 300, templet: '<div><a href="https://www.baidu.com/s?wd={{ d.keywords }}" target="_blank" class="layui-table-link">{{ d.keywords }}</div>'}
|
||||
,{field: 'frequency', title: '搜索次数', minWidth: 120, sort: true}
|
||||
,{field: 'userNums', title: '用户数', sort: true}
|
||||
]]
|
||||
,skin: 'line'
|
||||
});
|
||||
|
||||
//今日热贴
|
||||
table.render({
|
||||
elem: '#LAY-index-topCard'
|
||||
,url: layui.setter.base + 'json/console/top-card.js' //模拟接口
|
||||
,url: '/admin/index/forums' //模拟接口
|
||||
,page: true
|
||||
,cellMinWidth: 120
|
||||
,cols: [[
|
||||
{type: 'numbers', fixed: 'left'}
|
||||
,{field: 'title', title: '标题', minWidth: 300, templet: '<div><a href="{{ d.href }}" target="_blank" class="layui-table-link">{{ d.title }}</div>'}
|
||||
,{field: 'username', title: '发帖者'}
|
||||
,{field: 'channel', title: '类别'}
|
||||
,{field: 'crt', title: '点击率', sort: true}
|
||||
,{field: 'title', title: '标题', minWidth: 300, templet: '<div><a href="/index/jie/{{d.id}}.html" target="_blank" class="layui-table-link">{{ d.title }}</div>'}
|
||||
,{field: 'name', title: '发帖者'}
|
||||
,{field: 'catename', title: '类别'}
|
||||
,{field: 'pv', title: '点击率', sort: true}
|
||||
]]
|
||||
,skin: 'line'
|
||||
});
|
||||
|
||||
//本周评论
|
||||
table.render({
|
||||
elem: '#LAY-index-topCard'
|
||||
,url: '/admin/index/replys' //模拟接口
|
||||
,page: true
|
||||
,cellMinWidth: 120
|
||||
,cols: [[
|
||||
{type: 'numbers', fixed: 'left'}
|
||||
,{field: 'content', title: '评论'}
|
||||
,{field: 'title', title: '帖子', minWidth: 300, templet: '<div><a href="/index/jie/{{d.cid}}.html" target="_blank" class="layui-table-link">{{ d.title }}</div>'}
|
||||
,{field: 'name', title: '评论者'}
|
||||
|
||||
]]
|
||||
,skin: 'line'
|
||||
});
|
||||
|
@ -14,49 +14,49 @@
|
||||
<div carousel-item>
|
||||
<ul class="layui-row layui-col-space10">
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="home/homepage1.html">
|
||||
<i class="layui-icon layui-icon-console"></i>
|
||||
<cite>主页一</cite>
|
||||
<a lay-href="{:url('admin/forum/list')}">
|
||||
<i class="layui-icon layui-icon-list"></i>
|
||||
<cite>帖子</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="home/homepage2.html">
|
||||
<i class="layui-icon layui-icon-chart"></i>
|
||||
<cite>主页二</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="component/layer/list.html">
|
||||
<i class="layui-icon layui-icon-template-1"></i>
|
||||
<cite>弹层</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a layadmin-event="im">
|
||||
<i class="layui-icon layui-icon-chat"></i>
|
||||
<cite>聊天</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="component/progress/index.html">
|
||||
<i class="layui-icon layui-icon-find-fill"></i>
|
||||
<cite>进度条</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="app/workorder/list.html">
|
||||
<a lay-href="{:url('admin/forum/replys')}">
|
||||
<i class="layui-icon layui-icon-survey"></i>
|
||||
<cite>工单</cite>
|
||||
<cite>评论</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="user/user/list.html">
|
||||
<a lay-href="{:url('admin/forum/tags')}">
|
||||
<i class="layui-icon layui-icon-template-1"></i>
|
||||
<cite>分类</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/Admin/repass')}">
|
||||
<i class="layui-icon layui-icon-password"></i>
|
||||
<cite>密码</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/slider/index')}">
|
||||
<i class="layui-icon layui-icon-dollar"></i>
|
||||
<cite>广告</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/Admin/info')}">
|
||||
<i class="layui-icon layui-icon-form"></i>
|
||||
<cite>资料</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="{:url('admin/User/list')}">
|
||||
<i class="layui-icon layui-icon-user"></i>
|
||||
<cite>用户</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="set/system/website.html">
|
||||
<a lay-href="{:url('admin/set/website')}">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
<cite>设置</cite>
|
||||
</a>
|
||||
@ -64,49 +64,7 @@
|
||||
</ul>
|
||||
<ul class="layui-row layui-col-space10">
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="set/user/info.html">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
<cite>我的资料</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="set/user/info.html">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
<cite>我的资料</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="set/user/info.html">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
<cite>我的资料</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="set/user/info.html">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
<cite>我的资料</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="set/user/info.html">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
<cite>我的资料</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="set/user/info.html">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
<cite>我的资料</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="set/user/info.html">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
<cite>我的资料</cite>
|
||||
</a>
|
||||
</li>
|
||||
<li class="layui-col-xs3">
|
||||
<a lay-href="set/user/info.html">
|
||||
<a lay-href="">
|
||||
<i class="layui-icon layui-icon-set"></i>
|
||||
<cite>我的资料</cite>
|
||||
</a>
|
||||
@ -183,8 +141,8 @@
|
||||
<div class="layui-card">
|
||||
<div class="layui-tab layui-tab-brief layadmin-latestData">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">今日热搜</li>
|
||||
<li>今日热帖</li>
|
||||
<li class="layui-this">今周发帖</li>
|
||||
<li>今周评论</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
|
Loading…
Reference in New Issue
Block a user