|
@@ -1,5 +1,5 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { Message } from '../../../core/libs/models'
|
|
|
+import { Coupon, Message } from '../../../core/libs/models'
|
|
|
import Card from '@/components/card.vue'
|
|
|
import { integral, interact, message, system } from '../../../core/libs/svgs'
|
|
|
import { beforeNow } from '../../../utils/date-util'
|
|
@@ -10,10 +10,14 @@ import { getMessageType } from '../../../core/libs/message-types'
|
|
|
import { useRouter } from '../../../core/utils/router'
|
|
|
import ButtonEvo from '@/components/button-evo.vue'
|
|
|
import { messages } from '../../../core/libs/messages'
|
|
|
+import { stringify } from 'qs'
|
|
|
|
|
|
-const props = withDefaults(defineProps<{ options?: Message }>(), {})
|
|
|
+const props = withDefaults(
|
|
|
+ defineProps<{ options?: Message & { selectedCoupons?: Coupon[] } }>(),
|
|
|
+ {},
|
|
|
+)
|
|
|
const emits = defineEmits<{
|
|
|
- submit: [message: Message]
|
|
|
+ submit: [message: Message, coupons: Coupon[]]
|
|
|
cancel: [message: Message]
|
|
|
selectCoupon: [message: Message, coupons: any[]]
|
|
|
}>()
|
|
@@ -27,6 +31,16 @@ const { data: coupons, run: setCoupons } = useRequest(
|
|
|
}),
|
|
|
{ initialData: [] },
|
|
|
)
|
|
|
+const couponSelectText = computed(() => {
|
|
|
+ // `${coupons.value.length > 0 ? `${coupons.value.length}张可用` : '无可用'}`
|
|
|
+ if (props.options.selectedCoupons?.length) {
|
|
|
+ return `${props.options.selectedCoupons.at(0)?.brandPoints ?? 0}积分`
|
|
|
+ }
|
|
|
+ if (coupons.value.length) {
|
|
|
+ return `${coupons.value.length}张可用`
|
|
|
+ }
|
|
|
+ return '无可用'
|
|
|
+})
|
|
|
const init = async () => {
|
|
|
if (
|
|
|
props.options.messageType === MessageType.Integral &&
|
|
@@ -34,17 +48,34 @@ const init = async () => {
|
|
|
props.options.isRead !== '1'
|
|
|
) {
|
|
|
await setCoupons()
|
|
|
- // console.log(coupons.value)
|
|
|
}
|
|
|
}
|
|
|
+const handleJump = () => {
|
|
|
+ console.log(props)
|
|
|
+ const query: Record<string, string> = {}
|
|
|
+ switch (props.options.messageSubType) {
|
|
|
+ case 5:
|
|
|
+ query.title = props.options.title
|
|
|
+ query.contentDetail = props.options.detailBody
|
|
|
+ query.createTime = String(props.options.createTime)
|
|
|
+ query.viewsCount = props.options.viewCount
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ console.log(stringify(query))
|
|
|
+ // return
|
|
|
+ router.push(getMessageType(props.options.messageSubType)?.path + '?' + stringify(query))
|
|
|
+}
|
|
|
watch(
|
|
|
() => props.options,
|
|
|
- async () => {
|
|
|
+ async (value, oldValue, onCleanup) => {
|
|
|
+ // console.log('====>', value)
|
|
|
await init()
|
|
|
},
|
|
|
)
|
|
|
onMounted(async () => {
|
|
|
- // await init()
|
|
|
+ await init()
|
|
|
})
|
|
|
</script>
|
|
|
<template>
|
|
@@ -69,7 +100,11 @@ onMounted(async () => {
|
|
|
</div>
|
|
|
<div class="row-start-1 col-start-2 text-start">
|
|
|
<div class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-[30px]">
|
|
|
- {{ options.title }}
|
|
|
+ {{
|
|
|
+ String(options.messageSubType) === '5'
|
|
|
+ ? getMessageType(options.messageSubType)?.desc
|
|
|
+ : options.title
|
|
|
+ }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="row-start-1 col-start-3 text-end">
|
|
@@ -81,7 +116,10 @@ onMounted(async () => {
|
|
|
<div class="my-3 text-black/40 text-sm font-normal font-['PingFang_SC'] leading-[25px]">
|
|
|
<!-- {{ options.detailBody }} -->
|
|
|
<div
|
|
|
- v-if="[MessageType.Integral, MessageType.System].includes(options.messageType)"
|
|
|
+ v-if="
|
|
|
+ [MessageType.Integral, MessageType.System].includes(options.messageType) &&
|
|
|
+ String(options.messageSubType) !== '5'
|
|
|
+ "
|
|
|
v-html="options.detailBody"
|
|
|
></div>
|
|
|
<div class="grid grid-cols-[auto_1fr] gap-x-5 gap-y-4.5">
|
|
@@ -93,13 +131,14 @@ onMounted(async () => {
|
|
|
</div>
|
|
|
<div
|
|
|
class="flex items-center h-full overflow-hidden"
|
|
|
- @click="coupons.length && emits('selectCoupon', options, coupons)"
|
|
|
+ @click="emits('selectCoupon', options, coupons)"
|
|
|
>
|
|
|
<div
|
|
|
class="text-sm font-normal font-['PingFang_SC']"
|
|
|
:class="`${coupons.length > 0 ? 'text-[#ef4343]' : 'text-black/60'}`"
|
|
|
>
|
|
|
- {{ `${coupons.length > 0 ? `${coupons.length}张可用` : '无可用'}` }}
|
|
|
+ <!-- {{ `${coupons.length > 0 ? `${coupons.length}张可用` : '无可用'}` }}-->
|
|
|
+ {{ couponSelectText }}
|
|
|
</div>
|
|
|
<div class="h-5.5 flex items-center overflow-hidden">
|
|
|
<wd-icon
|
|
@@ -111,11 +150,13 @@ onMounted(async () => {
|
|
|
</div>
|
|
|
</template>
|
|
|
</div>
|
|
|
- <!-- {{ options.detailBody }} -->
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div v-if="options.coverUrl" class="row-start-3 col-start-2 col-end-4">
|
|
|
- <img class="w-[279px] h-[164px] rounded-md" :src="options.coverUrl" />
|
|
|
+ <div
|
|
|
+ v-if="options.coverUrl"
|
|
|
+ class="row-start-3 col-start-2 col-end-4 aspect-[1.7/1] rounded-md overflow-hidden"
|
|
|
+ >
|
|
|
+ <wd-img width="100%" height="100%" mode="aspectFill" :src="options.coverUrl" />
|
|
|
</div>
|
|
|
<div class="row-start-4 col-start-1 col-end-4 my-2">
|
|
|
<div v-if="!options.coverUrl" class="bg-[#dadada] w-full h-[1px]"></div>
|
|
@@ -142,7 +183,7 @@ onMounted(async () => {
|
|
|
<template v-if="options.pointsDetail?.pointsStauts === PointStatus.Rejected">
|
|
|
<span class="text-[#EF4343]">
|
|
|
<!-- 确认积分后,即刻到账,如有问题请驳回,联系材料商修改积分后再次确认 -->
|
|
|
- 驳回原因:{{ options.pointsDetail?.cancelReason }}
|
|
|
+ 已驳回,驳回原因:{{ options.pointsDetail?.cancelReason }}
|
|
|
</span>
|
|
|
</template>
|
|
|
</template>
|
|
@@ -156,7 +197,7 @@ onMounted(async () => {
|
|
|
</template>
|
|
|
<template v-if="getMessageType(options.messageSubType)?.path">
|
|
|
<div
|
|
|
- @click="router.push(getMessageType(options.messageSubType)?.path)"
|
|
|
+ @click="handleJump"
|
|
|
class="flex items-center text-[rgba(0,0,0,0.85)] text-xs font-normal font-['PingFang_SC'] leading-[25px]"
|
|
|
>
|
|
|
查看详情
|
|
@@ -185,7 +226,7 @@ onMounted(async () => {
|
|
|
</div> -->
|
|
|
<div class="flex-1">
|
|
|
<!-- <wd-button block :round="false" @click="emits('submit', options)">确认</wd-button> -->
|
|
|
- <ButtonEvo block @click="emits('submit', options)">确认</ButtonEvo>
|
|
|
+ <ButtonEvo block @click="emits('submit', options, coupons)">确认</ButtonEvo>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|