HotCommodity.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <div class="hot-commodity recommend-fragment">
  3. <div class="title-icon">
  4. <span>产品推荐</span>
  5. <img src="/images/original/line.png" alt=""/>
  6. </div>
  7. <div v-swiper:mySwiper="swiperOption" v-if="hotComponents || hotComponents.length>0">
  8. <div class="swiper-wrapper">
  9. <div class="swiper-slide" v-if="hotComponents.length>0">
  10. <ul class="recommend-list clearfix">
  11. <li v-for="(component, index) in hotComponents.slice(0,2)" class="big">
  12. <a :href="'/store/productDetail/' + component.batchCode" target="_blank">
  13. <div class="img"><img :src="component.img || '/images/store/common/default.png'"/></div>
  14. <span class="name">{{component.code}}</span>
  15. <div class="price">1111.23242</div>
  16. </a>
  17. </li>
  18. </ul>
  19. </div>
  20. <div class="swiper-slide" v-if="hotComponents.length>=2">
  21. <ul class="recommend-list clearfix">
  22. <li v-for="(component, index) in hotComponents.slice(2,4)" class="big">
  23. <a :href="'/store/productDetail/' + component.batchCode" target="_blank">
  24. <div class="img"><img :src="component.img || '/images/store/common/default.png'"/></div>
  25. <span class="name">{{component.code}}</span>
  26. <div class="price">1111.23242</div>
  27. </a>
  28. </li>
  29. </ul>
  30. </div>
  31. <div class="swiper-slide" v-if="hotComponents.length>=4">
  32. <ul class="recommend-list clearfix">
  33. <li v-for="(component, index) in hotComponents.slice(4,6)" class="big">
  34. <a :href="'/store/productDetail/' + component.batchCode" target="_blank">
  35. <div class="img"><img :src="component.img || '/images/store/common/default.png'"/></div>
  36. <span class="name">{{component.code}}</span>
  37. <div class="price">1111.23242</div>
  38. </a>
  39. </li>
  40. </ul>
  41. </div>
  42. <div class="swiper-slide" v-if="hotComponents.length>=6">
  43. <ul class="recommend-list clearfix">
  44. <li v-for="(component, index) in hotComponents.slice(6,8)" class="big">
  45. <a :href="'/store/productDetail/' + component.batchCode" target="_blank">
  46. <div class="img"><img :src="component.img || '/images/store/common/default.png'"/></div>
  47. <span class="name">{{component.code}}</span>
  48. <div class="price">1111.23242</div>
  49. </a>
  50. </li>
  51. </ul>
  52. </div>
  53. </div>
  54. <div class="swiper-pagination swiper-pagination-bullets" style="bottom: -3px!important;"></div>
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. export default {
  60. name: 'hot-commodity',
  61. computed: {
  62. hotComponents () {
  63. console.log(this.$store.state.provider.storeCms.hotComponents.data, 'c')
  64. return this.$store.state.provider.storeCms.hotComponents.data
  65. },
  66. // 产品推荐轮播
  67. swiperOption () {
  68. return {
  69. autoplay: 5000,
  70. initialSlide: 0,
  71. loop: true,
  72. effect: this.effect,
  73. lazyLoading: true,
  74. // 解决点击分页器后图片就不能轮播的问题
  75. autoplayDisableOnInteraction: false,
  76. pagination: '.swiper-pagination',
  77. paginationClickable: true,
  78. paginationElement: 'li'
  79. }
  80. }
  81. }
  82. }
  83. </script>
  84. <style scoped lang="scss">
  85. .hot-commodity {
  86. margin: 10px 0 30px 0;
  87. width: 220px;
  88. height: 464px;
  89. background-color: #fff;
  90. border-radius: 5px;
  91. .title-icon {
  92. position: relative;
  93. width: 100%;
  94. height: 34px;
  95. line-height: 34px;
  96. text-align: center;
  97. span{
  98. font-size: 16px;
  99. color: #333;
  100. }
  101. img{
  102. position: absolute;
  103. top: 14px;
  104. left: 25px;
  105. }
  106. }
  107. ul{
  108. padding: 14px 0 0;
  109. width: 220px;
  110. li{
  111. margin: 0 auto 25px;
  112. text-align: center;
  113. .img{
  114. margin: 0 auto;
  115. width: 181px;
  116. height: 117px;
  117. border-radius: 2px;
  118. border: solid 1px #e2e2e2;
  119. img{
  120. width: 91px;
  121. height: 87px;
  122. }
  123. }
  124. .name {
  125. display: inline-block;
  126. margin: 10px auto;
  127. font-size: 14px;
  128. color: #333;
  129. }
  130. .price{
  131. margin: 0 auto;
  132. width: 124px;
  133. height: 21px;
  134. line-height: 21px;
  135. font-size: 13px;
  136. color: #fff;
  137. background-color: #e6382f;
  138. }
  139. }
  140. }
  141. }
  142. </style>