fix: 优化界面以及更新接口
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 1m27s

This commit is contained in:
sexygoat
2026-04-15 11:54:43 +08:00
parent 0d0b5ec14a
commit 91d7d4c21f
30 changed files with 1863 additions and 1742 deletions

View File

@@ -1,13 +1,13 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { getAssetDetail, getAssetPackages, getCurrentPackage, getAssetHistory, stopCard, startCard, stopDevice, startDevice } from '@/api/assets'
import { getAssetDetail, getAssetPackages, getCurrentPackage, getAssetHistory, stopAsset, startAsset } from '@/api/assets'
import type { AssetType, CardInfo, DeviceInfo, AssetPackage, HistoryRecord } from '@/api/assets'
// 资产类型
const assetType = ref<AssetType>('card')
// 资产ID
const assetId = ref('')
// 资产标识符 (ICCID 或 VirtualNo)
const assetIdentifier = ref('')
// 资产详情数据
const assetDetail = ref<CardInfo | DeviceInfo | null>(null)
@@ -57,11 +57,11 @@ const statusColor = computed(() => {
// 页面加载
onMounted(() => {
// 从路由参数获取 assetType 和 assetId
// 从路由参数获取 assetType 和 assetIdentifier
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1] as any
assetType.value = currentPage.options.type as AssetType
assetId.value = currentPage.options.id
assetIdentifier.value = currentPage.options.id
loadAssetDetail()
})
@@ -120,7 +120,7 @@ async function loadPackages() {
try {
// 1. 调用当前生效套餐接口
try {
const current = await getCurrentPackage(assetType.value, Number(assetId.value))
const current = await getCurrentPackage(assetIdentifier.value)
currentPackage.value = current
} catch (error) {
console.warn('获取当前套餐失败:', error)
@@ -128,7 +128,7 @@ async function loadPackages() {
}
// 2. 调用套餐列表接口
const packagesData = await getAssetPackages(assetType.value, Number(assetId.value), {
const packagesData = await getAssetPackages(assetIdentifier.value, {
page: 1,
page_size: 50
})
@@ -147,7 +147,7 @@ async function loadPackages() {
// 加载历史记录
async function loadHistory() {
try {
const historyData = await getAssetHistory(assetType.value, assetId.value, {
const historyData = await getAssetHistory(assetIdentifier.value, {
page: 1,
pageSize: 20,
})
@@ -193,7 +193,7 @@ async function handleTabChange(tab: 'info' | 'package' | 'history') {
}
// 停机
async function stopAsset() {
async function handleStopAsset() {
uni.showModal({
title: '确认停机',
content: '停机后将无法使用网络服务,确定要停机吗?',
@@ -201,13 +201,8 @@ async function stopAsset() {
if (res.confirm) {
operating.value = true
try {
// 调用停机接口
if (assetType.value === 'card') {
await stopCard({ id: assetId.value })
}
else {
await stopDevice({ id: assetId.value })
}
// 调用统一停机接口
await stopAsset(assetIdentifier.value)
uni.showToast({
title: '停机成功',
@@ -232,7 +227,7 @@ async function stopAsset() {
}
// 复机
async function startAsset() {
async function handleStartAsset() {
uni.showModal({
title: '确认复机',
content: '复机后将恢复网络服务,确定要复机吗?',
@@ -240,13 +235,8 @@ async function startAsset() {
if (res.confirm) {
operating.value = true
try {
// 调用复机接口
if (assetType.value === 'card') {
await startCard({ id: assetId.value })
}
else {
await startDevice({ id: assetId.value })
}
// 调用统一复机接口
await startAsset(assetIdentifier.value)
uni.showToast({
title: '复机成功',
@@ -274,7 +264,7 @@ async function startAsset() {
function viewWallet() {
// 跳转到钱包页面
uni.navigateTo({
url: `/pages/agent-system/asset-wallet/index?type=${assetType.value}&id=${assetId.value}`,
url: `/pages/agent-system/asset-wallet/index?type=${assetType.value}&id=${assetIdentifier.value}`,
})
}
</script>
@@ -459,7 +449,7 @@ function viewWallet() {
<text class="text-16px font-700 text-[#212121] block mb-2">
{{ currentPackage.package_name || '-' }}
</text>
<text class="text-14px text-[#ff6700] font-600 block mb-3">
<text class="text-14px text-[var(--brand-primary)] font-600 block mb-3">
已用: {{ currentPackage.virtual_used_mb || 0 }}MB / 总量: {{ currentPackage.virtual_limit_mb || 0 }}MB
</text>
@@ -546,7 +536,7 @@ function viewWallet() {
transition-all duration-200
active:opacity-80
"
@click="stopAsset"
@click="handleStopAsset"
>
<i class="i-mdi-pause-circle text-18px text-[#c62828] mr-1" />
<text class="text-15px font-600 text-[#c62828]">
@@ -562,7 +552,7 @@ function viewWallet() {
transition-all duration-200
active:opacity-80
"
@click="startAsset"
@click="handleStartAsset"
>
<i class="i-mdi-play-circle text-18px text-[#2e7d32] mr-1" />
<text class="text-15px font-600 text-[#2e7d32]">