This commit is contained in:
@@ -171,20 +171,25 @@ export function useAssetInfo() {
|
||||
const loadCurrentPackage = async (identifier: string) => {
|
||||
try {
|
||||
currentPackageLoading.value = true
|
||||
// 清空之前的错误信息
|
||||
currentPackageErrorMsg.value = ''
|
||||
|
||||
const response = await AssetService.getCurrentPackage(identifier)
|
||||
if (response.code === 0) {
|
||||
if (response.data) {
|
||||
const pkg = response.data
|
||||
const [currentPkgResponse, packageListResponse] = await Promise.all([
|
||||
AssetService.getCurrentPackage(identifier),
|
||||
AssetService.getAssetPackages(identifier, { page: 1, page_size: 50 })
|
||||
])
|
||||
|
||||
const activePackage = packageListResponse.data?.items?.find((p: any) => p.status === 1)
|
||||
const activePaidAmount = activePackage?.paid_amount || 0
|
||||
|
||||
if (currentPkgResponse.code === 0) {
|
||||
if (currentPkgResponse.data) {
|
||||
const pkg = currentPkgResponse.data
|
||||
|
||||
// 转换为组件期望的格式
|
||||
currentPackage.value = {
|
||||
id: pkg.package_usage_id || 0,
|
||||
package_id: pkg.package_id || 0,
|
||||
package_name: pkg.package_name || '',
|
||||
package_price: 0, // API 没有返回价格
|
||||
package_price: activePaidAmount,
|
||||
package_total_data: pkg.data_limit_mb || 0,
|
||||
real_data_used: pkg.data_usage_mb || 0,
|
||||
real_data_remaining: (pkg.data_limit_mb || 0) - (pkg.data_usage_mb || 0),
|
||||
@@ -196,10 +201,10 @@ export function useAssetInfo() {
|
||||
expire_time: pkg.expires_at || '',
|
||||
status: pkg.status || 0,
|
||||
status_name: pkg.status_name,
|
||||
duration_days: undefined, // API 没有返回时长
|
||||
virtual_ratio: pkg.virtual_ratio, // 虚流量比例
|
||||
package_type: pkg.package_type, // 套餐类型
|
||||
enable_virtual_data: pkg.enable_virtual_data, // 是否启用虚流量
|
||||
duration_days: undefined,
|
||||
virtual_ratio: pkg.virtual_ratio,
|
||||
package_type: pkg.package_type,
|
||||
enable_virtual_data: pkg.enable_virtual_data,
|
||||
data_limit_mb: pkg.data_limit_mb,
|
||||
virtual_limit_mb: pkg.virtual_limit_mb,
|
||||
virtual_remain_mb: pkg.virtual_remain_mb,
|
||||
|
||||
Reference in New Issue
Block a user