banner.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div class="banner" :class="'terminal' + terminal">
  3. <swiper :options="swiperOption">
  4. <swiper-slide class="banner-item" v-for="(item,index) in bannerList" :key="index" :style="{backgroundImage: 'url('+ item.bannerUrl +')','height':componentContent.height + 'px'}" @click="jumpLink(item.linkObj)">
  5. <!-- <div class="a-link" @click="jumpLink(item.linkObj)"><img class="img" :src="item.bannerUrl" v-show="item.bannerUrl"></div>-->
  6. </swiper-slide>
  7. </swiper>
  8. <div class="swiper-pagination" slot="pagination"></div>
  9. </div>
  10. </template>
  11. <script>
  12. import { directive, Swiper, SwiperSlide } from 'vue-awesome-swiper'
  13. import 'swiper/css/swiper.css'
  14. import {funMixin} from '../config/mixin'
  15. export default {
  16. name: 'Banner',
  17. mixins: [funMixin],
  18. data () {
  19. return {
  20. swiperOption: {
  21. autoplay: false, // 可选选项,自动滑动
  22. loop: true,
  23. pagination: {
  24. el: '.swiper-pagination'
  25. }
  26. }
  27. }
  28. },
  29. props: {
  30. terminal: {
  31. type: Number,
  32. default: 4
  33. },
  34. componentContent: {
  35. type: Object
  36. }
  37. },
  38. components: {
  39. Swiper,
  40. SwiperSlide
  41. },
  42. directives: {
  43. swiper: directive
  44. },
  45. mounted() {
  46. this.$forceUpdate() // 刷新轮播图
  47. },
  48. computed: {
  49. bannerList: function () {
  50. console.log(this.componentContent)
  51. return this.componentContent.bannerData.filter(function (item) {
  52. return item.bannerUrl
  53. })
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .banner{
  60. .banner-item {
  61. width: 100%;
  62. background-repeat: no-repeat;
  63. background-position: center;
  64. background-size: auto 100%;
  65. img {
  66. width: 100%;
  67. }
  68. }
  69. &.terminal4{
  70. ::v-deep .el-carousel{
  71. height: 100%;
  72. .el-carousel__container{
  73. height: 100%;
  74. }
  75. }
  76. .banner-item{
  77. img{
  78. display: none;
  79. }
  80. }
  81. }
  82. .swiper-pagination{
  83. display: flex;
  84. justify-content: center;
  85. bottom: 20px;
  86. width: 100%;
  87. ::v-deep .swiper-pagination-bullet{
  88. width: 30px;
  89. height: 4px;
  90. background: #fff;
  91. opacity: 0.5;
  92. border-radius: 2px;
  93. margin: 0 7.5px;
  94. }
  95. ::v-deep .swiper-pagination-bullet-active{
  96. opacity: 1;
  97. width: 58px;
  98. }
  99. }
  100. }
  101. </style>