This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<UserInfoCard :currentCardNo="currentCardNo" :deviceInfo="deviceInfo" :onlineStatus="onlineStatus"
|
||||
:isDevice="userInfo.isDevice" :networkStatus="deviceInfo.network_status" />
|
||||
:isDevice="userInfo.isDevice" :networkStatus="deviceInfo.network_status"
|
||||
:isExpiring="deviceInfo.isExpiring" :expiryDays="deviceInfo.expiryDays" />
|
||||
|
||||
<DeviceStatusCard v-if="userInfo.isDevice" :deviceInfo="deviceInfo" :isRealName="isRealName"
|
||||
:isDevice="userInfo.isDevice" @authentication="enterDetail('authentication')" />
|
||||
@@ -156,6 +157,9 @@
|
||||
status: 1,
|
||||
packageName: '-',
|
||||
expireDate: '-',
|
||||
isExpiring: false,
|
||||
expiryDays: null,
|
||||
expiryEstimateStatus: 'none',
|
||||
walletBalance: 0,
|
||||
iccid: '-',
|
||||
currentIccid: '-',
|
||||
@@ -250,12 +254,16 @@
|
||||
deviceInfo.asset_type = data.asset_type || 'device';
|
||||
deviceInfo.bound_phone = data.bound_phone || '';
|
||||
deviceInfo.packageName = data.current_package || '-';
|
||||
deviceInfo.expireDate = formatDate(data.current_package_expires_at);
|
||||
deviceInfo.expireDate = formatDate(data.estimated_final_expires_at);
|
||||
deviceInfo.isExpiring = data.is_expiring === true;
|
||||
deviceInfo.expiryDays = data.days_until_final_expiry ?? null;
|
||||
deviceInfo.expiryEstimateStatus = data.expiry_estimate_status || 'none';
|
||||
deviceInfo.iccid = data.iccid || '-';
|
||||
deviceInfo.walletBalance = data.wallet_balance ?? 0;
|
||||
const currentCard = resolveCurrentCard(data.cards || []);
|
||||
isRealName.value = !!currentCard?.real_name_at || currentCard?.real_name_status === 1 || data.real_name_status === 1;
|
||||
isRealName.value = Number(data.real_name_status) === 1;
|
||||
realNameStatus.value = isRealName.value ? '已实名' : '未实名';
|
||||
userStore.setRealNameStatus(data.real_name_status);
|
||||
boundPhone.value = data.bound_phone || '';
|
||||
alreadyBindPhone.value = !!data.bound_phone;
|
||||
|
||||
@@ -312,7 +320,7 @@
|
||||
deviceInfo.signal_bad_reason = '';
|
||||
}
|
||||
|
||||
// 到期时间由 TrafficCard 组件获取套餐信息时一并返回
|
||||
// 最终到期时间和临期状态均以后端 asset/info 返回值为准。
|
||||
return data;
|
||||
} catch (e) {
|
||||
console.error('加载资产信息失败', e);
|
||||
@@ -342,18 +350,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
// 处理套餐加载完成事件(从 TrafficCard 组件传递过来)
|
||||
const handlePackageLoaded = (activePackage) => {
|
||||
if (activePackage && activePackage.expires_at) {
|
||||
// 格式化到期时间
|
||||
const date = new Date(activePackage.expires_at);
|
||||
deviceInfo.expireDate =
|
||||
`${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||
} else {
|
||||
deviceInfo.expireDate = '-';
|
||||
}
|
||||
};
|
||||
|
||||
const modifyWifi = () => {
|
||||
wifi_info.ssid = deviceInfo.ssidName;
|
||||
wifi_info.pwd = deviceInfo.ssidPwd;
|
||||
@@ -810,7 +806,9 @@
|
||||
const loadUnreadNotifications = async () => {
|
||||
try {
|
||||
const data = await notificationApi.getList(1, 50, false);
|
||||
const items = (data?.items || []).filter(item => !item.is_read);
|
||||
const items = (data?.items || [])
|
||||
.filter(item => !item.is_read)
|
||||
.sort((a, b) => getNotificationPriority(b) - getNotificationPriority(a));
|
||||
if (!items.length) return;
|
||||
|
||||
notificationItems.value = items;
|
||||
@@ -823,6 +821,17 @@
|
||||
}
|
||||
};
|
||||
|
||||
const getNotificationPriority = (item) => {
|
||||
const severityRank = { info: 10, warning: 20, error: 30, critical: 40 };
|
||||
const remainingDays = Number(item?.days_until_expiry ?? item?.days_remaining ?? item?.remaining_days);
|
||||
const expiryLevel = String(item?.expiry_level || '').toLowerCase();
|
||||
if (item?.category === 'expiry' && ((Number.isFinite(remainingDays) && remainingDays >= 0 && remainingDays <= 3) ||
|
||||
['0_3', '0-3', '0~3', 'critical'].includes(expiryLevel))) {
|
||||
return 100;
|
||||
}
|
||||
return severityRank[item?.severity] || 0;
|
||||
};
|
||||
|
||||
const onNotificationChange = (event) => {
|
||||
const index = Number(event?.detail?.current ?? event?.current ?? 0);
|
||||
notificationPopupCurrent.value = index;
|
||||
|
||||
Reference in New Issue
Block a user