...
|
...
|
@@ -5,7 +5,6 @@ |
|
|
*/
|
|
|
|
|
|
var $ = require('jquery'),
|
|
|
lazyLoad = require('yoho.lazyload'),
|
|
|
Hammer = require('yoho.hammer');
|
|
|
|
|
|
var chosePanel = require('./chose-panel'),
|
...
|
...
|
@@ -16,14 +15,21 @@ var $cartContent = $('.cart-content'), |
|
|
cartType = $('#cartType').val(),
|
|
|
hasShowCartPresellTip = false;
|
|
|
|
|
|
var $cartContentShow = $cartContent.not('.hide');
|
|
|
|
|
|
var navHammer,
|
|
|
advanceBuyHammer,
|
|
|
freebieHammer;
|
|
|
freebieHammer,
|
|
|
switchChose = false;
|
|
|
|
|
|
require('../product/recommend-for-you');
|
|
|
|
|
|
var hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false; //是否有选中商品
|
|
|
function hasChecked() {
|
|
|
return $cartContentShow.find('.icon-cb-checked').length > 0 ? true : false;
|
|
|
}
|
|
|
|
|
|
function shouldSelectGift() {
|
|
|
var $freebie = $('.freebie');
|
|
|
var $freebie = $cartContentShow.find('.freebie');
|
|
|
|
|
|
if ($freebie.length <= 0) {
|
|
|
return false;
|
...
|
...
|
@@ -33,9 +39,15 @@ function shouldSelectGift() { |
|
|
}
|
|
|
|
|
|
function shouldLowStocks() {
|
|
|
var $lowStocks = $('.low-stocks'),
|
|
|
var $lowStocks,
|
|
|
result = false;
|
|
|
|
|
|
if ('ordinary' === cartType) {
|
|
|
$lowStocks = $('.common .low-stocks');
|
|
|
} else if ('advance' === cartType) {
|
|
|
$lowStocks = $('.presell .low-stocks');
|
|
|
}
|
|
|
|
|
|
if ($lowStocks.length <= 0) {
|
|
|
return result;
|
|
|
}
|
...
|
...
|
@@ -58,7 +70,7 @@ function showChooseGifDialog() { |
|
|
rightBtnText: '去选择'
|
|
|
}
|
|
|
}, function() {
|
|
|
window.location.href = $('.freebie').find('a').attr('href');
|
|
|
window.location.href = $cartContentShow.find('.freebie > a').attr('href');
|
|
|
}, function() {
|
|
|
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
|
|
|
});
|
...
|
...
|
@@ -66,7 +78,7 @@ function showChooseGifDialog() { |
|
|
|
|
|
require('./good');
|
|
|
|
|
|
lazyLoad($('img.lazy'));
|
|
|
//lazyLoad($('img.lazy'));
|
|
|
|
|
|
if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) {
|
|
|
$('#presell-tip').removeClass('show').addClass('hide');
|
...
|
...
|
@@ -93,10 +105,6 @@ if ($('.cart-nav').length > 0) { |
|
|
return;
|
|
|
}
|
|
|
|
|
|
$('.shopping-cart-good .name').each(function() {
|
|
|
this.mlellipsis(2);
|
|
|
});
|
|
|
|
|
|
if (cartType === 'ordinary') {
|
|
|
cartType = 'advance';
|
|
|
$('#cartType').val('advance');
|
...
|
...
|
@@ -111,7 +119,14 @@ if ($('.cart-nav').length > 0) { |
|
|
//切换普通商品和预售商品购物车显示
|
|
|
$cartContent.toggleClass('hide');
|
|
|
|
|
|
hasChecked = $('.cart-content:not(.hide) .icon-cb-checked').length > 0 ? true : false;
|
|
|
$cartContentShow = $cartContent.not('.hide');
|
|
|
|
|
|
if (switchChose === false) {
|
|
|
$cartContentShow.find('.shopping-cart-good .name').each(function() {
|
|
|
this.mlellipsis(2);
|
|
|
});
|
|
|
switchChose = true;
|
|
|
}
|
|
|
|
|
|
//trigger lazyload
|
|
|
$(window).trigger('scroll');
|
...
|
...
|
@@ -141,7 +156,7 @@ if ($('.freebie').length > 0) { |
|
|
|
|
|
$('.btn-balance').on('touchend', function() {
|
|
|
if (shouldLowStocks()) {
|
|
|
tip.show('库存不足无法结算');
|
|
|
tip.show('所选商品中含有库存不足的商品');
|
|
|
return false;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -150,7 +165,7 @@ $('.btn-balance').on('touchend', function() { |
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (hasChecked) {
|
|
|
if (hasChecked()) {
|
|
|
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
|
|
|
} else {
|
|
|
tip.show('请先勾选商品');
|
...
|
...
|
@@ -161,10 +176,6 @@ $('.chose').on('touchend', function() { |
|
|
chosePanel.show();
|
|
|
});
|
|
|
|
|
|
if ($('.shopping-cart-good').length <= 0) {
|
|
|
require('../product/recommend-for-you');
|
|
|
}
|
|
|
|
|
|
function notAllowScroll() {
|
|
|
var docH = $(document).height(),
|
|
|
winH = $(window).height();
|
...
|
...
|
|