banner.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="swiper-banner-box">
  3. <swiper
  4. class="tui-banner-swiper tui-banner tui-skeleton-fillet"
  5. :autoplay="true"
  6. :interval="5000"
  7. :duration="500"
  8. @change="swiperChange"
  9. :circular="true"
  10. >
  11. <swiper-item v-for="(item, index) in list" :key="index">
  12. <image :src="item" class="tui-slide-image" mode="scaleToFill" />
  13. </swiper-item>
  14. </swiper>
  15. <view class="swiper__dots-box" v-if="list.length > 1">
  16. <view
  17. v-for="(item, idx) in list"
  18. :key="idx"
  19. :class="[idx === current ? 'swiper__dots-long' : 'none']"
  20. :data-index="current"
  21. class="swiper__dots-item"
  22. >
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. name: 'address',
  30. props: {
  31. list: {
  32. type: Array
  33. }
  34. },
  35. data() {
  36. return {
  37. current: 0
  38. }
  39. },
  40. methods: {
  41. swiperChange(e) {
  42. //轮播图切换
  43. const index = e.detail.current
  44. this.current = index
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="scss">
  50. .swiper-banner-box {
  51. width: 100%;
  52. height: 340rpx;
  53. position: relative;
  54. background-size: cover;
  55. }
  56. .tui-banner-swiper {
  57. width: 700rpx;
  58. margin: 0 auto;
  59. height: 340rpx;
  60. border-radius: 16rpx;
  61. overflow: hidden;
  62. transform: translateY(0);
  63. .banner-item {
  64. border-radius: 16rpx;
  65. }
  66. .tui-slide-image {
  67. width: 100%;
  68. height: 340rpx;
  69. display: block;
  70. }
  71. }
  72. .swiper__dots-box {
  73. position: absolute;
  74. bottom: 24rpx;
  75. left: 0;
  76. right: 0;
  77. /* #ifndef APP-NVUE */
  78. display: flex;
  79. /* #endif */
  80. flex: 1;
  81. flex-direction: row;
  82. justify-content: center;
  83. align-items: center;
  84. .swiper__dots-item {
  85. width: 10rpx;
  86. height: 10rpx;
  87. border-radius: 100%;
  88. margin-left: 6px;
  89. background-color: rgba(255, 255, 255, 0.7);
  90. }
  91. .swiper__dots-long {
  92. width: 10rpx;
  93. height: 10rpx;
  94. border-radius: 4rpx;
  95. background-color: #fa55bf;
  96. transition: all 0.4s;
  97. }
  98. }
  99. </style>