收藏优化
This commit is contained in:
parent
d8d6ce1a15
commit
170d146af9
@ -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){
|
||||
|
@ -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'];
|
||||
|
@ -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']
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ return [
|
||||
'delete post' => '删除帖子',
|
||||
'post now' => '立即发布',
|
||||
'my collection' => '我的收藏',
|
||||
'collection' => '收藏',
|
||||
'cancel collection' => '取消收藏',
|
||||
'all' => '综合',
|
||||
'finished' => '已结',
|
||||
|
@ -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){
|
||||
|
@ -54,6 +54,7 @@ layui.define(['laypage', 'fly', 'element', 'flow'], function(exports){
|
||||
{type: 'numbers', fixed: 'left'}
|
||||
,{field: 'title', title: '标题',minWidth: 250,templet: '<div><a href="{{d.url}}" target="_blank">{{d.title}}</a></div>'}
|
||||
,{field: 'auther', title: '作者', width: 120}
|
||||
,{field: 'status', title: '状态', width: 80}
|
||||
,{field: 'ctime', title: '时间', width: 120}
|
||||
,{title: '取消', width: 80, align: 'center', toolbar: '#collTool'}
|
||||
]]
|
||||
|
@ -1,11 +1,11 @@
|
||||
<script>
|
||||
var messageNums = "{:url('index/Message/nums')}",
|
||||
messageRead = "{:url('index/Message/read')}",
|
||||
var messageNums = "{:url('Message/nums')}",
|
||||
messageRead = "{:url('Message/read')}",
|
||||
userMessage = "{:url('index/User/message')}",
|
||||
login = "{:url('Login/index')}",
|
||||
articleAdd = "{:url('Article/add')}",
|
||||
websearch = "{:url('index/index/search')}",
|
||||
textImgUpload = "{:url('index/article/textImgUpload')}",
|
||||
websearch = "{:url('index/search')}",
|
||||
textImgUpload = "{:url('article/textImgUpload')}",
|
||||
searchUrl = "{:url('index/search')}";
|
||||
</script>
|
||||
<script src="/static/layui/jquery.min.js" charset="utf-8"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user