作者 anyv
1 个管道 的构建 通过 耗费 1 秒

25

... ... @@ -138,7 +138,7 @@ class GoodsdetailsController extends WeChatBaseController{
$uid = cmf_get_current_user_id();
$arr['goods_id'] = $goods_id;
$arr['uid'] = $uid;
$collect = Db::name('collect') -> where('goods_id',$arr['goods_id']) -> find();
$collect = Db::name('collect') -> where('goods_id',$arr['goods_id']) -> where('uid',$uid) -> find();
if($collect){
return 3;
}else{
... ... @@ -153,6 +153,35 @@ class GoodsdetailsController extends WeChatBaseController{
}
/**
* 点击取消收藏
*/
public function cancel_goods_collection(){
$uid = cmf_get_current_user_id();
$goods_id = $_POST['goods_id'];
$data = Db::name('collect') -> where("uid=".$uid." and goods_id=".$goods_id) -> delete();
if($data){
return true;
}else{
return false;
}
}
/**
* 立即支付判断
*/
public function goodsdetails_go_pay(){
... ...
... ... @@ -121,8 +121,8 @@
<div class="de_footer">
<if condition="$is_collect eq 1">
<div class="de_footerLeft" >
<div class="de_footerLeftLi" style="margin-top: 0.1rem" onclick="goods_collection({$data.id})">
<div class="de_footerLeftImg">
<div class="de_footerLeftLi collection" style="margin-top: 0.1rem" >
<div class="de_footerLeftImg" onclick="goods_collection({$data.id})">
<img src="__TMPL__/public/assets/images/26.png" alt="" id="imgsss">
</div>
<p id="shoucang">收藏</p>
... ... @@ -130,8 +130,8 @@
</div>
<else/>
<div class="de_footerLeft">
<div class="de_footerLeftLi">
<div class="de_footerLeftImg">
<div class="de_footerLeftLi cancel">
<div class="de_footerLeftImg" onclick="cancel_goods_collection({{$data.id}})">
<img src="__TMPL__/public/assets/images/xin (1).png" alt="">
</div>
<p>已收藏</p>
... ... @@ -253,9 +253,11 @@
alert('已收藏');
}else{
if(data){
$("#imgsss").attr("src","__TMPL__/public/assets/images/xin (1).png");
/*$("#imgsss").attr("src","__TMPL__/public/assets/images/xin (1).png");
$('#shoucang').text('已收藏');
alert('收藏成功');
alert('收藏成功');*/
$('.collection').html("<div class='de_footerLeftImg' onclick='cancel_goods_collection("+id+")'><img src='__TMPL__/public/assets/images/xin (1).png' ></div><p>已收藏</p>");
}else{
alert('收藏失败');
}
... ... @@ -268,10 +270,29 @@
}
});
}
/**
*点击取消收藏
*/
function cancel_goods_collection(id){
$.post("{:url('Goodsdetails/cancel_goods_collection')}",{goods_id:id},function(data){
if(data){
$('.cancel').html("<div class='de_footerLeftImg' onclick='goods_collection("+id+")'><img src='__TMPL__/public/assets/images/26.png' id='imgsss'></div><p id='shoucang'>收藏</p>");
}else{
alert('取消收藏失败');
}
});
}
/**
*点击加入购物车
*/
... ...