This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<!-- <VoiceCard v-if="!userInfo.isDevice" :voiceStats="voiceStats" :dateRangeText="dateRangeText"
|
||||
@openDatePicker="openDateRangePicker" /> -->
|
||||
|
||||
<TrafficCard :identifier="userStore.state.identifier" />
|
||||
<TrafficCard :assetInfo="assetStore.state.assetInfo" />
|
||||
|
||||
<!-- <WhitelistCard v-if="!userInfo.isDevice" :whitelistData="whitelistData" @refresh="refreshWhitelist"
|
||||
@add="showAddWhitelistDialog" @showSms="showSmsCodeDialog" /> -->
|
||||
@@ -205,6 +205,8 @@
|
||||
let recoverShow = ref(false);
|
||||
let logoutShow = ref(false);
|
||||
let loading = ref(false);
|
||||
let syncing = ref(false);
|
||||
let assetRequestId = 0;
|
||||
|
||||
let userInfo = reactive({
|
||||
isDevice: true,
|
||||
@@ -284,7 +286,6 @@
|
||||
let showSmsCode = ref(false);
|
||||
let smsCodePhone = ref('');
|
||||
let smsCode = ref('');
|
||||
let indexEntryChecking = ref(false);
|
||||
let notificationUnreadCount = ref(0);
|
||||
let notificationPopupShow = ref(false);
|
||||
let notificationItems = ref([]);
|
||||
@@ -309,11 +310,12 @@
|
||||
if (!identifier) return;
|
||||
if (userStore.state.identifier !== identifier) userStore.setIdentifier(identifier);
|
||||
const context = getSessionContext();
|
||||
const requestId = ++assetRequestId;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await assetApi.getInfo(identifier);
|
||||
if (!isCurrentSession(context)) return null;
|
||||
if (!isCurrentSession(context) || requestId !== assetRequestId) return null;
|
||||
|
||||
// 基本信息
|
||||
userInfo.isDevice = data.asset_type === 'device';
|
||||
@@ -338,7 +340,7 @@
|
||||
effectiveRealnamePolicy.value = data.effective_realname_policy || 'none';
|
||||
userStore.setRealNameStatus(data.real_name_status);
|
||||
|
||||
// 流量信息已由 TrafficCard 组件独立获取,这里不再处理
|
||||
// 流量卡片消费同一次 asset/info 快照,支付和有效期变化后一起更新。
|
||||
|
||||
// 当前卡信息
|
||||
if (data.cards && data.cards.length > 0) {
|
||||
@@ -397,7 +399,7 @@
|
||||
console.error('加载资产信息失败', e);
|
||||
return null;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
if (requestId === assetRequestId) loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -415,14 +417,7 @@
|
||||
}
|
||||
if (userStore.state.identifier !== identifier) userStore.setIdentifier(identifier);
|
||||
|
||||
if (indexEntryChecking.value) return;
|
||||
indexEntryChecking.value = true;
|
||||
|
||||
try {
|
||||
await loadAssetInfo();
|
||||
} finally {
|
||||
indexEntryChecking.value = false;
|
||||
}
|
||||
await loadAssetInfo();
|
||||
};
|
||||
|
||||
const onRenewalVisibilityChange = (visible) => {
|
||||
@@ -738,6 +733,7 @@
|
||||
};
|
||||
|
||||
const onSync = async () => {
|
||||
if (syncing.value) return;
|
||||
const identifier = userStore.state.identifier;
|
||||
if (!identifier) {
|
||||
uni.showToast({
|
||||
@@ -747,11 +743,13 @@
|
||||
return;
|
||||
}
|
||||
|
||||
const context = getSessionContext();
|
||||
uni.showModal({
|
||||
title: '确认同步',
|
||||
content: '确定要同步运营商数据吗?',
|
||||
content: '确定要同步运营商数据吗?受理不代表同步或停复机已执行完成,结果以稍后读取的实际状态为准。',
|
||||
success: (res) => {
|
||||
if (!res.confirm) return;
|
||||
if (!res.confirm || syncing.value || !isCurrentSession(context)) return;
|
||||
syncing.value = true;
|
||||
uni.showLoading({
|
||||
title: '同步中...',
|
||||
mask: true
|
||||
@@ -759,17 +757,19 @@
|
||||
|
||||
assetApi.refresh(identifier).then((data) => {
|
||||
uni.hideLoading();
|
||||
if (!isCurrentSession(context)) return;
|
||||
|
||||
if (data.accepted) {
|
||||
if (data?.accepted === true || data?.accepted === 1) {
|
||||
const refreshTypeText = data.refresh_type === 'device' ? '设备' : '卡';
|
||||
uni.showToast({
|
||||
title: `${refreshTypeText}数据同步成功`,
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
title: `${refreshTypeText}同步请求已受理,请稍后查看状态`,
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
|
||||
loadAssetInfo();
|
||||
setTimeout(() => {
|
||||
loadAssetInfo();
|
||||
if (homeActive.value && isCurrentSession(context)) loadAssetInfo();
|
||||
}, 2000);
|
||||
} else {
|
||||
uni.showToast({
|
||||
@@ -779,6 +779,7 @@
|
||||
}
|
||||
}).catch((e) => {
|
||||
uni.hideLoading();
|
||||
if (!isCurrentSession(context)) return;
|
||||
console.error('同步数据失败', e);
|
||||
|
||||
if (e.msg && e.msg.includes('冷却')) {
|
||||
@@ -793,7 +794,7 @@
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
}).finally(() => { syncing.value = false; });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1018,9 +1019,8 @@
|
||||
handleIndexEntry();
|
||||
return;
|
||||
}
|
||||
if (consumePendingPaymentRefresh(PAYMENT_REFRESH_TARGETS.HOME)) {
|
||||
loadAssetInfo();
|
||||
}
|
||||
// 每次返回首页都重新读取实际状态,支付返回不再重复发起两次请求。
|
||||
consumePendingPaymentRefresh(PAYMENT_REFRESH_TARGETS.HOME);
|
||||
loadNotificationUnreadCount();
|
||||
runPopupCandidate();
|
||||
await handleIndexEntry();
|
||||
@@ -1030,6 +1030,7 @@
|
||||
});
|
||||
onHide(() => {
|
||||
homeEntryId++;
|
||||
assetRequestId++;
|
||||
homeActive.value = false;
|
||||
shownExpiryReminder.value = null;
|
||||
notificationPopupShow.value = false;
|
||||
|
||||
Reference in New Issue
Block a user