fix: some
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 2m16s

This commit is contained in:
luo
2026-10-13 18:02:13 +08:00
parent 97dec4dc65
commit 697ff9c33c
6 changed files with 263 additions and 54 deletions

View File

@@ -3,8 +3,6 @@
<UserInfoCard :currentCardNo="currentCardNo" :deviceInfo="deviceInfo" :onlineStatus="onlineStatus"
:isDevice="userInfo.isDevice" :networkStatus="deviceInfo.network_status"
:isExpiring="deviceInfo.isExpiring" :expiryDays="deviceInfo.expiryDays" @renew="startHomepageRenewal" />
<ExpiryReminderBanner v-if="visibleExpiryReminder" :reminder="visibleExpiryReminder"
@close="closeExpiryReminder" />
<DeviceStatusCard v-if="userInfo.isDevice" :deviceInfo="deviceInfo" :isRealName="isRealName"
:isDevice="userInfo.isDevice" @authentication="enterDetail('authentication')" />
@@ -99,6 +97,8 @@
</FunctionCard>
<view class="bottom-spacer"></view>
<ExpiryReminderPopup v-if="visibleExpiryReminder" :reminder="visibleExpiryReminder"
@close="closeExpiryReminder" />
<NotificationPopup :show="notificationPopupShow" :items="notificationItems"
:current="notificationPopupCurrent" @change="onNotificationChange" @close="closeNotificationPopup"
@@ -140,7 +140,7 @@
import FunctionCard from '@/components/FunctionCard.vue';
import FloatingButton from '@/components/FloatingButton.vue';
import NotificationPopup from '@/components/NotificationPopup.vue';
import ExpiryReminderBanner from '@/components/ExpiryReminderBanner.vue';
import ExpiryReminderPopup from '@/components/ExpiryReminderPopup.vue';
import RenewalPaymentPopup from '@/components/RenewalPaymentPopup.vue';
import PopupCandidate from '@/components/PopupCandidate.vue';
import {
@@ -161,6 +161,10 @@
const assetStore = useAssetStore();
const homeActive = ref(false);
const shownExpiryReminder = ref(null);
const awaitingHomeReminders = ref(false);
let notificationFallbackPending = false;
let notificationQueued = false;
let homeEntryId = 0;
const visibleExpiryReminder = computed(() => {
const entry = shownExpiryReminder.value;
return homeActive.value && entry && isCurrentSession(entry) && entry.day === getShanghaiDay()
@@ -168,15 +172,31 @@
});
const showPendingExpiryReminder = () => {
const entry = assetStore.state.expiryReminder;
if (!homeActive.value || !entry || entry.shown || !isCurrentSession(entry) || entry.day !== getShanghaiDay()) return;
if (!homeActive.value || awaitingHomeReminders.value || popupCandidateShow.value || notificationPopupShow.value ||
visibleExpiryReminder.value || !entry || entry.shown || !isCurrentSession(entry) || entry.day !== getShanghaiDay()) return;
shownExpiryReminder.value = { ...entry };
assetStore.markExpiryReminderShown();
};
const closeExpiryReminder = () => {
shownExpiryReminder.value = null;
assetStore.dismissExpiryReminder();
advanceHomePopupQueue();
};
watch(() => assetStore.state.expiryReminder, showPendingExpiryReminder);
const advanceHomePopupQueue = () => {
if (!homeActive.value || awaitingHomeReminders.value || popupCandidateShow.value ||
visibleExpiryReminder.value || notificationPopupShow.value) return;
showPendingExpiryReminder();
if (visibleExpiryReminder.value) return;
if (notificationQueued) {
notificationQueued = false;
notificationPopupShow.value = true;
markNotificationRead(notificationItems.value[0]);
} else if (notificationFallbackPending) {
notificationFallbackPending = false;
loadUnreadNotifications();
}
};
watch(() => assetStore.state.expiryReminder, advanceHomePopupQueue);
let showModifyWifi = ref(false);
let restartShow = ref(false);
@@ -899,18 +919,18 @@
const loadUnreadNotifications = async () => {
const context = getSessionContext();
const entryId = homeEntryId;
try {
const data = await notificationApi.getList(1, 50, false);
if (!homeActive.value || !isCurrentSession(context)) return;
if (!homeActive.value || entryId !== homeEntryId || !isCurrentSession(context)) return;
const items = (data?.items || [])
.filter(item => !item.is_read && item.category !== 'expiry');
if (!items.length) return;
notificationItems.value = items;
notificationPopupCurrent.value = 0;
notificationPopupShow.value = true;
// 弹窗打开即视为用户已看到第一条通知。
markNotificationRead(items[0]);
notificationQueued = true;
advanceHomePopupQueue();
} catch (error) {
console.error('加载首页未读通知失败', error);
}
@@ -931,6 +951,7 @@
const closeNotificationPopup = () => {
notificationPopupShow.value = false;
advanceHomePopupQueue();
};
const runPopupCandidate = () => {
@@ -938,10 +959,12 @@
};
const onPopupCandidateClose = (reason) => {
if (!homeActive.value) return;
popupCandidateShow.value = false;
if (reason === 'empty' || reason === 'invisible') {
loadUnreadNotifications();
notificationFallbackPending = true;
}
advanceHomePopupQueue();
loadNotificationUnreadCount();
};
@@ -949,31 +972,44 @@
initCurrentMonth();
});
onShow(() => {
onShow(async () => {
const entryId = ++homeEntryId;
homeActive.value = true;
shownExpiryReminder.value = null;
showPendingExpiryReminder();
awaitingHomeReminders.value = true;
notificationFallbackPending = false;
notificationQueued = false;
if (!getSessionContext().token) {
awaitingHomeReminders.value = false;
handleIndexEntry();
return;
}
if (consumePendingPaymentRefresh(PAYMENT_REFRESH_TARGETS.HOME)) {
loadAssetInfo();
}
handleIndexEntry();
loadNotificationUnreadCount();
runPopupCandidate();
await handleIndexEntry();
if (!homeActive.value || entryId !== homeEntryId) return;
awaitingHomeReminders.value = false;
advanceHomePopupQueue();
});
onHide(() => {
homeEntryId++;
homeActive.value = false;
shownExpiryReminder.value = null;
notificationPopupShow.value = false;
popupCandidateShow.value = false;
notificationQueued = false;
notificationFallbackPending = false;
});
watch(() => [userStore.state.token, userStore.state.identifier], () => {
shownExpiryReminder.value = null;
notificationItems.value = [];
notificationUnreadCount.value = 0;
notificationPopupShow.value = false;
notificationQueued = false;
notificationFallbackPending = false;
});
</script>

View File

@@ -17,11 +17,11 @@
</view>
<view v-else class="notification-list">
<view v-for="item in notifications" :key="item.id" class="card notification-card"
:class="{ unread: !item.is_read }" @tap="markItemRead(item)">
<view v-for="item in notifications" :key="item.id" class="card notification-card" @tap="markItemRead(item)">
<view class="notification-header flex-row-sb">
<view class="notification-title">{{ item.title || '业务通知' }}</view>
<view v-if="!item.is_read" class="unread-dot"></view>
<button class="read-status" :class="item.is_read ? 'status-read' : 'status-unread'"
@tap.stop="markItemRead(item)">{{ item.is_read ? '已读' : '未读' }}</button>
</view>
<view class="notification-body">{{ item.body || '-' }}</view>
<view class="notification-footer flex-row-sb">
@@ -171,11 +171,13 @@
.toolbar { margin-bottom: var(--space-md); }
.summary { color: var(--text-tertiary); font-size: 24rpx; }
.mark-all { margin: 0; padding: 0 24rpx; height: 64rpx; line-height: 64rpx; font-size: 24rpx; }
.notification-card { margin-bottom: var(--space-md); border-left: 6rpx solid transparent; }
.notification-card.unread { border-left-color: var(--primary); }
.notification-header { margin-bottom: var(--space-sm); }
.notification-card { margin-bottom: var(--space-md); }
.notification-header { margin-bottom: var(--space-sm); gap: 20rpx; align-items: flex-start; }
.notification-title { color: var(--text-primary); font-size: 30rpx; font-weight: 600; flex: 1; }
.unread-dot { width: 14rpx; height: 14rpx; margin-left: 16rpx; border-radius: 50%; background: var(--primary); }
.read-status { flex-shrink: 0; margin: 0; padding: 6rpx 18rpx; border-radius: 999rpx; font-size: 22rpx; font-weight: 500; line-height: 1.5; }
.read-status::after { border: none; }
.status-unread { color: var(--primary-dark); background: var(--success-light); }
.status-read { color: var(--text-tertiary); background: var(--gray-100); }
.notification-body { color: var(--text-secondary); font-size: 26rpx; line-height: 1.6; white-space: pre-wrap; }
.notification-footer { margin-top: var(--space-md); }
.notification-meta, .notification-time { color: var(--text-tertiary); font-size: 22rpx; }