red-packet-item.vue 8.2 KB

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