多租户商城-商户小程序端
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.

107 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. console.log(this.componentContent)
  41. return this.componentContent.bannerData.filter(function (item) {
  42. return item.bannerUrl
  43. })
  44. }
  45. },
  46. methods:{
  47. swiperChange(e) {
  48. this.swiperCurrent = e.detail.current;
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss" scoped>
  54. .banner{
  55. position: relative;
  56. .banner-item{
  57. width: 100%;
  58. background-repeat: no-repeat;
  59. background-position: center;
  60. background-size: auto 100%;
  61. img{
  62. display: none;
  63. }
  64. }
  65. &.terminal4{
  66. ::v-deep .el-carousel{
  67. height: 100%;
  68. .el-carousel__container{
  69. height: 100%;
  70. }
  71. }
  72. .banner-item{
  73. background-repeat: no-repeat;
  74. background-position: center;
  75. background-size: auto 100%;
  76. img{
  77. display: none;
  78. }
  79. }
  80. }
  81. .swiper-dots {
  82. display: flex;
  83. position: absolute;
  84. left: 50%;
  85. transform: translateX(-50%);
  86. bottom: 20upx;
  87. z-index: 200;
  88. .dot {
  89. width: 12upx;
  90. height: 12upx;
  91. background: #FFFFFF;
  92. border-radius: 6upx;
  93. opacity: 0.2;
  94. margin: 0 10upx;
  95. }
  96. .dot-active {
  97. opacity: 1;
  98. width: 24upx;
  99. }
  100. }
  101. }
  102. </style>