home-play.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <!--
  2. * @Author: jmy
  3. * @Date: 2026-01-06 12:02:41
  4. * @LastEditors: Please set LastEditors
  5. * @LastEditTime: 2026-01-06 15:02:20
  6. * @Description: 自定义轮播图组件
  7. -->
  8. <template>
  9. <view class="w-all relative zi-2" :style="{ height: height * 2 + 30 + 'rpx', }">
  10. <swiper class="w-all mt-5 rounded-8 overflow-hidden" :style="{ height: height * 2 + 'rpx', }"
  11. :circular="circular" :class="isDotStyle ? 'dotStyle' : ''" :indicator-dots="indicatorDots"
  12. indicator-active-color="#02B176 " indicator-color="#EEEEEE" :autoplay="autoplay" :interval="interval"
  13. :duration="duration" :current="current" :display-multiple-items='displayMultipleItems'
  14. :next-margin="nextMargin" @change="change" @transition="transition" @animationfinish="animationfinish">
  15. <swiper-item class="flex flex-wrap h-all w-all bg-light relative" v-for="(item, index) in swiperList"
  16. :key="index">
  17. <image src="https://img1.baidu.com/it/u=2172818577,3783888802&fm=253&app=138&f=JPEG?w=800&h=1422"
  18. class="w-all h-all" />
  19. <view class="flex items-center h-30 fw-400 fs-10 rounded-6 overflow-hidden absolute top-8 left-8">
  20. <view class="h-all left-box text-white px-4 lh-30">预约中</view>
  21. <view class="h-all px-4 text-white bg-000000 opacity-6 lh-30">1800人已预约</view>
  22. </view>
  23. </swiper-item>
  24. </swiper>
  25. <view class="flex items-center justify-center w-all gap-1 mt-11">
  26. <view v-for="(item, index) in swiperList" :key="index" class="w-10 h-2 rounded-1"
  27. :class="index == current ? 'bg-02B176' : 'bg-EEEEEE'"></view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. props: {
  34. swiperList: {
  35. type: Array,
  36. default: () => []
  37. },
  38. // 轮播图高度px
  39. height: {
  40. type: Number,
  41. default: 202
  42. },
  43. // 是否显示指示器
  44. indicatorDots: {
  45. type: Boolean,
  46. default: false
  47. },
  48. // 是否循环播放
  49. circular: {
  50. type: Boolean,
  51. default: true
  52. },
  53. // 是否自动切换
  54. autoplay: {
  55. type: Boolean,
  56. default: false
  57. },
  58. // 自动切换时间间隔
  59. interval: {
  60. type: Number,
  61. default: 3000
  62. },
  63. // 切换动画时长
  64. duration: {
  65. type: Number,
  66. default: 1000
  67. },
  68. // 显示多个项
  69. displayMultipleItems: {
  70. type: Number,
  71. default: 1
  72. },
  73. // 下一个项的外边距
  74. nextMargin: {
  75. type: String,
  76. default: '0'
  77. },
  78. // 当前滑块显示项的索引
  79. current: {
  80. type: Number,
  81. default: 0
  82. },
  83. },
  84. data() {
  85. return {
  86. currentDot: 0,
  87. }
  88. },
  89. methods: {
  90. // current 改变时会触发 change 事件
  91. change(e) {
  92. this.$emit('change', e.detail.current)
  93. },
  94. // swiper-item 的位置发生改变时会触发
  95. transition(e) {
  96. // console.log('transition:', e.detail)
  97. this.$emit('transition', e.detail.current)
  98. },
  99. // swiper-item 的位置发生改变并且动画结束时会触发
  100. animationfinish(e) {
  101. this.$emit('animationfinish', e.detail.current)
  102. },
  103. // 导航到对应页面
  104. handleNavTo(value) {
  105. // 根据实际需求实现导航逻辑
  106. console.log('导航到:', value)
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .left-box {
  113. background: linear-gradient(136deg, #38D97D 0%, #02B176 100%);
  114. }
  115. </style>