cm-coupon-area.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <view class="coupon-area">
  3. <cm-simple-swiper
  4. @change="onChange"
  5. :current="current"
  6. :circular="true"
  7. :swiperHeight="500"
  8. :data="testList"
  9. :rows="2"
  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="receive"></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. list: {
  29. type: Array,
  30. default: () => []
  31. }
  32. },
  33. data() {
  34. return {
  35. current: 0,
  36. testList: []
  37. }
  38. },
  39. async created() {
  40. try {
  41. const params = {
  42. status: 0,
  43. userId: this.$store.getters.userId,
  44. pageNum: 1,
  45. pageSize: 10
  46. }
  47. const res = await fetchReceivedCouponList(params)
  48. this.testList = res.data.list
  49. } catch (e) {
  50. //TODO handle the exception
  51. }
  52. },
  53. methods: {
  54. onChange(e) {
  55. this.current = e.current
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. .swiper-slide {
  62. box-sizing: border-box;
  63. padding: 12rpx 0;
  64. }
  65. </style>