red-packet-item.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="red-packet-item" :class="{ 'is-disabled': isDisabled }">
  3. <image class="bg-img" :src="isDisabled ? '/pages-car/static/coupon-no.png' : '/pages-car/static/coupon.png'"
  4. mode="scaleToFill"></image>
  5. <view class="content">
  6. <view class="left-part">
  7. <view class="amount-box">
  8. <text class="symbol">¥</text>
  9. <text class="amount">{{ info.faceMoney || 0 }}</text>
  10. </view>
  11. <view class="condition" v-if="info.thresholdMoney === 0">无门槛使用</view>
  12. <view class="condition" v-else>满{{ info.thresholdMoney || 0 }}使用</view>
  13. </view>
  14. <view class="right-part">
  15. <view class="info-top">
  16. <view class="title-row">
  17. <text class="type-name">{{ getTypeName(info.type) }}</text>
  18. <view class="condition" v-if="info.thresholdMoney === 0">无门槛减{{ info.faceMoney || 0 }}元</view>
  19. <text class="sub-title" v-else>满{{ info.thresholdMoney || 0 }}减{{ info.faceMoney || 0 }}元</text>
  20. </view>
  21. <view class="date">{{ formatEndTime }}到期</view>
  22. </view>
  23. <view class="action-box" v-if="status === 0">
  24. <view class="btn-use" @click="onUse">立即使用</view>
  25. <!-- <view class="btn-use" @click="onUse">{{ info.type == 2 ? '赠送给朋友' : '立即使用' }}</view> -->
  26. </view>
  27. </view>
  28. </view>
  29. <image v-if="status === 1" class="stamp-img" src="/pages-car/static/coupon-used.png" mode="aspectFit"></image>
  30. <image v-if="status === 2" class="stamp-img" src="/pages-car/static/coupon-gq.png" mode="aspectFit"></image>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. name: "red-packet-item",
  36. props: {
  37. info: {
  38. type: Object,
  39. default: () => ({})
  40. }
  41. },
  42. computed: {
  43. // 0: unused, 1: used, 2: expired
  44. status() {
  45. if (this.info.useTime) {
  46. return 1;
  47. } else if (this.info.effectEndTime && new Date(this.info.effectEndTime.replace(/-/g, '/')).getTime() < new Date().getTime()) {
  48. return 2;
  49. }
  50. return 0;
  51. },
  52. isDisabled() {
  53. return this.status !== 0;
  54. },
  55. formatEndTime() {
  56. let endTime = this.info.effectEndTime || '';
  57. if (endTime && endTime.length >= 10) {
  58. return endTime.substring(0, 10).replace(/-/g, '.');
  59. }
  60. return endTime;
  61. }
  62. },
  63. methods: {
  64. getTypeName(type) {
  65. if (type == 2) return '惊喜红包';
  66. if (type == 3) return '买书得红包';
  67. return '普通红包';
  68. },
  69. onUse() {
  70. this.$emit('use', this.info);
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .red-packet-item {
  77. position: relative;
  78. width: 702rpx;
  79. height: 180rpx;
  80. margin: 20rpx auto;
  81. border-radius: 12rpx;
  82. padding: 6rpx;
  83. background: radial-gradient( 0% 0% at 0% 0%, #F81011 0%, #FE6F43 100%);
  84. .bg-img {
  85. position: absolute;
  86. top: 8rpx;
  87. left: 6rpx;
  88. right: 6rpx;
  89. bottom: 4rpx;
  90. width: calc(100% - 12rpx);
  91. height: calc(100% - 12rpx);
  92. z-index: 0;
  93. }
  94. .content {
  95. position: relative;
  96. z-index: 1;
  97. display: flex;
  98. width: 100%;
  99. height: 100%;
  100. }
  101. .left-part {
  102. width: 220rpx;
  103. display: flex;
  104. flex-direction: column;
  105. justify-content: center;
  106. align-items: center;
  107. color: #F53F3F;
  108. padding-left: 10rpx;
  109. position: relative;
  110. &::after {
  111. content: '';
  112. position: absolute;
  113. right: 0;
  114. top: 20rpx;
  115. bottom: 20rpx;
  116. border-right: 4rpx dashed #E91B13;
  117. }
  118. .amount-box {
  119. display: flex;
  120. align-items: baseline;
  121. font-weight: bold;
  122. .symbol {
  123. font-size: 28rpx;
  124. margin-right: 4rpx;
  125. }
  126. .amount {
  127. font-size: 64rpx;
  128. line-height: 1;
  129. background: radial-gradient(0% 0% at 0% 0%, #F81011 0%, #FE6F43 100%);
  130. -webkit-background-clip: text;
  131. -webkit-text-fill-color: transparent;
  132. color: transparent;
  133. }
  134. }
  135. .condition {
  136. font-size: 24rpx;
  137. margin-top: 12rpx;
  138. color: #666;
  139. }
  140. }
  141. .right-part {
  142. flex: 1;
  143. padding: 30rpx 30rpx 30rpx 20rpx;
  144. display: flex;
  145. flex-direction: column;
  146. justify-content: space-between;
  147. position: relative;
  148. .info-top {
  149. .title-row {
  150. display: flex;
  151. align-items: center;
  152. margin-bottom: 20rpx;
  153. .type-name {
  154. font-size: 28rpx;
  155. color: #F53F3F;
  156. font-weight: 500;
  157. margin-right: 16rpx;
  158. }
  159. .sub-title {
  160. font-size: 26rpx;
  161. color: #333;
  162. }
  163. }
  164. .date {
  165. font-size: 24rpx;
  166. color: #999;
  167. }
  168. }
  169. .action-box {
  170. position: absolute;
  171. right: 30rpx;
  172. bottom: 30rpx;
  173. .btn-use {
  174. background: radial-gradient( 0% 0% at 0% 0%, #F3B26B 0%, #FFF1D8 100%);
  175. color: #E91B13;
  176. font-size: 24rpx;
  177. padding: 10rpx 26rpx;
  178. border-radius: 30rpx;
  179. box-shadow: 0 4rpx 8rpx rgba(255, 133, 89, 0.3);
  180. }
  181. }
  182. }
  183. .stamp-img {
  184. position: absolute;
  185. right: 16rpx;
  186. top: 28rpx;
  187. width: 133rpx;
  188. height: 120rpx;
  189. z-index: 2;
  190. }
  191. &.is-disabled {
  192. background: radial-gradient( 0% 0% at 0% 0%, #C4C4C4 0%, #DCDCDC 100%);
  193. .left-part {
  194. color: #787878;
  195. &::after {
  196. border-right: 4rpx dashed #787878;
  197. }
  198. .amount-box {
  199. .amount {
  200. background: none;
  201. -webkit-text-fill-color: initial;
  202. color: #787878;
  203. }
  204. }
  205. .condition {
  206. color: #787878;
  207. }
  208. }
  209. .right-part {
  210. .info-top {
  211. .title-row {
  212. .type-name {
  213. color: #787878;
  214. }
  215. .sub-title {
  216. color: #787878;
  217. }
  218. .condition {
  219. color: #787878;
  220. }
  221. }
  222. .date {
  223. color: #787878;
  224. }
  225. }
  226. }
  227. }
  228. }
  229. </style>