message-card.vue 6.8 KB

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