HotCommodity.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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-top: 10px;
  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-family: AdobeHeitiStd-Regular;
  99. font-size: 16px;
  100. color: #333;
  101. }
  102. img{
  103. position: absolute;
  104. top: 14px;
  105. left: 25px;
  106. }
  107. }
  108. ul{
  109. padding: 14px 0 0;
  110. width: 220px;
  111. li{
  112. margin: 0 auto 25px;
  113. text-align: center;
  114. .img{
  115. margin: 0 auto;
  116. width: 181px;
  117. height: 117px;
  118. border-radius: 2px;
  119. border: solid 1px #e2e2e2;
  120. img{
  121. width: 91px;
  122. height: 87px;
  123. }
  124. }
  125. .name {
  126. display: inline-block;
  127. margin: 10px auto;
  128. font-size: 14px;
  129. color: #333;
  130. }
  131. .price{
  132. margin: 0 auto;
  133. width: 124px;
  134. height: 21px;
  135. line-height: 21px;
  136. font-size: 13px;
  137. color: #fff;
  138. background-color: #e6382f;
  139. }
  140. }
  141. }
  142. }
  143. </style>