功能:完善门店能力与用户安全配置
This commit is contained in:
@@ -0,0 +1,179 @@
|
||||
<template>
|
||||
<div class="notifications-page">
|
||||
<header class="page-header">
|
||||
<button class="back-btn" type="button" @click="router.back()">‹</button>
|
||||
<div>
|
||||
<h1>消息通知</h1>
|
||||
<p>{{ unreadCount }} 条未读消息</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="message-list">
|
||||
<button
|
||||
v-for="item in messages"
|
||||
:key="item.id"
|
||||
class="message-item"
|
||||
:class="{ unread: item.readStatus !== 1 }"
|
||||
type="button"
|
||||
@click="openMessage(item)"
|
||||
>
|
||||
<span class="dot"></span>
|
||||
<span class="message-main">
|
||||
<strong>{{ item.title }}</strong>
|
||||
<small>{{ item.publisherName || '系统消息' }} · {{ item.publishTime || item.createTime }}</small>
|
||||
<em v-if="item.imageUrl">含图片</em>
|
||||
</span>
|
||||
</button>
|
||||
<a-empty v-if="!loading && messages.length === 0" description="暂无消息" />
|
||||
</main>
|
||||
|
||||
<a-modal v-model:open="detailVisible" title="消息详情" @ok="detailVisible = false">
|
||||
<h3>{{ currentMessage?.title }}</h3>
|
||||
<p class="message-meta">{{ currentMessage?.publisherName || '系统消息' }} · {{ currentMessage?.publishTime }}</p>
|
||||
<div v-if="currentMessage?.content" class="message-content">{{ currentMessage?.content }}</div>
|
||||
<img v-if="currentMessage?.imageUrl" class="message-image" :src="currentMessage.imageUrl" alt="消息图片" />
|
||||
</a-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* NotificationsView page script.
|
||||
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
||||
*/
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { userApi, type SystemMessageVO } from '@/api/user'
|
||||
|
||||
const router = useRouter()
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
const loading = ref(false)
|
||||
const messages = ref<SystemMessageVO[]>([])
|
||||
/** detailVisible is a reactive state variable used by the template and event handlers. */
|
||||
const detailVisible = ref(false)
|
||||
const currentMessage = ref<SystemMessageVO | null>(null)
|
||||
/** unreadCount is a reactive state variable used by the template and event handlers. */
|
||||
const unreadCount = computed(() => messages.value.filter(item => item.readStatus !== 1).length)
|
||||
|
||||
/** loadMessages is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const loadMessages = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
messages.value = await userApi.listMyMessages()
|
||||
} catch (error: any) {
|
||||
message.error(error?.message || '消息加载失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** openMessage is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
|
||||
const openMessage = async (item: SystemMessageVO) => {
|
||||
currentMessage.value = item
|
||||
detailVisible.value = true
|
||||
if (item.readStatus !== 1) {
|
||||
await userApi.markMessageRead(item.id)
|
||||
item.readStatus = 1
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadMessages)
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.notifications-page {
|
||||
min-height: 100vh;
|
||||
background: #fff7f8;
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: center;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.page-header p {
|
||||
margin: 4px 0 0;
|
||||
color: #8a7b83;
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 0;
|
||||
border-radius: 20px;
|
||||
background: #fff;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.message-list {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
padding: 16px;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.message-item .dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: #d7c9cf;
|
||||
}
|
||||
|
||||
.message-item.unread .dot {
|
||||
background: #ff5c8a;
|
||||
}
|
||||
|
||||
.message-main {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.message-main em {
|
||||
width: fit-content;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: #fff0f4;
|
||||
color: #d74270;
|
||||
font-size: 12px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.message-main small,
|
||||
.message-meta {
|
||||
color: #8a7b83;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
white-space: pre-wrap;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.message-image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: 420px;
|
||||
margin-top: 14px;
|
||||
object-fit: contain;
|
||||
border-radius: 8px;
|
||||
background: #fff7f8;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user