s-coupon-list.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="ss-m-20" :style="{ opacity: disabled ? '0.5' : '1' }">
  3. <view class="content">
  4. <view
  5. class="tag ss-flex ss-row-center"
  6. :class="isDisable ? 'disabled-bg-color' : 'info-bg-color'"
  7. >
  8. {{ data.discountType === 1 ? '满减券' : '折扣券' }}
  9. </view>
  10. <view class="title ss-m-x-30 ss-p-t-18">
  11. <view class="ss-flex ss-row-between">
  12. <view
  13. class="value-text ss-flex-1 ss-m-r-10"
  14. :class="isDisable ? 'disabled-color' : 'info-color'"
  15. >
  16. {{ data.name }}
  17. </view>
  18. <view>
  19. <view
  20. class="ss-flex ss-col-bottom"
  21. :class="isDisable ? 'disabled-color' : 'price-text'"
  22. >
  23. <view class="value-reduce ss-m-b-10" v-if="data.discountType === 1">¥</view>
  24. <view class="value-price">
  25. {{
  26. data.discountType === 1
  27. ? fen2yuan(data.discountPrice)
  28. : data.discountPercent / 10.0
  29. }}
  30. </view>
  31. <view class="value-discount ss-m-b-10 ss-m-l-4" v-if="data.discountType === 2"
  32. >折</view
  33. >
  34. </view>
  35. </view>
  36. </view>
  37. <view class="ss-flex ss-row-between ss-m-t-16">
  38. <view
  39. class="sellby-text"
  40. :class=" isDisable ? 'disabled-color' : 'subtitle-color'"
  41. v-if="data.validityType === 2"
  42. >
  43. 有效期:领取后 {{ data.fixedEndTerm }} 天内可用
  44. </view>
  45. <view
  46. class="sellby-text"
  47. :class=" isDisable ? 'disabled-color' : 'subtitle-color'"
  48. v-else
  49. >
  50. 有效期: {{ sheep.$helper.timeFormat(data.validStartTime, 'yyyy-mm-dd') }} 至
  51. {{ sheep.$helper.timeFormat(data.validEndTime, 'yyyy-mm-dd') }}
  52. </view>
  53. <view
  54. class="value-enough"
  55. :class="isDisable ? 'disabled-color' : 'subtitle-color'"
  56. >
  57. 满 {{ fen2yuan(data.usePrice) }} 可用
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- TODO 芋艿:可优化,增加优惠劵的描述 -->
  63. <view class="desc ss-flex ss-row-between">
  64. <view>
  65. <view class="desc-title">{{ data.description }}</view>
  66. <view>
  67. <slot name="reason" />
  68. </view>
  69. </view>
  70. <view>
  71. <slot />
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script setup>
  77. import { computed, reactive } from 'vue';
  78. import { fen2yuan } from '../../hooks/useGoods';
  79. import sheep from '../../index';
  80. const state = reactive({
  81. stateMap: {
  82. 0: '立即领取',
  83. 1: '去使用',
  84. },
  85. });
  86. const isDisable = computed(() => {
  87. if (props.type === 'coupon') {
  88. return false;
  89. }
  90. return props.data.status !== 1;
  91. });
  92. // 接受参数
  93. const props = defineProps({
  94. data: {
  95. type: Object,
  96. default: {},
  97. },
  98. disabled: {
  99. type: Boolean,
  100. default: false,
  101. },
  102. type: {
  103. type: String,
  104. default: 'coupon', // coupon 优惠劵模版;user 用户优惠劵
  105. },
  106. });
  107. </script>
  108. <style lang="scss" scoped>
  109. .info-bg-color {
  110. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  111. }
  112. .disabled-bg-color {
  113. background: #999;
  114. }
  115. .info-color {
  116. color: #333;
  117. }
  118. .subtitle-color {
  119. color: #666;
  120. }
  121. .disabled-color {
  122. color: #999;
  123. }
  124. .content {
  125. width: 100%;
  126. background: #fff;
  127. border-radius: 20rpx 20rpx 0 0;
  128. -webkit-mask: radial-gradient(circle at 12rpx 100%, #0000 12rpx, red 0) -12rpx;
  129. box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.04);
  130. .tag {
  131. width: 100rpx;
  132. color: #fff;
  133. height: 40rpx;
  134. font-size: 24rpx;
  135. border-radius: 20rpx 0 20rpx 0;
  136. }
  137. .title {
  138. padding-bottom: 22rpx;
  139. border-bottom: 2rpx dashed #d3d3d3;
  140. .value-text {
  141. font-size: 32rpx;
  142. font-weight: 600;
  143. }
  144. .sellby-text {
  145. font-size: 24rpx;
  146. font-weight: 400;
  147. }
  148. .value-price {
  149. font-size: 64rpx;
  150. font-weight: 500;
  151. line-height: normal;
  152. font-family: OPPOSANS;
  153. }
  154. .value-reduce {
  155. line-height: normal;
  156. font-size: 32rpx;
  157. }
  158. .value-discount {
  159. line-height: normal;
  160. font-size: 28rpx;
  161. }
  162. .value-enough {
  163. font-size: 24rpx;
  164. font-weight: 400;
  165. font-family: OPPOSANS;
  166. }
  167. }
  168. }
  169. .desc {
  170. width: 100%;
  171. background: #fff;
  172. -webkit-mask: radial-gradient(circle at 12rpx 0%, #0000 12rpx, red 0) -12rpx;
  173. box-shadow: rgba(#000, 0.1);
  174. box-sizing: border-box;
  175. padding: 24rpx 30rpx;
  176. box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.04);
  177. border-radius: 0 0 20rpx 20rpx;
  178. .desc-title {
  179. font-size: 24rpx;
  180. color: #999;
  181. font-weight: 400;
  182. }
  183. }
  184. .price-text {
  185. color: #ff0000;
  186. }
  187. </style>