...
|
...
|
@@ -350,6 +350,20 @@ handlebars.registerHelper('notzero', function(v1, options) { |
|
|
}
|
|
|
});
|
|
|
|
|
|
handlebars.registerHelper('gt', function(v1, v2, options) {
|
|
|
var ret = v1 > v2;
|
|
|
|
|
|
if (options.fn) {
|
|
|
if (ret) {
|
|
|
return options.fn(this);
|
|
|
} else {
|
|
|
return options.inverse(this);
|
|
|
}
|
|
|
} else {
|
|
|
return ret;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 获取头部banner的回调函数
|
|
|
* @param {[type]} data [description]
|
...
|
...
|
@@ -1108,6 +1122,28 @@ function actionUpdateCartNum() { |
|
|
cartNum: '.ic-infomation'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function refreshCartNum() {
|
|
|
var $miniCart = $('#miniCartBox');
|
|
|
var $totalInfo = $miniCart.find('[data-role=totalinfo]');
|
|
|
var total = 0;
|
|
|
|
|
|
$miniCart.find('.goods-list .goods-item.hide').each(function() {
|
|
|
|
|
|
var $t = $(this);
|
|
|
var val = $t.data('num') || 0;
|
|
|
|
|
|
total += Number(val);
|
|
|
});
|
|
|
|
|
|
if (total > 0) {
|
|
|
$totalInfo.show();
|
|
|
$totalInfo.find('[data-role=last-num]').text(total);
|
|
|
} else {
|
|
|
$totalInfo.hide();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 加载购物车数据
|
|
|
* @return {[type]} [description]
|
...
|
...
|
@@ -1124,6 +1160,9 @@ function loadCartData() { |
|
|
$('#miniCartBox').children('.gobuy-wrapper').html(cartTpl({
|
|
|
carData: jsonData
|
|
|
}));
|
|
|
|
|
|
refreshCartNum();
|
|
|
|
|
|
if (parseInt($('.ic-infomation').html()) === 0) {
|
|
|
$('#miniCartBox .gobuy-wrapper').html('<div class="gobuy-empty">' +
|
|
|
'<h3 class="information">您的购物车暂无商品</h3></div>');
|
...
|
...
|
|