cart.js 667 Bytes
/**
 * 购物车Logic
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/10/20
 */

var $ = require('jquery'),
    Hammer = require('yoho.hammer');

var $cartContent = $('.cart-content');

var navHammer;

require('./good');

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');
});