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