RecommendBrand.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <div class="recommend-brand">
  3. <div class="brand-content">
  4. <div class="brand-index-tab">
  5. <div class="index-head">
  6. <img src="/images/brandCenter/search-index.png"/>品牌索引
  7. </div>
  8. <div style="padding-top: 8px;">
  9. <div class="brand-index-group index-group" v-for="(indexGroup, index) in indexGroups">
  10. <span v-if="index == 5"></span>
  11. <a @click="goBrandIndex(group_index)" v-for="group_index in indexGroup" :class="{'active': activeIndex==group_index}">{{group_index}}</a>
  12. <span v-if="index == 5"></span>
  13. </div>
  14. </div>
  15. </div>
  16. <div v-swiper:mySwiper="swiperOption" class="swiper-container">
  17. <div class="swiper-wrapper">
  18. <div class="swiper-slide" v-for="banner in sliceBanners">
  19. <a :href="banner.detailsLink" target="_blank">
  20. <img :src="banner.pictureLink"/>
  21. </a>
  22. </div>
  23. <div v-if="sliceBanners.length === 0" class="swiper-button-prev"><i class="iconfont icon-swiper-left"></i></div>
  24. <div v-if="sliceBanners.length === 0"class="swiper-button-next"><i class="iconfont icon-swiper-right"></i></div>
  25. </div>
  26. <div v-if="sliceBanners.length === 0" class="swiper-pagination swiper-pagination-bullets"></div>
  27. </div>
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. export default {
  33. data () {
  34. return {
  35. indexGroups: [
  36. ['A', 'B', 'C', 'D', 'E'],
  37. ['F', 'G', 'H', 'I', 'J'],
  38. ['K', 'L', 'M', 'N', 'O'],
  39. ['P', 'Q', 'R', 'S', 'T'],
  40. ['U', 'V', 'W', 'X', 'Y', 'Z'],
  41. ['0~9']
  42. ],
  43. nowPage: 1,
  44. keyword: '',
  45. isSearch: false,
  46. activeSlide: 0,
  47. swiperOption: {
  48. autoplay: 6000,
  49. pagination: '.swiper-pagination',
  50. paginationClickable: true,
  51. mousewheelControl: false,
  52. effect: 'fade',
  53. lazyLoading: true,
  54. loop: true,
  55. prevButton: '.swiper-button-prev',
  56. nextButton: '.swiper-button-next',
  57. onTransitionStart: (swiper) => {
  58. if (this.banners.data && this.banners.data.length && (swiper.activeIndex > this.banners.data.length)) {
  59. swiper.activeIndex = 1
  60. }
  61. if (this.banners.data && this.banners.data.length && swiper.activeIndex <= 0) {
  62. swiper.activeIndex = this.banners.data.length
  63. }
  64. }
  65. }
  66. }
  67. },
  68. filters: {
  69. applicationFilter: function (str) {
  70. return str.split(',').join('|')
  71. },
  72. introduceFilter: function (title) {
  73. if (title === '') {
  74. return title
  75. }
  76. let len = 0
  77. let index = 0
  78. for (let i = 0; i < title.length; i++) {
  79. if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
  80. len = len + 2
  81. } else {
  82. len++
  83. }
  84. if (len > 60) {
  85. index = i
  86. break
  87. }
  88. }
  89. if (index > 0) {
  90. return title.substring(0, index) + '...'
  91. } else {
  92. return title
  93. }
  94. }
  95. },
  96. computed: {
  97. floors () {
  98. return this.$store.state.floor.list.data
  99. },
  100. banners () {
  101. return this.$store.state.carousel.brandCarousel.data
  102. },
  103. sliceBanners () {
  104. return this.banners.data && this.banners.data.length ? this.banners.data.slice(0, 3) : []
  105. },
  106. activeIndex () {
  107. return !this.isSearch ? this.$route.params.initial : ''
  108. }
  109. },
  110. methods: {
  111. goBrandIndex: function (index) {
  112. if (index === this.$route.params.initial) {
  113. this.initParams()
  114. this.reloadData()
  115. } else {
  116. this.$router.push('/product/brand/brandList/' + index)
  117. // window.location.href = '/product/brand/brandList/' + index + '#index'
  118. // window.open('/product/brand/brandList/' + index + '#index', '_self')
  119. }
  120. },
  121. initParams: function () {
  122. this.nowPage = 1
  123. this.isSearch = false
  124. this.keyword = ''
  125. this.reloadData()
  126. },
  127. reloadData: function () {
  128. !this.isSearch ? this.$store.dispatch('product/loadBrandsPager', {'initial': this.$route.params.initial, 'page': this.nowPage, 'count': this.pageSize, 'keyword': this.keyword}) : this.searchData()
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .recommend-brand {
  135. width: 1190px;
  136. margin: 0 auto;
  137. margin-top: 10px;
  138. .brand-content{
  139. overflow: hidden;
  140. .brand-index-tab {
  141. margin-right: 15px;
  142. float: left;
  143. width: 220px;
  144. height: 400px;
  145. background-color: #ffffff;
  146. border-radius: 5px;
  147. border: solid 1px #d2d2d2;
  148. .index-head {
  149. padding-left: 10px;
  150. width: 220px;
  151. height: 34px;
  152. line-height: 34px;
  153. background-color: #2496f1;
  154. font-size: 14px;
  155. border-top-left-radius: 5px;
  156. border-top-right-radius: 5px;
  157. color: #fff;
  158. img{
  159. margin-right: 6px;
  160. margin-top: -2px;
  161. }
  162. }
  163. .brand-index-group {
  164. margin: 0 auto 22px;
  165. width: 200px;
  166. height: 40px;
  167. background-color: rgba(36, 150, 241, 0.1);
  168. border-radius: 4px;
  169. /*opacity: 0.1;*/
  170. a{
  171. display: inline-block;
  172. width: 40px;
  173. height: 40px;
  174. line-height: 40px;
  175. text-align: center;
  176. font-size: 16px;
  177. color: #666;
  178. border-radius: 5px;
  179. /*background-color: #2496f1;*/
  180. &:hover{
  181. background-color: #2496f1;
  182. color: #fff;
  183. }
  184. }
  185. &:last-child{
  186. margin-bottom: 0;
  187. }
  188. &:last-child a{
  189. letter-spacing: 15px;
  190. padding-left: 12px;
  191. }
  192. }
  193. }
  194. }
  195. .swiper-container {
  196. z-index: 2;
  197. float: left;
  198. width: 955px;
  199. height: 400px;
  200. .swiper-wrapper {
  201. width: 955px;
  202. height: 400px;
  203. margin: 0 auto;
  204. .swiper-slide {
  205. height: 400px;
  206. margin: 0 auto;
  207. display: flex;
  208. img {
  209. width: 955px;
  210. height: 400px;
  211. border: 1px solid #ccc;
  212. }
  213. }
  214. .swiper-button-prev i, .swiper-button-next i {
  215. font-size: 26px;
  216. }
  217. }
  218. .swiper-pagination-bullets {
  219. .swiper-pagination-bullet {
  220. width: 10px!important;
  221. height: 10px!important;
  222. }
  223. }
  224. }
  225. .recommend-adv {
  226. margin: 0 auto;
  227. width: 1190px;
  228. height: 163px;
  229. display: block;
  230. border-radius: 3px;
  231. }
  232. .recommend-area {
  233. margin: 20px auto 0;
  234. width: 1190px;
  235. height: 263px;
  236. background:url("/images/brandCenter/recommend-bg1.png") no-repeat;
  237. .recommend-items {
  238. padding-top: 51px;
  239. padding-left: 3px;
  240. li {
  241. border-radius: 3px;
  242. width: 233px;
  243. height: 98px;
  244. background: #fff;
  245. display: inline-block;
  246. margin-right: 3px;
  247. margin-bottom: 8px;
  248. text-align: center;
  249. border: solid 1px #f4f4f4;
  250. &:nth-child(5n) {
  251. margin-right: 0;
  252. }
  253. a {
  254. padding-top: 22px;
  255. width: 233px;
  256. height: 98px;
  257. line-height: 60px;
  258. display: block;
  259. position: relative;
  260. top:-1px;
  261. left: -1px;
  262. img {
  263. max-width: 140px;
  264. max-height: 60px;
  265. }
  266. >div {
  267. display: none;
  268. position: absolute;
  269. border-radius: 3px;
  270. width: 233px;
  271. height: 98px;
  272. background-color: #3a78f4;
  273. opacity: 0.9;
  274. top: 0;
  275. text-align: left;
  276. padding: 13px 7px;
  277. p {
  278. font-size: 15px;
  279. color: #fff;
  280. font-weight: bold;
  281. height: 16px;
  282. line-height: 16px;
  283. }
  284. span {
  285. color: #fff;
  286. display: block;
  287. width: 228px;
  288. line-height: 18px;
  289. font-size: 12px;
  290. &.brand-application {
  291. padding-right: 5px;
  292. text-overflow: ellipsis;
  293. white-space: nowrap;
  294. overflow: hidden;
  295. }
  296. &.brand-introduce {
  297. padding-right: 5px;
  298. word-break: break-all;
  299. }
  300. }
  301. }
  302. }
  303. &:hover {
  304. /*position: relative;
  305. bottom: 5px;*/
  306. a {
  307. div {
  308. display: block;
  309. }
  310. }
  311. }
  312. }
  313. }
  314. }
  315. }
  316. .recommend-brand .brand-content .brand-index-tab .brand-index-group a.active{
  317. background-color: #2496f1;
  318. border-radius: 2px;
  319. color: #fff;
  320. }
  321. </style>