RecommendBrand.vue 6.4 KB

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