|
@@ -552,3 +552,43 @@ function dialog(txt,callback) {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+// 加入购物车
|
|
|
+function addShoppingCart(userId, productId, count){
|
|
|
+ tokenAjax("post", "/shoppingCart/addCart", {
|
|
|
+ userID: userId,
|
|
|
+ productID: productId,
|
|
|
+ productCount: count
|
|
|
+ },function (res) {
|
|
|
+ if(res && res.code*1 === 0){
|
|
|
+ globalHead.getHeadCart(userId);
|
|
|
+ $.confirm({
|
|
|
+ useBootstrap: false,
|
|
|
+ boxWidth: (isPC?'338px':'74.6vw'),
|
|
|
+ title: false,
|
|
|
+ content:'<div class="cartAlert"><h6>商品已成功加入购物车!</h6><p>当前购物车共'+res.data+'种商品去结算继续购物</p></div>',
|
|
|
+ closeIcon: true,
|
|
|
+ animation: 'opacity',
|
|
|
+ closeAnimation: 'opacity',
|
|
|
+ animateFromElement: false,
|
|
|
+ scrollToPreviousElement: false,
|
|
|
+ buttons: {
|
|
|
+ login: {
|
|
|
+ text: '去结算',
|
|
|
+ btnClass: 'btn-to-cart',
|
|
|
+ action: function(){
|
|
|
+ window.location.href = '/shopping/cart.html';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ close: {
|
|
|
+ text: '继续购物',
|
|
|
+ btnClass: 'btn-cancel'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ dialog("加入购物车失败!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|