coupon-card.vue 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <script setup lang="ts">
  2. import Card from '@/components/card.vue'
  3. import { Coupon } from '../../../core/libs/models'
  4. import dayjs from 'dayjs'
  5. import { useMessage } from 'wot-design-uni'
  6. import used from '@designer-hub/assets/src/libs/assets/used'
  7. import invalid from '@designer-hub/assets/src/libs/assets/invalid'
  8. import expired from '@designer-hub/assets/src/libs/assets/expired'
  9. const props = withDefaults(
  10. defineProps<{ options?: Coupon; canSelect?: boolean; selected?: boolean }>(),
  11. {
  12. canSelect: false,
  13. selected: false,
  14. },
  15. )
  16. const emits = defineEmits<{ select: [coupon: Coupon]; clickInstruction: [coupon: Coupon] }>()
  17. </script>
  18. <template>
  19. <Card custom-class="mx-3.5">
  20. <div class="relative">
  21. <div class="flex gap-3">
  22. <div class="w-[94px] h-[94px] bg-[#f6f6f6] rounded-2.5 overflow-hidden">
  23. <template v-if="options.couponType === 1">
  24. <div class="bg-[#fff8f8] w-full h-full flex flex-col items-center justify-center">
  25. <div class="text-[#ff7878] text-[26px] font-normal font-['PingFang_SC']">
  26. {{ options.brandPoints }}
  27. </div>
  28. <div class="text-[#ff7878] text-base font-normal font-['PingFang_SC']">积分</div>
  29. </div>
  30. </template>
  31. <template v-else>
  32. <wd-img width="100%" height="100%" :src="options.couponImgUrl"></wd-img>
  33. </template>
  34. </div>
  35. <div class="flex-1 flex flex-col justify-around">
  36. <div class="flex items-center gap-1">
  37. <div
  38. class="px-[3px] rounded border border-solid border-[#ff3636] justify-center items-center gap-2.5 inline-flex"
  39. >
  40. <div
  41. class="text-[#ff3e3e] text-[10px] font-normal font-['PingFang_SC'] leading-normal"
  42. >
  43. {{ options.materialName }}
  44. </div>
  45. </div>
  46. <div class="text-black text-sm font-normal font-['PingFang_SC'] leading-normal">
  47. <!-- GELATO咖啡兑换券 -->
  48. {{ options.couponName }}
  49. </div>
  50. </div>
  51. <div class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal">
  52. 有效期:
  53. <!-- 2024/04/01-2024/05/30 -->
  54. {{ dayjs(options.validityStartDate).format('YYYY/MM/DD') }}-{{
  55. dayjs(options.validityEndDate).format('YYYY/MM/DD')
  56. }}
  57. </div>
  58. <div
  59. class="text-black/40 text-xs font-normal font-['PingFang_SC'] leading-normal flex items-center"
  60. @click="emits('clickInstruction', options)"
  61. >
  62. 使用说明
  63. <wd-icon name="arrow-right" size="14"></wd-icon>
  64. </div>
  65. </div>
  66. <div class="flex items-center" v-if="canSelect" @click="emits('select', options)">
  67. <div
  68. class="w-4 h-4 rounded-full border border-black/60 border-solid"
  69. :class="`${selected ? 'bg-black' : ''}`"
  70. ></div>
  71. </div>
  72. </div>
  73. <div class="absolute top--4 right--4">
  74. <wd-img width="58" height="58" :src="options.isUse ? used : options.isValid ? invalid : expired"></wd-img>
  75. </div>
  76. </div>
  77. </Card>
  78. </template>