cm-coupon-area.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. <template v-if="row.type !== 'tip'">
  17. <cm-coupon :couponData="row" :controlType="row.controlType" @click="onCouponClick"></cm-coupon>
  18. </template>
  19. <template v-else>
  20. <view class="coupon-tip" :class="'coupon-tip-' + row.id" @click="onCouponTipClick(row)">
  21. <view class="text" v-text="row.name"></view>
  22. <view class="control">点击查看</view>
  23. </view>
  24. </template>
  25. </view>
  26. </template>
  27. </cm-simple-swiper>
  28. </view>
  29. </template>
  30. <script>
  31. // 测试数据
  32. import { fetchReceivedCouponList } from '@/services/api/coupon.js'
  33. export default {
  34. name: 'cm-coupon-area',
  35. props: {
  36. couponList: {
  37. type: Array,
  38. default: () => []
  39. }
  40. },
  41. data() {
  42. return {
  43. current: 0
  44. }
  45. },
  46. computed: {
  47. swiperRows() {
  48. return this.couponList.length === 1 ? 1 : 2
  49. },
  50. swiperHeight() {
  51. return 250 * this.swiperRows
  52. }
  53. },
  54. methods: {
  55. onChange(e) {
  56. this.current = e.current
  57. },
  58. onCouponClick(coupon) {
  59. this.$emit('click', coupon)
  60. },
  61. onCouponTipClick(item) {
  62. this.$router.navigateTo('coupon/coupon-description?entryType=' + item.id)
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .swiper-slide {
  69. box-sizing: border-box;
  70. padding: 12rpx 0;
  71. }
  72. .coupon-tip {
  73. $bg-entry-1: url('https://static.caimei365.com/app/mini-hehe/icon/bg-coupon-desc-entry-01.png');
  74. $bg-entry-2: url('https://static.caimei365.com/app/mini-hehe/icon/bg-coupon-desc-entry-02.png');
  75. $bg-entry-3: url('https://static.caimei365.com/app/mini-hehe/icon/bg-coupon-desc-entry-03.png');
  76. $width: 702rpx;
  77. $height: 200rpx;
  78. @extend .cm-flex-center;
  79. flex-direction: column;
  80. align-items: flex-start;
  81. box-sizing: border-box;
  82. padding-left: 32rpx;
  83. width: $width;
  84. height: $height;
  85. background-position: center;
  86. background-repeat: no-repeat;
  87. background-size: $width $height;
  88. &.coupon-tip-1 {
  89. background-image: $bg-entry-1;
  90. .text {
  91. color: #ee6531;
  92. }
  93. }
  94. &.coupon-tip-2 {
  95. background-image: $bg-entry-2;
  96. .text {
  97. color: #4197ef;
  98. }
  99. }
  100. &.coupon-tip-3 {
  101. background-image: $bg-entry-3;
  102. .text {
  103. color: #ff445e;
  104. }
  105. }
  106. .text {
  107. margin-bottom: 24rpx;
  108. font-size: 46rpx;
  109. font-weight: bold;
  110. }
  111. .control {
  112. @extend .cm-flex-center;
  113. width: 160rpx;
  114. height: 40rpx;
  115. background: linear-gradient(90deg, #ff903b 0%, #fc2744 100%);
  116. border-radius: 20rpx;
  117. font-size: 24rpx;
  118. color: #fff;
  119. &::after {
  120. content: '';
  121. display: block;
  122. margin-left: 12rpx;
  123. width: 0;
  124. height: 0;
  125. border-style: solid;
  126. border-width: 10rpx 0 10rpx 16rpx;
  127. border-color: transparent transparent transparent #fff;
  128. }
  129. }
  130. }
  131. </style>