Authored by uedxwg

购物车错误修改

... ... @@ -36,13 +36,15 @@ function GoodInfo(properties) {
this.buy_number = properties.buy_number;
this.product_sku = properties.product_sku;
this.selected = properties.selected;
this.hasPromotion = properties.hasPromotion;
}
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$('.cart-goods').on('touchstart', '.checkbox', function() {
var $this = $(this),
$good = $this.closest('.shopping-cart-good'),
id = $good.data('id');
id = $good.data('id'),
promotion = $good.data('promotion');
var goodsList = [],
goodInfo = {};
... ... @@ -55,9 +57,10 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
goodInfo.goods_type = $('#cartType').val();
goodInfo.selected = $this.hasClass('icon-cb-checked') ? 'N' : 'Y';
goodInfo.product_sku = id;
goodInfo.hasPromotion = promotion;
goodInfo.buy_number = $good.find('.count').eq(0).text().trim().replace('×', '');
goodsList.push(new GoodInfo(goodInfo));
console.log(goodInfo);
$.ajax({
type: 'post',
url: 'select',
... ... @@ -188,6 +191,7 @@ $('.icon-del').on('touchstart', function(e) {
}
}, function() {
var id = $this.closest('.shopping-cart-good').data('id'),
promotion = $this.closest('.shopping-cart-good').data('promotion'),
count = $this.data('count');
$.ajax({
... ... @@ -195,6 +199,7 @@ $('.icon-del').on('touchstart', function(e) {
url: '/cart/index/del',
data: {
sku: id,
hasPromotion: promotion,
count: count
}
}).then(function(data) {
... ...
<div class="shopping-cart-good clearfix" data-id="{{id}}" data-skn="{{skn}}">
<div class="shopping-cart-good clearfix" data-promotion="{{promotion_id}}" data-id="{{id}}" data-skn="{{skn}}">
{{#if inValid}}
<span class="few-tag-expire">失效</span>
{{/if}}
... ...