111
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user