message-card.vue 7.3 KB

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