295 lines
11 KiB
Dart
295 lines
11 KiB
Dart
import 'package:flutter/material.dart';
|
||
import '../../../../app/theme/app_colors.dart';
|
||
import '../../../../app/i18n/app_localizations.dart';
|
||
|
||
/// 信用评级页面
|
||
///
|
||
/// 四因子信用评分:核销率35% + (1-Breakage率)25% + 市场存续20% + 用户满意度20%
|
||
/// AI建议列表:信用提升建议
|
||
class CreditPage extends StatelessWidget {
|
||
const CreditPage({super.key});
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return Scaffold(
|
||
appBar: AppBar(title: Text(context.t('credit_title'))),
|
||
body: SingleChildScrollView(
|
||
padding: const EdgeInsets.all(20),
|
||
child: Column(
|
||
children: [
|
||
// Score Gauge
|
||
_buildScoreGauge(context),
|
||
const SizedBox(height: 24),
|
||
|
||
// Four Factors
|
||
_buildFactorsCard(context),
|
||
const SizedBox(height: 20),
|
||
|
||
// Tier Progress
|
||
_buildTierProgress(context),
|
||
const SizedBox(height: 20),
|
||
|
||
// AI Suggestions
|
||
_buildAiSuggestions(context),
|
||
const SizedBox(height: 20),
|
||
|
||
// Credit History
|
||
_buildCreditHistory(context),
|
||
],
|
||
),
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _buildScoreGauge(BuildContext context) {
|
||
return Container(
|
||
padding: const EdgeInsets.all(24),
|
||
decoration: BoxDecoration(
|
||
color: AppColors.surface,
|
||
borderRadius: BorderRadius.circular(16),
|
||
border: Border.all(color: AppColors.borderLight),
|
||
),
|
||
child: Column(
|
||
children: [
|
||
Container(
|
||
width: 120,
|
||
height: 120,
|
||
decoration: BoxDecoration(
|
||
shape: BoxShape.circle,
|
||
gradient: LinearGradient(
|
||
begin: Alignment.topCenter,
|
||
end: Alignment.bottomCenter,
|
||
colors: [AppColors.creditAA, AppColors.creditAA.withValues(alpha: 0.3)],
|
||
),
|
||
),
|
||
child: const Center(
|
||
child: Column(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: [
|
||
Text('AA', style: TextStyle(fontSize: 32, fontWeight: FontWeight.w700, color: Colors.white)),
|
||
Text('82分', style: TextStyle(fontSize: 14, color: Colors.white70)),
|
||
],
|
||
),
|
||
),
|
||
),
|
||
const SizedBox(height: 16),
|
||
Text(context.t('credit_score_label'), style: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600)),
|
||
const SizedBox(height: 4),
|
||
Text(context.t('credit_gap_label'), style: const TextStyle(fontSize: 13, color: AppColors.textSecondary)),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _buildFactorsCard(BuildContext context) {
|
||
final factors = [
|
||
(context.t('credit_factor_redemption'), 0.85, 0.35, AppColors.success),
|
||
(context.t('credit_factor_breakage'), 0.72, 0.25, AppColors.info),
|
||
(context.t('credit_factor_market'), 0.90, 0.20, AppColors.primary),
|
||
(context.t('credit_factor_satisfaction'), 0.78, 0.20, AppColors.warning),
|
||
];
|
||
|
||
return Container(
|
||
padding: const EdgeInsets.all(16),
|
||
decoration: BoxDecoration(
|
||
color: AppColors.surface,
|
||
borderRadius: BorderRadius.circular(12),
|
||
border: Border.all(color: AppColors.borderLight),
|
||
),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text(context.t('credit_factors'), style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600)),
|
||
const SizedBox(height: 16),
|
||
...factors.map((f) {
|
||
final (label, score, weight, color) = f;
|
||
return Padding(
|
||
padding: const EdgeInsets.only(bottom: 16),
|
||
child: Column(
|
||
children: [
|
||
Row(
|
||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
children: [
|
||
Text(label, style: const TextStyle(fontSize: 13)),
|
||
Text(
|
||
'${(score * 100).toInt()}分 (权重${(weight * 100).toInt()}%)',
|
||
style: const TextStyle(fontSize: 12, color: AppColors.textSecondary),
|
||
),
|
||
],
|
||
),
|
||
const SizedBox(height: 6),
|
||
ClipRRect(
|
||
borderRadius: BorderRadius.circular(4),
|
||
child: LinearProgressIndicator(
|
||
value: score,
|
||
backgroundColor: AppColors.gray100,
|
||
valueColor: AlwaysStoppedAnimation(color),
|
||
minHeight: 8,
|
||
),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _buildTierProgress(BuildContext context) {
|
||
final tiers = [
|
||
(context.t('credit_tier_silver'), AppColors.tierSilver, true),
|
||
(context.t('credit_tier_gold'), AppColors.tierGold, true),
|
||
(context.t('credit_tier_platinum'), AppColors.tierPlatinum, false),
|
||
(context.t('credit_tier_diamond'), AppColors.tierDiamond, false),
|
||
];
|
||
|
||
return Container(
|
||
padding: const EdgeInsets.all(16),
|
||
decoration: BoxDecoration(
|
||
color: AppColors.surface,
|
||
borderRadius: BorderRadius.circular(12),
|
||
border: Border.all(color: AppColors.borderLight),
|
||
),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text(context.t('credit_tier_title'), style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600)),
|
||
const SizedBox(height: 16),
|
||
Row(
|
||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||
children: tiers.map((t) {
|
||
final (name, color, isReached) = t;
|
||
return Column(
|
||
children: [
|
||
Container(
|
||
width: 44,
|
||
height: 44,
|
||
decoration: BoxDecoration(
|
||
color: isReached ? color.withValues(alpha: 0.15) : AppColors.gray100,
|
||
shape: BoxShape.circle,
|
||
border: isReached ? Border.all(color: color, width: 2) : null,
|
||
),
|
||
child: Icon(
|
||
Icons.star_rounded,
|
||
color: isReached ? color : AppColors.textTertiary,
|
||
size: 22,
|
||
),
|
||
),
|
||
const SizedBox(height: 6),
|
||
Text(
|
||
name,
|
||
style: TextStyle(
|
||
fontSize: 12,
|
||
color: isReached ? color : AppColors.textTertiary,
|
||
fontWeight: isReached ? FontWeight.w600 : FontWeight.w400,
|
||
),
|
||
),
|
||
],
|
||
);
|
||
}).toList(),
|
||
),
|
||
const SizedBox(height: 12),
|
||
Text(
|
||
context.t('credit_tier_progress'),
|
||
style: const TextStyle(fontSize: 12, color: AppColors.textSecondary),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _buildAiSuggestions(BuildContext context) {
|
||
final suggestions = [
|
||
('提升核销率', '建议在周末推出限时核销活动,预计可提升核销率5%', Icons.trending_up_rounded),
|
||
('降低Breakage', '当前有12%的券过期未用,建议到期前7天推送提醒', Icons.notification_important_rounded),
|
||
('增加用户满意度', '回复消费者评价可提升满意度评分', Icons.rate_review_rounded),
|
||
];
|
||
|
||
return Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Row(
|
||
children: [
|
||
const Icon(Icons.auto_awesome_rounded, color: AppColors.primary, size: 20),
|
||
const SizedBox(width: 8),
|
||
Text(context.t('credit_ai_title'), style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600)),
|
||
],
|
||
),
|
||
const SizedBox(height: 12),
|
||
...suggestions.map((s) {
|
||
final (title, desc, icon) = s;
|
||
return Container(
|
||
margin: const EdgeInsets.only(bottom: 10),
|
||
padding: const EdgeInsets.all(14),
|
||
decoration: BoxDecoration(
|
||
color: AppColors.primarySurface,
|
||
borderRadius: BorderRadius.circular(10),
|
||
),
|
||
child: Row(
|
||
children: [
|
||
Icon(icon, color: AppColors.primary, size: 20),
|
||
const SizedBox(width: 12),
|
||
Expanded(
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text(title, style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w600)),
|
||
const SizedBox(height: 2),
|
||
Text(desc, style: const TextStyle(fontSize: 12, color: AppColors.textSecondary)),
|
||
],
|
||
),
|
||
),
|
||
],
|
||
),
|
||
);
|
||
}),
|
||
],
|
||
);
|
||
}
|
||
|
||
Widget _buildCreditHistory(BuildContext context) {
|
||
return Container(
|
||
padding: const EdgeInsets.all(16),
|
||
decoration: BoxDecoration(
|
||
color: AppColors.surface,
|
||
borderRadius: BorderRadius.circular(12),
|
||
border: Border.all(color: AppColors.borderLight),
|
||
),
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text(context.t('credit_history_title'), style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600)),
|
||
const SizedBox(height: 12),
|
||
_buildHistoryItem('信用分 +3', '核销率提升至85%', '2天前', AppColors.success),
|
||
_buildHistoryItem('信用分 -1', 'Breakage率微升', '1周前', AppColors.error),
|
||
_buildHistoryItem('升级至黄金', '月发行量达100万', '2周前', AppColors.tierGold),
|
||
_buildHistoryItem('信用分 +5', '完成首月营业', '1月前', AppColors.success),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
Widget _buildHistoryItem(String title, String desc, String time, Color color) {
|
||
return Padding(
|
||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||
child: Row(
|
||
children: [
|
||
Container(width: 8, height: 8, decoration: BoxDecoration(color: color, shape: BoxShape.circle)),
|
||
const SizedBox(width: 12),
|
||
Expanded(
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.start,
|
||
children: [
|
||
Text(title, style: TextStyle(fontSize: 13, fontWeight: FontWeight.w600, color: color)),
|
||
Text(desc, style: const TextStyle(fontSize: 12, color: AppColors.textSecondary)),
|
||
],
|
||
),
|
||
),
|
||
Text(time, style: const TextStyle(fontSize: 11, color: AppColors.textTertiary)),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
}
|