多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.5 KiB

2 years ago
  1. <template>
  2. <div class="banner" :class="'terminal' + terminal">
  3. <swiper class="swiper" :circular="true" :indicator-dots="false" :autoplay="true" :style="{'height':bannerHeight + 'rpx'}" @change="swiperChange">
  4. <swiper-item class="banner-item" v-for="(item,index) in bannerList" :key="index" :style="{backgroundImage: 'url('+ item.bannerUrl +')'}" @click="jumpLink(item.linkObj)">
  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. <view class="swiper-dots" v-if="bannerList && bannerList.length > 1">
  9. <text class="dot" :class="index === swiperCurrent && 'dot-active'" v-for="(dot, index) in bannerList.length"
  10. :key="index"></text>
  11. </view>
  12. </div>
  13. </template>
  14. <script>
  15. import {funMixin} from '../config/mixin'
  16. export default {
  17. name: 'cereBanner',
  18. mixins: [funMixin],
  19. data () {
  20. return {
  21. bannerHeight: 0,
  22. swiperCurrent: 0
  23. }
  24. },
  25. props: {
  26. terminal: {
  27. type: Number,
  28. default: 4
  29. },
  30. componentContent: {
  31. type: Object
  32. }
  33. },
  34. mounted() {
  35. this.bannerHeight = this.componentContent.height
  36. this.$forceUpdate() // 刷新轮播图
  37. },
  38. computed: {
  39. bannerList: function () {
  40. return this.componentContent.bannerData.filter(function (item) {
  41. return item.bannerUrl
  42. })
  43. }
  44. },
  45. methods:{
  46. swiperChange(e) {
  47. this.swiperCurrent = e.detail.current;
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .banner{
  54. position: relative;
  55. .banner-item{
  56. width: 100%;
  57. background-repeat: no-repeat;
  58. background-position: center;
  59. background-size: auto 100%;
  60. img{
  61. display: none;
  62. }
  63. }
  64. &.terminal4{
  65. ::v-deep .el-carousel{
  66. height: 100%;
  67. .el-carousel__container{
  68. height: 100%;
  69. }
  70. }
  71. .banner-item{
  72. background-repeat: no-repeat;
  73. background-position: center;
  74. background-size: auto 100%;
  75. img{
  76. display: none;
  77. }
  78. }
  79. }
  80. .swiper-dots {
  81. display: flex;
  82. position: absolute;
  83. left: 50%;
  84. transform: translateX(-50%);
  85. bottom: 20upx;
  86. z-index: 200;
  87. .dot {
  88. width: 12upx;
  89. height: 12upx;
  90. background: #FFFFFF;
  91. border-radius: 6upx;
  92. opacity: 0.2;
  93. margin: 0 10upx;
  94. }
  95. .dot-active {
  96. opacity: 1;
  97. width: 24upx;
  98. }
  99. }
  100. }
  101. </style>