message-card.vue 7.2 KB

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