banner.vue 2.0 KB

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