Showing
5 changed files
with
69 additions
and
19 deletions
@@ -90,7 +90,7 @@ const component = { | @@ -90,7 +90,7 @@ const component = { | ||
90 | saveRecentGoodInCookies(req.cookies._browseskn_h5, res, result[0].data.product_skn); | 90 | saveRecentGoodInCookies(req.cookies._browseskn_h5, res, result[0].data.product_skn); |
91 | } | 91 | } |
92 | 92 | ||
93 | - if (result[0].data.vip) { | 93 | + if (result[0].data && result[0].data.vip) { |
94 | for (let val of result[0].data.vip) { | 94 | for (let val of result[0].data.vip) { |
95 | vipPrice.push({ | 95 | vipPrice.push({ |
96 | level: vipLe(val.caption), | 96 | level: vipLe(val.caption), |
@@ -179,6 +179,24 @@ const component = { | @@ -179,6 +179,24 @@ const component = { | ||
179 | }).catch(next); | 179 | }).catch(next); |
180 | }, | 180 | }, |
181 | 181 | ||
182 | + isFavorite(req, res, next) { | ||
183 | + if (!req.user.uid) { | ||
184 | + return res.json({ | ||
185 | + code: 401, | ||
186 | + message: '用户未登录' | ||
187 | + }); | ||
188 | + } | ||
189 | + | ||
190 | + let params = { | ||
191 | + id: req.params.id, | ||
192 | + uid: req.user.uid | ||
193 | + }; | ||
194 | + | ||
195 | + model.isFavorite(params).then(result => { | ||
196 | + res.json(result); | ||
197 | + }).catch(next); | ||
198 | + }, | ||
199 | + | ||
182 | /** | 200 | /** |
183 | * 获取购物车数量 | 201 | * 获取购物车数量 |
184 | * | 202 | * |
@@ -80,6 +80,16 @@ const model = { | @@ -80,6 +80,16 @@ const model = { | ||
80 | }, | 80 | }, |
81 | 81 | ||
82 | /** | 82 | /** |
83 | + * 判断是否收藏 | ||
84 | + * @param params | ||
85 | + */ | ||
86 | + isFavorite(params){ | ||
87 | + return api.get('/favorite', Object.assign({ | ||
88 | + method: 'app.favorite.isFavoriteNew' | ||
89 | + }, params)); | ||
90 | + }, | ||
91 | + | ||
92 | + /** | ||
83 | * 获取购物车数量 | 93 | * 获取购物车数量 |
84 | * | 94 | * |
85 | * @param params | 95 | * @param params |
@@ -48,6 +48,7 @@ router.get(/\/product\/product_([\d]+)\.json/, detail.product); | @@ -48,6 +48,7 @@ router.get(/\/product\/product_([\d]+)\.json/, detail.product); | ||
48 | router.get(/\/product\/intro_([\d]+)\.json/, detail.intro); | 48 | router.get(/\/product\/intro_([\d]+)\.json/, detail.intro); |
49 | router.get('/product/refundExchange/:skn', detail.supportRefundExchange); // 是否支持7天无理由退换货 | 49 | router.get('/product/refundExchange/:skn', detail.supportRefundExchange); // 是否支持7天无理由退换货 |
50 | router.get('/product/mightLike', detail.mightLike); // 猜你喜欢 | 50 | router.get('/product/mightLike', detail.mightLike); // 猜你喜欢 |
51 | +router.get('/product/isFavorite/:id', detail.isFavorite); // 判断是否收藏 | ||
51 | router.post(/\product\/cart.json/, detail.addToCart); | 52 | router.post(/\product\/cart.json/, detail.addToCart); |
52 | router.post(/\product\/favorite.json/, auth, detail.favorite); | 53 | router.post(/\product\/favorite.json/, auth, detail.favorite); |
53 | router.get(/\/product\/cart-count.json/, detail.getCartCount); | 54 | router.get(/\/product\/cart-count.json/, detail.getCartCount); |
@@ -72,16 +72,8 @@ | @@ -72,16 +72,8 @@ | ||
72 | }, | 72 | }, |
73 | methods: { | 73 | methods: { |
74 | showcase: function() { | 74 | showcase: function() { |
75 | - let index; | ||
76 | - const len =this.goods.length; | ||
77 | const realIndex = this.swiper.realIndex; | 75 | const realIndex = this.swiper.realIndex; |
78 | - | ||
79 | - if (len < 4) { | ||
80 | - index = realIndex; | ||
81 | - } else { | ||
82 | - index = realIndex - 4 > -1 ? | ||
83 | - realIndex - 4 : len + realIndex - 4; | ||
84 | - } | 76 | + const index = this.calcIndex(realIndex); |
85 | 77 | ||
86 | const opts = { | 78 | const opts = { |
87 | index, | 79 | index, |
@@ -93,16 +85,28 @@ | @@ -93,16 +85,28 @@ | ||
93 | yoho.goImageBrowser(opts); | 85 | yoho.goImageBrowser(opts); |
94 | }, | 86 | }, |
95 | setActiveSlide(idx){ | 87 | setActiveSlide(idx){ |
96 | - let index; | 88 | + this.activeIndex = this.calcIndex(idx); |
89 | + }, | ||
90 | + calcIndex(realIdx){ | ||
97 | const len = this.goods.length; | 91 | const len = this.goods.length; |
98 | - if (len < 4) { | ||
99 | - index = idx; | 92 | + |
93 | + if (len >= 4) { | ||
94 | + if (realIdx === len -1) { | ||
95 | + realIdx = 0; | ||
100 | } else { | 96 | } else { |
101 | - index = idx - 4 > -1 ? | ||
102 | - idx - 4 : len + idx - 4; | 97 | + realIdx += 1; |
98 | + } | ||
99 | + | ||
100 | + if (realIdx < len -2) { | ||
101 | + realIdx += 2; | ||
102 | + } else if (realIdx === len -2) { | ||
103 | + realIdx = 0; | ||
104 | + } else { | ||
105 | + realIdx = 1; | ||
106 | + } | ||
103 | } | 107 | } |
104 | 108 | ||
105 | - this.activeIndex = index; | 109 | + return realIdx; |
106 | } | 110 | } |
107 | } | 111 | } |
108 | }; | 112 | }; |
@@ -424,6 +424,15 @@ | @@ -424,6 +424,15 @@ | ||
424 | 424 | ||
425 | this.$set('intro.supportRefundExchange', support); | 425 | this.$set('intro.supportRefundExchange', support); |
426 | }); | 426 | }); |
427 | + | ||
428 | + // 是否收藏 | ||
429 | + $.get(`/product/isFavorite/${data.product_id}`).then(fav => { | ||
430 | + if (fav.code === 200) { | ||
431 | + this.$set('entity.is_collect', fav.data ? 'Y' : 'N'); | ||
432 | + } else { | ||
433 | + this.$set('entity.is_collect', 'N'); | ||
434 | + } | ||
435 | + }); | ||
427 | }); | 436 | }); |
428 | } | 437 | } |
429 | }) | 438 | }) |
@@ -443,6 +452,10 @@ | @@ -443,6 +452,10 @@ | ||
443 | <style> | 452 | <style> |
444 | .product-page { | 453 | .product-page { |
445 | background: #f6f6f6; | 454 | background: #f6f6f6; |
455 | + | ||
456 | + hr { | ||
457 | + margin: 25px 0!important; | ||
458 | + } | ||
446 | } | 459 | } |
447 | 460 | ||
448 | .show-box.brand { | 461 | .show-box.brand { |
@@ -568,14 +581,15 @@ | @@ -568,14 +581,15 @@ | ||
568 | 581 | ||
569 | .item-price { | 582 | .item-price { |
570 | text-align: left; | 583 | text-align: left; |
571 | - margin-top: 45px; | ||
572 | - margin-bottom: 40px; | 584 | + margin-top: 35px; |
585 | + margin-bottom: 30px; | ||
573 | max-height: 195px; | 586 | max-height: 195px; |
574 | 587 | ||
575 | .price { | 588 | .price { |
576 | color: #b0b0b0; | 589 | color: #b0b0b0; |
577 | font-size: 32px; | 590 | font-size: 32px; |
578 | font-style: normal; | 591 | font-style: normal; |
592 | + line-height: 1; | ||
579 | font-family: "BrownStd-Regular"; | 593 | font-family: "BrownStd-Regular"; |
580 | 594 | ||
581 | &.line-through { | 595 | &.line-through { |
@@ -585,13 +599,16 @@ | @@ -585,13 +599,16 @@ | ||
585 | } | 599 | } |
586 | 600 | ||
587 | &.highlight { | 601 | &.highlight { |
602 | + line-height: 1; | ||
588 | color: #b0021b; | 603 | color: #b0021b; |
589 | } | 604 | } |
590 | } | 605 | } |
591 | 606 | ||
592 | .product-name { | 607 | .product-name { |
593 | - font-size: 24px; | 608 | + margin-top: 15px; |
594 | color: #000; | 609 | color: #000; |
610 | + font-size: 24px; | ||
611 | + line-height: 1.2; | ||
595 | } | 612 | } |
596 | 613 | ||
597 | .vip-level { | 614 | .vip-level { |
-
Please register or login to post a comment