This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
<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')" />
|
||||
@@ -10,7 +12,7 @@
|
||||
<!-- <VoiceCard v-if="!userInfo.isDevice" :voiceStats="voiceStats" :dateRangeText="dateRangeText"
|
||||
@openDatePicker="openDateRangePicker" /> -->
|
||||
|
||||
<TrafficCard :identifier="currentCardNo" />
|
||||
<TrafficCard :identifier="userStore.state.identifier" />
|
||||
|
||||
<!-- <WhitelistCard v-if="!userInfo.isDevice" :whitelistData="whitelistData" @refresh="refreshWhitelist"
|
||||
@add="showAddWhitelistDialog" @showSms="showSmsCodeDialog" /> -->
|
||||
@@ -18,7 +20,8 @@
|
||||
<WifiCard v-if="userInfo.isDevice" :deviceInfo="deviceInfo" @modify="modifyWifi"
|
||||
@copy-config="copyWifiConfig" />
|
||||
|
||||
<FunctionCard :realNameStatus="realNameStatus" :alreadyBindPhone="alreadyBindPhone"
|
||||
<FunctionCard :realNameStatus="realNameStatus" :assetPhoneBound="userStore.state.assetPhoneBound"
|
||||
:customerPhone="userStore.state.customerPhone"
|
||||
:isDevice="userInfo.isDevice" :walletBalance="deviceInfo.walletBalance" :unreadCount="notificationUnreadCount"
|
||||
@enter="enterDetail" @sync="onSync">
|
||||
<!-- 修改配置弹窗 -->
|
||||
@@ -124,9 +127,10 @@
|
||||
ref,
|
||||
reactive,
|
||||
onMounted,
|
||||
computed
|
||||
computed,
|
||||
watch
|
||||
} from 'vue';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import { onShow, onHide } from '@dcloudio/uni-app';
|
||||
import UserInfoCard from '@/components/UserInfoCard.vue';
|
||||
import DeviceStatusCard from '@/components/DeviceStatusCard.vue';
|
||||
import VoiceCard from '@/components/VoiceCard.vue';
|
||||
@@ -136,6 +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 RenewalPaymentPopup from '@/components/RenewalPaymentPopup.vue';
|
||||
import PopupCandidate from '@/components/PopupCandidate.vue';
|
||||
import {
|
||||
@@ -145,12 +150,33 @@
|
||||
notificationApi
|
||||
} from '@/api/index.js';
|
||||
import {
|
||||
useUserStore
|
||||
useUserStore,
|
||||
useAssetStore
|
||||
} from '@/store/index.js';
|
||||
import { consumePendingPaymentRefresh, PAYMENT_REFRESH_TARGETS } from '@/utils/payment.js';
|
||||
import { getPhoneBindStatus, setPhoneBindStatus } from '@/utils/phone-bind.js';
|
||||
import { getSessionContext, isCurrentSession } from '@/utils/session-context.js';
|
||||
import { getShanghaiDay } from '@/utils/expiry-reminder.js';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const assetStore = useAssetStore();
|
||||
const homeActive = ref(false);
|
||||
const shownExpiryReminder = ref(null);
|
||||
const visibleExpiryReminder = computed(() => {
|
||||
const entry = shownExpiryReminder.value;
|
||||
return homeActive.value && entry && isCurrentSession(entry) && entry.day === getShanghaiDay()
|
||||
? entry.reminder : null;
|
||||
});
|
||||
const showPendingExpiryReminder = () => {
|
||||
const entry = assetStore.state.expiryReminder;
|
||||
if (!homeActive.value || !entry || entry.shown || !isCurrentSession(entry) || entry.day !== getShanghaiDay()) return;
|
||||
shownExpiryReminder.value = { ...entry };
|
||||
assetStore.markExpiryReminderShown();
|
||||
};
|
||||
const closeExpiryReminder = () => {
|
||||
shownExpiryReminder.value = null;
|
||||
assetStore.dismissExpiryReminder();
|
||||
};
|
||||
watch(() => assetStore.state.expiryReminder, showPendingExpiryReminder);
|
||||
|
||||
let showModifyWifi = ref(false);
|
||||
let restartShow = ref(false);
|
||||
@@ -200,8 +226,8 @@
|
||||
});
|
||||
|
||||
let isRealName = ref(false);
|
||||
let alreadyBindPhone = ref(false);
|
||||
let boundPhone = ref('');
|
||||
const boundPhone = computed(() => userStore.state.customerPhone || '');
|
||||
watch(boundPhone, (phone) => { deviceInfo.bound_phone = phone; });
|
||||
let realNameStatus = ref('');
|
||||
let effectiveRealnamePolicy = ref('none');
|
||||
let realnameEntryChecking = ref(false);
|
||||
@@ -259,11 +285,12 @@
|
||||
const loadAssetInfo = async () => {
|
||||
const identifier = userStore.state.identifier;
|
||||
if (!identifier) return;
|
||||
const localBindStatus = getPhoneBindStatus(identifier);
|
||||
const context = getSessionContext();
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await assetApi.getInfo(identifier);
|
||||
if (!isCurrentSession(context)) return null;
|
||||
|
||||
// 基本信息
|
||||
userInfo.isDevice = data.asset_type === 'device';
|
||||
@@ -272,9 +299,7 @@
|
||||
deviceInfo.status = data.status;
|
||||
deviceInfo.imei = data.imei || '-';
|
||||
deviceInfo.asset_type = data.asset_type || 'device';
|
||||
const apiBoundPhone = data.bound_phone || '';
|
||||
const effectiveBoundPhone = localBindStatus?.phone || apiBoundPhone || '';
|
||||
deviceInfo.bound_phone = effectiveBoundPhone;
|
||||
deviceInfo.bound_phone = userStore.state.customerPhone || '';
|
||||
deviceInfo.packageName = data.current_package || '-';
|
||||
deviceInfo.currentPackageId = Number(data.current_package_id || 0);
|
||||
deviceInfo.renewalPrice = data.renewal_price ?? null;
|
||||
@@ -289,11 +314,6 @@
|
||||
realNameStatus.value = isRealName.value ? '已实名' : '未实名';
|
||||
effectiveRealnamePolicy.value = data.effective_realname_policy || 'none';
|
||||
userStore.setRealNameStatus(data.real_name_status);
|
||||
boundPhone.value = effectiveBoundPhone;
|
||||
alreadyBindPhone.value = !!(apiBoundPhone || localBindStatus?.bound);
|
||||
if (apiBoundPhone && (!localBindStatus || apiBoundPhone === localBindStatus.phone)) {
|
||||
setPhoneBindStatus(identifier, apiBoundPhone);
|
||||
}
|
||||
|
||||
// 流量信息已由 TrafficCard 组件独立获取,这里不再处理
|
||||
|
||||
@@ -539,6 +559,7 @@
|
||||
recoverShow.value = false;
|
||||
};
|
||||
const YesLogout = () => {
|
||||
userStore.clearUser();
|
||||
uni.clearStorageSync();
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
@@ -820,7 +841,7 @@
|
||||
return;
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: `/pages/change-phone/change-phone?oldPhone=${boundPhone.value}`
|
||||
url: '/pages/change-phone/change-phone'
|
||||
});
|
||||
break;
|
||||
case 'device-exchange':
|
||||
@@ -849,8 +870,10 @@
|
||||
};
|
||||
|
||||
const loadNotificationUnreadCount = async () => {
|
||||
const context = getSessionContext();
|
||||
try {
|
||||
const data = await notificationApi.getUnreadCount();
|
||||
if (!isCurrentSession(context)) return;
|
||||
notificationUnreadCount.value = Number(data?.count || 0);
|
||||
} catch (error) {
|
||||
console.error('加载通知未读数失败', error);
|
||||
@@ -860,8 +883,10 @@
|
||||
const markNotificationRead = async (item) => {
|
||||
if (!item || item.is_read || notificationReadPending.has(item.id)) return;
|
||||
notificationReadPending.add(item.id);
|
||||
const context = getSessionContext();
|
||||
try {
|
||||
await notificationApi.markRead(item.id);
|
||||
if (!isCurrentSession(context)) return;
|
||||
item.is_read = true;
|
||||
item.read_at = new Date().toISOString();
|
||||
notificationUnreadCount.value = Math.max(notificationUnreadCount.value - 1, 0);
|
||||
@@ -873,10 +898,12 @@
|
||||
};
|
||||
|
||||
const loadUnreadNotifications = async () => {
|
||||
const context = getSessionContext();
|
||||
try {
|
||||
const data = await notificationApi.getList(1, 50, false);
|
||||
if (!homeActive.value || !isCurrentSession(context)) return;
|
||||
const items = (data?.items || [])
|
||||
.filter(item => !item.is_read);
|
||||
.filter(item => !item.is_read && item.category !== 'expiry');
|
||||
if (!items.length) return;
|
||||
|
||||
notificationItems.value = items;
|
||||
@@ -923,6 +950,13 @@
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
homeActive.value = true;
|
||||
shownExpiryReminder.value = null;
|
||||
showPendingExpiryReminder();
|
||||
if (!getSessionContext().token) {
|
||||
handleIndexEntry();
|
||||
return;
|
||||
}
|
||||
if (consumePendingPaymentRefresh(PAYMENT_REFRESH_TARGETS.HOME)) {
|
||||
loadAssetInfo();
|
||||
}
|
||||
@@ -930,6 +964,17 @@
|
||||
loadNotificationUnreadCount();
|
||||
runPopupCandidate();
|
||||
});
|
||||
onHide(() => {
|
||||
homeActive.value = false;
|
||||
shownExpiryReminder.value = null;
|
||||
notificationPopupShow.value = false;
|
||||
});
|
||||
watch(() => [userStore.state.token, userStore.state.identifier], () => {
|
||||
shownExpiryReminder.value = null;
|
||||
notificationItems.value = [];
|
||||
notificationUnreadCount.value = 0;
|
||||
notificationPopupShow.value = false;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user