Authored by 郝肖肖

清除失效商品

... ... @@ -108,10 +108,13 @@
{{# if invalidPros}}
<div class="cart-pro-list invalid-pros">
<div class="title">
<span class="main">失效商品</span>
</div>
<div class="pro-list">
{{#each invalidPros}}
<ul>
<li class="chk" data-product_info='{"goods_type": "invalid", "buy_number": {{buy_number}}, "selected": "{{selected}}", "product_sku": "{{product_sku}}", "promotion_id": 0}'>
<li class="chk" data-product_info='{"goods_type": "invalid", "buy_number": {{buy_number}}, "selected": "{{selected}}", "product_sku": "{{product_sku}}", "promotion_id": 0}' title="失效">
<span class="iconfont warning">&#xe625;</span>
</li>
<li>
... ...
... ... @@ -15,6 +15,7 @@
</div>
<div id="remove_selected" class="action hoverable">删除选中的商品</div>
<div id="send_favorite" class="action hoverable">移入收藏夹</div>
<div id="clear_invalid_all" class="action hoverable">清除失效商品</div>
<div class="selected-num">已选<span>{{selectedNum}}</span></div>
<div class="checkout-total">
<div class="total-title">商品金额:</div>
... ...
... ... @@ -104,6 +104,18 @@ $(function() {
});
}
return false;
}).delegate('#clear_invalid_all', 'click', function(e) {
//清除失效商品
var selectedProducts = [],
product;
e.preventDefault();
$('.invalid-pros').find('li.chk').each(function() {
product = $(this);
selectedProducts.push($.parseJSON(product.attr('data-product_info')));
});
Cart.removeInvalid(selectedProducts);
});
// 商品删除模块
... ...
... ... @@ -230,6 +230,39 @@ Cart = {
new _alert('请至少选中一件商品!').show();
}
},
/*
* 删除失效商品
* @function [removePro]
* @params { Array } products 商品列表
* @params { Array } extraInfos 删除商品额外信息
*/
removeInvalid: function(products, extraInfos) {
var dialog;
if (products.length) {
dialog = new _confirm({
content: '<p style="font-size:25px;margin-bottom:20px;">清除失效商品</p><p>确定要清除失效商品吗?</p>',
cb: function() {
dialog.close();
Util.ajax({
url: '/shopping/cart/product/remove',
data: {skuList: JSON.stringify(products)},
type: 'DELETE',
success: function(res) {
Util.refreshCart(res, function() {
Stepper.init();
// 显示或者更新删除商品模块
Cart.showRemovedProducts(products, extraInfos);
});
}
});
}
}).show();
} else {
new _alert('购物袋中没有失效商品!').show();
}
},
/*
* 显示或者更新删除商品模块
... ...
... ... @@ -256,8 +256,6 @@ $hoverColor: #379ed6;
}
.invalid-pros {
margin-top: 80px;
border-top: 1px solid #eee;
color: #999;
input {
... ...
... ... @@ -73,7 +73,7 @@
font-size: 14px;
color: #1b1b1b;
font-weight: bold;
margin: 0 60px 0 224px;
margin-left: 85px;
}
.checkout-total {
... ...
... ... @@ -221,6 +221,7 @@
</div>
<div id="remove_selected" class="action hoverable">删除选中的商品</div>
<div id="send_favorite" class="action hoverable">移入收藏夹</div>
<div id="clear_invalid_all" class="action hoverable">清除失效商品</div>
<div class="selected-num">已选<span>{{selectedNum}}</span></div>
<div class="checkout-total">
<div class="total-title">商品金额:</div>
... ...