Browse Source

加入购物车

chao 4 years ago
parent
commit
7d5989f28a

+ 8 - 14
src/main/resources/static/js/product/detail.js

@@ -174,20 +174,14 @@ var productDetail = new Vue({
 				}
 			},
 		addShopCart:function(){ //加入购物车
-			    var _this = this;
-               $.getJSON(spiServer + "/shoppingCart/addCart",{
-                        productID: _this.productId,
-                        userID: _this.userId,
-                        productCount: _this.number,
-                   }).done(function (res) {
-                          if(res.code==0){
-                                _this.cartAlert = true;
-                                _this.typedata = res.data;//商品种数
-                            }else {
-
-                                _this.cartAlert = false;
-                            }
-                })
+			var _this = this;
+            tokenAjax("post", "/shoppingCart/addCart", {
+                userID: this.userId,
+                productID: this.productId,
+                productCount: this.number
+            },function (res) {
+                alertInfo(res.msg);
+            });
 		},
 		Continueshop:function(){ //继续购物
             var _this = this;

+ 1 - 1
src/main/resources/templates/product/detail.html

@@ -155,7 +155,7 @@
                       <a class="upgrade" @click="clubupgrade" href="javascript:0">升级会员查看价格</a>
                    </div>
                     <div class="btnBox" v-else-if="priceFlag==0">
-                        <a href="javascript:void(0);" class="cart icon" @click='addShopCart'>加入购物车</a>
+                        <a href="javascript:void(0);" class="cart icon" @click='addShopCart()'>加入购物车</a>
                         <a href="javascript:void(0);" class="buy" @click="buyNowSubmit()">立即购买</a>
                     </div>
                 </template>