This commit is contained in:
sion
2026-04-07 01:05:05 +08:00
parent edad10ff06
commit 5ca1274607
83 changed files with 1561 additions and 1241 deletions

View File

@@ -9,7 +9,7 @@ import '../../../data/models/account_models.dart';
import '../../../data/services/bonus_service.dart';
import '../../../providers/asset_provider.dart';
/// 账单页面 — 代币盈亏账单 + 新人福利账单 + 推广福利账单
/// 賬單頁面 — 代幣盈虧賬單 + 新人福利賬單 + 推福利賬單
class BillsPage extends StatefulWidget {
const BillsPage({super.key});
@@ -42,7 +42,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
final provider = context.read<AssetProvider>();
final bonusService = context.read<BonusService>();
// 行加载持仓和福利记录
// 行加載持倉和福利記錄
await provider.loadTradeAccount(force: true);
final welfareResponse = await bonusService.getWelfareStatus();
@@ -73,7 +73,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
if (newUser != null) {
final claimed = newUser['claimed'] as bool? ?? false;
final eligible = newUser['eligible'] as bool? ?? false;
// 状态: 1=已取, 0=可取(待取), 2=不可用(未解)
// 狀態: 1=已取, 0=可取(待取), 2=不可用(未解)
final int status;
if (claimed) {
status = 1;
@@ -91,15 +91,15 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
});
}
// 推广福利列表
// 推福利列表
final referralRewards = data['referralRewards'] as List<dynamic>? ?? [];
for (var r in referralRewards) {
final map = r as Map<String, dynamic>;
final username = map['username'] as String? ?? '';
final username = map['username'] as String? ?? '';
final milestones = map['milestones'] as List<dynamic>? ?? [];
final claimableCount = map['claimableCount'] as int? ?? 0;
// 每 milestone 生成一条记录
// 每 milestone 生成一條記錄
for (var m in milestones) {
final ms = m as Map<String, dynamic>;
final earned = ms['earned'] as bool? ?? false;
@@ -108,26 +108,26 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
final int status;
if (earned) {
status = 1; // 已
status = 1; // 已
} else if (claimable) {
status = 0; // 可
status = 0; // 可
} else {
status = 2; // 未达标
status = 2; // 未達標
}
records.add({
'type': 'referral',
'title': '广福利 - $username (${milestoneVal}000)',
'title': '福利 - $username (${milestoneVal}000)',
'amount': '100.00',
'status': status,
'time': ms['claimTime'] ?? ms['createTime'],
});
}
// 如果有 milestone 但有 claimableCount也生成记录
// 如果有 milestone 但有 claimableCount也生成記錄
if (milestones.isEmpty && claimableCount > 0) {
records.add({
'type': 'referral',
'title': '广福利 - $username',
'title': '福利 - $username',
'amount': '${claimableCount * 100}',
'status': 0,
'time': null,
@@ -150,7 +150,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
icon: const Icon(LucideIcons.arrowLeft, size: 20),
onPressed: () => Navigator.of(context).pop(),
),
title: Text('我的账单', style: AppTextStyles.headlineLarge(context)),
title: Text('我的賬單', style: AppTextStyles.headlineLarge(context)),
backgroundColor: _isDark ? AppColorScheme.darkBackground : AppColorScheme.lightBackground,
elevation: 0,
scrolledUnderElevation: 0,
@@ -163,9 +163,9 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
labelStyle: AppTextStyles.headlineMedium(context).copyWith(fontWeight: FontWeight.w600),
unselectedLabelStyle: AppTextStyles.headlineMedium(context),
tabs: const [
Tab(text: '币盈亏'),
Tab(text: '幣盈虧'),
Tab(text: '新人福利'),
Tab(text: '广福利'),
Tab(text: '福利'),
],
),
),
@@ -183,16 +183,16 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
}
// ============================================
// 代币盈亏账单
// 代幣盈虧賬單
// ============================================
Widget _buildCoinProfitTab() {
final colorScheme = Theme.of(context).colorScheme;
if (_holdings.isEmpty) {
return _buildEmptyState(LucideIcons.wallet, '暂无持仓记录');
return _buildEmptyState(LucideIcons.wallet, '暫無持倉記錄');
}
// 汇总统计
// 彙總統計
double totalCost = 0;
double totalValue = 0;
double totalProfit = 0;
@@ -210,7 +210,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
child: ListView(
padding: const EdgeInsets.all(AppSpacing.md),
children: [
// 汇总卡片
// 彙總卡片
Container(
padding: const EdgeInsets.all(AppSpacing.lg),
decoration: BoxDecoration(
@@ -224,7 +224,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
),
child: Column(
children: [
Text('总盈亏 (USDT)', style: AppTextStyles.bodyMedium(context).copyWith(
Text('總盈虧 (USDT)', style: AppTextStyles.bodyMedium(context).copyWith(
color: colorScheme.onSurfaceVariant,
)),
const SizedBox(height: AppSpacing.xs),
@@ -239,9 +239,9 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildSummaryItem('成本', totalCost.toStringAsFixed(2)),
_buildSummaryItem('成本', totalCost.toStringAsFixed(2)),
Container(width: 1, height: 16, color: colorScheme.outlineVariant.withValues(alpha: 0.3)),
_buildSummaryItem('市值', totalValue.toStringAsFixed(2)),
_buildSummaryItem('市值', totalValue.toStringAsFixed(2)),
Container(width: 1, height: 16, color: colorScheme.outlineVariant.withValues(alpha: 0.3)),
_buildSummaryItem('收益率', '${profitRate >= 0 ? '+' : ''}${profitRate.toStringAsFixed(2)}%'),
],
@@ -251,7 +251,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
),
const SizedBox(height: AppSpacing.md),
// 各币种盈亏明细
// 各幣種盈虧明細
..._holdings.map((h) => _buildCoinProfitCard(h)),
],
),
@@ -296,7 +296,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
),
child: Column(
children: [
// 名 + 盈亏金额
// 名 + 盈虧金額
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@@ -333,11 +333,11 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
],
),
const SizedBox(height: AppSpacing.sm),
// 明
// 明
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(': ${h.avgPrice}', style: AppTextStyles.bodySmall(context).copyWith(
Text(': ${h.avgPrice}', style: AppTextStyles.bodySmall(context).copyWith(
color: colorScheme.onSurfaceVariant,
)),
Text('市值: ${h.currentValue} USDT', style: AppTextStyles.bodySmall(context).copyWith(
@@ -355,7 +355,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
}
// ============================================
// 福利账单
// 福利賬單
// ============================================
Widget _buildWelfareTab(String type) {
final records = _welfareRecords.where((r) => r['type'] == type).toList();
@@ -363,7 +363,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
if (records.isEmpty) {
return _buildEmptyState(
LucideIcons.gift,
type == 'new_user' ? '暂无新人福利记录' : '暂无推广福利记录',
type == 'new_user' ? '暫無新人福利記錄' : '暫無推廣福利記錄',
);
}
@@ -382,20 +382,20 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
final amount = double.tryParse(record['amount']?.toString() ?? '0') ?? 0;
final status = record['status'] as int? ?? 0;
// status: 0=待取, 1=已取, 2=未达标
// status: 0=待取, 1=已取, 2=未達標
String statusText;
Color statusColor;
switch (status) {
case 1:
statusText = '';
statusText = '';
statusColor = context.appColors.up;
break;
case 2:
statusText = '达标';
statusText = '達標';
statusColor = colorScheme.onSurfaceVariant;
break;
default:
statusText = '';
statusText = '';
statusColor = AppColorScheme.warning;
}
@@ -463,7 +463,7 @@ class _BillsPageState extends State<BillsPage> with SingleTickerProviderStateMix
}
// ============================================
// 通用
// 通用
// ============================================
Widget _buildEmptyState(IconData icon, String text) {
final colorScheme = Theme.of(context).colorScheme;