red-packet-item.vue 7.6 KB

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