Authored by 梁志锋

修改购物车tab

... ... @@ -13,7 +13,7 @@ var chosePanel = require('./chose-panel');
var $cartContent = $('.cart-content');
var navHammer,
cartType = 'ordinary';
cartType = $('#cartType').val();
require('./good');
... ...
... ... @@ -13,9 +13,9 @@ var dialog = require('../me/dialog'),
tip = require('../plugin/tip');
var $names,
$selectAllBtn = $('.balance .iconfont');
var requesting = false;
$selectAllBtn = $('.balance .iconfont'),
cartType = $('#cartType').val(),
requesting = false;
ellipsis.init();
... ... @@ -29,20 +29,6 @@ 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),
... ... @@ -95,13 +81,24 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
},
success: function(data) {
if (data) {
$('#good-totalprice').html('¥' + data.commonCart.price);
$('#good-activityPrice').html('¥' + data.commonCart.activityPrice);
$('#good-total').html('总计:¥' + data.commonCart.sumPrice + ' (' + data.commonCart.count + '件)');
if (data.commonCart.isAllSelected) {
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
if (cartType === 'ordinary') {
$('#good-totalprice').html('¥' + data.commonCart.price);
$('#good-activityPrice').html('¥' + data.commonCart.activityPrice);
$('#good-total').html('总计:¥' + data.commonCart.sumPrice + ' (' + data.commonCart.count + '件)');
if (data.commonCart.isAllSelected) {
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
} else {
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
}
} else {
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
$('#good-totalprice').html('¥' + data.preSellCart.price);
$('#good-activityPrice').html('¥' + data.preSellCart.activityPrice);
$('#good-total').html('总计:¥' + data.preSellCart.sumPrice + ' (' + data.preSellCart.count + '件)');
if (data.preSellCart.isAllSelected) {
$('.balance span').removeClass('icon-checkbox').addClass('icon-cb-checked');
} else {
$('.balance span').removeClass('icon-cb-checked').addClass('icon-checkbox');
}
}
}
},
... ... @@ -115,26 +112,6 @@ $('.cart-goods').on('touchstart', '.checkbox', function() {
}).fail(function() {
tip.show('网络错误');
});
}).on('touchstart', '.icon-edit', function() {
//var $this = $(this);
//
//var $cartgood = $this.closest('.shopping-cart-good');
//
////var id = $this.closest('.shopping-cart-good').data('id');
//
//var $viewGood = $cartgood.find('.deps');
// $editGoot = $cartgood.find('.calculate-num');
//
//if ($viewGood.hasClass('show')) {
// $viewGood.removeClass('show').addClass('hide');
// $editGoot.removeClass('hide').addClass('show');
//} else {
// $viewGood.removeClass('hide').addClass('show');
// $editGoot.removeClass('show').addClass('hide');
//}
}).on('touchstart', '.icon-del', function(e) {
var $this = $(this);
... ... @@ -274,7 +251,7 @@ function willBeSelected($this) {
//全选按钮点击事件
$selectAllBtn.on('touchend', function() {
var $this = $(this);
bottomCheckBoxHandeler(willBeSelected($this), getCartType(), didUpdateAllGoodsCheckStatus);
bottomCheckBoxHandeler(willBeSelected($this), cartType, didUpdateAllGoodsCheckStatus);
});
$('.down').on('touchend', function() {
... ...