fix: ui
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 1m38s

This commit is contained in:
luo
2026-08-24 09:37:36 +08:00
parent ecb594dbb6
commit 5216530714
23 changed files with 3608 additions and 2906 deletions

View File

@@ -1,105 +1,7 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { getAssetWallet } from '@/api/wallet'
import type { AssetWalletInfo, AssetType } from '@/api/wallet'
import { onLoad } from '@dcloudio/uni-app'
// 资产类型和ID (从URL参数获取)
const assetType = ref<AssetType>('card')
const assetId = ref<number>(0)
// 钱包信息
const walletInfo = ref<AssetWalletInfo | null>(null)
// 加载状态
const loading = ref(false)
// 格式化金额(分转元)
function formatAmount(amount : number) {
return `¥${(amount / 100).toFixed(2)}`
}
// 获取钱包状态文本
function getStatusText(status : number, statusText ?: string) {
if (statusText) return statusText
const map : Record<number, string> = {
1: '正常',
2: '冻结',
3: '已停用',
}
return map[status] || '未知'
}
// 获取钱包状态颜色
function getStatusColor(status : number) {
const map : Record<number, { bg : string, text : string }> = {
1: { bg: '#e8f5e9', text: '#2e7d32' }, // 正常
2: { bg: '#fff3e0', text: '#e65100' }, // 冻结
3: { bg: '#f5f5f5', text: '#999' }, // 已停用
}
return map[status] || { bg: '#f5f5f5', text: '#999' }
}
// 格式化时间
function formatTime(time : string) {
if (!time) return '-'
const date = new Date(time)
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
const hour = String(date.getHours()).padStart(2, '0')
const minute = String(date.getMinutes()).padStart(2, '0')
return `${year}-${month}-${day} ${hour}:${minute}`
}
// 页面加载时获取参数
onLoad((options) => {
if (options.asset_type) {
assetType.value = options.asset_type as AssetType
}
if (options.asset_id) {
assetId.value = Number(options.asset_id)
}
})
// 页面挂载
onMounted(() => {
if (assetId.value) {
loadWalletInfo()
}
})
// 加载钱包信息
async function loadWalletInfo() {
if (!assetId.value) {
uni.$u.toast('缺少资产ID')
return
}
loading.value = true
try {
const wallet = await getAssetWallet(assetType.value, assetId.value)
walletInfo.value = wallet
}
catch (error) {
console.error('加载资产钱包信息失败:', error)
}
finally {
loading.value = false
}
}
// 返回上一页
function goBack() {
uni.navigateBack()
}
</script>
<template>
<view class="bg-[#fafafa] min-h-screen pb-safe">
<view class="min-h-screen bg-[#fafafa] pb-safe">
<!-- 加载中 -->
<view v-if="loading" class="pt-20 center">
<view v-if="loading" class="center pt-20">
<i class="i-mdi-loading animate-spin text-40px text-[#999]" />
</view>
@@ -107,34 +9,41 @@
<view v-else-if="walletInfo" class="px-4 pt-4">
<!-- 余额卡片 -->
<view
class="bg-gradient-to-r from-[var(--brand-primary)] to-[var(--brand-primary-light)] rounded-16px shadow-brand-colored p-4 mb-3">
<view class="flex items-center justify-between mb-3">
class="mb-3 rounded-16px from-[var(--brand-primary)] to-[var(--brand-primary-light)] bg-gradient-to-r p-4"
>
<view class="mb-3 flex items-center justify-between">
<view>
<text class="text-13px text-white/70 block mb-1">
<text class="mb-1 block text-13px text-white/70">
可用余额
</text>
<text class="text-32px font-700 text-white block">
<text class="block text-32px text-white font-700">
{{ formatAmount(walletInfo.available_balance) }}
</text>
</view>
<view :style="{
<view
:style="{
backgroundColor: getStatusColor(walletInfo.status).bg,
color: getStatusColor(walletInfo.status).text,
}" class="px-3 py-1 rounded-8px text-12px font-600">
}" class="rounded-8px px-3 py-1 text-12px font-600"
>
{{ getStatusText(walletInfo.status, walletInfo.status_text) }}
</view>
</view>
<view class="grid grid-cols-2 gap-3 pt-3 border-t-1px border-white/20">
<view class="grid grid-cols-2 gap-3 border-t-1px border-white/20 pt-3">
<view>
<text class="text-11px text-white/70 block mb-1">总余额</text>
<text class="text-14px font-600 text-white">
<text class="mb-1 block text-11px text-white/70">
总余额
</text>
<text class="text-14px text-white font-600">
{{ formatAmount(walletInfo.balance) }}
</text>
</view>
<view>
<text class="text-11px text-white/70 block mb-1">冻结金额</text>
<text class="text-14px font-600 text-white">
<text class="mb-1 block text-11px text-white/70">
冻结金额
</text>
<text class="text-14px text-white font-600">
{{ formatAmount(walletInfo.frozen_balance) }}
</text>
</view>
@@ -142,52 +51,64 @@
</view>
<!-- 钱包详情 -->
<view class="bg-white rounded-16px shadow-[0_2px_12px_rgba(0,0,0,0.06)] p-4 mb-3">
<view class="flex items-center gap-2 mb-3">
<view class="mb-3 rounded-16px bg-white p-4">
<view class="mb-3 flex items-center gap-2">
<i class="i-mdi-information-outline text-20px text-[var(--brand-primary)]" />
<text class="text-15px font-600 text-[#212121]">
<text class="text-15px text-[#212121] font-600">
钱包详情
</text>
</view>
<view class="space-y-2">
<view class="flex items-center justify-between">
<text class="text-13px text-[#666]">钱包ID</text>
<text class="text-13px text-[#666]">
钱包ID
</text>
<text class="text-13px text-[#212121]">
{{ walletInfo.wallet_id }}
</text>
</view>
<view class="flex items-center justify-between">
<text class="text-13px text-[#666]">资产ID</text>
<text class="text-13px text-[#666]">
资产ID
</text>
<text class="text-13px text-[#212121]">
{{ walletInfo.resource_id }}
</text>
</view>
<view class="flex items-center justify-between">
<text class="text-13px text-[#666]">资产类型</text>
<text class="text-13px text-[#666]">
资产类型
</text>
<text class="text-13px text-[#212121]">
{{ walletInfo.resource_type === 'iot_card' ? 'IoT卡' : '设备' }}
</text>
</view>
<view class="flex items-center justify-between">
<text class="text-13px text-[#666]">币种</text>
<text class="text-13px text-[#666]">
币种
</text>
<text class="text-13px text-[#212121]">
{{ walletInfo.currency }}
</text>
</view>
<view class="flex items-center justify-between">
<text class="text-13px text-[#666]">创建时间</text>
<text class="text-13px text-[#666]">
创建时间
</text>
<text class="text-11px text-[#999]">
{{ formatTime(walletInfo.created_at) }}
</text>
</view>
<view class="flex items-center justify-between">
<text class="text-13px text-[#666]">更新时间</text>
<text class="text-13px text-[#666]">
更新时间
</text>
<text class="text-11px text-[#999]">
{{ formatTime(walletInfo.updated_at) }}
</text>
@@ -196,11 +117,11 @@
</view>
<!-- 温馨提示 -->
<view class="bg-[#fff3e0] rounded-12px p-3 mb-3">
<view class="mb-3 rounded-12px bg-[#fff3e0] p-3">
<view class="flex items-start gap-2">
<i class="i-mdi-information text-16px text-[#e65100] mt-0.5" />
<i class="i-mdi-information mt-0.5 text-16px text-[#e65100]" />
<view class="flex-1">
<text class="text-12px text-[#666] block">
<text class="block text-12px text-[#666]">
此钱包为资产专属钱包,余额仅可用于该资产相关的费用支付。
</text>
</view>
@@ -209,9 +130,9 @@
</view>
<!-- 空状态 -->
<view v-else class="pt-20 center flex-col">
<i class="i-mdi-wallet-outline text-60px text-[#ddd] mb-3" />
<text class="text-14px text-[#999] mb-2">
<view v-else class="center flex-col pt-20">
<i class="i-mdi-wallet-outline mb-3 text-60px text-[#ddd]" />
<text class="mb-2 text-14px text-[#999]">
暂无钱包信息
</text>
<text class="text-12px text-[#ccc]">
@@ -224,6 +145,104 @@
</view>
</template>
<script setup lang="ts">
import type { AssetType, AssetWalletInfo } from '@/api/wallet';
import { onLoad } from '@dcloudio/uni-app';
import { onMounted, ref } from 'vue';
import { getAssetWallet } from '@/api/wallet';
// 资产类型和ID (从URL参数获取)
const assetType = ref<AssetType>('card');
const assetId = ref<number>(0);
// 钱包信息
const walletInfo = ref<AssetWalletInfo | null>(null);
// 加载状态
const loading = ref(false);
// 格式化金额(分转元)
function formatAmount(amount: number) {
return `¥${(amount / 100).toFixed(2)}`;
}
// 获取钱包状态文本
function getStatusText(status: number, statusText?: string) {
if (statusText) return statusText;
const map: Record<number, string> = {
1: '正常',
2: '冻结',
3: '已停用',
};
return map[status] || '未知';
}
// 获取钱包状态颜色
function getStatusColor(status: number) {
const map: Record<number, { bg: string; text: string }> = {
1: { bg: '#e8f5e9', text: '#2e7d32' }, // 正常
2: { bg: '#fff3e0', text: '#e65100' }, // 冻结
3: { bg: '#f5f5f5', text: '#999' }, // 已停用
};
return map[status] || { bg: '#f5f5f5', text: '#999' };
}
// 格式化时间
function formatTime(time: string) {
if (!time) return '-';
const date = new Date(time);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hour = String(date.getHours()).padStart(2, '0');
const minute = String(date.getMinutes()).padStart(2, '0');
return `${year}-${month}-${day} ${hour}:${minute}`;
}
// 页面加载时获取参数
onLoad((options) => {
if (options.asset_type) {
assetType.value = options.asset_type as AssetType;
}
if (options.asset_id) {
assetId.value = Number(options.asset_id);
}
});
// 页面挂载
onMounted(() => {
if (assetId.value) {
loadWalletInfo();
}
});
// 加载钱包信息
async function loadWalletInfo() {
if (!assetId.value) {
uni.$u.toast('缺少资产ID');
return;
}
loading.value = true;
try {
const wallet = await getAssetWallet(assetType.value, assetId.value);
walletInfo.value = wallet;
}
catch (error) {
console.error('加载资产钱包信息失败:', error);
}
finally {
loading.value = false;
}
}
// 返回上一页
function goBack() {
uni.navigateBack();
}
</script>
<style scoped>
.center {
display: flex;