RecommendBrand.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="recommend-brand">
  3. <div v-swiper:mySwiper="swiperOption">
  4. <div class="swiper-wrapper">
  5. <div class="swiper-slide" v-for="banner in sliceBanners">
  6. <a :href="banner.hrefUrl" target="_blank" v-if="banner.hrefUrl">
  7. <img :src="banner.pictureLink"/>
  8. </a>
  9. <span v-if="!banner.hrefUrl">
  10. <img :src="banner.pictureLink"/>
  11. </span>
  12. </div>
  13. <div class="swiper-button-prev"><i class="iconfont icon-swiper-left"></i></div>
  14. <div class="swiper-button-next"><i class="iconfont icon-swiper-right"></i></div>
  15. </div>
  16. <div class="swiper-pagination swiper-pagination-bullets"></div>
  17. </div>
  18. <div class="recommend-area">
  19. <ul class="recommend-items">
  20. <li v-for="item in hotBrands.data">
  21. <a :href="item.detailsLink" target="_blank">
  22. <img :src="item.pictureLink" alt="">
  23. <div>
  24. <p>{{item.title}}</p>
  25. <span class="brand-application" v-if="item.metadatas.contExp_abstract" :title="item.metadatas.contExp_abstract">应用领域:{{item.metadatas.contExp_abstract | applicationFilter}}</span>
  26. <span class="brand-introduce" v-if="item.metadatas.contExp_select">品牌介绍:{{item.metadatas.contExp_select | introduceFilter}}</span>
  27. </div>
  28. </a>
  29. </li>
  30. </ul>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. export default {
  36. data () {
  37. return {
  38. activeSlide: 0,
  39. swiperOption: {
  40. autoplay: 6000,
  41. pagination: '.swiper-pagination',
  42. paginationClickable: true,
  43. mousewheelControl: false,
  44. effect: 'fade',
  45. lazyLoading: true,
  46. loop: true,
  47. prevButton: '.swiper-button-prev',
  48. nextButton: '.swiper-button-next',
  49. onTransitionStart: (swiper) => {
  50. if (this.banners.data && this.banners.data.length && (swiper.activeIndex > this.banners.data.length)) {
  51. swiper.activeIndex = 1
  52. }
  53. if (this.banners.data && this.banners.data.length && swiper.activeIndex <= 0) {
  54. swiper.activeIndex = this.banners.data.length
  55. }
  56. }
  57. }
  58. }
  59. },
  60. filters: {
  61. applicationFilter: function (str) {
  62. return str.split(',').join('|')
  63. },
  64. introduceFilter: function (title) {
  65. if (title === '') {
  66. return title
  67. }
  68. let len = 0
  69. let index = 0
  70. for (let i = 0; i < title.length; i++) {
  71. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  72. len = len + 2
  73. } else {
  74. len++
  75. }
  76. if (len > 80) {
  77. index = i
  78. break
  79. }
  80. }
  81. if (index > 0) {
  82. return title.substring(0, index) + '...'
  83. } else {
  84. return title
  85. }
  86. }
  87. },
  88. computed: {
  89. floors () {
  90. return this.$store.state.floor.list.data
  91. },
  92. hotBrands () {
  93. return this.$store.state.product.brand.recommends.data
  94. },
  95. banners () {
  96. return this.$store.state.carousel.brandCarousel.data
  97. },
  98. sliceBanners () {
  99. return this.banners.data && this.banners.data.length ? this.banners.data.slice(0, 3) : []
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .recommend-brand {
  106. width: 1190px;
  107. margin: 0 auto;
  108. .swiper-container {
  109. z-index: 2;
  110. .swiper-wrapper {
  111. width: 1190px;
  112. margin: 0 auto;
  113. .swiper-slide {
  114. height: 163px;
  115. margin: 0 auto;
  116. display: flex;
  117. img {
  118. width: 1190px;
  119. height: 163px;
  120. border: 1px solid #ccc;
  121. }
  122. }
  123. .swiper-button-prev i, .swiper-button-next i {
  124. font-size: 26px;
  125. }
  126. }
  127. .swiper-pagination-bullets {
  128. .swiper-pagination-bullet {
  129. width: 10px!important;
  130. height: 10px!important;
  131. }
  132. }
  133. }
  134. .recommend-adv {
  135. margin: 0 auto;
  136. width: 1190px;
  137. height: 163px;
  138. display: block;
  139. border-radius: 3px;
  140. }
  141. .recommend-area {
  142. margin: 29px auto 0;
  143. width: 1190px;
  144. height: 362px;
  145. background:url("/images/brandCenter/recommend-bg.png") no-repeat;
  146. .recommend-items {
  147. padding-top: 80px;
  148. padding-left: 2px;
  149. li {
  150. border-radius: 3px;
  151. width: 234px;
  152. height: 127px;
  153. background: #fff;
  154. display: inline-block;
  155. margin-right: 4px;
  156. vertical-align: middle;
  157. margin-bottom: 5px;
  158. text-align: center;
  159. &:nth-child(5n) {
  160. margin-right: 0;
  161. }
  162. a {
  163. padding-top: 22px;
  164. width: 234px;
  165. height: 127px;
  166. line-height: 91px;
  167. display: block;
  168. position: relative;
  169. img {
  170. max-width: 140px;
  171. max-height: 91px;
  172. }
  173. >div {
  174. display: none;
  175. position: absolute;
  176. bottom: 2px;
  177. border-radius: 3px;
  178. width: 234px;
  179. height: 127px;
  180. background-color: #3a78f4;
  181. opacity: 0.9;
  182. top: 0;
  183. text-align: left;
  184. padding: 13px 7px;
  185. p {
  186. font-size: 15px;
  187. color: #fff;
  188. font-weight: bold;
  189. height: 16px;
  190. line-height: 16px;
  191. }
  192. span {
  193. color: #fff;
  194. display: block;
  195. width: 228px;
  196. line-height: 18px;
  197. font-size: 12px;
  198. &.brand-application {
  199. padding-right: 5px;
  200. text-overflow: ellipsis;
  201. white-space: nowrap;
  202. overflow: hidden;
  203. }
  204. &.brand-introduce {
  205. padding-right: 5px;
  206. word-break: break-all;
  207. }
  208. }
  209. }
  210. }
  211. &:hover {
  212. /*position: relative;
  213. bottom: 5px;*/
  214. a {
  215. div {
  216. display: block;
  217. }
  218. }
  219. }
  220. }
  221. }
  222. }
  223. }
  224. </style>