cm-coupon-area.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <view class="coupon-area">
  3. <cm-simple-swiper
  4. @change="onChange"
  5. :current="current"
  6. :circular="true"
  7. :swiperHeight="swiperHeight"
  8. :data="couponList"
  9. :rows="swiperRows"
  10. :columns="1"
  11. :gapY="16"
  12. :autoplay="false"
  13. >
  14. <template v-slot:slide="{ row }">
  15. <view class="swiper-slide">
  16. <cm-coupon :couponData="row" :controlType="row.controlType" @click="onCouponClick"></cm-coupon>
  17. </view>
  18. </template>
  19. </cm-simple-swiper>
  20. </view>
  21. </template>
  22. <script>
  23. // 测试数据
  24. import { fetchReceivedCouponList } from '@/services/api/coupon.js'
  25. export default {
  26. name: 'cm-coupon-area',
  27. props: {
  28. couponList: {
  29. type: Array,
  30. default: () => []
  31. }
  32. },
  33. data() {
  34. return {
  35. current: 0
  36. }
  37. },
  38. computed: {
  39. swiperRows() {
  40. return this.couponList.length === 1 ? 1 : 2
  41. },
  42. swiperHeight() {
  43. return 250 * this.swiperRows
  44. }
  45. },
  46. methods: {
  47. onChange(e) {
  48. this.current = e.current
  49. },
  50. onCouponClick(coupon) {
  51. this.$emit('click', coupon)
  52. }
  53. }
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. .swiper-slide {
  58. box-sizing: border-box;
  59. padding: 12rpx 0;
  60. }
  61. </style>