fix: 修改index数据来源
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 47s

This commit is contained in:
sexygoat
2026-04-14 10:31:25 +08:00
parent 0b8dd7af00
commit 1a407924de
7 changed files with 216 additions and 54 deletions

View File

@@ -8,7 +8,7 @@
<VoiceCard v-if="!userInfo.isDevice" :voiceStats="voiceStats" :dateRangeText="dateRangeText"
@openDatePicker="openDateRangePicker" />
<TrafficCard :deviceInfo="deviceInfo" :isDevice="userInfo.isDevice" />
<TrafficCard :identifier="currentCardNo" />
<WhitelistCard v-if="!userInfo.isDevice" :whitelistData="whitelistData" @refresh="refreshWhitelist"
@add="showAddWhitelistDialog" @showSms="showSmsCodeDialog" />
@@ -139,7 +139,7 @@
let deviceInfo = reactive({
battery: 100,
connect: 0,
statusStr: '正常',
status: 1,
expireDate: '',
currentIccid: '',
category: '',
@@ -155,11 +155,14 @@
last_online_time: '',
lan_ip: '',
kf_url: '',
mchList: []
mchList: [],
imei: '',
max_clients: 1
});
let isRealName = ref(false);
let alreadyBindPhone = ref(false);
let boundPhone = ref('');
let realNameStatus = ref('');
let wifi_info = reactive({
ssid: '',
@@ -200,15 +203,34 @@
loading.value = true;
try {
const data = await assetApi.getInfo(identifier);
// 基本信息
userInfo.isDevice = data.asset_type === 'device';
currentCardNo.value = data.identifier;
deviceInfo.statusStr = data.status === 1 ? '正常' : '禁用';
deviceInfo.status = data.status;
deviceInfo.imei = data.imei || '';
isRealName.value = data.real_name_status === 1;
realNameStatus.value = data.real_name_status === 1 ? '已实名' : '未实名';
deviceInfo.flowSize = data.package_remain_mb || 0;
deviceInfo.totalBytesCnt = data.package_total_mb || 0;
deviceInfo.currentIccid = data.identifier;
boundPhone.value = data.bound_phone || '';
alreadyBindPhone.value = !!data.bound_phone;
// 流量信息已由 TrafficCard 组件独立获取,这里不再处理
// 当前卡信息
if (data.cards && data.cards.length > 0) {
// 找到当前卡
const currentCard = data.cards.find(card => card.is_current) || data.cards[0];
deviceInfo.currentIccid = currentCard.iccid;
// 卡列表
deviceInfo.mchList = data.cards.map(card => ({
iccidMark: card.iccid,
category: card.slot_position,
is_current: card.is_current
}));
}
// 设备实时信息
if (data.device_realtime) {
const rt = data.device_realtime;
deviceInfo.onlineStatus = rt.online_status === 1 ? '1' : '0';
@@ -217,22 +239,48 @@
deviceInfo.ssidPwd = rt.wifi_password || '';
deviceInfo.lan_ip = rt.lan_ip || '';
deviceInfo.connCnt = rt.client_number || 0;
deviceInfo.max_clients = rt.max_clients || 1;
deviceInfo.run_time = rt.run_time || 0;
deviceInfo.rssi = rt.rssi || '强';
deviceInfo.rssi = calculateSignalStrength(rt.rsrp, rt.rsrq, rt.rssi);
}
if (data.cards && data.cards.length > 0) {
deviceInfo.mchList = data.cards.map(card => ({
iccidMark: card.iccid,
category: card.slot_position
}));
}
// 获取到期时间(从套餐历史中获取)
await loadExpireDate(identifier);
} catch (e) {
console.error('加载资产信息失败', e);
}
loading.value = false;
};
// 计算信号强度
const calculateSignalStrength = (rsrp, rsrq, rssi) => {
// 简单的信号强度计算逻辑
if (!rsrp && !rsrq && !rssi) return '强';
const rsrpNum = parseInt(rsrp) || 0;
if (rsrpNum >= -80) return '强';
if (rsrpNum >= -95) return '中';
return '弱';
};
// 获取到期时间(从生效中的套餐获取)
const loadExpireDate = async (identifier) => {
try {
const historyData = await assetApi.getPackageHistory(identifier, 1, 10, { status: 1 });
if (historyData.items && historyData.items.length > 0) {
// 找到生效中的套餐
const activePackage = historyData.items.find(item => item.status === 1);
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')}`;
}
}
} catch (e) {
console.error('获取到期时间失败', e);
}
};
const modifyWifi = () => {
wifi_info.ssid = deviceInfo.ssidName;
wifi_info.pwd = deviceInfo.ssidPwd;
@@ -460,8 +508,16 @@
});
break;
case 'change-phone':
if (!boundPhone.value) {
uni.showToast({
title: '请先去绑定手机号',
icon: 'none',
duration: 2000
});
return;
}
uni.navigateTo({
url: '/pages/change-phone/change-phone'
url: `/pages/change-phone/change-phone?oldPhone=${boundPhone.value}`
});
break;
case 'device-exchange':