Authored by 李奇

图片轮播问题修改

... ... @@ -90,7 +90,7 @@ const component = {
saveRecentGoodInCookies(req.cookies._browseskn_h5, res, result[0].data.product_skn);
}
if (result[0].data.vip) {
if (result[0].data && result[0].data.vip) {
for (let val of result[0].data.vip) {
vipPrice.push({
level: vipLe(val.caption),
... ... @@ -179,6 +179,24 @@ const component = {
}).catch(next);
},
isFavorite(req, res, next) {
if (!req.user.uid) {
return res.json({
code: 401,
message: '用户未登录'
});
}
let params = {
id: req.params.id,
uid: req.user.uid
};
model.isFavorite(params).then(result => {
res.json(result);
}).catch(next);
},
/**
* 获取购物车数量
*
... ...
... ... @@ -80,6 +80,16 @@ const model = {
},
/**
* 判断是否收藏
* @param params
*/
isFavorite(params){
return api.get('/favorite', Object.assign({
method: 'app.favorite.isFavoriteNew'
}, params));
},
/**
* 获取购物车数量
*
* @param params
... ...
... ... @@ -48,6 +48,7 @@ router.get(/\/product\/product_([\d]+)\.json/, detail.product);
router.get(/\/product\/intro_([\d]+)\.json/, detail.intro);
router.get('/product/refundExchange/:skn', detail.supportRefundExchange); // 是否支持7天无理由退换货
router.get('/product/mightLike', detail.mightLike); // 猜你喜欢
router.get('/product/isFavorite/:id', detail.isFavorite); // 判断是否收藏
router.post(/\product\/cart.json/, detail.addToCart);
router.post(/\product\/favorite.json/, auth, detail.favorite);
router.get(/\/product\/cart-count.json/, detail.getCartCount);
... ...
... ... @@ -72,16 +72,8 @@
},
methods: {
showcase: function() {
let index;
const len =this.goods.length;
const realIndex = this.swiper.realIndex;
if (len < 4) {
index = realIndex;
} else {
index = realIndex - 4 > -1 ?
realIndex - 4 : len + realIndex - 4;
}
const index = this.calcIndex(realIndex);
const opts = {
index,
... ... @@ -93,16 +85,28 @@
yoho.goImageBrowser(opts);
},
setActiveSlide(idx){
let index;
this.activeIndex = this.calcIndex(idx);
},
calcIndex(realIdx){
const len = this.goods.length;
if (len < 4) {
index = idx;
if (len >= 4) {
if (realIdx === len -1) {
realIdx = 0;
} else {
index = idx - 4 > -1 ?
idx - 4 : len + idx - 4;
realIdx += 1;
}
if (realIdx < len -2) {
realIdx += 2;
} else if (realIdx === len -2) {
realIdx = 0;
} else {
realIdx = 1;
}
}
this.activeIndex = index;
return realIdx;
}
}
};
... ...
... ... @@ -424,6 +424,15 @@
this.$set('intro.supportRefundExchange', support);
});
// 是否收藏
$.get(`/product/isFavorite/${data.product_id}`).then(fav => {
if (fav.code === 200) {
this.$set('entity.is_collect', fav.data ? 'Y' : 'N');
} else {
this.$set('entity.is_collect', 'N');
}
});
});
}
})
... ... @@ -443,6 +452,10 @@
<style>
.product-page {
background: #f6f6f6;
hr {
margin: 25px 0!important;
}
}
.show-box.brand {
... ... @@ -568,14 +581,15 @@
.item-price {
text-align: left;
margin-top: 45px;
margin-bottom: 40px;
margin-top: 35px;
margin-bottom: 30px;
max-height: 195px;
.price {
color: #b0b0b0;
font-size: 32px;
font-style: normal;
line-height: 1;
font-family: "BrownStd-Regular";
&.line-through {
... ... @@ -585,13 +599,16 @@
}
&.highlight {
line-height: 1;
color: #b0021b;
}
}
.product-name {
font-size: 24px;
margin-top: 15px;
color: #000;
font-size: 24px;
line-height: 1.2;
}
.vip-level {
... ...