作者 潘浩文
1 个管道 的构建 通过 耗费 0 秒

1

... ... @@ -70,7 +70,7 @@ class BrandController extends WeChatBaseController
$where['b.name']=['like','%'.$param['search'].'%'];
}
if (!empty($param['order'])){
$order['b.like']='desc';
$order['b.dolike']='desc';
}else{
$order['b.create_time']='desc';
}
... ... @@ -144,16 +144,23 @@ class BrandController extends WeChatBaseController
//品牌评论页面
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['users_id']=session('wechat_user')['users_id'];
Db::name('comment')->insert($param);
Db::name('brand')->where('id',$param['cid'])->setInc('comment',1);
$this->redirect('portal/brand/brandComment',['id'=>$param['cid']]);
$param['users_id']=$re['id'];
$re1=Db::name('comment')->insert($param);
$re2=Db::name('brand')->where('id',$param['cid'])->setInc('comment',1);
if ($re1 && $re2) {
$url = url('portal/brand/brandComment', array('id' => $param['cid']));
return $url;
}else{
return 0;
}
}
//点赞ajax接口
public function like(){
... ...
... ... @@ -53,7 +53,7 @@
<td>{$vo.bc1name}</td>
<td>{$vo.bc2name}</td>
<td>{$vo.address}</td>
<td>{$vo.like}</td>
<td>{$vo.dolike}</td>
<td>{$vo.comment}</td>
<td>{:date('Y-m-d H:i',$vo['create_time'])}</td>
<td>
... ...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">
<script type="text/javascript" src="__TMPL__/public/assets/js/base.js"></script>
<title>写评价</title>
<style>
body,html{
background: #fff;
}
.evalute{
width:6.86rem;
margin: 0 auto;
height:3.6rem;
background:#F7F8FA ;
margin-top: 0.35rem;
border-radius: 0.1rem;
}
.write{
width:6.86rem;
margin: 0 auto;
height:3.6rem;
background:#F7F8FA ;
margin-top: 0.35rem;
border-radius: 0.1rem;
border:none;
outline:none;
padding-left: 0.31rem;
color:#999999;
font-size: 0.33rem;
}
.footer{
width:6.86rem;
text-align: center;
height:0.88rem;
line-height: 0.88rem;
position:fixed;
bottom:0.55rem;
left:0;
right:0;
margin: 0 auto;
background:#CA277B ;
border-radius: 0.44rem;
color:#fff;
font-size:0.32rem ;
}
</style>
</head>
<body>
<div class="container">
<div class="evalute">
<textarea name="" id="comment" cols="30" rows="10" class="write" placeholder="请写下您的评价"></textarea>
</div>
</div>
<div class="footer">发表</div>
<script>
$(".footer").click(function(){
var comment=$("#comment").val()
// alert("{$list.id}")
$.ajax({
url: "{:url('portal/brand/commentPost')}",
type: "post",
data: {
cid:"{$id}",
comment:comment,
},
success: function (data) {
if (data!=0){
alert('评论成功')
window.location.href=data;
}
else if (data==2){
alert('评论失败')
return false;
}
}
})
})
</script>
</body>
</html>
... ...