Showing
5 changed files
with
65 additions
and
66 deletions
public/img/product/shopping-bag.png
0 → 100644
![](/fe/yohoblk-wap/raw/5bf793432df8623f12e033cc316e805e4824cccb/public/img/product/shopping-bag.png)
1.5 KB
@@ -86,10 +86,6 @@ | @@ -86,10 +86,6 @@ | ||
86 | swipeItem: swipe.SwipeItem, | 86 | swipeItem: swipe.SwipeItem, |
87 | }, | 87 | }, |
88 | methods: { | 88 | methods: { |
89 | - initActiveSides: function () { | ||
90 | - | ||
91 | - | ||
92 | - }, | ||
93 | showcase: function() { | 89 | showcase: function() { |
94 | const opts = { | 90 | const opts = { |
95 | images: this.goods.map((item) => { | 91 | images: this.goods.map((item) => { |
1 | <template> | 1 | <template> |
2 | <div class="image-swipe"> | 2 | <div class="image-swipe"> |
3 | <div class="swipe-wrap"> | 3 | <div class="swipe-wrap"> |
4 | - <swiper :options="swiperOption"> | 4 | + <swiper :options="swiperOption" v-ref:swiper> |
5 | <swiper-slide v-for="item in goods"> | 5 | <swiper-slide v-for="item in goods"> |
6 | <img title="{{item.title}}" | 6 | <img title="{{item.title}}" |
7 | :src="item.color_image | resize 580 770" | 7 | :src="item.color_image | resize 580 770" |
8 | width="100%" alt="" | 8 | width="100%" alt="" |
9 | - @click.prevent="showcase()"> | 9 | + data-index="{{$index}}" |
10 | + @click.stop.prevent="showcase()"> | ||
10 | </swiper-slide> | 11 | </swiper-slide> |
11 | </swiper> | 12 | </swiper> |
12 | </div> | 13 | </div> |
@@ -60,7 +61,8 @@ | @@ -60,7 +61,8 @@ | ||
60 | } | 61 | } |
61 | </style> | 62 | </style> |
62 | <script> | 63 | <script> |
63 | - import { swiper, swiperSlide } from 'vue-awesome-swiper' | 64 | + const yoho = require('yoho'); |
65 | + const vas = require('vue-awesome-swiper'); | ||
64 | 66 | ||
65 | module.exports = { | 67 | module.exports = { |
66 | props: { | 68 | props: { |
@@ -71,26 +73,26 @@ | @@ -71,26 +73,26 @@ | ||
71 | swiperOption: { | 73 | swiperOption: { |
72 | loop: true, | 74 | loop: true, |
73 | pagination : '.swiper-pagination', | 75 | pagination : '.swiper-pagination', |
74 | - paginationClickable :true, | ||
75 | slidesPerView: 3 | 76 | slidesPerView: 3 |
76 | } | 77 | } |
77 | }; | 78 | }; |
78 | }, | 79 | }, |
79 | components: { | 80 | components: { |
80 | - swiper, | ||
81 | - swiperSlide, | 81 | + swiper: vas.swiper, |
82 | + swiperSlide: vas.swiperSlide, | ||
83 | + }, | ||
84 | + computed: { | ||
85 | + swiper() { | ||
86 | + return this.$refs.swiper.swiper | ||
87 | + } | ||
82 | }, | 88 | }, |
83 | methods: { | 89 | methods: { |
84 | - initActiveSides: function () { | ||
85 | - | ||
86 | - | ||
87 | - }, | ||
88 | showcase: function() { | 90 | showcase: function() { |
89 | const opts = { | 91 | const opts = { |
90 | images: this.goods.map((item) => { | 92 | images: this.goods.map((item) => { |
91 | return item.color_image; | 93 | return item.color_image; |
92 | }).filter(image => image), | 94 | }).filter(image => image), |
93 | - index: this.$refs.swipe.index | 95 | + index: this.swiper.activeIndex |
94 | }; | 96 | }; |
95 | 97 | ||
96 | yoho.goImageBrowser(opts); | 98 | yoho.goImageBrowser(opts); |
@@ -263,7 +263,7 @@ | @@ -263,7 +263,7 @@ | ||
263 | </show-box> | 263 | </show-box> |
264 | 264 | ||
265 | <div v-if="isApp && isReady"> | 265 | <div v-if="isApp && isReady"> |
266 | - <shopping-bag></shopping-bag> | 266 | + <shopping-bag :cart-count="cartCount"></shopping-bag> |
267 | </div> | 267 | </div> |
268 | 268 | ||
269 | <div v-if="!isApp"> | 269 | <div v-if="!isApp"> |
@@ -352,6 +352,7 @@ | @@ -352,6 +352,7 @@ | ||
352 | topNav: require('./top-nav.vue'), | 352 | topNav: require('./top-nav.vue'), |
353 | shareBottom: require('component/tool/share-bottom.vue'), | 353 | shareBottom: require('component/tool/share-bottom.vue'), |
354 | preferList: require('component/product/prefer-list.vue'), | 354 | preferList: require('component/product/prefer-list.vue'), |
355 | + shoppingBag: require('./shopping-bag.vue'), | ||
355 | operationBar: require('./operation-bar.vue') | 356 | operationBar: require('./operation-bar.vue') |
356 | }, | 357 | }, |
357 | methods: { | 358 | methods: { |
1 | <template> | 1 | <template> |
2 | - <div class="shopping-bag"> | 2 | + <div class="shopping-bag" @click="yoho.goShopingCart()"> |
3 | <div class="background"></div> | 3 | <div class="background"></div> |
4 | - | ||
5 | - <!--<button class="button control-button">--> | ||
6 | - <!--<span @click="yoho.goShopingCart()" style="position: relative;">--> | ||
7 | - <!--<span class="shopbag"></span>--> | ||
8 | - <!--<span v-if="isApp && cartCount > 0" class="badge badge-tr">{{cartCount >= 100 ? '99+': cartCount}}</span>--> | ||
9 | - <!--</span>--> | ||
10 | - <!--</button>--> | ||
11 | - <!--<button class="button control-button" @click="toggleFavorite()">--> | ||
12 | - <!--<span v-if="entity.is_collect === 'Y' " class="icon icon-focused"></span>--> | ||
13 | - <!--<span v-else class="focus"></span>--> | ||
14 | - <!--</button>--> | ||
15 | - <!--<button class="button button-solid add-to-cart"--> | ||
16 | - <!--@click="showAddToCart()"--> | ||
17 | - <!--:disabled="isSoldOut">--> | ||
18 | - <!--<span v-if="isSoldOut">--> | ||
19 | - <!--已售完--> | ||
20 | - <!--</span>--> | ||
21 | - <!--<span v-else="">--> | ||
22 | - <!--加入购物袋--> | ||
23 | - <!--</span>--> | ||
24 | - <!--</button>--> | 4 | + <div class="bag"></div> |
5 | + <span v-if="cartCount > 0" class="number" :class="{over: cartCount > 99}"> | ||
6 | + {{cartCount > 99 ? '99+' : cartCount}} | ||
7 | + </span> | ||
25 | </div> | 8 | </div> |
26 | </template> | 9 | </template> |
27 | <style> | 10 | <style> |
28 | .shopping-bag { | 11 | .shopping-bag { |
12 | + position: fixed; | ||
13 | + bottom: 100px; | ||
14 | + left: 50px; | ||
15 | + text-align: center; | ||
16 | + | ||
17 | + .background { | ||
18 | + width: 108px; | ||
19 | + height: 108px; | ||
20 | + opacity: .3; | ||
21 | + border-radius: 50%; | ||
22 | + background-color: #000; | ||
23 | + } | ||
24 | + | ||
25 | + .bag { | ||
26 | + position: absolute; | ||
27 | + top: 50%; | ||
28 | + left: 50%; | ||
29 | + width: 48px; | ||
30 | + height: 48px; | ||
31 | + margin-left: -24px; | ||
32 | + margin-top: -26px; | ||
33 | + background: resolve("product/shopping-bag.png"); | ||
34 | + background-size: contain; | ||
35 | + } | ||
29 | 36 | ||
37 | + .number { | ||
38 | + position: absolute; | ||
39 | + width: 36px; | ||
40 | + height: 36px; | ||
41 | + top: 0; | ||
42 | + right: 0; | ||
43 | + color: #fff; | ||
44 | + font-size: 20px; | ||
45 | + line-height: 36px; | ||
46 | + text-align: center; | ||
47 | + border-radius: 50%; | ||
48 | + background-color: #d0021b; | ||
49 | + | ||
50 | + &.over { | ||
51 | + font-size: 14px; | ||
52 | + } | ||
53 | + } | ||
30 | } | 54 | } |
31 | </style> | 55 | </style> |
32 | <script> | 56 | <script> |
@@ -36,36 +60,12 @@ | @@ -36,36 +60,12 @@ | ||
36 | module.exports = { | 60 | module.exports = { |
37 | name: 'shopping-bag', | 61 | name: 'shopping-bag', |
38 | props: { | 62 | props: { |
39 | - shareImg: String | 63 | + cartCount: [Number, String] |
40 | }, | 64 | }, |
41 | data() { | 65 | data() { |
42 | - return {}; | ||
43 | - }, | ||
44 | - methods: { | ||
45 | - share() { | ||
46 | - yoho.goShare({ | ||
47 | - title: this.shareTitle || '', | ||
48 | - des: '我在BLK发现了一个不错的商品,快来看看吧!', | ||
49 | - img: location.protocol + this.shareImg, | ||
50 | - url: location.href | ||
51 | - }); | ||
52 | - }, | ||
53 | - toggleFavorite: function() { | ||
54 | - $.post('/product/favorite.json', { | ||
55 | - operation: this.entity.is_collect === 'Y' ? 'remove' : 'add', | ||
56 | - id: this.entity.product_id | ||
57 | - }).then((result)=> { | ||
58 | - if (result.code === 200) { | ||
59 | - tip(this.entity.is_collect === 'Y' ? '取消收藏成功' : '收藏成功'); | ||
60 | - this.entity.is_collect = this.entity.is_collect === 'Y' ? 'N' : 'Y'; | ||
61 | - yoho.store.set('productReload', true); | ||
62 | - } else if (result.code === 401) { | ||
63 | - yoho.goLogin('', () => { | ||
64 | - this.toggleFavorite(); | ||
65 | - }); | ||
66 | - } | ||
67 | - }); | ||
68 | - } | 66 | + return { |
67 | + yoho: yoho | ||
68 | + }; | ||
69 | } | 69 | } |
70 | }; | 70 | }; |
71 | </script> | 71 | </script> |
-
Please register or login to post a comment