banner.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="banner" :class="'terminal' + terminal">
  3. <swiper class="swiper" :indicator-dots="true" :autoplay="true" :style="{'height':componentContent.height + 'rpx'}">
  4. <swiper-item class="banner-item" v-for="(item,index) in bannerList" :key="index" :style="{backgroundImage: 'url('+ item.bannerUrl +')','height':componentContent.height + 'rpx'}">
  5. <div class="a-link" @click="jumpLink(item.linkObj)"><img class="img" :src="item.bannerUrl" v-show="item.bannerUrl" mode="widthFix"></div>
  6. </swiper-item>
  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: 'cereBanner',
  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. img {
  63. width: 100%;
  64. }
  65. }
  66. &.terminal4{
  67. ::v-deep .el-carousel{
  68. height: 100%;
  69. .el-carousel__container{
  70. height: 100%;
  71. }
  72. }
  73. .banner-item{
  74. background-repeat: no-repeat;
  75. background-position: center;
  76. background-size: auto 100%;
  77. img{
  78. display: none;
  79. }
  80. }
  81. }
  82. ::v-deep .uni-swiper-dots{
  83. display: flex;
  84. justify-content: center;
  85. bottom: 20upx;
  86. width: 100%;
  87. .uni-swiper-dot{
  88. width: 30upx;
  89. height: 4upx;
  90. background: #fff;
  91. opacity: 0.5;
  92. border-radius: 2upx;
  93. margin: 0 7.5upx;
  94. .uni-swiper-dot-active{
  95. opacity: 1;
  96. width: 58upx;
  97. }
  98. }
  99. }
  100. /* wx-swiper-dots wx-swiper-dots-horizontal */
  101. wx-swiper .wx-swiper-dot-active{
  102. width: 40rpx;
  103. border-radius: 10rpx;
  104. background: #eb544d;
  105. }
  106. //.swiper-pagination{
  107. // display: flex;
  108. // justify-content: center;
  109. // bottom: 20upx;
  110. // width: 100%;
  111. // ::v-deep .swiper-pagination-bullet{
  112. // width: 30upx;
  113. // height: 4upx;
  114. // background: #fff;
  115. // opacity: 0.5;
  116. // border-radius: 2upx;
  117. // margin: 0 7.5upx;
  118. // }
  119. // ::v-deep .swiper-pagination-bullet-active{
  120. // opacity: 1;
  121. // width: 58upx;
  122. // }
  123. //}
  124. }
  125. </style>