message-card.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <script setup lang="ts">
  2. import { Message } from '../../../core/libs/models'
  3. import Card from '@/components/card.vue'
  4. import { integral, interact, message, system } from '../../../core/libs/svgs'
  5. import { beforeNow } from '../../../utils/date-util'
  6. import dayjs from 'dayjs'
  7. import { MessageType, PointStatus } from '../../../core/libs/enums'
  8. import { getPointsCoupons } from '../../../core/libs/requests'
  9. const props = withDefaults(defineProps<{ options?: Message }>(), {})
  10. const emits = defineEmits<{
  11. submit: [message: Message]
  12. cancel: [message: Message]
  13. selectCoupon: [message: Message, coupons: any[]]
  14. }>()
  15. const { data: coupons, run: setCoupons } = useRequest(
  16. () =>
  17. getPointsCoupons({ userId: props.options.designerId, businessId: props.options.businessId }),
  18. { initialData: [] },
  19. )
  20. onMounted(async () => {
  21. if (
  22. props.options.messageType === MessageType.Integral &&
  23. props.options.messageSubType === 31 &&
  24. props.options.isRead !== '1'
  25. ) {
  26. await setCoupons()
  27. // console.log(coupons.value)
  28. }
  29. })
  30. </script>
  31. <template>
  32. <Card>
  33. <div class="grid items-center grid-cols-[38px_auto_100px]">
  34. <div class="row-start-1 col-start-1">
  35. <div
  36. class="w-[30px] h-[30px] bg-neutral-100 rounded-full mr-2 flex items-center justify-center"
  37. >
  38. <wd-img
  39. width="18"
  40. height="18"
  41. :src="
  42. {
  43. [MessageType.Integral]: integral,
  44. [MessageType.System]: system,
  45. [MessageType.Interact]: interact,
  46. }[options.messageType]
  47. "
  48. ></wd-img>
  49. </div>
  50. </div>
  51. <div class="row-start-1 col-start-2 text-start">
  52. <div class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-[30px]">
  53. {{ options.title }}
  54. </div>
  55. </div>
  56. <div class="row-start-1 col-start-3 text-end">
  57. <div class="text-black/30 text-sm font-normal font-['PingFang_SC'] leading-[10.18px]">
  58. {{ beforeNow(dayjs(options.createTime).toDate()) }}
  59. </div>
  60. </div>
  61. <div class="row-start-2 col-start-2 col-end-4">
  62. <div class="my-3 text-black/40 text-sm font-normal font-['PingFang_SC'] leading-[25px]">
  63. <div
  64. v-if="options.messageType === MessageType.Integral"
  65. v-html="options.detailBody"
  66. ></div>
  67. <div class="grid grid-cols-[auto_1fr] gap-x-5 gap-y-4.5">
  68. <template v-if="options.messageSubType === 31 && options.isRead !== '1'">
  69. <div
  70. class="text-black/40 text-sm font-normal font-['PingFang_SC'] h-5.5 flex items-center"
  71. >
  72. 积分券
  73. </div>
  74. <div
  75. class="flex items-center"
  76. @click="coupons.length && emits('selectCoupon', options, coupons)"
  77. >
  78. <div
  79. class="text-sm font-normal font-['PingFang_SC']"
  80. :class="`${coupons.length > 0 ? 'text-[#ef4343]' : 'text-black/60'}`"
  81. >
  82. {{ `${coupons.length > 0 ? `${coupons.length}张可用` : '无可用'}` }}
  83. </div>
  84. <div class="h-5.5 overflow-hidden">
  85. <wd-icon
  86. name="chevron-right"
  87. :custom-class="`${coupons.length > 0 ? 'text-[#ef4343]' : 'text-black/60'}`"
  88. size="20"
  89. ></wd-icon>
  90. </div>
  91. </div>
  92. </template>
  93. </div>
  94. <!-- {{ options.detailBody }} -->
  95. </div>
  96. </div>
  97. <div v-if="options.coverUrl" class="row-start-3 col-start-2 col-end-4">
  98. <img class="w-[279px] h-[164px] rounded-md" :src="options.coverUrl" />
  99. </div>
  100. <div class="row-start-4 col-start-1 col-end-4 my-2">
  101. <div v-if="!options.coverUrl" class="bg-[#dadada] w-full h-[1px]"></div>
  102. </div>
  103. <div class="row-start-5 col-start-2 col-end-4">
  104. <div class="text-black/40 text-xs font-normal font-['PingFang_SC']">
  105. <template
  106. v-if="
  107. [MessageType.Integral].includes(Number(options.messageType)) &&
  108. options.messageSubType === 31 &&
  109. options.isRead !== '1' &&
  110. options.pointsDetail?.pointsStauts === PointStatus.PendingConfirmation
  111. "
  112. >
  113. <span class="text-black/40">
  114. 确认积分后,即刻到账,如有问题请驳回,联系材料商修改积分后再次确认
  115. </span>
  116. </template>
  117. <template
  118. v-else-if="
  119. [MessageType.Integral].includes(Number(options.messageType)) &&
  120. options.messageSubType === 31 &&
  121. options.isRead === '1'
  122. "
  123. >
  124. <template v-if="options.pointsDetail?.pointsStauts === PointStatus.Rejected">
  125. <span class="text-black/40">
  126. <!-- 确认积分后,即刻到账,如有问题请驳回,联系材料商修改积分后再次确认 -->
  127. 驳回原因:{{ options.pointsDetail?.cancelReason }}
  128. </span>
  129. </template>
  130. </template>
  131. <template
  132. v-else-if="
  133. [MessageType.Integral].includes(Number(options.messageType)) &&
  134. [21, 22].includes(options.messageSubType)
  135. "
  136. >
  137. 如有问题请您联系官方客服!
  138. </template>
  139. <template v-else>
  140. <div class="flex items-center text-black">
  141. 查看详情
  142. <wd-icon name="arrow-right" size="16"></wd-icon>
  143. </div>
  144. </template>
  145. </div>
  146. </div>
  147. <div
  148. class="row-start-6 col-start-1 col-end-4 my-1"
  149. v-if="
  150. [MessageType.Integral].includes(Number(options.messageType)) &&
  151. options.messageSubType === 31 &&
  152. options.isRead !== '1' &&
  153. options.pointsDetail?.pointsStauts === PointStatus.PendingConfirmation
  154. "
  155. >
  156. <div class="flex gap-4">
  157. <div class="flex-1">
  158. <wd-button block :round="false" plain @click="emits('cancel', options)">驳回</wd-button>
  159. </div>
  160. <!-- <div class="flex-1">
  161. <wd-button block :round="false" @click="handleQ(it)">积分券</wd-button>
  162. </div> -->
  163. <div class="flex-1">
  164. <wd-button block :round="false" @click="emits('submit', options)">确认</wd-button>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. </Card>
  170. </template>