...
|
...
|
@@ -32,13 +32,39 @@ if ($names.length > 0) { |
|
|
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
|
|
|
$('.cart-goods').on('touchstart', '.checkbox', function() {
|
|
|
var $this = $(this),
|
|
|
id = $(this).closest('.shopping-cart-good').data('id');
|
|
|
$good = $this.closest('.shopping-cart-good'),
|
|
|
id = $good.data('id');
|
|
|
|
|
|
var goodsList = [],
|
|
|
goodInfo = {},
|
|
|
isSelected = true;
|
|
|
|
|
|
if ($this.hasClass('icon-cb-checked')) {
|
|
|
isSelected = true;
|
|
|
} else {
|
|
|
isSelected = false;
|
|
|
}
|
|
|
|
|
|
function GoodInfo(properties) {
|
|
|
this.goods_type = properties.goods_type;
|
|
|
this.buy_number = properties.buy_number;
|
|
|
this.product_sku = properties.product_sku;
|
|
|
this.selected = properties.selected;
|
|
|
}
|
|
|
|
|
|
goodInfo.goods_type = getCartType();
|
|
|
goodInfo.selected = isSelected ? 'Y' : 'N';
|
|
|
goodInfo.product_sku = id;
|
|
|
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
|
|
|
|
|
|
goodsList.push(new GoodInfo(goodInfo));
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/cart/index/select',
|
|
|
type: 'post',
|
|
|
url: 'select',
|
|
|
data: {
|
|
|
id: id
|
|
|
skuList: JSON.stringify(goodsList)
|
|
|
}
|
|
|
}).then(function(data) {
|
|
|
if (data.code === 200) {
|
...
|
...
|
@@ -49,9 +75,9 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { |
|
|
}
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/cart/index/getCartData',
|
|
|
url: 'getCartData',
|
|
|
data: {
|
|
|
skuList: JSON.stringfy(id)
|
|
|
id: id
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data) {
|
...
|
...
|
@@ -64,7 +90,7 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { |
|
|
tip.show('网络错误');
|
|
|
}
|
|
|
});
|
|
|
} else if (data.code === 200) {
|
|
|
} else if (data.code === 400) {
|
|
|
tip.show('网络错误');
|
|
|
}
|
|
|
}).fail(function() {
|
...
|
...
|
@@ -95,13 +121,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { |
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
//手动触发docTouchEvt清除因点击到del按钮上而被阻止冒泡到doc上的事件从而清除已打开的删除面板
|
|
|
//docTouchEvt();
|
|
|
//
|
|
|
//$curDelPanel = $(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
|
|
|
//
|
|
|
//$(document).on('touchstart', docTouchEvt);
|
|
|
|
|
|
dialog.showDialog({
|
|
|
dialogText: '您确定要从购物车中删除吗?',
|
|
|
hasFooter: {
|
...
|
...
|
@@ -136,30 +155,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { |
|
|
|
|
|
});
|
|
|
|
|
|
// .on('touchstart', '.opt-panel', function() {
|
|
|
// var $this = $(this),
|
|
|
// id = $this.closest('.shopping-cart-good').data('id'),
|
|
|
// url;
|
|
|
//
|
|
|
// if ($this.closest('.put-in-favorite').length > 0) {
|
|
|
//
|
|
|
// //移入收藏夹
|
|
|
// url = '/shoppingCart/col';
|
|
|
// } else {
|
|
|
//
|
|
|
// //删除
|
|
|
// url = '/shoppingCart/del';
|
|
|
// }
|
|
|
//
|
|
|
// $.ajax({
|
|
|
// type: 'POST',
|
|
|
// url: url,
|
|
|
// data: {
|
|
|
// id: id
|
|
|
// }
|
|
|
// });
|
|
|
//})
|
|
|
|
|
|
function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
|
|
|
if (requesting) {
|
|
|
return;
|
...
|
...
|
@@ -236,7 +231,6 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { |
|
|
|
|
|
goodsList.push(new GoodInfo(goodInfo));
|
|
|
});
|
|
|
console.log(goodsList);
|
|
|
|
|
|
requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch);
|
|
|
}
|
...
|
...
|
|