This commit is contained in:
niannian zheng 2026-03-12 19:17:43 +08:00
commit 739152ab13

View File

@ -1,5 +1,12 @@
<template>
<view class="page-container">
<!-- 全局加载遮罩 -->
<view class="loading-overlay" v-if="loading">
<view class="loading-content">
<uni-icons type="spinner-cycle" size="40" color="#064E3B" class="loading-spin"></uni-icons>
<text class="loading-text">加载中...</text>
</view>
</view>
<view class="header-section">
@ -278,6 +285,8 @@ const getCurrencySymbol = (currency) => {
};
const portfolioId = ref('');
const loading = ref(false);
const portfolioData = ref({
id: '',
name: '',
@ -391,6 +400,7 @@ const selectStock = (result) => {
const fetchPortfolioData = async () => {
try {
loading.value = true;
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const id = currentPage.options?.id;
@ -410,11 +420,15 @@ const fetchPortfolioData = async () => {
}
} catch (error) {
console.error('获取投资组合数据失败:', error);
uni.showToast({ title: '加载失败,请重试', icon: 'none' });
} finally {
loading.value = false;
}
};
const fetchTransactions = async () => {
try {
loading.value = true;
if (!portfolioId.value) return;
const response = await api.assets.getTransactions({
@ -429,6 +443,9 @@ const fetchTransactions = async () => {
}
} catch (error) {
console.error('获取交易记录失败:', error);
uni.showToast({ title: '加载交易记录失败', icon: 'none' });
} finally {
loading.value = false;
}
};
@ -575,6 +592,42 @@ const deletePortfolio = async () => {
/* 关键:底部留出空间,防止内容被固定按钮遮挡 */
padding-bottom: 180rpx;
}
/* 加载遮罩 */
.loading-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
}
.loading-content {
background-color: #FFFFFF;
border-radius: 16rpx;
padding: 40rpx;
display: flex;
flex-direction: column;
align-items: center;
gap: 16rpx;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.15);
}
.loading-spin {
animation: rotate 1s linear infinite;
}
@keyframes rotate {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.loading-text {
font-size: 26rpx;
color: #374151;
font-weight: 500;
}
.flex-row { display: flex; flex-direction: row; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }