...
|
...
|
@@ -29,16 +29,56 @@ if ($names.length > 0) { |
|
|
$names[0].mlellipsis(2);
|
|
|
}
|
|
|
|
|
|
//获取当前购物车类型
|
|
|
function getCartType() {
|
|
|
var $navItem = $('.cart-nav ').find('li'),
|
|
|
type = 'ordinary';
|
|
|
|
|
|
if ($navItem.eq(0).hasClass('active')) {
|
|
|
type = 'ordinary';
|
|
|
} else {
|
|
|
type = 'advance';
|
|
|
}
|
|
|
|
|
|
return type;
|
|
|
}
|
|
|
|
|
|
//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 +89,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 +104,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 +135,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 +169,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,24 +245,11 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { |
|
|
|
|
|
goodsList.push(new GoodInfo(goodInfo));
|
|
|
});
|
|
|
console.log(goodsList);
|
|
|
|
|
|
requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch);
|
|
|
}
|
|
|
|
|
|
//获取当前购物车类型
|
|
|
function getCartType() {
|
|
|
var $navItem = $('.cart-nav ').find('li'),
|
|
|
type = 'ordinary';
|
|
|
|
|
|
if ($navItem.eq(0).hasClass('active')) {
|
|
|
type = 'ordinary';
|
|
|
} else {
|
|
|
type = 'advance';
|
|
|
}
|
|
|
|
|
|
return type;
|
|
|
}
|
|
|
|
|
|
//是否要全选
|
|
|
function willBeSelected() {
|
...
|
...
|
|