articel coment zan

This commit is contained in:
toogee 2020-09-24 17:16:18 +08:00
parent 6fd4c19a4d
commit 13ca055f74

View File

@ -81,8 +81,8 @@ class Comment extends BaseController
$data['user_id'] = session('user_id'); $data['user_id'] = session('user_id');
//查询是否已存在点赞 //查询是否已存在点赞
$zan = UserZan::where(['comment_id'=>input('post.id'),'user_id'=>session('user_id')])->find(); $zan = UserZan::where(['comment_id'=>input('post.id'),'user_id'=>session('user_id')])->find();
Session::set('ok',$zan['comment_id']);
if(!$zan ){ //如果没有点过赞执行点赞操作 if(!$zan){ //如果没有点过赞执行点赞操作
$coms = CommentModel::find(input('post.id')); $coms = CommentModel::find(input('post.id'));
if($coms['user_id'] == session('user_id')){ if($coms['user_id'] == session('user_id')){
$res = ['msg' => '不能给自己点赞哦']; $res = ['msg' => '不能给自己点赞哦'];
@ -97,6 +97,7 @@ class Comment extends BaseController
} }
} }
} else { } else {
Session::set('ok',$zan['comment_id']);
$res = ['status'=>-1,'msg' => '你已赞过了']; $res = ['status'=>-1,'msg' => '你已赞过了'];
} }
return json($res); return json($res);