...
|
...
|
@@ -5,6 +5,7 @@ |
|
|
*/
|
|
|
|
|
|
var $ = require('jquery'),
|
|
|
ellipsis = require('mlellipsis'),
|
|
|
Hammer = require('yoho.hammer');
|
|
|
|
|
|
var chosePanel = require('./chose-panel'),
|
...
|
...
|
@@ -13,23 +14,36 @@ var chosePanel = require('./chose-panel'), |
|
|
|
|
|
var $cartContent = $('.cart-content'),
|
|
|
cartType = $('#cartType').val(),
|
|
|
$cartNav = $('.cart-nav'),
|
|
|
hasShowCartPresellTip = false;
|
|
|
|
|
|
var $cartContentShow = $cartContent.not('.hide');
|
|
|
|
|
|
var navHammer,
|
|
|
advanceBuyHammer,
|
|
|
freebieHammer,
|
|
|
switchChose = false;
|
|
|
|
|
|
require('../product/recommend-for-you');
|
|
|
require('./good');
|
|
|
|
|
|
ellipsis.init();
|
|
|
|
|
|
function cartContentShow() {
|
|
|
return $cartContent.not('.hide');
|
|
|
}
|
|
|
|
|
|
function mlellipsisHiddenNames() {
|
|
|
cartContentShow().find('.shopping-cart-good .name').each(function() {
|
|
|
this.mlellipsis(2);
|
|
|
});
|
|
|
switchChose = true;
|
|
|
}
|
|
|
|
|
|
function hasChecked() {
|
|
|
return $cartContentShow.find('.icon-cb-checked').length > 0 ? true : false;
|
|
|
return cartContentShow().find('.cart-goods .icon-cb-checked').length > 0 ? true : false;
|
|
|
}
|
|
|
|
|
|
function shouldSelectGift() {
|
|
|
var $freebie = $cartContentShow.find('.freebie');
|
|
|
var $freebie = cartContentShow().find('.freebie');
|
|
|
|
|
|
if ($freebie.length <= 0) {
|
|
|
return false;
|
...
|
...
|
@@ -70,16 +84,12 @@ function showChooseGifDialog() { |
|
|
rightBtnText: '去选择'
|
|
|
}
|
|
|
}, function() {
|
|
|
window.location.href = $cartContentShow.find('.freebie > a').attr('href');
|
|
|
window.location.href = cartContentShow().find('.freebie > a').attr('href');
|
|
|
}, function() {
|
|
|
window.location.href = '/cart/index/orderEnsure?cartType=' + cartType;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
require('./good');
|
|
|
|
|
|
//lazyLoad($('img.lazy'));
|
|
|
|
|
|
if (typeof window.cookie === 'function' && 'y' === window.cookie('_hasShowCartPresellTip')) {
|
|
|
$('#presell-tip').removeClass('show').addClass('hide');
|
|
|
hasShowCartPresellTip = true;
|
...
|
...
|
@@ -91,12 +101,12 @@ if ('advance' === cartType) { |
|
|
$cartContent.toggleClass('hide');
|
|
|
$('#common-cart-nav').removeClass('active');
|
|
|
$('#presell-cart-nav').addClass('active');
|
|
|
$('.shopping-cart-good .name').each(function() {
|
|
|
this.mlellipsis(2);
|
|
|
});
|
|
|
|
|
|
mlellipsisHiddenNames();
|
|
|
$(window).trigger('scroll');
|
|
|
}
|
|
|
|
|
|
if ($('.cart-nav').length > 0) {
|
|
|
if ($cartNav.length > 0) {
|
|
|
navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
|
|
|
navHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target).closest('li');
|
...
|
...
|
@@ -119,13 +129,8 @@ if ($('.cart-nav').length > 0) { |
|
|
//切换普通商品和预售商品购物车显示
|
|
|
$cartContent.toggleClass('hide');
|
|
|
|
|
|
$cartContentShow = $cartContent.not('.hide');
|
|
|
|
|
|
if (switchChose === false) {
|
|
|
$cartContentShow.find('.shopping-cart-good .name').each(function() {
|
|
|
this.mlellipsis(2);
|
|
|
});
|
|
|
switchChose = true;
|
|
|
mlellipsisHiddenNames();
|
|
|
}
|
|
|
|
|
|
//trigger lazyload
|
...
|
...
|
@@ -176,16 +181,11 @@ $('.chose').on('touchend', function() { |
|
|
chosePanel.show();
|
|
|
});
|
|
|
|
|
|
function notAllowScroll() {
|
|
|
var docH = $(document).height(),
|
|
|
winH = $(window).height();
|
|
|
|
|
|
if (docH - winH <= 10) {
|
|
|
$('body').css('overflow', 'hidden');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
notAllowScroll();
|
|
|
$cartNav.on('touchstart', 'li', function(e) {
|
|
|
$(this).addClass('bytouch');
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$cartNav.find('li').removeClass('bytouch');
|
|
|
});
|
|
|
|
|
|
//提前触发lazyload
|
|
|
$(window).scrollTop(1).scrollTop(0); |
...
|
...
|
|