diff --git a/app/portal/controller/GoodsdetailsController.php b/app/portal/controller/GoodsdetailsController.php index e981854..e2519f4 100644 --- a/app/portal/controller/GoodsdetailsController.php +++ b/app/portal/controller/GoodsdetailsController.php @@ -44,6 +44,23 @@ class GoodsdetailsController extends WeChatBaseController{ } + /** + * 点击收藏 + */ + public function goods_collection(){ + + $goods_id = $_POST['goods_id']; + $uid = cmf_get_current_user_id(); + $arr['goods_id'] = $goods_id; + $arr['uid'] = $uid; + $data = Db::name('collect') -> insert($arr); + if($data){ + return true; + }else{ + return false; + } + + } diff --git a/public/themes/simpleboot3/portal/goodsdetails/goods_details.html b/public/themes/simpleboot3/portal/goodsdetails/goods_details.html index 5b837a0..0bf5179 100644 --- a/public/themes/simpleboot3/portal/goodsdetails/goods_details.html +++ b/public/themes/simpleboot3/portal/goodsdetails/goods_details.html @@ -141,9 +141,13 @@ *点击收藏 */ function goods_collection(id){ - - alert(id); - + $.post("{:url('Goodsdetails/goods_collection')}",{goods_id:id},function(data){ + if(data){ + alert('收藏成功'); + }else{ + alert('收藏失败'); + } + }); } </script> </body>