This commit is contained in:
@@ -20,15 +20,12 @@
|
|||||||
<view class="subtitle" v-if="isDevice">IMEI:{{ deviceInfo.imei || '-' }}</view>
|
<view class="subtitle" v-if="isDevice">IMEI:{{ deviceInfo.imei || '-' }}</view>
|
||||||
<view class="subtitle" v-else>手机号:{{ deviceInfo.bound_phone || '-' }}</view>
|
<view class="subtitle" v-else>手机号:{{ deviceInfo.bound_phone || '-' }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="info-values flex-row-g20">
|
|
||||||
<view class="tag-apple tag-primary">{{ statusText }}</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="device-metrics flex-row-sb mt-md">
|
<view class="device-metrics flex-row-sb mt-md">
|
||||||
<view class="metric-item flex-col-center">
|
<view class="metric-item flex-col-center">
|
||||||
<view class="caption mb-xs">信号强度</view>
|
<view class="caption mb-xs">信号强度</view>
|
||||||
<view class="metric-value">{{ getSignalText(deviceInfo.rssi) }}</view>
|
<view class="metric-value">{{ getSignalText(deviceInfo) }}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="metric-item flex-col-center">
|
<view class="metric-item flex-col-center">
|
||||||
<view class="caption mb-xs">设备电量</view>
|
<view class="caption mb-xs">设备电量</view>
|
||||||
@@ -43,8 +40,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
deviceInfo: { type: Object, default: () => ({}) },
|
deviceInfo: { type: Object, default: () => ({}) },
|
||||||
isRealName: { type: Boolean, default: false },
|
isRealName: { type: Boolean, default: false },
|
||||||
@@ -54,17 +49,34 @@
|
|||||||
|
|
||||||
defineEmits(['authentication']);
|
defineEmits(['authentication']);
|
||||||
|
|
||||||
const getSignalText = (rssi) => rssi || '强';
|
const normalizeSignalScore = (value, min, max) => {
|
||||||
|
if (value === null || value === undefined || value === '' || value === '-') return null;
|
||||||
|
|
||||||
const statusText = computed(() => {
|
const numericValue = Number(value);
|
||||||
const statusMap = {
|
if (!Number.isFinite(numericValue)) return null;
|
||||||
1: '在库',
|
if (numericValue <= min) return 0;
|
||||||
2: '已分销',
|
if (numericValue >= max) return 100;
|
||||||
3: '已激活',
|
|
||||||
4: '已停用'
|
return ((numericValue - min) / (max - min)) * 100;
|
||||||
};
|
};
|
||||||
return statusMap[props.deviceInfo.status] || '-';
|
|
||||||
});
|
const getSignalText = (deviceInfo) => {
|
||||||
|
const signalScores = [
|
||||||
|
{ score: normalizeSignalScore(deviceInfo?.rsrp, -120, -80), weight: 0.5 },
|
||||||
|
{ score: normalizeSignalScore(deviceInfo?.rsrq, -20, -10), weight: 0.25 },
|
||||||
|
{ score: normalizeSignalScore(deviceInfo?.rssi, -100, -65), weight: 0.25 }
|
||||||
|
].filter(item => item.score !== null);
|
||||||
|
|
||||||
|
if (!signalScores.length) return '-';
|
||||||
|
|
||||||
|
const totalWeight = signalScores.reduce((sum, item) => sum + item.weight, 0);
|
||||||
|
const weightedScore =
|
||||||
|
signalScores.reduce((sum, item) => sum + item.score * item.weight, 0) / totalWeight;
|
||||||
|
|
||||||
|
if (weightedScore >= 67) return '强';
|
||||||
|
if (weightedScore >= 34) return '中';
|
||||||
|
return '弱';
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -156,6 +156,8 @@
|
|||||||
ssidName: '-',
|
ssidName: '-',
|
||||||
ssidPwd: '-',
|
ssidPwd: '-',
|
||||||
rssi: '-',
|
rssi: '-',
|
||||||
|
rsrp: '-',
|
||||||
|
rsrq: '-',
|
||||||
onlineStatus: '0',
|
onlineStatus: '0',
|
||||||
connCnt: 0,
|
connCnt: 0,
|
||||||
run_time: 0,
|
run_time: 0,
|
||||||
@@ -265,7 +267,9 @@
|
|||||||
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 = rt.rssi ?? '-';
|
||||||
|
deviceInfo.rsrp = rt.rsrp ?? '-';
|
||||||
|
deviceInfo.rsrq = rt.rsrq ?? '-';
|
||||||
} else {
|
} else {
|
||||||
// 没有实时信息时设置默认值
|
// 没有实时信息时设置默认值
|
||||||
deviceInfo.onlineStatus = '0';
|
deviceInfo.onlineStatus = '0';
|
||||||
@@ -277,6 +281,8 @@
|
|||||||
deviceInfo.max_clients = 1;
|
deviceInfo.max_clients = 1;
|
||||||
deviceInfo.run_time = 0;
|
deviceInfo.run_time = 0;
|
||||||
deviceInfo.rssi = '-';
|
deviceInfo.rssi = '-';
|
||||||
|
deviceInfo.rsrp = '-';
|
||||||
|
deviceInfo.rsrq = '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 到期时间由 TrafficCard 组件获取套餐信息时一并返回
|
// 到期时间由 TrafficCard 组件获取套餐信息时一并返回
|
||||||
|
|||||||
Reference in New Issue
Block a user