ReceiveCoupon.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <script lang="ts" setup>
  2. import CouponBtnBg from '@img/receiveCoupon/button.png'
  3. import CouponImg from '@img/receiveCoupon/coupon-bg.png'
  4. const props = defineProps({
  5. coupon: {
  6. type: Object,
  7. default: () => ({
  8. ruleReductionAmount: '0',
  9. ruleMinSpendAmount: '0',
  10. }),
  11. },
  12. })
  13. const emit = defineEmits(['button-click'])
  14. const coupon = computed(() => props.coupon)
  15. const category = computed(() => {
  16. const relatedType = props.coupon.relatedType
  17. if (relatedType === '1') {
  18. return `限${props.coupon.relatedName}分类商品使用`
  19. }
  20. else {
  21. return `限${props.coupon.relatedName}商品使用`
  22. }
  23. })
  24. function handleButtonClick() {
  25. emit('button-click')
  26. }
  27. </script>
  28. <template>
  29. <view class="discount-coupon">
  30. <view class="coupon-container">
  31. <view class="coupon-content">
  32. <image class="coupon-bg" :src="CouponImg" mode="aspectFit" />
  33. <view class="coupon-content-layout">
  34. <view class="coupon-content-text-content">
  35. <view v-if="coupon.type === '2'" class="coupon-content-text-title">
  36. <view class="coupon-amount">
  37. <view class="coupon-amount-count-number">
  38. {{ coupon.ruleDiscountRate }}
  39. </view>
  40. <view class="coupon-amount-count-unit">
  41. </view>
  42. </view>
  43. <view class="coupon-type">
  44. <view style="font-size: 18rpx;">
  45. COUPON
  46. </view>
  47. <view style="font-size: 34rpx;">
  48. 折扣券
  49. </view>
  50. <view style="font-size:18rpx;">
  51. 最高优惠{{ coupon.ruleDiscountCapAmount }}元
  52. </view>
  53. </view>
  54. </view>
  55. <view v-else class="coupon-content-text-title">
  56. <view class="coupon-amount">
  57. <view class="coupon-amount-count-icon">
  58. </view>
  59. <view class="coupon-amount-count-number">
  60. {{ coupon?.ruleReductionAmount || '0' }}
  61. </view>
  62. </view>
  63. <view class="coupon-type">
  64. <view style="font-size: 18rpx;">
  65. YUAN
  66. </view>
  67. <view style="font-size: 34rpx;">
  68. 满减券
  69. </view>
  70. <view style="font-size:18rpx;">
  71. COUPON
  72. </view>
  73. </view>
  74. </view>
  75. <view class="coupon-content-text-cart">
  76. {{ category }}
  77. </view>
  78. <view class="coupon-content-text-amount">
  79. 订单满{{ coupon?.ruleMinSpendAmount }}元可用此券
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <button class="coupon-button" hover-class="none" @click="handleButtonClick">
  85. <image class="coupon-btn-bg" :src="CouponBtnBg" mode="aspectFit" />
  86. <view class="coupon-btn-text">
  87. 立即领取
  88. </view>
  89. </button>
  90. </view>
  91. </view>
  92. </template>
  93. <style lang="scss" scoped>
  94. .discount-coupon {
  95. // width: 670rpx;
  96. width: 100%;
  97. height: 100%;
  98. position: absolute;
  99. // position: relative;
  100. overflow: hidden;
  101. // top: 50%;
  102. // left: 50%;
  103. // transform: translate(-50%, -50%);
  104. background-color: rgba(0, 0, 0, 0.5);
  105. z-index: 99999;
  106. .coupon-container {
  107. position: relative;
  108. height: inherit;
  109. width: inherit;
  110. display: flex;
  111. flex-direction: column;
  112. justify-content: center;
  113. .coupon-content {
  114. position: relative;
  115. width: 100%;
  116. height: 638rpx;
  117. .coupon-bg {
  118. position: absolute;
  119. left: 50%;
  120. transform: translate(-50%, -30%);
  121. width: 149%;
  122. height: 149%;
  123. z-index: 10;
  124. object-fit: cover;
  125. }
  126. .coupon-content-layout {
  127. position: absolute;
  128. left: 50%;
  129. transform: translate(-46%, 45%);
  130. z-index: 11;
  131. width: 400rpx;
  132. height: 370rpx;
  133. .coupon-content-text-content {
  134. width: 347rpx;
  135. height: 206rpx;
  136. margin-top: 125rpx;
  137. margin-left: 31rpx;
  138. display: flex;
  139. flex-direction: column;
  140. align-items: center;
  141. justify-content: center;
  142. gap: 12rpx;
  143. color: #ffffff;
  144. .coupon-content-text-title {
  145. display: flex;
  146. flex-direction: row;
  147. flex-wrap: nowrap;
  148. gap: 29rpx;
  149. .coupon-amount {
  150. display: flex;
  151. flex-direction: row;
  152. flex-wrap: nowrap;
  153. align-items: baseline;
  154. justify-content: end;
  155. .coupon-amount-count-number {
  156. font-weight: 400;
  157. font-size: 89rpx;
  158. color: #ffffff;
  159. }
  160. .coupon-amount-count-unit {
  161. font-weight: 500;
  162. font-size: 31rpx;
  163. color: #f62a2a;
  164. background: #ffffff;
  165. border-radius: 50%;
  166. border: 3px solid #f62a2a;
  167. padding: 8rpx;
  168. margin-left: -19rpx;
  169. }
  170. .coupon-amount-count-icon {
  171. font-weight: 400;
  172. font-size: 43rpx;
  173. color: #ffffff;
  174. }
  175. }
  176. .coupon-type {
  177. display: flex;
  178. flex-direction: column;
  179. justify-content: space-evenly;
  180. gap: 6rpx;
  181. font-weight: 400;
  182. font-size: 18rpx;
  183. color: #ffffff;
  184. }
  185. }
  186. .coupon-content-text-cart {
  187. padding: 8rpx 38rpx;
  188. background-color: #ffffff;
  189. font-weight: 500;
  190. font-size: 24rpx;
  191. color: #f62a2a;
  192. }
  193. .coupon-content-text-amount {
  194. font-weight: 400;
  195. font-size: 24rpx;
  196. color: #ffffff;
  197. }
  198. }
  199. }
  200. }
  201. .coupon-button {
  202. position: relative;
  203. width: 254rpx;
  204. height: 75rpx;
  205. left: 50%;
  206. transform: translate(-43%, -83%);
  207. z-index: 99999;
  208. display: flex;
  209. justify-content: center;
  210. align-items: center;
  211. // 去除button默认样式
  212. background-color: transparent;
  213. border: none;
  214. padding: 0;
  215. margin: 0;
  216. outline: none;
  217. cursor: pointer;
  218. -webkit-appearance: none; // 移除浏览器默认样式
  219. -moz-appearance: none;
  220. appearance: none;
  221. // 去除uni-app button默认样式
  222. &::after {
  223. display: none; // 移除默认边框
  224. }
  225. .coupon-btn-bg {
  226. position: absolute;
  227. width: 100%;
  228. height: 110%;
  229. z-index: 10;
  230. object-fit: cover;
  231. pointer-events: none; // 确保文字不阻挡点击事件
  232. }
  233. .coupon-btn-text {
  234. position: absolute;
  235. z-index: 11;
  236. height: 34rpx;
  237. width: 138rpx;
  238. text-align: center;
  239. font-weight: bolder;
  240. font-size: 34rpx;
  241. color: #bd521e;
  242. line-height: 30rpx;
  243. padding-bottom: 14rpx;
  244. background: linear-gradient(180deg, #fffadc 0%, #ffef8d 100%);
  245. -webkit-background-clip: text;
  246. -webkit-text-fill-color: transparent;
  247. pointer-events: none; // 确保文字不阻挡点击事件
  248. }
  249. }
  250. }
  251. }
  252. </style>