正在显示
2 个修改的文件
包含
57 行增加
和
7 行删除
@@ -138,7 +138,7 @@ class GoodsdetailsController extends WeChatBaseController{ | @@ -138,7 +138,7 @@ class GoodsdetailsController extends WeChatBaseController{ | ||
138 | $uid = cmf_get_current_user_id(); | 138 | $uid = cmf_get_current_user_id(); |
139 | $arr['goods_id'] = $goods_id; | 139 | $arr['goods_id'] = $goods_id; |
140 | $arr['uid'] = $uid; | 140 | $arr['uid'] = $uid; |
141 | - $collect = Db::name('collect') -> where('goods_id',$arr['goods_id']) -> find(); | 141 | + $collect = Db::name('collect') -> where('goods_id',$arr['goods_id']) -> where('uid',$uid) -> find(); |
142 | if($collect){ | 142 | if($collect){ |
143 | return 3; | 143 | return 3; |
144 | }else{ | 144 | }else{ |
@@ -153,6 +153,35 @@ class GoodsdetailsController extends WeChatBaseController{ | @@ -153,6 +153,35 @@ class GoodsdetailsController extends WeChatBaseController{ | ||
153 | } | 153 | } |
154 | 154 | ||
155 | /** | 155 | /** |
156 | + * 点击取消收藏 | ||
157 | + */ | ||
158 | + public function cancel_goods_collection(){ | ||
159 | + | ||
160 | + $uid = cmf_get_current_user_id(); | ||
161 | + $goods_id = $_POST['goods_id']; | ||
162 | + $data = Db::name('collect') -> where("uid=".$uid." and goods_id=".$goods_id) -> delete(); | ||
163 | + if($data){ | ||
164 | + return true; | ||
165 | + }else{ | ||
166 | + return false; | ||
167 | + } | ||
168 | + | ||
169 | + } | ||
170 | + | ||
171 | + | ||
172 | + | ||
173 | + | ||
174 | + | ||
175 | + | ||
176 | + | ||
177 | + | ||
178 | + | ||
179 | + | ||
180 | + | ||
181 | + | ||
182 | + | ||
183 | + | ||
184 | + /** | ||
156 | * 立即支付判断 | 185 | * 立即支付判断 |
157 | */ | 186 | */ |
158 | public function goodsdetails_go_pay(){ | 187 | public function goodsdetails_go_pay(){ |
@@ -121,8 +121,8 @@ | @@ -121,8 +121,8 @@ | ||
121 | <div class="de_footer"> | 121 | <div class="de_footer"> |
122 | <if condition="$is_collect eq 1"> | 122 | <if condition="$is_collect eq 1"> |
123 | <div class="de_footerLeft" > | 123 | <div class="de_footerLeft" > |
124 | - <div class="de_footerLeftLi" style="margin-top: 0.1rem" onclick="goods_collection({$data.id})"> | ||
125 | - <div class="de_footerLeftImg"> | 124 | + <div class="de_footerLeftLi collection" style="margin-top: 0.1rem" > |
125 | + <div class="de_footerLeftImg" onclick="goods_collection({$data.id})"> | ||
126 | <img src="__TMPL__/public/assets/images/26.png" alt="" id="imgsss"> | 126 | <img src="__TMPL__/public/assets/images/26.png" alt="" id="imgsss"> |
127 | </div> | 127 | </div> |
128 | <p id="shoucang">收藏</p> | 128 | <p id="shoucang">收藏</p> |
@@ -130,8 +130,8 @@ | @@ -130,8 +130,8 @@ | ||
130 | </div> | 130 | </div> |
131 | <else/> | 131 | <else/> |
132 | <div class="de_footerLeft"> | 132 | <div class="de_footerLeft"> |
133 | - <div class="de_footerLeftLi"> | ||
134 | - <div class="de_footerLeftImg"> | 133 | + <div class="de_footerLeftLi cancel"> |
134 | + <div class="de_footerLeftImg" onclick="cancel_goods_collection({{$data.id}})"> | ||
135 | <img src="__TMPL__/public/assets/images/xin (1).png" alt=""> | 135 | <img src="__TMPL__/public/assets/images/xin (1).png" alt=""> |
136 | </div> | 136 | </div> |
137 | <p>已收藏</p> | 137 | <p>已收藏</p> |
@@ -253,9 +253,11 @@ | @@ -253,9 +253,11 @@ | ||
253 | alert('已收藏'); | 253 | alert('已收藏'); |
254 | }else{ | 254 | }else{ |
255 | if(data){ | 255 | if(data){ |
256 | - $("#imgsss").attr("src","__TMPL__/public/assets/images/xin (1).png"); | 256 | + /*$("#imgsss").attr("src","__TMPL__/public/assets/images/xin (1).png"); |
257 | $('#shoucang').text('已收藏'); | 257 | $('#shoucang').text('已收藏'); |
258 | - alert('收藏成功'); | 258 | + alert('收藏成功');*/ |
259 | + $('.collection').html("<div class='de_footerLeftImg' onclick='cancel_goods_collection("+id+")'><img src='__TMPL__/public/assets/images/xin (1).png' ></div><p>已收藏</p>"); | ||
260 | + | ||
259 | }else{ | 261 | }else{ |
260 | alert('收藏失败'); | 262 | alert('收藏失败'); |
261 | } | 263 | } |
@@ -268,10 +270,29 @@ | @@ -268,10 +270,29 @@ | ||
268 | } | 270 | } |
269 | }); | 271 | }); |
270 | 272 | ||
273 | + } | ||
271 | 274 | ||
275 | + /** | ||
276 | + *点击取消收藏 | ||
277 | + */ | ||
278 | + function cancel_goods_collection(id){ | ||
279 | + | ||
280 | + $.post("{:url('Goodsdetails/cancel_goods_collection')}",{goods_id:id},function(data){ | ||
281 | + if(data){ | ||
282 | + $('.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>"); | ||
283 | + }else{ | ||
284 | + alert('取消收藏失败'); | ||
285 | + } | ||
286 | + }); | ||
272 | 287 | ||
273 | } | 288 | } |
274 | 289 | ||
290 | + | ||
291 | + | ||
292 | + | ||
293 | + | ||
294 | + | ||
295 | + | ||
275 | /** | 296 | /** |
276 | *点击加入购物车 | 297 | *点击加入购物车 |
277 | */ | 298 | */ |
-
请 注册 或 登录 后发表评论