Authored by 毕凯

商品列表增加收藏商品功能

... ... @@ -101,12 +101,18 @@ exports.init = function(num) {
removeHtmlFn();
ulStr = createColorList(data).colorListStr; //ajax请求的颜色列表
ulNum = createColorList(data).ulNum;//ajax请求的颜色的数量
ulStr = createColorList(data.pics).colorListStr; //ajax请求的颜色列表
ulNum = createColorList(data.pics).ulNum;//ajax请求的颜色的数量
$goodInfoMain.append(event.targetDuplicate);
$goodSelectColor.append($(ulStr));
if (data.isFavorite) {
$goodInfoMain.find('.col-btn').addClass('coled');
} else {
$goodInfoMain.find('.col-btn').removeClass('coled');
}
wrapperPl = $goodItemWrapper.css('paddingLeft');
wrapperPt = $goodItemWrapper.css('paddingTop');
containerPt = $goodsContainer.css('paddingTop');
... ... @@ -134,8 +140,8 @@ exports.init = function(num) {
});
// 鼠标悬浮获取到商品信息后显示第一张图片
if (data[0] && data[0].src) {
$goodInfoMain.find('.good-thumb img').attr('src', data[0].src);
if (data.pics[0] && data.pics[0].src) {
$goodInfoMain.find('.good-thumb img').attr('src', data.pics[0].src);
}
//}, 1000);
... ... @@ -143,6 +149,7 @@ exports.init = function(num) {
});
$goodItemWrapper.mouseleave(function() {
removeHtmlFn();
});
... ... @@ -163,6 +170,19 @@ $(document).on('hover', '.good-select-color li', function() {
$coverImg.attr('src', coverImg);
});
$goodInfoMain.on('click', '.col-btn', function() {
$.ajax({
type: 'POST',
url: '/product/list/changeFavorite',
data: {
skn: $(this).closest('.good-info').data('skn'),
isFavorite: !$(this).hasClass('coled')
}
}).then(function(res) {
console.log(res);
});
});
// 左侧导航
$productListNav.click(function() {
if ($(this).hasClass('active')) {
... ...
... ... @@ -66,6 +66,10 @@
color: #ccc;
font-size: 12px;
display: none;
&.coled {
color: #f95b4f;
}
}
.tag-container {
... ...