推拿小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.2 KiB

  1. <template>
  2. <view class="voucher">
  3. <image class="voucher-bg" src="/pages_order/static/voucher/voucher-bg.png" ></image>
  4. <view class="voucher-info">
  5. <view class="voucher-row voucher-title">{{ data.vouchersId_dictText }}</view>
  6. <!-- todo -->
  7. <view class="voucher-row voucher-time">{{ validRange }}</view>
  8. <view class="voucher-row voucher-desc">{{ data.desc ||'' }}</view>
  9. </view>
  10. <!-- status: 0-未使用 1-已使用 -->
  11. <template v-if="!readonly && data.status == 0 && isValid">
  12. <button plain class="btn" @click="onClick">立即使用</button>
  13. </template>
  14. </view>
  15. </template>
  16. <script>
  17. import dayjs from 'dayjs'
  18. import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'
  19. dayjs.extend(isSameOrBefore)
  20. export default {
  21. props: {
  22. data: {
  23. type: Object,
  24. default() {
  25. return {}
  26. }
  27. },
  28. readonly: {
  29. type: Boolean,
  30. default: false,
  31. }
  32. },
  33. computed: {
  34. validRange() {
  35. const { createTime, validDate } = this.data || {}
  36. let startTime = createTime ? this.$dayjs(createTime).format('YYYY.MM.DD') : '-'
  37. let endTime = validDate ? this.$dayjs(validDate).format('YYYY.MM.DD') : '-'
  38. return `${startTime}-${endTime}`
  39. },
  40. isValid() {
  41. const { validDate } = this.data || {}
  42. return dayjs().isSameOrBefore(dayjs(validDate), 'day')
  43. },
  44. },
  45. methods: {
  46. onClick() {
  47. this.$utils.navigateTo(`/pages_order/mine/verifyVoucher?id=${this.data.id}`)
  48. }
  49. },
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .voucher {
  54. width: 100%;
  55. height: 202rpx;
  56. position: relative;
  57. &-bg {
  58. width: 100%;
  59. height: 100%;
  60. }
  61. &-info {
  62. position: absolute;
  63. top: 49rpx;
  64. left: 253rpx;
  65. color: $uni-color-light;
  66. font-size: 18rpx;
  67. }
  68. &-row {
  69. & + & {
  70. margin-top: 6rpx;
  71. }
  72. }
  73. &-title {
  74. font-size: 28rpx;
  75. font-weight: 900;
  76. }
  77. .btn {
  78. position: absolute;
  79. bottom: 39rpx;
  80. right: 39rpx;
  81. width: auto;
  82. padding: 12rpx 29rpx;
  83. color: $uni-text-color-inverse;
  84. font-size: 18rpx;
  85. line-height: 25rpx;
  86. border-radius: 25rpx;
  87. border: none;
  88. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  89. }
  90. }
  91. </style>