fix: 修改index数据来源
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 44s
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 44s
This commit is contained in:
@@ -47,6 +47,8 @@
|
|||||||
identifier: { type: String, default: '' }
|
identifier: { type: String, default: '' }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['packageLoaded']);
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
// 流量数据
|
// 流量数据
|
||||||
@@ -117,11 +119,15 @@
|
|||||||
totalMB.value = activePackage.data_limit_mb || 0;
|
totalMB.value = activePackage.data_limit_mb || 0;
|
||||||
remainMB.value = totalMB.value - usedMB.value;
|
remainMB.value = totalMB.value - usedMB.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 将套餐信息(包括到期时间)传递给父组件
|
||||||
|
emit('packageLoaded', activePackage);
|
||||||
} else {
|
} else {
|
||||||
// 没有生效中的套餐
|
// 没有生效中的套餐
|
||||||
usedMB.value = 0;
|
usedMB.value = 0;
|
||||||
totalMB.value = 0;
|
totalMB.value = 0;
|
||||||
remainMB.value = 0;
|
remainMB.value = 0;
|
||||||
|
emit('packageLoaded', null);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('加载套餐流量数据失败', e);
|
console.error('加载套餐流量数据失败', e);
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, onMounted } from 'vue';
|
import { ref, reactive, onMounted } from 'vue';
|
||||||
import { assetApi, realnameApi } from '@/api/index.js';
|
import { deviceApi, realnameApi } from '@/api/index.js';
|
||||||
import { useUserStore } from '@/store/index.js';
|
import { useUserStore } from '@/store/index.js';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -55,11 +55,11 @@
|
|||||||
|
|
||||||
const loadCards = async () => {
|
const loadCards = async () => {
|
||||||
try {
|
try {
|
||||||
const data = await assetApi.getInfo(userStore.state.identifier);
|
const data = await deviceApi.getCards(userStore.state.identifier);
|
||||||
if (data.cards && data.cards.length > 0) {
|
if (data.cards && data.cards.length > 0) {
|
||||||
list.splice(0, list.length, ...data.cards.map(card => ({
|
list.splice(0, list.length, ...data.cards.map(card => ({
|
||||||
iccid: card.iccid,
|
iccid: card.iccid,
|
||||||
category: card.carrier_name.includes('电信') ? '124' : card.carrier_name.includes('联通') ? '125' : '126',
|
category: getCarrierCategory(card.carrier_name),
|
||||||
isRealName: card.real_name_status === 1
|
isRealName: card.real_name_status === 1
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
@@ -68,6 +68,14 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getCarrierCategory = (carrierName) => {
|
||||||
|
if (!carrierName) return '126';
|
||||||
|
if (carrierName.includes('电信')) return '124';
|
||||||
|
if (carrierName.includes('联通')) return '125';
|
||||||
|
if (carrierName.includes('移动')) return '126';
|
||||||
|
return '126';
|
||||||
|
};
|
||||||
|
|
||||||
const toReal = async (card) => {
|
const toReal = async (card) => {
|
||||||
currentCard.value = card;
|
currentCard.value = card;
|
||||||
currentModalIccid.value = card.iccid;
|
currentModalIccid.value = card.iccid;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<VoiceCard v-if="!userInfo.isDevice" :voiceStats="voiceStats" :dateRangeText="dateRangeText"
|
<VoiceCard v-if="!userInfo.isDevice" :voiceStats="voiceStats" :dateRangeText="dateRangeText"
|
||||||
@openDatePicker="openDateRangePicker" />
|
@openDatePicker="openDateRangePicker" />
|
||||||
|
|
||||||
<TrafficCard :identifier="currentCardNo" />
|
<TrafficCard :identifier="currentCardNo" @packageLoaded="handlePackageLoaded" />
|
||||||
|
|
||||||
<WhitelistCard v-if="!userInfo.isDevice" :whitelistData="whitelistData" @refresh="refreshWhitelist"
|
<WhitelistCard v-if="!userInfo.isDevice" :whitelistData="whitelistData" @refresh="refreshWhitelist"
|
||||||
@add="showAddWhitelistDialog" @showSms="showSmsCodeDialog" />
|
@add="showAddWhitelistDialog" @showSms="showSmsCodeDialog" />
|
||||||
@@ -120,8 +120,13 @@
|
|||||||
import WifiCard from '@/components/WifiCard.vue';
|
import WifiCard from '@/components/WifiCard.vue';
|
||||||
import FunctionCard from '@/components/FunctionCard.vue';
|
import FunctionCard from '@/components/FunctionCard.vue';
|
||||||
import FloatingButton from '@/components/FloatingButton.vue';
|
import FloatingButton from '@/components/FloatingButton.vue';
|
||||||
import { assetApi, deviceApi } from '@/api/index.js';
|
import {
|
||||||
import { useUserStore } from '@/store/index.js';
|
assetApi,
|
||||||
|
deviceApi
|
||||||
|
} from '@/api/index.js';
|
||||||
|
import {
|
||||||
|
useUserStore
|
||||||
|
} from '@/store/index.js';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
@@ -137,26 +142,26 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
let deviceInfo = reactive({
|
let deviceInfo = reactive({
|
||||||
battery: 100,
|
battery: 0,
|
||||||
connect: 0,
|
connect: 0,
|
||||||
status: 1,
|
status: 1,
|
||||||
expireDate: '',
|
expireDate: '-',
|
||||||
currentIccid: '',
|
currentIccid: '-',
|
||||||
category: '',
|
category: '-',
|
||||||
phone: '',
|
phone: '-',
|
||||||
flowSize: 0,
|
flowSize: 0,
|
||||||
totalBytesCnt: 0,
|
totalBytesCnt: 0,
|
||||||
ssidName: '',
|
ssidName: '-',
|
||||||
ssidPwd: '',
|
ssidPwd: '-',
|
||||||
rssi: '强',
|
rssi: '-',
|
||||||
onlineStatus: '0',
|
onlineStatus: '0',
|
||||||
connCnt: 0,
|
connCnt: 0,
|
||||||
run_time: 0,
|
run_time: 0,
|
||||||
last_online_time: '',
|
last_online_time: '-',
|
||||||
lan_ip: '',
|
lan_ip: '-',
|
||||||
kf_url: '',
|
kf_url: '-',
|
||||||
mchList: [],
|
mchList: [],
|
||||||
imei: '',
|
imei: '-',
|
||||||
max_clients: 1
|
max_clients: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -206,9 +211,9 @@
|
|||||||
|
|
||||||
// 基本信息
|
// 基本信息
|
||||||
userInfo.isDevice = data.asset_type === 'device';
|
userInfo.isDevice = data.asset_type === 'device';
|
||||||
currentCardNo.value = data.identifier;
|
currentCardNo.value = data.identifier || '-';
|
||||||
deviceInfo.status = data.status;
|
deviceInfo.status = data.status || 1;
|
||||||
deviceInfo.imei = data.imei || '';
|
deviceInfo.imei = data.imei || '-';
|
||||||
isRealName.value = data.real_name_status === 1;
|
isRealName.value = data.real_name_status === 1;
|
||||||
realNameStatus.value = data.real_name_status === 1 ? '已实名' : '未实名';
|
realNameStatus.value = data.real_name_status === 1 ? '已实名' : '未实名';
|
||||||
boundPhone.value = data.bound_phone || '';
|
boundPhone.value = data.bound_phone || '';
|
||||||
@@ -220,32 +225,45 @@
|
|||||||
if (data.cards && data.cards.length > 0) {
|
if (data.cards && data.cards.length > 0) {
|
||||||
// 找到当前卡
|
// 找到当前卡
|
||||||
const currentCard = data.cards.find(card => card.is_current) || data.cards[0];
|
const currentCard = data.cards.find(card => card.is_current) || data.cards[0];
|
||||||
deviceInfo.currentIccid = currentCard.iccid;
|
deviceInfo.currentIccid = currentCard.iccid || '-';
|
||||||
|
|
||||||
// 卡列表
|
// 卡列表
|
||||||
deviceInfo.mchList = data.cards.map(card => ({
|
deviceInfo.mchList = data.cards.map(card => ({
|
||||||
iccidMark: card.iccid,
|
iccidMark: card.iccid || '-',
|
||||||
category: card.slot_position,
|
category: card.slot_position,
|
||||||
is_current: card.is_current
|
is_current: card.is_current
|
||||||
}));
|
}));
|
||||||
|
} else {
|
||||||
|
deviceInfo.currentIccid = '-';
|
||||||
|
deviceInfo.mchList = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设备实时信息
|
// 设备实时信息
|
||||||
if (data.device_realtime) {
|
if (data.device_realtime) {
|
||||||
const rt = data.device_realtime;
|
const rt = data.device_realtime;
|
||||||
deviceInfo.onlineStatus = rt.online_status === 1 ? '1' : '0';
|
deviceInfo.onlineStatus = rt.online_status === 1 ? '1' : '0';
|
||||||
deviceInfo.battery = rt.battery_level || 100;
|
deviceInfo.battery = rt.battery_level ?? 0;
|
||||||
deviceInfo.ssidName = rt.ssid || '';
|
deviceInfo.ssidName = rt.ssid || '-';
|
||||||
deviceInfo.ssidPwd = rt.wifi_password || '';
|
deviceInfo.ssidPwd = rt.wifi_password || '-';
|
||||||
deviceInfo.lan_ip = rt.lan_ip || '';
|
deviceInfo.lan_ip = rt.lan_ip || '-';
|
||||||
deviceInfo.connCnt = rt.client_number || 0;
|
deviceInfo.connCnt = rt.client_number ?? 0;
|
||||||
deviceInfo.max_clients = rt.max_clients || 1;
|
deviceInfo.max_clients = rt.max_clients ?? 1;
|
||||||
deviceInfo.run_time = rt.run_time || 0;
|
deviceInfo.run_time = rt.run_time || 0;
|
||||||
deviceInfo.rssi = calculateSignalStrength(rt.rsrp, rt.rsrq, rt.rssi);
|
deviceInfo.rssi = calculateSignalStrength(rt.rsrp, rt.rsrq, rt.rssi);
|
||||||
|
} else {
|
||||||
|
// 没有实时信息时设置默认值
|
||||||
|
deviceInfo.onlineStatus = '0';
|
||||||
|
deviceInfo.battery = 0;
|
||||||
|
deviceInfo.ssidName = '-';
|
||||||
|
deviceInfo.ssidPwd = '-';
|
||||||
|
deviceInfo.lan_ip = '-';
|
||||||
|
deviceInfo.connCnt = 0;
|
||||||
|
deviceInfo.max_clients = 1;
|
||||||
|
deviceInfo.run_time = 0;
|
||||||
|
deviceInfo.rssi = '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取到期时间(从套餐历史中获取)
|
// 到期时间由 TrafficCard 组件获取套餐信息时一并返回
|
||||||
await loadExpireDate(identifier);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('加载资产信息失败', e);
|
console.error('加载资产信息失败', e);
|
||||||
}
|
}
|
||||||
@@ -255,29 +273,24 @@
|
|||||||
// 计算信号强度
|
// 计算信号强度
|
||||||
const calculateSignalStrength = (rsrp, rsrq, rssi) => {
|
const calculateSignalStrength = (rsrp, rsrq, rssi) => {
|
||||||
// 简单的信号强度计算逻辑
|
// 简单的信号强度计算逻辑
|
||||||
if (!rsrp && !rsrq && !rssi) return '强';
|
if (!rsrp && !rsrq && !rssi) return '-';
|
||||||
|
|
||||||
|
const rsrpNum = parseInt(rsrp);
|
||||||
|
if (isNaN(rsrpNum)) return '-';
|
||||||
|
|
||||||
const rsrpNum = parseInt(rsrp) || 0;
|
|
||||||
if (rsrpNum >= -80) return '强';
|
if (rsrpNum >= -80) return '强';
|
||||||
if (rsrpNum >= -95) return '中';
|
if (rsrpNum >= -95) return '中';
|
||||||
return '弱';
|
return '弱';
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取到期时间(从生效中的套餐获取)
|
// 处理套餐加载完成事件(从 TrafficCard 组件传递过来)
|
||||||
const loadExpireDate = async (identifier) => {
|
const handlePackageLoaded = (activePackage) => {
|
||||||
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) {
|
if (activePackage && activePackage.expires_at) {
|
||||||
// 格式化日期
|
// 格式化到期时间
|
||||||
const date = new Date(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')}`;
|
deviceInfo.expireDate = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||||
}
|
} else {
|
||||||
}
|
deviceInfo.expireDate = '-';
|
||||||
} catch (e) {
|
|
||||||
console.error('获取到期时间失败', e);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -297,7 +310,10 @@
|
|||||||
);
|
);
|
||||||
deviceInfo.ssidName = wifi_info.ssid;
|
deviceInfo.ssidName = wifi_info.ssid;
|
||||||
deviceInfo.ssidPwd = wifi_info.pwd;
|
deviceInfo.ssidPwd = wifi_info.pwd;
|
||||||
uni.showToast({ title: '修改成功', icon: 'success' });
|
uni.showToast({
|
||||||
|
title: '修改成功',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('修改WiFi失败', e);
|
console.error('修改WiFi失败', e);
|
||||||
}
|
}
|
||||||
@@ -308,6 +324,7 @@
|
|||||||
title: '正在跳转客服',
|
title: '正在跳转客服',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
});
|
});
|
||||||
|
|
||||||
const enterBack = () => uni.showToast({
|
const enterBack = () => uni.showToast({
|
||||||
title: '正在跳转后台',
|
title: '正在跳转后台',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@@ -316,7 +333,10 @@
|
|||||||
const YesRestart = async () => {
|
const YesRestart = async () => {
|
||||||
try {
|
try {
|
||||||
await deviceApi.reboot(userStore.state.identifier);
|
await deviceApi.reboot(userStore.state.identifier);
|
||||||
uni.showToast({ title: '重启指令已发送', icon: 'success' });
|
uni.showToast({
|
||||||
|
title: '重启指令已发送',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('重启设备失败', e);
|
console.error('重启设备失败', e);
|
||||||
}
|
}
|
||||||
@@ -336,7 +356,10 @@
|
|||||||
const YesRecover = async () => {
|
const YesRecover = async () => {
|
||||||
try {
|
try {
|
||||||
await deviceApi.factoryReset(userStore.state.identifier);
|
await deviceApi.factoryReset(userStore.state.identifier);
|
||||||
uni.showToast({ title: '恢复出厂设置指令已发送', icon: 'success' });
|
uni.showToast({
|
||||||
|
title: '恢复出厂设置指令已发送',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('恢复出厂设置失败', e);
|
console.error('恢复出厂设置失败', e);
|
||||||
}
|
}
|
||||||
@@ -474,7 +497,10 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const onSync = () => {
|
const onSync = () => {
|
||||||
uni.showToast({ title: '同步成功', icon: 'success' });
|
uni.showToast({
|
||||||
|
title: '同步成功',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const enterDetail = (name) => {
|
const enterDetail = (name) => {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, ref, onMounted } from 'vue';
|
import { reactive, ref, onMounted } from 'vue';
|
||||||
import { deviceApi, assetApi } from '@/api/index.js';
|
import { deviceApi } from '@/api/index.js';
|
||||||
import { useUserStore } from '@/store/index.js';
|
import { useUserStore } from '@/store/index.js';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -56,11 +56,15 @@
|
|||||||
|
|
||||||
const loadCards = async () => {
|
const loadCards = async () => {
|
||||||
try {
|
try {
|
||||||
const data = await assetApi.getInfo(userStore.state.identifier);
|
const data = await deviceApi.getCards(userStore.state.identifier);
|
||||||
if (data.cards && data.cards.length > 0) {
|
if (data.cards && data.cards.length > 0) {
|
||||||
mchList.splice(0, mchList.length, ...data.cards.map(card => ({
|
mchList.splice(0, mchList.length, ...data.cards.map(card => ({
|
||||||
...card,
|
iccid: card.iccid,
|
||||||
category: card.carrier_name.includes('电信') ? '124' : card.carrier_name.includes('联通') ? '125' : '126'
|
carrier_name: card.carrier_name,
|
||||||
|
is_current: card.is_active,
|
||||||
|
real_name_status: card.real_name_status,
|
||||||
|
slot_position: card.slot_position,
|
||||||
|
category: getCarrierCategory(card.carrier_name)
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -68,6 +72,14 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getCarrierCategory = (carrierName) => {
|
||||||
|
if (!carrierName) return '126';
|
||||||
|
if (carrierName.includes('电信')) return '124';
|
||||||
|
if (carrierName.includes('联通')) return '125';
|
||||||
|
if (carrierName.includes('移动')) return '126';
|
||||||
|
return '126';
|
||||||
|
};
|
||||||
|
|
||||||
const switchOperator = async (item) => {
|
const switchOperator = async (item) => {
|
||||||
switching.value = true;
|
switching.value = true;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user