正在显示
2 个修改的文件
包含
24 行增加
和
3 行删除
@@ -44,6 +44,23 @@ class GoodsdetailsController extends WeChatBaseController{ | @@ -44,6 +44,23 @@ class GoodsdetailsController extends WeChatBaseController{ | ||
44 | 44 | ||
45 | } | 45 | } |
46 | 46 | ||
47 | + /** | ||
48 | + * 点击收藏 | ||
49 | + */ | ||
50 | + public function goods_collection(){ | ||
51 | + | ||
52 | + $goods_id = $_POST['goods_id']; | ||
53 | + $uid = cmf_get_current_user_id(); | ||
54 | + $arr['goods_id'] = $goods_id; | ||
55 | + $arr['uid'] = $uid; | ||
56 | + $data = Db::name('collect') -> insert($arr); | ||
57 | + if($data){ | ||
58 | + return true; | ||
59 | + }else{ | ||
60 | + return false; | ||
61 | + } | ||
62 | + | ||
63 | + } | ||
47 | 64 | ||
48 | 65 | ||
49 | 66 |
@@ -141,9 +141,13 @@ | @@ -141,9 +141,13 @@ | ||
141 | *点击收藏 | 141 | *点击收藏 |
142 | */ | 142 | */ |
143 | function goods_collection(id){ | 143 | function goods_collection(id){ |
144 | - | ||
145 | - alert(id); | ||
146 | - | 144 | + $.post("{:url('Goodsdetails/goods_collection')}",{goods_id:id},function(data){ |
145 | + if(data){ | ||
146 | + alert('收藏成功'); | ||
147 | + }else{ | ||
148 | + alert('收藏失败'); | ||
149 | + } | ||
150 | + }); | ||
147 | } | 151 | } |
148 | </script> | 152 | </script> |
149 | </body> | 153 | </body> |
-
请 注册 或 登录 后发表评论