Authored by Lynnic

为购物车商品数量添加ajax请求 --code viewed by zhaobiao

... ... @@ -3,7 +3,7 @@
* @author: liangzhifeng<zhifeng.liang@yoho.cn>
* @date: 2015/10/20
*/
var $ = require('jquery'),
var $ = require('jquery'),
Swiper = require('yoho.iswiper'),
Hammer = require('yoho.hammer'),
lazyLoad = require('yoho.lazyload');
... ... @@ -15,6 +15,8 @@ var goodsSwiper,
var goodsDiscountEl = document.getElementById('goodsDiscount'),
goodsDiscountHammer = goodsDiscountEl && new Hammer(goodsDiscountEl);
var $cart = $('.cart-bar');
require('./desc');
require('./comments-consults');
... ... @@ -67,6 +69,16 @@ if (goodsDiscountHammer) {
});
}
//购物车商品数量
$.ajax({
type: 'GET',
url: '/cart/index/count',
success: function(data) {
if (data.code === 200) {
$cart.find('.num-tag').html(data.data.cart_goods_count).removeClass('hide');
}
}
});
require('./like');
... ...
... ... @@ -405,6 +405,9 @@ $basicBtnC:#eb0313;
border-radius: 50%;
color: #fff;
font-size: pxToRem(24px);
&.hide{
display: none;
}
}
}
// .recommend-for-you {
... ...
... ... @@ -117,10 +117,8 @@
{{> product/recommend-for-you}}
{{#cartInfo}}
<div class="cart-bar">
{{#if numInCart}}
<span class="num-tag">{{numInCart}}</span>
{{/if}}
<div class="cart-bar">
<span class="num-tag hide"></span>
<a href="{{cartUrl}}" class="num-incart iconfont">&#xe62c;</a>
{{#if addToCart}}
... ...