suspend-cart.js 582 Bytes
/**
 * 悬浮购物车
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/11/1
 */

var $ = require('jquery');

var $cart = $('#suspend-cart');

$.ajax({
    type: 'GET',
    url: '/cart/index/count',
    success: function(data) {
        var count;

        if (data.code === 200) {
            count = data.data.cart_goods_count;
            if (count > 99) {
                count = '99+';
            }
            if (count === 0) {
                $('.cart-count').remove();
            }
            $cart.find('.cart-count').html(count).removeClass('hide');
        }
    }
});