敢为人鲜小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
4.5 KiB

  1. <template>
  2. <view class="coupon-item" :class="{ 'used': coupon.status === '1', 'expired': coupon.status === '2' }">
  3. <!-- 左侧金额 -->
  4. <view class="coupon-left">
  5. <view class="coupon-amount">
  6. <text class="currency">¥</text>
  7. <text class="number">{{ Number(coupon.discount) }}</text>
  8. </view>
  9. </view>
  10. <!-- 中间信息 -->
  11. <view class="coupon-middle">
  12. <view class="coupon-type">{{ coupon.couponId_dictText }}</view>
  13. <view class="coupon-validity">{{ coupon.validDate }} 前有效</view>
  14. </view>
  15. <!-- 右侧使用按钮 -->
  16. <view class="coupon-right">
  17. <view class="use-btn" @click="useCoupon" v-if="coupon.status === '0'">
  18. <text>立即</text>
  19. <text>使用</text>
  20. </view>
  21. <view class="use-btn" v-if="coupon.status === '1'">
  22. <text>已使用</text>
  23. </view>
  24. <view class="use-btn" v-if="coupon.status === '2'">
  25. <text>已过期</text>
  26. </view>
  27. </view>
  28. <!-- 装饰元素 -->
  29. <view class="coupon-left-dot"></view>
  30. <view class="coupon-right-dot"></view>
  31. <!-- Logo -->
  32. <!-- <image src="/static/image/logo.png" class="logo-image"></image> -->
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. name: 'CouponItem',
  38. props: {
  39. coupon: {
  40. type: Object,
  41. default: () => ({
  42. couponId: '',
  43. discount: 0,
  44. couponId_dictText: '新人专享优惠券',
  45. validDate: '2025/4/12 23:59',
  46. status: "0" // 0-未使用 1-已使用 2-已过期
  47. })
  48. }
  49. },
  50. methods: {
  51. useCoupon() {
  52. this.$emit('use', this.coupon)
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. .coupon-item {
  59. position: relative;
  60. width: 100%;
  61. height: 160rpx;
  62. background-color: #fff;
  63. display: flex;
  64. border-radius: 16rpx;
  65. margin-bottom: 30rpx;
  66. overflow: hidden;
  67. box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.05);
  68. &::before {
  69. content: '';
  70. position: absolute;
  71. left: 0;
  72. top: 0;
  73. width: 20rpx;
  74. height: 100%;
  75. background-color: $uni-color;
  76. border-radius: 16rpx 0 0 16rpx;
  77. }
  78. &.used,
  79. &.expired {
  80. opacity: 0.6;
  81. }
  82. .coupon-left {
  83. width: 200rpx;
  84. display: flex;
  85. align-items: center;
  86. justify-content: center;
  87. background-color: #f9f9f9;
  88. position: relative;
  89. .coupon-amount {
  90. display: flex;
  91. align-items: baseline;
  92. color: $uni-color;
  93. .currency {
  94. font-size: 36rpx;
  95. font-weight: bold;
  96. }
  97. .number {
  98. font-size: 80rpx;
  99. font-weight: bold;
  100. line-height: 1;
  101. }
  102. }
  103. }
  104. .coupon-middle {
  105. flex: 1;
  106. padding: 20rpx 20rpx 20rpx 30rpx;
  107. display: flex;
  108. flex-direction: column;
  109. justify-content: center;
  110. .coupon-type {
  111. font-size: 28rpx;
  112. color: #333;
  113. margin-bottom: 16rpx;
  114. font-weight: bold;
  115. }
  116. .coupon-validity {
  117. font-size: 24rpx;
  118. color: #999;
  119. }
  120. }
  121. .coupon-right {
  122. width: 120rpx;
  123. display: flex;
  124. align-items: center;
  125. justify-content: center;
  126. .use-btn {
  127. width: 80rpx;
  128. height: 80rpx;
  129. background-color: $uni-color;
  130. border-radius: 50%;
  131. display: flex;
  132. flex-direction: column;
  133. align-items: center;
  134. justify-content: center;
  135. color: #fff;
  136. font-size: 24rpx;
  137. font-weight: bold;
  138. }
  139. .status-image {
  140. width: 80rpx;
  141. height: 80rpx;
  142. }
  143. }
  144. .coupon-left-dot,
  145. .coupon-right-dot {
  146. position: absolute;
  147. width: 30rpx;
  148. height: 30rpx;
  149. background-color: #f5f5f5;
  150. border-radius: 50%;
  151. z-index: 1;
  152. }
  153. .coupon-left-dot {
  154. left: 185rpx;
  155. top: -15rpx;
  156. }
  157. .coupon-right-dot {
  158. left: 185rpx;
  159. bottom: -15rpx;
  160. }
  161. .logo-image {
  162. position: absolute;
  163. width: 60rpx;
  164. height: 60rpx;
  165. right: 30rpx;
  166. top: 10rpx;
  167. opacity: 0.2;
  168. }
  169. }
  170. </style>