ソースを参照

店铺轮播和点击切换事件

hangb 7 年 前
コミット
42f767f038

+ 1 - 7
components/provider/Carousel.vue

@@ -23,19 +23,13 @@
         activeSlide: 0
       }
     },
+    props: ['banners'],
     mixins: [carousel],
     computed: {
       storeType () {
         this.activeSlide = 0
         return this.$store.state.provider.stores.storeType.data
       },
-      banners () {
-        if (this.$store.state.carousel.banners) {
-          return this.$store.state.carousel.banners.data.data
-        } else {
-          return ''
-        }
-      },
       swiperOption () {
         return {
           autoplay: 5000,

+ 1 - 1
components/provider/HotCommodity.vue

@@ -74,7 +74,7 @@ export default {
   name: 'hot-commodity',
   computed: {
     hotComponents () {
-      console.log(this.$store.state.provider.storeCms.hotComponents.data.data)
+      // console.log(this.$store.state.provider.storeCms.hotComponents.data.data)
       return this.$store.state.provider.storeCms.hotComponents.data.data
     },
     // 产品推荐轮播

+ 18 - 1
components/provider/RecommendStore.vue

@@ -4,7 +4,7 @@
       <toggle-store/>
     </div>
     <div class="carousel">
-      <carousel />
+      <carousel :banners="banners" v-for="item in init" v-if="item.show" :key="item.id" />
     </div>
   </div>
 </template>
@@ -14,6 +14,11 @@ import Carousel from './Carousel.vue'
 
 export default {
   name: 'recommend-store',
+  data () {
+    return {
+      init: [{id: 0, show: true}]
+    }
+  },
   components: {
     ToggleStore,
     Carousel
@@ -21,6 +26,18 @@ export default {
   computed: {
     providerType () {
       return this.$route.path === '/provider/home' ? 'agency' : 'original'
+    },
+    banners () {
+      if (this.$store.state.carousel.banners) {
+        this.init[this.init.length - 1].show = false
+        this.init.push({
+          id: this.init.length,
+          show: true
+        })
+        return this.$store.state.carousel.banners.data.data
+      } else {
+        return ''
+      }
     }
   }
 }

+ 1 - 0
pages/provider/shop.vue

@@ -14,6 +14,7 @@ export default {
   layout: 'main',
   fetch ({ store }) {
     return Promise.all([
+      store.commit('provider/stores/SET_STORETYPE', 'factory'),
       store.dispatch('loadBanners', {type: 'factory_banner_carousel'}),
       store.dispatch('provider/loadSalesStore', { isOriginal: true }),
       store.dispatch('provider/loadNewStores', { types: 'ORIGINAL_FACTORY', size: 5 }),