cart.js
734 Bytes
/**
* 购物车Logic
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/10/20
*/
var $ = require('jquery'),
lazyLoad = require('yoho.lazyload'),
Hammer = require('yoho.hammer');
var $cartContent = $('.cart-content');
var navHammer;
require('./good');
lazyLoad($('img.lazy'));
navHammer = new Hammer(document.getElementsByClassName('cart-nav')[0]);
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li');
if ($this.hasClass('active')) {
return;
}
$this.siblings('.active').removeClass('active');
$this.addClass('active');
//切换普通商品和预售商品购物车显示
$cartContent.toggleClass('hide');
//trigger lazyload
$(window).trigger('scroll');
});