diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index e4eb217..c30b1eb 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -246,12 +246,13 @@ class Article extends BaseController { $file = request()->file('file'); try { - validate(['file'=>'fileSize:1024000|fileExt:jpg,png,gif']) + validate(['file'=>['fileExt'=>['jpg','jpeg','png']]]) ->check(['file'=>$file]); $savename = \think\facade\Filesystem::disk('public')->putFile('article_pic',$file); } catch (ValidateException $e) { return json(['status'=>-1,'msg'=>$e->getMessage()]); } + $upload = Config::get('filesystem.disks.public.url'); if($savename){ diff --git a/app/index/controller/Collection.php b/app/index/controller/Collection.php index 9676d6e..65331b8 100644 --- a/app/index/controller/Collection.php +++ b/app/index/controller/Collection.php @@ -18,7 +18,10 @@ class Collection extends BaseController public function add(){ //$data = Request::param(); $data['article_id'] = intval(input('cid')); - $data['user_id'] = session::get('user_id'); + $data['user_id'] = $this->uid; + $arts = Article::with(['user'])->field('id,title,user_id')->find($data['article_id']); + $data['collect_title'] = $arts['title']; + $data['auther'] = $arts->user->name; $result = CollectionModel::create($data); if($result){ $res['status'] = 0; @@ -32,9 +35,8 @@ class Collection extends BaseController $cid = input('cid'); $aid = intval($cid); - $user['user_id'] = session::get('user_id'); //$result = CollectionModel::where('cid',$arid)->select(); - $result = Db::name('collection')->where(['article_id' => $aid,'user_id' => $user['user_id']])->delete(); + $result = Db::name('collection')->where(['article_id' => $aid,'user_id' => $this->uid])->delete(); if($result){ $res['status'] = 0; //$res=['type' => 'add','type' => 'remove', 'msg' => '收藏成功']; @@ -47,9 +49,7 @@ class Collection extends BaseController //$cid = Request::param(); $cid = input('cid'); $aid = intval($cid); - $user['user_id'] = session::get('user_id'); - //halt($artid); - $collectData = Db::name('collection')->where(['article_id' => $aid,'user_id' => $user['user_id']])->find(); + $collectData = Db::name('collection')->where(['article_id' => $aid,'user_id' => $this->uid])->find(); if($collectData){ $res['status'] = 0; $res['data']['collection'] = $collectData['article_id']; diff --git a/app/index/controller/User.php b/app/index/controller/User.php index 206e651..d027961 100644 --- a/app/index/controller/User.php +++ b/app/index/controller/User.php @@ -70,11 +70,11 @@ class User extends BaseController $res['data'][] = [ 'id' =>$v['id'], - 'title' => $v->article->title, + 'title' => $v['collect_title'], 'url' => (string) url('article/detail',['id'=>$v['article_id']]), - 'auther' => $v->article->user->name, - 'ctime'=> $v['create_time'], - 'comment' =>$v->article->comments_count, + 'auther' => $v['auther'], + 'status' => is_null(Db::name('article')->field('id')->where('delete_time',0)->find($v['article_id'])) ? '已失效' : '正常', + 'ctime' => $v['create_time'] ]; } diff --git a/app/index/lang/zh-cn.php b/app/index/lang/zh-cn.php index 3d8a486..214faf9 100644 --- a/app/index/lang/zh-cn.php +++ b/app/index/lang/zh-cn.php @@ -50,7 +50,8 @@ return [ 'edit post' => '编辑帖子', 'delete post' => '删除帖子', 'post now' => '立即发布', - 'my collection' => '我的收藏', + 'my collection' => '我的收藏', + 'collection' => '收藏', 'cancel collection' => '取消收藏', 'all' => '综合', 'finished' => '已结', diff --git a/public/static/res/mods/index.js b/public/static/res/mods/index.js index 15826dc..d1200bb 100644 --- a/public/static/res/mods/index.js +++ b/public/static/res/mods/index.js @@ -4,7 +4,7 @@ 2021-5.21 */ -layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util'], function(exports){ +layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util', 'imgcom'], function(exports){ var $ = layui.jquery ,layer = layui.layer @@ -13,8 +13,8 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util'], function( ,element = layui.element ,upload = layui.upload ,util = layui.util + ,imgcom = layui.imgcom ,device = layui.device() - ,DISABLED = 'layui-btn-disabled'; //阻止IE7以下访问 @@ -165,10 +165,12 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util'], function( //执行上传实例 upload.render({ elem: '#uploadImg' + ,accept: 'images' ,acceptMime: 'image/*' ,exts: 'jpg|png|gif|bmp|jpeg' ,url: textImgUpload - ,size: 2048 + ,auto: false + ,size: 10240 ,done: function(res){ if(res.status == 0){ image.val(res.url); @@ -176,6 +178,9 @@ layui.define(['layer', 'laytpl', 'form', 'element', 'upload', 'util'], function( layer.msg(res.msg, {icon: 5}); } } + ,error: function(){ + layer.msg('系统错误,请联系管理员'); + } }); form.on('submit(uploadImages)', function(data){ diff --git a/public/static/res/mods/user.js b/public/static/res/mods/user.js index aff6663..ca1f087 100644 --- a/public/static/res/mods/user.js +++ b/public/static/res/mods/user.js @@ -54,6 +54,7 @@ layui.define(['laypage', 'fly', 'element', 'flow'], function(exports){ {type: 'numbers', fixed: 'left'} ,{field: 'title', title: '标题',minWidth: 250,templet: '
'} ,{field: 'auther', title: '作者', width: 120} + ,{field: 'status', title: '状态', width: 80} ,{field: 'ctime', title: '时间', width: 120} ,{title: '取消', width: 80, align: 'center', toolbar: '#collTool'} ]] diff --git a/view/taoler/index/public/js.html b/view/taoler/index/public/js.html index b9f6dbe..0c4b6dd 100644 --- a/view/taoler/index/public/js.html +++ b/view/taoler/index/public/js.html @@ -1,11 +1,11 @@