banner.vue 2.3 KB

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