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

@@ -37,7 +37,7 @@
</template>
<script setup>
import { reactive, ref } from 'vue';
import { reactive, ref, onMounted } from 'vue';
import { authApi } from '@/api/index.js';
const form = reactive({
@@ -47,6 +47,17 @@
newCode: ''
});
onMounted(() => {
// 获取 URL 参数中的原手机号
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const options = currentPage.options;
if (options.oldPhone) {
form.oldPhone = options.oldPhone;
}
});
let oldCooldown = ref(0);
let newCooldown = ref(0);
let oldCodeText = ref('获取验证码');

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':

View File

@@ -2,8 +2,8 @@
<view class="login-page">
<view class="content">
<view class="header">
<view class="main-title">设备管理登录</view>
<view class="sub-title">请输入设备标识进行登录</view>
<view class="main-title">登录</view>
<view class="sub-title">请输入标识进行登录</view>
</view>
<view class="form-section">
@@ -11,14 +11,14 @@
<input
v-model="identifier"
class="input"
placeholder="请输入设备标识"
placeholder="请输入标识"
placeholder-class="placeholder"
@focus="inputFocus = true"
@blur="inputFocus = false"
@input="showError = false"
/>
</view>
<text v-if="showError" class="error">请输入设备标识</text>
<text v-if="showError" class="error">请输入标识</text>
</view>
<view class="btn-section">
@@ -139,10 +139,10 @@
<style lang="scss" scoped>
.login-page {
min-height: 100vh;
display: flex;
flex-direction: column;
background: #FFFFFF;
min-height: 100vh;
padding: 60rpx 40rpx;
}
@@ -184,8 +184,7 @@
}
.input-wrap.focus {
background: #FFFFFF;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
background: #f7f7f7;
}
.input {
@@ -213,28 +212,25 @@
.btn-login {
width: 100%;
height: 108rpx;
background: linear-gradient(135deg, #00DDA2 0%, #00E5A8 100%);
background: $uni-color-primary;
border: none;
border-radius: 20rpx;
font-size: 36rpx;
font-weight: 600;
color: #1A1A1A;
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s;
box-shadow: 0 8rpx 24rpx rgba(0, 221, 162, 0.25);
}
.btn-login.disabled {
background: #E5E7EB;
color: #9CA3AF;
box-shadow: none;
}
.btn-login:active:not(.disabled) {
transform: scale(0.98);
box-shadow: 0 4rpx 16rpx rgba(0, 221, 162, 0.3);
opacity: 0.8;
}
.loading {
@@ -246,7 +242,7 @@
.dot {
width: 10rpx;
height: 10rpx;
background: #1A1A1A;
background: #FFFFFF;
border-radius: 50%;
animation: load 1.4s infinite ease-in-out both;
}