Authored by hongweigao

Merge branch 'feature/new-product-detail' of http://git.yoho.cn/fe/yohobuy-node

…into feature/new-product-detail
... ... @@ -167,7 +167,7 @@
<p class="success-tip">该商品已成功添加到购物车</p>
<p class="cart-total">购物车共<span id="cart-num">0</span>件商品</p>
<p class="balance-btns">
<a class="go-cart buy-btn" href="{{goCartUrl}}">
<a id="go-to-cart-url" class="go-cart buy-btn" href="{{goCartUrl}}">
去购物车结算
<i class="iconfont">&#xe60c;</i>
</a>
... ...
... ... @@ -204,6 +204,17 @@ function once(fn, context) {
};
}
function isLogin() {
var uid = getUid();
if (uid) {
return true;
} else {
jumpUrl(signinUrl());
return false;
}
}
window.cookie = cookie;
window.setCookie = setCookie;
... ... @@ -220,6 +231,8 @@ window.queryString = queryString;
window.signinUrl = signinUrl;
window.isLogin = isLogin;
window.registerUrl = registerUrl;
window.jumpUrl = jumpUrl;
... ...
... ... @@ -118,6 +118,7 @@ function getSku() {
return $('.size:not(.hide) li.focus').data('sku');
}
// 加入购物车
function addCart() {
return $.ajax({
type: 'POST',
... ... @@ -136,7 +137,7 @@ function addCart() {
$('#cart-num').text(data.data.goods_count); // 更新数目
return $.Deferred().resolve().promise();
return $.Deferred().resolve().promise(); // eslint-diable-line
} else if (code === 500) {
if (deposit) {
alert = new Alert('定金预售商品只能在APP端购买');
... ... @@ -149,7 +150,7 @@ function addCart() {
}
}
return $.Deferred().reject().promise();
return $.Deferred().reject().promise(); // eslint-disable-line
});
}
... ... @@ -380,7 +381,7 @@ bindEvent.add(function() {
// 是否能:量贩购买,量贩小于库存才能购买
function canBundleBuy() {
return goodsBaseNum < maxStock;
return goodsBaseNum <= maxStock;
}
// 重置Num显示为最小购买数
... ... @@ -461,14 +462,11 @@ bindEvent.add(function() {
// 尺码选中的状态
if (maxStock !== -1) {
console.log(maxStock);
if (canBundleBuy()) {
console.log(1);
$itemBuy.removeClass('hide');
$soldOut.addClass('hide');
cartEvent.emit('gocart');
cartEvent.emit('selling');
} else {
console.log(2);
$itemBuy.addClass('hide');
$soldOut.removeClass('hide');
cartEvent.emit('sellout');
... ... @@ -488,12 +486,7 @@ bindEvent.add(function() {
// 包括默认的-1情况下
$itemBuy.removeClass('hide');
$soldOut.addClass('hide');
if (maxStock === -1) {
cartEvent.emit('selling');
} else {
cartEvent.emit('gocart');
}
cartEvent.emit('selling');
}
}
... ... @@ -832,7 +825,9 @@ bindEvent.add(function() {
PRD_SKU: getSku()
});
addCart();
addCart().then(function() {
cartEvent.emit('gocart');
});
});
// 收藏
... ... @@ -998,9 +993,10 @@ bindEvent.add(function() {
}
if (hasOnlyOneSize) {
$maxColor = $('.colors .focus').eq(0);
$sizes.eq($('.colors .focus').index()).find('li').click();
}
$maxColor = $('.colors .focus').eq(0);
}());
yasAtHead.yasHead();
... ... @@ -1186,8 +1182,6 @@ function loadComment() {
});
// 评论类型的切换
$('.comments').on('click', '.comment-tabs h2[data-comment-type]', function() {
... ... @@ -1872,10 +1866,7 @@ $('.shoppingCar-btn').on('click', function() {
}
if ($this.data('gocart') === 1) {
addCart().then(function() {
window.jumpUrl($('.go-cart').attr('href'));
});
window.jumpUrl($('#go-to-cart-url').attr('href'));
return;
}
... ...
... ... @@ -2323,7 +2323,6 @@
.title {
display: inline-block;
font-weight: bold;
cursor: pointer;
font-size: 14px;
margin-left: auto;
margin-right: auto;
... ...