feat: migrate app routes and business modules
This commit is contained in:
@@ -0,0 +1,211 @@
|
||||
<template>
|
||||
<view class="message-page">
|
||||
<ModulePageBackground module="notification" />
|
||||
<view class="page-header"><PageHeader root title="消息中心" :action="unreadCount > 0 ? '设为已读' : ''" @action="requestMarkAllRead" /></view>
|
||||
<view class="page-content">
|
||||
<view v-if="notificationListState === 'loading'" class="state-card"><AppLoading text="正在读取消息通知" /></view>
|
||||
<view v-else-if="notificationListState === 'error'" class="state-card">
|
||||
<text>暂时无法读取消息状态</text>
|
||||
<text>{{ notificationListError || "请检查网络后重新加载。" }}</text>
|
||||
<AppButton block type="secondary" label="重新加载" @click="loadNotifications" />
|
||||
<AppButton block label="返回我的" @click="returnToProfile" />
|
||||
</view>
|
||||
<view v-else-if="!notifications.length" class="state-card message-status-card">
|
||||
<text>当前没有通知</text>
|
||||
<text>新的家谱动态、审核和活动消息会在这里展示。</text>
|
||||
<text v-if="markAllReadError" class="message-operation-error">{{ markAllReadError }}</text>
|
||||
<AppButton block type="secondary" label="返回我的" @click="returnToProfile" />
|
||||
</view>
|
||||
<view v-else class="message-list">
|
||||
<view
|
||||
v-for="item in notifications"
|
||||
:key="item.notificationId"
|
||||
class="message-row"
|
||||
hover-class="action-hover"
|
||||
@click="openNotification(item)"
|
||||
>
|
||||
<view class="message-row__body">
|
||||
<view class="message-row__title-line">
|
||||
<text class="message-row__title">{{ item.noticeTitle || '通知消息' }}</text>
|
||||
<text v-if="item.readStatus === '0'" class="message-row__unread">未读</text>
|
||||
</view>
|
||||
<text class="message-row__summary">{{ item.noticeContent || item.bizSummary || '暂无通知摘要' }}</text>
|
||||
<text class="message-row__meta">{{ item.publishTime || '刚刚发布' }}</text>
|
||||
</view>
|
||||
<text class="message-row__chevron">›</text>
|
||||
</view>
|
||||
<text v-if="markAllReadError" class="message-operation-error">{{ markAllReadError }}</text>
|
||||
<AppButton v-if="unreadCount" block label="全部设为已读" @click="requestMarkAllRead" />
|
||||
</view>
|
||||
</view>
|
||||
<AppPromotionStrip placement="message_bottom" title="消息页推荐" />
|
||||
<AppTabbar active="profile" />
|
||||
<AppDialog
|
||||
:visible="markAllVisible"
|
||||
eyebrow="消息状态"
|
||||
title="把全部消息设为已读?"
|
||||
message="这些消息将不再显示为未读。"
|
||||
:confirm-text="markAllSubmitting ? '正在设置' : '确认设为已读'"
|
||||
cancel-text="取消"
|
||||
show-cancel
|
||||
:close-on-mask="false"
|
||||
@confirm="confirmMarkAllRead"
|
||||
@cancel="markAllVisible = false"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";
|
||||
import AppButton from "@/components/AppButton.vue";
|
||||
import AppDialog from "@/components/AppDialog.vue";
|
||||
import AppLoading from "@/components/AppLoading.vue";
|
||||
import AppPromotionStrip from "@/components/AppPromotionStrip.vue";
|
||||
import AppTabbar from "@/components/AppTabbar.vue";
|
||||
import ModulePageBackground from "@/components/ModulePageBackground.vue";
|
||||
import PageHeader from "@/components/PageHeader.vue";
|
||||
import {
|
||||
createRequestController,
|
||||
isRequestCancelled
|
||||
} from "@/services/api/request-controller.js";
|
||||
import { notificationApi } from "@/services/api/notification-service.js";
|
||||
import { getRequestErrorMessage } from "@/services/api/request-error-message.js";
|
||||
import { goRoot, openPage } from "@/utils/navigation/gateway.js";
|
||||
|
||||
const unreadCount = ref(0);
|
||||
const notifications = ref([]);
|
||||
const notificationListState = ref("loading");
|
||||
const notificationListError = ref("");
|
||||
const notificationListController = createRequestController();
|
||||
const markAllReadController = createRequestController();
|
||||
const markAllVisible = ref(false);
|
||||
const markAllSubmitting = ref(false);
|
||||
const markAllReadError = ref("");
|
||||
let isPageActive = true;
|
||||
|
||||
const loadNotifications = async () => {
|
||||
notificationListController.abort();
|
||||
notificationListState.value = "loading";
|
||||
notificationListError.value = "";
|
||||
try {
|
||||
const notificationRows = await notificationApi.getNotifications({
|
||||
requestController: notificationListController,
|
||||
});
|
||||
if (!isPageActive) return;
|
||||
notifications.value = notificationRows;
|
||||
unreadCount.value = notificationRows.filter((item) => item.readStatus === "0").length;
|
||||
notificationListState.value = "ready";
|
||||
} catch (error) {
|
||||
if (!isPageActive || isRequestCancelled(error)) return;
|
||||
notificationListError.value = getRequestErrorMessage(error, "请稍后重试。");
|
||||
notificationListState.value = "error";
|
||||
}
|
||||
};
|
||||
|
||||
const requestMarkAllRead = () => {
|
||||
if (notificationListState.value !== "ready" || !unreadCount.value || markAllSubmitting.value) return;
|
||||
markAllReadError.value = "";
|
||||
markAllVisible.value = true;
|
||||
};
|
||||
|
||||
const confirmMarkAllRead = async () => {
|
||||
if (markAllSubmitting.value || !unreadCount.value) return;
|
||||
markAllSubmitting.value = true;
|
||||
markAllReadError.value = "";
|
||||
try {
|
||||
await notificationApi.markAllNotificationsRead({ requestController: markAllReadController });
|
||||
if (!isPageActive) return;
|
||||
markAllVisible.value = false;
|
||||
await loadNotifications();
|
||||
} catch (error) {
|
||||
if (!isPageActive || isRequestCancelled(error)) return;
|
||||
markAllReadError.value = getRequestErrorMessage(error, "全部标记已读失败,请稍后重试。");
|
||||
} finally {
|
||||
if (isPageActive) markAllSubmitting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const returnToProfile = () => goRoot("M01");
|
||||
const openNotification = (item) => openPage("N02", { id: item.notificationId });
|
||||
onLoad(loadNotifications);
|
||||
onShow(() => {
|
||||
if (notificationListState.value !== "loading") loadNotifications();
|
||||
});
|
||||
onUnload(() => {
|
||||
isPageActive = false;
|
||||
notificationListController.abort();
|
||||
markAllReadController.abort();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import "../../styles/adaptive-frame-profiles.scss";
|
||||
.message-page {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
flex-direction: column;
|
||||
background: $paper;
|
||||
}
|
||||
.page-header,
|
||||
.page-content {
|
||||
z-index: 1;
|
||||
}
|
||||
.page-content {
|
||||
flex: 1;
|
||||
padding: 18rpx 24rpx 190rpx;
|
||||
}
|
||||
.state-card {
|
||||
box-sizing: border-box;
|
||||
min-height: 340rpx;
|
||||
padding: 78rpx 52rpx 50rpx;
|
||||
text-align: center;
|
||||
@include adaptive-notification-content;
|
||||
}
|
||||
.state-card text {
|
||||
display: block;
|
||||
}
|
||||
.state-card text:first-child {
|
||||
color: $ink;
|
||||
font-family: STKaiti, KaiTi, serif;
|
||||
font-size: clamp(19px, 35rpx, 24px);
|
||||
font-weight: 700;
|
||||
}
|
||||
.state-card text:nth-child(2) {
|
||||
margin-top: 18rpx;
|
||||
color: $ink-muted;
|
||||
font-size: clamp(15px, 24rpx, 18px);
|
||||
line-height: 1.65;
|
||||
}
|
||||
.state-card .app-button {
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
.message-list {
|
||||
display: grid;
|
||||
gap: 16rpx;
|
||||
@include adaptive-notification-content;
|
||||
}
|
||||
.message-row {
|
||||
display: flex;
|
||||
gap: 18rpx;
|
||||
align-items: center;
|
||||
padding: 24rpx;
|
||||
border: 1rpx solid rgba(128, 89, 49, 0.26);
|
||||
border-radius: 12rpx;
|
||||
background: rgba(255, 252, 245, 0.78);
|
||||
}
|
||||
.message-row__body { min-width: 0; flex: 1; }
|
||||
.message-row__title-line { display: flex; gap: 12rpx; align-items: center; }
|
||||
.message-row__title { overflow: hidden; flex: 1; color: $ink; font-size: clamp(16px, 27rpx, 20px); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.message-row__unread { flex: 0 0 auto; color: $brand-red; font-size: clamp(12px, 20rpx, 15px); }
|
||||
.message-row__summary, .message-row__meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.message-row__summary { margin-top: 9rpx; color: $ink-muted; font-size: clamp(14px, 23rpx, 17px); }
|
||||
.message-row__meta { margin-top: 9rpx; color: #8b7d6c; font-size: clamp(13px, 21rpx, 16px); }
|
||||
.message-row__chevron { color: $ink-muted; font-size: clamp(24px, 42rpx, 30px); line-height: 1; }
|
||||
.message-operation-error {
|
||||
margin-top: 18rpx;
|
||||
color: $brand-red;
|
||||
font-size: clamp(14px, 22rpx, 17px);
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,282 @@
|
||||
<template>
|
||||
<view class="message-detail-page">
|
||||
<ModulePageBackground module="notification" />
|
||||
<view class="page-header"
|
||||
><PageHeader
|
||||
title="消息详情"
|
||||
:action="notificationDetail.readStatus === '0' ? (markReadSubmitting ? '正在设置' : '设为已读') : ''"
|
||||
custom-back
|
||||
@action="requestMarkRead"
|
||||
@back="backToMessages"
|
||||
/></view>
|
||||
<view class="page-content">
|
||||
<view v-if="notificationDetailState === 'loading'" class="state-card"
|
||||
><AppLoading text="正在读取消息详情"
|
||||
/></view>
|
||||
<view v-else-if="notificationDetailState === 'error'" class="state-card">
|
||||
<text>暂时无法读取消息详情</text>
|
||||
<text>{{ notificationDetailError || "请稍后重试。" }}</text>
|
||||
<AppButton
|
||||
block
|
||||
type="secondary"
|
||||
label="重新加载"
|
||||
@click="loadDetail"
|
||||
/>
|
||||
<AppButton block label="返回消息中心" @click="backToMessages" />
|
||||
</view>
|
||||
<view v-else-if="notificationDetailState === 'invalid'" class="state-card">
|
||||
<text>消息不存在或链接已失效</text>
|
||||
<text>请返回消息中心查看最新通知。</text>
|
||||
<AppButton block label="返回消息中心" @click="backToMessages" />
|
||||
</view>
|
||||
<view v-else class="detail-card">
|
||||
<text class="detail-title">{{ notificationDetail.noticeTitle || "通知消息" }}</text>
|
||||
<text v-if="notificationDetail.publishTime" class="detail-time">{{
|
||||
notificationDetail.publishTime
|
||||
}}</text>
|
||||
<view class="detail-content"
|
||||
><text>{{ notificationDetail.noticeContent || "暂无通知正文" }}</text></view
|
||||
>
|
||||
<view
|
||||
v-if="
|
||||
notificationDetail.noticeTypeLabel ||
|
||||
notificationDetail.genealogyName ||
|
||||
notificationDetail.senderNickName ||
|
||||
notificationDetail.bizSummary
|
||||
"
|
||||
class="detail-meta"
|
||||
>
|
||||
<view v-if="notificationDetail.noticeTypeLabel" class="detail-meta__row"
|
||||
><text>通知类型</text><text>{{ notificationDetail.noticeTypeLabel }}</text></view
|
||||
>
|
||||
<view v-if="notificationDetail.genealogyName" class="detail-meta__row"
|
||||
><text>所属家谱</text><text>{{ notificationDetail.genealogyName }}</text></view
|
||||
>
|
||||
<view v-if="notificationDetail.senderNickName" class="detail-meta__row"
|
||||
><text>发送人</text><text>{{ notificationDetail.senderNickName }}</text></view
|
||||
>
|
||||
<view v-if="notificationDetail.bizSummary" class="detail-meta__row"
|
||||
><text>关联事项</text><text>{{ notificationDetail.bizSummary }}</text></view
|
||||
>
|
||||
</view>
|
||||
<AppButton v-if="noticeTarget" block :label="noticeTarget.label" @click="openRelatedBusiness" />
|
||||
<text v-if="markReadError" class="detail-operation-error">{{ markReadError }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<AppDialog
|
||||
:visible="markReadVisible"
|
||||
eyebrow="消息状态"
|
||||
title="把这条消息设为已读?"
|
||||
message="这条消息将不再显示为未读。"
|
||||
:confirm-text="markReadSubmitting ? '正在设置' : '确认设为已读'"
|
||||
cancel-text="取消"
|
||||
show-cancel
|
||||
:close-on-mask="false"
|
||||
@confirm="confirmMarkRead"
|
||||
@cancel="markReadVisible = false"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref } from "vue";
|
||||
import { onLoad, onUnload } from "@dcloudio/uni-app";
|
||||
import AppButton from "@/components/AppButton.vue";
|
||||
import AppDialog from "@/components/AppDialog.vue";
|
||||
import AppLoading from "@/components/AppLoading.vue";
|
||||
import ModulePageBackground from "@/components/ModulePageBackground.vue";
|
||||
import PageHeader from "@/components/PageHeader.vue";
|
||||
import {
|
||||
createRequestController,
|
||||
isRequestCancelled
|
||||
} from "@/services/api/request-controller.js";
|
||||
import { notificationApi } from "@/services/api/notification-service.js";
|
||||
import { getRequestErrorMessage } from "@/services/api/request-error-message.js";
|
||||
import { openNoticeTarget, returnTo } from "@/utils/navigation/gateway.js";
|
||||
|
||||
const notificationId = ref("");
|
||||
const notificationDetail = ref({});
|
||||
const notificationDetailState = ref("loading");
|
||||
const notificationDetailError = ref("");
|
||||
const notificationDetailController = createRequestController();
|
||||
const markReadController = createRequestController();
|
||||
const markReadVisible = ref(false);
|
||||
const markReadSubmitting = ref(false);
|
||||
const markReadError = ref("");
|
||||
let isPageActive = true;
|
||||
const noticeTarget = computed(() => {
|
||||
const genealogyId = notificationDetail.value?.genealogyId;
|
||||
const bizId = notificationDetail.value?.bizId;
|
||||
if (notificationDetail.value?.noticeType === "join_apply" && genealogyId) {
|
||||
return { type: "GENEALOGY_REVIEW", params: { genealogyId }, label: "去处理加入申请" };
|
||||
}
|
||||
if (notificationDetail.value?.noticeType === "family_feed" && genealogyId && bizId) {
|
||||
return { type: "FAMILY_FEED", params: { genealogyId, feedId: bizId }, label: "查看相关动态" };
|
||||
}
|
||||
if (notificationDetail.value?.noticeType === "memo_reminder" && genealogyId && bizId) {
|
||||
return { type: "MEMO_REMINDER", params: { genealogyId, memoId: bizId }, label: "查看相关备忘" };
|
||||
}
|
||||
if (notificationDetail.value?.noticeType === "CEREMONY_INVITE") {
|
||||
return { type: "CEREMONY_INVITE", params: {}, label: "查看活动邀请" };
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const loadDetail = async () => {
|
||||
if (!/^[1-9]\d*$/.test(notificationId.value)) {
|
||||
notificationDetailState.value = "invalid";
|
||||
return;
|
||||
}
|
||||
notificationDetailController.abort();
|
||||
notificationDetailState.value = "loading";
|
||||
notificationDetailError.value = "";
|
||||
try {
|
||||
const loadedNotification = await notificationApi.getNotificationDetail(notificationId.value, {
|
||||
requestController: notificationDetailController,
|
||||
});
|
||||
if (!isPageActive) return;
|
||||
notificationDetail.value = loadedNotification;
|
||||
notificationDetailState.value = "ready";
|
||||
} catch (error) {
|
||||
if (!isPageActive || isRequestCancelled(error)) return;
|
||||
notificationDetailError.value = getRequestErrorMessage(error, "请稍后重试。");
|
||||
notificationDetailState.value = "error";
|
||||
}
|
||||
};
|
||||
|
||||
const backToMessages = () => returnTo("N01");
|
||||
const openRelatedBusiness = () => noticeTarget.value
|
||||
? openNoticeTarget(noticeTarget.value.type, noticeTarget.value.params, "N02")
|
||||
: Promise.resolve(false);
|
||||
const requestMarkRead = () => {
|
||||
if (notificationDetailState.value !== "ready" || notificationDetail.value?.readStatus !== "0" || markReadSubmitting.value)
|
||||
return;
|
||||
markReadError.value = "";
|
||||
markReadVisible.value = true;
|
||||
};
|
||||
const confirmMarkRead = async () => {
|
||||
if (markReadSubmitting.value || notificationDetail.value?.readStatus !== "0") return;
|
||||
markReadSubmitting.value = true;
|
||||
markReadError.value = "";
|
||||
try {
|
||||
await notificationApi.markNotificationRead(notificationId.value, {
|
||||
requestController: markReadController,
|
||||
});
|
||||
if (!isPageActive) return;
|
||||
markReadVisible.value = false;
|
||||
await loadDetail();
|
||||
} catch (error) {
|
||||
if (!isPageActive || isRequestCancelled(error)) return;
|
||||
markReadError.value = getRequestErrorMessage(error, "标记已读失败,请稍后重试。");
|
||||
} finally {
|
||||
if (isPageActive) markReadSubmitting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onLoad((options) => {
|
||||
notificationId.value = String(options?.id || "");
|
||||
if (!/^[1-9]\d*$/.test(notificationId.value)) {
|
||||
notificationDetailState.value = "invalid";
|
||||
return;
|
||||
}
|
||||
loadDetail();
|
||||
});
|
||||
onUnload(() => {
|
||||
isPageActive = false;
|
||||
notificationDetailController.abort();
|
||||
markReadController.abort();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import "../../styles/adaptive-frame-profiles.scss";
|
||||
.message-detail-page {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
flex-direction: column;
|
||||
background: $paper;
|
||||
}
|
||||
.page-header,
|
||||
.page-content {
|
||||
z-index: 1;
|
||||
}
|
||||
.page-content {
|
||||
flex: 1;
|
||||
padding: 18rpx 24rpx 72rpx;
|
||||
}
|
||||
.state-card,
|
||||
.detail-card {
|
||||
box-sizing: border-box;
|
||||
@include adaptive-notification-content;
|
||||
}
|
||||
.state-card {
|
||||
min-height: 340rpx;
|
||||
padding: 78rpx 52rpx 50rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.state-card text {
|
||||
display: block;
|
||||
}
|
||||
.state-card text:first-child,
|
||||
.detail-title {
|
||||
color: $ink;
|
||||
font-family: STKaiti, KaiTi, serif;
|
||||
font-size: clamp(19px, 35rpx, 24px);
|
||||
font-weight: 700;
|
||||
}
|
||||
.state-card text:nth-child(2) {
|
||||
margin-top: 18rpx;
|
||||
color: $ink-muted;
|
||||
font-size: clamp(15px, 24rpx, 18px);
|
||||
line-height: 1.65;
|
||||
}
|
||||
.state-card .app-button {
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
.detail-card {
|
||||
padding: 44rpx 38rpx;
|
||||
}
|
||||
.detail-title,
|
||||
.detail-time {
|
||||
display: block;
|
||||
}
|
||||
.detail-time {
|
||||
margin-top: 16rpx;
|
||||
color: $ink-muted;
|
||||
font-size: clamp(15px, 24rpx, 18px);
|
||||
}
|
||||
.detail-content {
|
||||
margin-top: 36rpx;
|
||||
color: $ink;
|
||||
font-size: clamp(16px, 29rpx, 20px);
|
||||
line-height: 1.8;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.detail-meta {
|
||||
margin-top: 42rpx;
|
||||
padding-top: 24rpx;
|
||||
border-top: 1rpx solid rgba(91, 70, 42, 0.16);
|
||||
}
|
||||
.detail-meta__row {
|
||||
display: flex;
|
||||
gap: 22rpx;
|
||||
padding: 10rpx 0;
|
||||
color: $ink-muted;
|
||||
font-size: clamp(15px, 24rpx, 18px);
|
||||
line-height: 1.5;
|
||||
}
|
||||
.detail-meta__row text:first-child {
|
||||
flex: 0 0 116rpx;
|
||||
}
|
||||
.detail-meta__row text:last-child {
|
||||
flex: 1;
|
||||
color: $ink;
|
||||
}
|
||||
.detail-operation-error {
|
||||
display: block;
|
||||
margin-top: 22rpx;
|
||||
color: $brand-red;
|
||||
font-size: clamp(14px, 22rpx, 17px);
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
@@ -1,187 +0,0 @@
|
||||
<!-- 页面编号:N-01;用途:读取当前账号的消息通知。 -->
|
||||
<template>
|
||||
<view class="message-page">
|
||||
<ModulePageBackground module="notification" />
|
||||
<view class="page-header"><PageHeader root title="消息中心" /></view>
|
||||
<view class="page-content">
|
||||
<view v-if="state === 'loading'" class="state-card"
|
||||
><AppLoading text="正在读取消息"
|
||||
/></view>
|
||||
<view v-else-if="state === 'error'" class="state-card"
|
||||
><text>暂时无法读取消息</text
|
||||
><AppButton
|
||||
block
|
||||
type="secondary"
|
||||
label="重新加载"
|
||||
@click="loadNotifications"
|
||||
/></view>
|
||||
<view v-else-if="state === 'empty'" class="state-card"
|
||||
><text>暂无消息</text><text>消息列表会直接从服务端读取。</text
|
||||
><AppButton block label="返回我的" @click="returnToProfile"
|
||||
/></view>
|
||||
<view v-else class="message-list">
|
||||
<text class="message-list__count">共 {{ notifications.length }} 条消息</text>
|
||||
<view
|
||||
v-for="(item, index) in notifications"
|
||||
:key="notificationKey(item, index)"
|
||||
class="message-card"
|
||||
>
|
||||
<view class="message-card__heading"
|
||||
><text>{{ notificationTitle(item) }}</text><text>消息</text></view
|
||||
>
|
||||
<text class="message-card__summary">{{ notificationSummary(item) }}</text>
|
||||
<text v-if="notificationTime(item)" class="message-card__time">{{
|
||||
notificationTime(item)
|
||||
}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<AppTabbar active="profile" />
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";
|
||||
import AppButton from "@/components/AppButton.vue";
|
||||
import AppLoading from "@/components/AppLoading.vue";
|
||||
import AppTabbar from "@/components/AppTabbar.vue";
|
||||
import ModulePageBackground from "@/components/ModulePageBackground.vue";
|
||||
import PageHeader from "@/components/PageHeader.vue";
|
||||
import {
|
||||
appApi,
|
||||
createRequestController,
|
||||
isRequestCancelled,
|
||||
} from "@/utils/api.js";
|
||||
import { goRoot } from "@/utils/navigation.js";
|
||||
|
||||
const notifications = ref([]);
|
||||
const state = ref("loading");
|
||||
const controller = createRequestController();
|
||||
let active = true;
|
||||
const notificationKey = (item, index) =>
|
||||
String(item?.notificationId ?? item?.id ?? index);
|
||||
const notificationTitle = (item) =>
|
||||
String(item?.noticeTitle ?? item?.title ?? "通知消息");
|
||||
const notificationSummary = (item) =>
|
||||
String(item?.noticeContent ?? item?.content ?? "点击查看消息详情");
|
||||
const notificationTime = (item) =>
|
||||
String(item?.publishTime ?? item?.time ?? item?.createdAt ?? "");
|
||||
const loadNotifications = async () => {
|
||||
controller.abort();
|
||||
state.value = "loading";
|
||||
try {
|
||||
notifications.value = await appApi.getNotifications({
|
||||
requestController: controller,
|
||||
});
|
||||
if (!active) return;
|
||||
state.value = notifications.value.length ? "ready" : "empty";
|
||||
} catch (error) {
|
||||
if (!active || isRequestCancelled(error)) return;
|
||||
state.value = "error";
|
||||
}
|
||||
};
|
||||
const returnToProfile = () => goRoot("M01");
|
||||
onLoad(loadNotifications);
|
||||
onShow(() => {
|
||||
if (state.value !== "loading") loadNotifications();
|
||||
});
|
||||
onUnload(() => {
|
||||
active = false;
|
||||
controller.abort();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import "../../styles/adaptive-frame-profiles.scss";
|
||||
.message-page {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
flex-direction: column;
|
||||
background: $paper;
|
||||
}
|
||||
.page-header,
|
||||
.page-content {
|
||||
z-index: 1;
|
||||
}
|
||||
.page-content {
|
||||
flex: 1;
|
||||
padding: 18rpx 24rpx 190rpx;
|
||||
}
|
||||
.state-card {
|
||||
box-sizing: border-box;
|
||||
min-height: 340rpx;
|
||||
padding: 78rpx 52rpx 50rpx;
|
||||
text-align: center;
|
||||
@include adaptive-family-content;
|
||||
}
|
||||
.state-card text {
|
||||
display: block;
|
||||
}
|
||||
.state-card text:first-child {
|
||||
color: $ink;
|
||||
font-family: STKaiti, KaiTi, serif;
|
||||
font-size: clamp(19px, 35rpx, 24px);
|
||||
font-weight: 700;
|
||||
}
|
||||
.state-card text:nth-child(2) {
|
||||
margin-top: 18rpx;
|
||||
color: $ink-muted;
|
||||
font-size: clamp(15px, 24rpx, 18px);
|
||||
line-height: 1.65;
|
||||
}
|
||||
.state-card .app-button {
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
.message-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
}
|
||||
.message-list__count {
|
||||
display: block;
|
||||
color: $ink-muted;
|
||||
font-size: clamp(13px, 21rpx, 16px);
|
||||
}
|
||||
.message-card {
|
||||
padding: 28rpx 34rpx;
|
||||
@include adaptive-family-content;
|
||||
}
|
||||
.message-card__heading {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
.message-card__heading text:first-child {
|
||||
color: $ink;
|
||||
font-family: STKaiti, KaiTi, serif;
|
||||
font-size: clamp(17px, 30rpx, 22px);
|
||||
font-weight: 700;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.message-card__heading text:last-child {
|
||||
color: $brand-red;
|
||||
font-size: clamp(13px, 21rpx, 16px);
|
||||
}
|
||||
.message-card__summary,
|
||||
.message-card__time {
|
||||
display: block;
|
||||
}
|
||||
.message-card__summary {
|
||||
display: -webkit-box;
|
||||
margin-top: 12rpx;
|
||||
overflow: hidden;
|
||||
color: $ink-muted;
|
||||
font-size: clamp(14px, 22rpx, 17px);
|
||||
line-height: 1.55;
|
||||
overflow-wrap: anywhere;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
}
|
||||
.message-card__time {
|
||||
margin-top: 12rpx;
|
||||
color: #8b7d6c;
|
||||
font-size: clamp(13px, 20rpx, 16px);
|
||||
}
|
||||
</style>
|
||||
@@ -1,205 +0,0 @@
|
||||
<!-- 页面编号:N-02;用途:按通知 ID 读取服务端通知详情。 -->
|
||||
<template>
|
||||
<view class="message-detail-page">
|
||||
<ModulePageBackground module="notification" />
|
||||
<view class="page-header"
|
||||
><PageHeader title="消息详情" custom-back @back="backToMessages"
|
||||
/></view>
|
||||
<view class="page-content">
|
||||
<view v-if="state === 'loading'" class="state-card"
|
||||
><AppLoading text="正在读取消息详情"
|
||||
/></view>
|
||||
<view v-else-if="state === 'error'" class="state-card">
|
||||
<text>暂时无法读取消息详情</text>
|
||||
<text>{{ loadError || "请稍后重试。" }}</text>
|
||||
<AppButton
|
||||
block
|
||||
type="secondary"
|
||||
label="重新加载"
|
||||
@click="loadDetail"
|
||||
/>
|
||||
<AppButton block label="返回消息中心" @click="backToMessages" />
|
||||
</view>
|
||||
<view v-else-if="state === 'invalid'" class="state-card">
|
||||
<text>消息不存在或链接已失效</text>
|
||||
<text>请返回消息中心查看最新通知。</text>
|
||||
<AppButton block label="返回消息中心" @click="backToMessages" />
|
||||
</view>
|
||||
<view v-else class="detail-card">
|
||||
<text class="detail-title">{{ detail.noticeTitle || "通知消息" }}</text>
|
||||
<text v-if="detail.publishTime" class="detail-time">{{
|
||||
detail.publishTime
|
||||
}}</text>
|
||||
<view class="detail-content"
|
||||
><text>{{ detail.noticeContent || "暂无通知正文" }}</text></view
|
||||
>
|
||||
<view
|
||||
v-if="
|
||||
detail.noticeType ||
|
||||
detail.genealogyName ||
|
||||
detail.senderNickName ||
|
||||
detail.bizSummary
|
||||
"
|
||||
class="detail-meta"
|
||||
>
|
||||
<view v-if="detail.noticeType" class="detail-meta__row"
|
||||
><text>通知类型</text><text>{{ detail.noticeType }}</text></view
|
||||
>
|
||||
<view v-if="detail.genealogyName" class="detail-meta__row"
|
||||
><text>所属家谱</text><text>{{ detail.genealogyName }}</text></view
|
||||
>
|
||||
<view v-if="detail.senderNickName" class="detail-meta__row"
|
||||
><text>发送人</text><text>{{ detail.senderNickName }}</text></view
|
||||
>
|
||||
<view v-if="detail.bizSummary" class="detail-meta__row"
|
||||
><text>关联事项</text><text>{{ detail.bizSummary }}</text></view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { onLoad, onUnload } from "@dcloudio/uni-app";
|
||||
import AppButton from "@/components/AppButton.vue";
|
||||
import AppLoading from "@/components/AppLoading.vue";
|
||||
import ModulePageBackground from "@/components/ModulePageBackground.vue";
|
||||
import PageHeader from "@/components/PageHeader.vue";
|
||||
import {
|
||||
appApi,
|
||||
createRequestController,
|
||||
isRequestCancelled,
|
||||
} from "@/utils/api.js";
|
||||
import { returnTo } from "@/utils/navigation.js";
|
||||
|
||||
const notificationId = ref("");
|
||||
const detail = ref({});
|
||||
const state = ref("loading");
|
||||
const loadError = ref("");
|
||||
const controller = createRequestController();
|
||||
let active = true;
|
||||
|
||||
const loadDetail = async () => {
|
||||
if (!/^[1-9]\d*$/.test(notificationId.value)) {
|
||||
state.value = "invalid";
|
||||
return;
|
||||
}
|
||||
controller.abort();
|
||||
state.value = "loading";
|
||||
loadError.value = "";
|
||||
try {
|
||||
detail.value = await appApi.getNotificationDetail(notificationId.value, {
|
||||
requestController: controller,
|
||||
});
|
||||
if (!active) return;
|
||||
state.value = "ready";
|
||||
} catch (error) {
|
||||
if (!active || isRequestCancelled(error)) return;
|
||||
loadError.value = error?.message || "请稍后重试。";
|
||||
state.value = "error";
|
||||
}
|
||||
};
|
||||
|
||||
const backToMessages = () => returnTo("N01");
|
||||
|
||||
onLoad((options) => {
|
||||
notificationId.value = String(options?.id || "");
|
||||
if (!/^[1-9]\d*$/.test(notificationId.value)) {
|
||||
state.value = "invalid";
|
||||
return;
|
||||
}
|
||||
loadDetail();
|
||||
});
|
||||
onUnload(() => {
|
||||
active = false;
|
||||
controller.abort();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import "../../styles/adaptive-frame-profiles.scss";
|
||||
.message-detail-page {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
flex-direction: column;
|
||||
background: $paper;
|
||||
}
|
||||
.page-header,
|
||||
.page-content {
|
||||
z-index: 1;
|
||||
}
|
||||
.page-content {
|
||||
flex: 1;
|
||||
padding: 18rpx 24rpx 72rpx;
|
||||
}
|
||||
.state-card,
|
||||
.detail-card {
|
||||
box-sizing: border-box;
|
||||
@include adaptive-family-content;
|
||||
}
|
||||
.state-card {
|
||||
min-height: 340rpx;
|
||||
padding: 78rpx 52rpx 50rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.state-card text {
|
||||
display: block;
|
||||
}
|
||||
.state-card text:first-child,
|
||||
.detail-title {
|
||||
color: $ink;
|
||||
font-family: STKaiti, KaiTi, serif;
|
||||
font-size: clamp(19px, 35rpx, 24px);
|
||||
font-weight: 700;
|
||||
}
|
||||
.state-card text:nth-child(2) {
|
||||
margin-top: 18rpx;
|
||||
color: $ink-muted;
|
||||
font-size: clamp(15px, 24rpx, 18px);
|
||||
line-height: 1.65;
|
||||
}
|
||||
.state-card .app-button {
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
.detail-card {
|
||||
padding: 44rpx 38rpx;
|
||||
}
|
||||
.detail-title,
|
||||
.detail-time {
|
||||
display: block;
|
||||
}
|
||||
.detail-time {
|
||||
margin-top: 16rpx;
|
||||
color: $ink-muted;
|
||||
font-size: clamp(15px, 24rpx, 18px);
|
||||
}
|
||||
.detail-content {
|
||||
margin-top: 36rpx;
|
||||
color: $ink;
|
||||
font-size: clamp(16px, 29rpx, 20px);
|
||||
line-height: 1.8;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
.detail-meta {
|
||||
margin-top: 42rpx;
|
||||
padding-top: 24rpx;
|
||||
border-top: 1rpx solid rgba(91, 70, 42, 0.16);
|
||||
}
|
||||
.detail-meta__row {
|
||||
display: flex;
|
||||
gap: 22rpx;
|
||||
padding: 10rpx 0;
|
||||
color: $ink-muted;
|
||||
font-size: clamp(15px, 24rpx, 18px);
|
||||
line-height: 1.5;
|
||||
}
|
||||
.detail-meta__row text:first-child {
|
||||
flex: 0 0 116rpx;
|
||||
}
|
||||
.detail-meta__row text:last-child {
|
||||
flex: 1;
|
||||
color: $ink;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user