Authored by 周少峰

gulp ge

... ... @@ -855,6 +855,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]
... ... @@ -1613,6 +1627,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]
... ... @@ -1622,13 +1658,17 @@ function loadCartData() {
shoppingData,
strK;
$.getData('//www.yohobuy.com/common/shoppingCart', '', function(jsonData) {
$.getJSON('//www.yohobuy.com/cart/cart/minicart?callback=?', {}, function(jsonData) {
if (cartTpl === '') {
cartTpl = handlebars.compile($('#mini-cart-tpl').html());
}
$('#miniCartBox').children('.gobuy-wrapper').html(cartTpl({
carData: jsonData
carData: jsonData.data
}));
refreshCartNum();
if (parseInt($('.ic-infomation').html()) === 0) {
$('#miniCartBox .gobuy-wrapper').html('<div class="gobuy-empty">' +
'<h3 class="information">您的购物车暂无商品</h3></div>');
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.