...
|
...
|
@@ -27,6 +27,13 @@ $('.shopping-cart-good .name').each(function() { |
|
|
this.mlellipsis(2);
|
|
|
});
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
|
|
|
$('.cart-goods').on('touchstart', '.checkbox', function() {
|
|
|
var $this = $(this),
|
...
|
...
|
@@ -34,30 +41,14 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { |
|
|
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 = {};
|
|
|
|
|
|
goodInfo.goods_type = cartType;
|
|
|
goodInfo.selected = isSelected ? 'N' : 'Y';
|
|
|
goodInfo.selected = $this.hasClass('icon-cb-checked') ? 'N' : 'Y';
|
|
|
goodInfo.product_sku = id;
|
|
|
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
|
|
|
|
|
|
goodsList.push(new GoodInfo(goodInfo));
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'post',
|
|
|
url: 'select',
|
...
|
...
|
@@ -90,8 +81,8 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { |
|
|
rightBtnText: '确定'
|
|
|
}
|
|
|
}, function() {
|
|
|
var id = $this.closest('.shopping-cart-good').data('id');
|
|
|
var count = $this.data('count');
|
|
|
var id = $this.closest('.shopping-cart-good').data('id'),
|
|
|
count = $this.data('count');
|
|
|
|
|
|
$.ajax({
|
|
|
method: 'post',
|
...
|
...
|
@@ -117,7 +108,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() { |
|
|
tip.show('网络异常');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) {
|
...
|
...
|
@@ -138,7 +128,7 @@ function requestUpdateAllGoodsCheckStatus(theGoods, successHandeler) { |
|
|
tip.show(res.message);
|
|
|
}
|
|
|
},
|
|
|
error: function(err) {
|
|
|
error: function() {
|
|
|
tip.show('网络异常');
|
|
|
},
|
|
|
complete: function() {
|
...
|
...
|
@@ -174,17 +164,10 @@ function didUpdateAllGoodsCheckStatus() { |
|
|
}
|
|
|
|
|
|
function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) {
|
|
|
var goodInfo = {};
|
|
|
var $goods = $('.cart-content:not(.hide) .shopping-cart-good');
|
|
|
var $good = null;
|
|
|
var goodsList = [];
|
|
|
|
|
|
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;
|
|
|
}
|
|
|
var goodInfo = {},
|
|
|
$goods = $('.cart-content:not(.hide) .shopping-cart-good'),
|
|
|
$good = null,
|
|
|
goodsList = [];
|
|
|
|
|
|
goodInfo.goods_type = type;
|
|
|
goodInfo.selected = isSelected ? 'N' : 'Y';
|
...
|
...
|
@@ -201,26 +184,9 @@ function bottomCheckBoxHandeler(isSelected, type, handlerAfterTouch) { |
|
|
requestUpdateAllGoodsCheckStatus(goodsList, handlerAfterTouch);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//是否要全选
|
|
|
function willBeSelected($this) {
|
|
|
var isSelected = true;
|
|
|
|
|
|
if ($this.hasClass('icon-cb-checked')) {
|
|
|
isSelected = true;
|
|
|
} else {
|
|
|
isSelected = false;
|
|
|
}
|
|
|
|
|
|
return isSelected;
|
|
|
}
|
|
|
|
|
|
//全选按钮点击事件
|
|
|
$selectAllBtn.on('touchend', function() {
|
|
|
var $this = $(this);
|
|
|
|
|
|
bottomCheckBoxHandeler(willBeSelected($this), cartType, didUpdateAllGoodsCheckStatus);
|
|
|
bottomCheckBoxHandeler($(this).hasClass('icon-cb-checked'), cartType, didUpdateAllGoodsCheckStatus);
|
|
|
});
|
|
|
|
|
|
$('.down').on('touchend', function() {
|
...
|
...
|
|