MkCouponCard.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view
  3. class="coupon-card"
  4. :class="{ 'coupon-card--dimmed': dimmed, 'coupon-card--clickable': clickable }"
  5. @click="handleClick"
  6. >
  7. <view class="coupon-card__left">
  8. <text class="coupon-card__amount">{{ amountText }}</text>
  9. <text class="coupon-card__unit">{{ unitText }}</text>
  10. </view>
  11. <view class="coupon-card__divider" />
  12. <view class="coupon-card__body">
  13. <view class="coupon-card__name-row">
  14. <text class="coupon-card__name">{{ name }}</text>
  15. <text v-if="couponType" class="coupon-card__type">{{ couponType }}</text>
  16. </view>
  17. <text v-if="meta" class="coupon-card__meta">{{ meta }}</text>
  18. <text v-if="subMeta" class="coupon-card__sub-meta">{{ subMeta }}</text>
  19. <view class="coupon-card__bottom">
  20. <view v-if="tag" class="coupon-card__tag">{{ tag }}</view>
  21. <text v-if="validPeriod" class="coupon-card__period">{{ validPeriod }}</text>
  22. </view>
  23. </view>
  24. <view v-if="$slots.action" class="coupon-card__action" @click.stop>
  25. <slot name="action" />
  26. </view>
  27. <view v-else-if="clickable" class="coupon-card__arrow">
  28. <text class="coupon-card__arrow-icon">›</text>
  29. </view>
  30. </view>
  31. </template>
  32. <script setup lang="ts">
  33. const props = withDefaults(
  34. defineProps<{
  35. name?: string
  36. meta?: string
  37. amountText?: string
  38. unitText?: string
  39. tag?: string
  40. dimmed?: boolean
  41. couponType?: string
  42. validPeriod?: string
  43. subMeta?: string
  44. clickable?: boolean
  45. }>(),
  46. {
  47. name: '优惠券',
  48. meta: '',
  49. amountText: '惠',
  50. unitText: '券',
  51. tag: '',
  52. dimmed: false,
  53. couponType: '',
  54. validPeriod: '',
  55. subMeta: '',
  56. clickable: false
  57. }
  58. )
  59. const emit = defineEmits<{ click: [] }>()
  60. function handleClick() {
  61. if (props.clickable) emit('click')
  62. }
  63. </script>
  64. <style scoped lang="scss">
  65. .coupon-card {
  66. display: flex;
  67. align-items: stretch;
  68. background: #fff;
  69. border-radius: 24rpx;
  70. overflow: hidden;
  71. box-shadow: 0 10rpx 32rpx rgba(255, 107, 53, 0.1);
  72. margin-bottom: 24rpx;
  73. &--dimmed {
  74. box-shadow: 0 8rpx 24rpx rgba(44, 24, 16, 0.06);
  75. .coupon-card__left {
  76. background: linear-gradient(160deg, #c4b5a5, #a89888);
  77. }
  78. .coupon-card__name {
  79. color: #8c7b6a;
  80. }
  81. .coupon-card__tag {
  82. background: #f5f0ea;
  83. color: #a89888;
  84. }
  85. }
  86. &--clickable {
  87. cursor: pointer;
  88. &:active {
  89. opacity: 0.85;
  90. }
  91. }
  92. }
  93. .coupon-card__left {
  94. width: 168rpx;
  95. background: linear-gradient(160deg, #ff9a3c, #ff5722);
  96. color: #fff;
  97. display: flex;
  98. flex-direction: column;
  99. align-items: center;
  100. justify-content: center;
  101. padding: 24rpx 12rpx;
  102. }
  103. .coupon-card__amount {
  104. font-size: 44rpx;
  105. font-weight: 800;
  106. line-height: 1.1;
  107. }
  108. .coupon-card__unit {
  109. margin-top: 6rpx;
  110. font-size: 22rpx;
  111. opacity: 0.92;
  112. }
  113. .coupon-card__divider {
  114. width: 0;
  115. border-left: 2rpx dashed rgba(255, 107, 53, 0.25);
  116. margin: 16rpx 0;
  117. }
  118. .coupon-card__body {
  119. flex: 1;
  120. padding: 20rpx 20rpx;
  121. min-width: 0;
  122. display: flex;
  123. flex-direction: column;
  124. justify-content: center;
  125. }
  126. .coupon-card__name-row {
  127. display: flex;
  128. align-items: center;
  129. gap: 8rpx;
  130. }
  131. .coupon-card__name {
  132. font-size: 30rpx;
  133. font-weight: 700;
  134. color: #2c1810;
  135. }
  136. .coupon-card__type {
  137. flex-shrink: 0;
  138. padding: 2rpx 10rpx;
  139. border-radius: 6rpx;
  140. background: #fff3e6;
  141. color: #ff7a1a;
  142. font-size: 20rpx;
  143. font-weight: 600;
  144. }
  145. .coupon-card__meta {
  146. display: block;
  147. margin-top: 8rpx;
  148. font-size: 24rpx;
  149. color: #8c7b6a;
  150. line-height: 1.5;
  151. }
  152. .coupon-card__sub-meta {
  153. display: block;
  154. margin-top: 4rpx;
  155. font-size: 22rpx;
  156. color: #b5a89d;
  157. line-height: 1.4;
  158. }
  159. .coupon-card__bottom {
  160. display: flex;
  161. align-items: center;
  162. gap: 12rpx;
  163. margin-top: 10rpx;
  164. flex-wrap: wrap;
  165. }
  166. .coupon-card__tag {
  167. display: inline-block;
  168. padding: 4rpx 14rpx;
  169. border-radius: 999rpx;
  170. background: #fff3e6;
  171. color: #ff7a1a;
  172. font-size: 22rpx;
  173. }
  174. .coupon-card__period {
  175. font-size: 22rpx;
  176. color: #b5a89d;
  177. }
  178. .coupon-card__action {
  179. display: flex;
  180. align-items: center;
  181. padding-right: 20rpx;
  182. }
  183. .coupon-card__arrow {
  184. display: flex;
  185. align-items: center;
  186. padding-right: 16rpx;
  187. }
  188. .coupon-card__arrow-icon {
  189. font-size: 36rpx;
  190. color: #c4b5a5;
  191. font-weight: 300;
  192. }
  193. </style>