diff --git a/app/portal/controller/PrizeController.php b/app/portal/controller/PrizeController.php index 07a1583..b949419 100644 --- a/app/portal/controller/PrizeController.php +++ b/app/portal/controller/PrizeController.php @@ -73,40 +73,9 @@ class PrizeController extends WeChatBaseController $this->assign('list',$data); return $this->fetch('active_detail'); } - public function comment(){ - $this->checkUser(); - $id=$this->request->param('id'); - $this->assign('id',$id); - return $this->fetch(); - } - public function commentPost(){ - $re=$this->checkUser(); - $param=$this->request->param(); - $param['create_time']=time(); - $param['status']=2; - $param['users_id']=$re['id']; - $result=Db::name('comment')->where(['users_id'=>$param['users_id'],'status'=>2,'cid'=>$param['cid']])->find(); - if ($result){ - return 2; - } - $re1=Db::name('comment')->insert($param); - $re2=Db::name('active')->where('id',$param['cid'])->setInc('comment',1); - if ($re1 && $re2) { - $url = url('portal/active/activeDetail', array('id' => $param['cid'])); - return $url; - }else{ - return 0; - } - } - //点赞ajax接口 - public function like(){ - $re=$this->checkUser(); - $param=$this->request->param(); - $like=new LikeService(); - return $like->like($param['id'],2,$re['id']); - } + @@ -173,6 +142,41 @@ class PrizeController extends WeChatBaseController $this->assign('list',$data); return $this->fetch('prize_detail'); } + //点赞ajax接口 + public function like(){ + $re=$this->checkUser(); + $param=$this->request->param(); + $like=new LikeService(); + return $like->like($param['id'],3,$re['id']); + } + public function comment(){ + $this->checkUser(); + $id=$this->request->param('id'); + $this->assign('id',$id); + return $this->fetch(); + } + + public function commentPost(){ + $re=$this->checkUser(); + $param=$this->request->param(); + $param['create_time']=time(); + $param['status']=3; + $param['users_id']=$re['id']; + $result=Db::name('comment')->where(['users_id'=>$param['users_id'],'status'=>3,'cid'=>$param['cid']])->find(); + if ($result){ + return 2; + } + $re1=Db::name('comment')->insert($param); + $re2=Db::name('prize')->where('id',$param['cid'])->setInc('comment',1); + if ($re1 && $re2) { + $url = url('portal/prize/prizeDetail', array('id' => $param['cid'])); + return $url; + }else{ + return 0; + } + } + + diff --git a/public/themes/simpleboot3/portal/active/active_detail.html b/public/themes/simpleboot3/portal/active/active_detail.html index 64ba410..0425c72 100644 --- a/public/themes/simpleboot3/portal/active/active_detail.html +++ b/public/themes/simpleboot3/portal/active/active_detail.html @@ -287,10 +287,6 @@ }) - //评论留言 - $(".comment").click(function(){ - window.location.href='writeevalute.html' - }) //点赞 $(".praise").click(function(){ $.ajax({ diff --git a/public/themes/simpleboot3/portal/prize/prize_detail.html b/public/themes/simpleboot3/portal/prize/prize_detail.html index 84f3926..056eec8 100644 --- a/public/themes/simpleboot3/portal/prize/prize_detail.html +++ b/public/themes/simpleboot3/portal/prize/prize_detail.html @@ -401,22 +401,32 @@ } }) - //评论留言 - $(".comment").click(function(){ - window.location.href='writeevalute.html' - }) - //立即兑换 - $(".right_now").click(function(){ - window.location.href='uploadticket.html' - }) //点赞 - $(".discuss").click(function(){ - window.event.stopPropagation(); - var num=$(".commentnum").html(); - num++; - - $(".commentnum").html(num) + $(".praise").click(function(){ + $.ajax({ + url: "{:url('portal/prize/like')}", + type: "post", + data: { + id:"{$list.id}", + }, + success: function (data) { + if (data==1){ + alert('点赞成功') + window.event.stopPropagation(); + var num=$(".commentnum").html(); + num++; + $(".commentnum").html(num) + } + else if (data==2){ + alert('取消点赞成功') + window.event.stopPropagation(); + var num=$(".commentnum").html(); + num--; + $(".commentnum").html(num) + } + } + }) }) </script> </body>