suspend-cart.js
587 Bytes
/**
* 悬浮购物车
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2015/11/1
*/
var $ = require('yoho-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');
}
}
});