作者 李涵

合并分支 'li' 到 'master'

评论,购物车



查看合并请求 !13
... ... @@ -19,7 +19,9 @@ class CartController extends HomeBaseController
if ($request->isAjax()) {
$gid = $request->param('gid');
$num = $request->param('num');
$cart->addToCart(session('user.id', $gid, $num));
if ($cart->addToCart(session('user.id'), $gid, $num)) {
$this->success('', '', true);
}
}
}
... ...
... ... @@ -67,8 +67,17 @@ class GoodsController extends HomeBaseController
{
$id = request()->param('id');
$data = Db::name('zj_goods')->field('thumb,name,intro,price,content')->where(['id' => $id])->find();
$total = Db::name('zj_cart')->field('sum(num) as total')->where(['uid' => session('user.id')])->select();
if ($total[0]['total'] == '') {
$total = 0;
} else {
$total = $total[0]['total'];
}
return $this->fetch(':detail', [
'data' => $data
'total' => $total,
'data' => $data,
'id' => $id,
'comment' => $this->getGoodsComment($id)
]);
}
... ... @@ -77,4 +86,14 @@ class GoodsController extends HomeBaseController
return Db::name('zj_category')->field('id,name')->where(['cid' => $cid])->select()->toArray();
}
public function getGoodsComment($gid) {
return Db::name('zj_evaluate')->alias('e')
->field('u.user_nickname,avatar,e.content,e.create_time')
->join('user u', 'u.id=e.uid')
->where(['gid'=>$gid])
->order('create_time DESC')
->select()
->toArray();
}
}
\ No newline at end of file
... ...
... ... @@ -86,41 +86,28 @@
</div>
</div>
<div class="evalute" style="display:none">
<volist name="comment" id="vo">
<div class="evalute_list">
<div class="evalute_people">
<p class="people_img">
<img src="__INDEX__/img/people.png" alt="">
<img src="{$vo.avatar}" alt="">
</p>
<div class="people_info">
<p class="people_name">向昱筱</p>
<p class="people_date">2018-03-09</p>
<p class="people_name">{$vo.user_nickname}</p>
<p class="people_date">{$vo.create_time|date='Y-m-d',###}</p>
</div>
</div>
<div class="evalute_text">
颜值高口感好,很新鲜,奶油一点都不腻,超清爽的口
感,奶香味很浓,非常喜欢。
</div>
</div>
<div class="evalute_list">
<div class="evalute_people">
<p class="people_img">
<img src="__INDEX__/img/people.png" alt="">
</p>
<div class="people_info">
<p class="people_name">向昱筱</p>
<p class="people_date">2018-03-09</p>
</div>
</div>
<div class="evalute_text">
质量很好,很好的一次购物,味道不错!
{$vo.content}
</div>
</div>
</volist>
</div>
<div class="foot">
<div class="cartnum">
<p class="goodcart">
<img src="__INDEX__/img/goodcart.png" alt="">
<p class="num">12</p>
<p class="num">{$total}</p>
</p>
</div>
<p class="addcart">加入购物车</p>
... ... @@ -159,7 +146,19 @@
})
//加入购物车
$(".addcart").click(function(){
window.location.href='__INDEX__/shopcar/cart.html'
$.ajax({
url:"{:url('cart/Cart/addCart')}",
data:{
gid:'{$id}',
num:1
},
type:"POST",
dataType:"JSON",
success: function () {
$(".num").html(parseInt($(".num").html())+1);
}
})
})
</script>
</body>
... ...