feat(profile): 添加市团队/省团队/市区域/省区域权益考核显示

在"我的"页面社区权益考核下方,根据用户拥有的角色显示对应的权益考核组件:
- 市团队:每新增认种1棵可获得30 USDT
- 省团队:每新增认种1棵可获得10 USDT
- 市区域:每新增认种1棵可获得20 USDT
- 省区域:每新增认种1棵可获得10 USDT

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-14 08:40:34 -08:00
parent 090c8b747e
commit 13d1bedb73
1 changed files with 335 additions and 0 deletions

View File

@ -61,6 +61,38 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
int _communityMonthlyTarget = 10; //
int _communityMonthIndex = 0; //
//
bool _hasAuthCityCompanyAuth = false;
bool _authCityCompanyBenefitActive = false;
int _authCityCompanyCurrentTreeCount = 0;
int _authCityCompanyInitialTarget = 100;
int _authCityCompanyMonthlyTarget = 100;
int _authCityCompanyMonthIndex = 0;
//
bool _hasAuthProvinceCompanyAuth = false;
bool _authProvinceCompanyBenefitActive = false;
int _authProvinceCompanyCurrentTreeCount = 0;
int _authProvinceCompanyInitialTarget = 500;
int _authProvinceCompanyMonthlyTarget = 500;
int _authProvinceCompanyMonthIndex = 0;
//
bool _hasCityCompanyAuth = false;
bool _cityCompanyBenefitActive = false;
int _cityCompanyCurrentTreeCount = 0;
int _cityCompanyInitialTarget = 100;
int _cityCompanyMonthlyTarget = 100;
int _cityCompanyMonthIndex = 0;
//
bool _hasProvinceCompanyAuth = false;
bool _provinceCompanyBenefitActive = false;
int _provinceCompanyCurrentTreeCount = 0;
int _provinceCompanyInitialTarget = 500;
int _provinceCompanyMonthlyTarget = 500;
int _provinceCompanyMonthIndex = 0;
// reward-service
double _pendingUsdt = 0.0;
double _pendingPower = 0.0;
@ -345,6 +377,54 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
} else {
_hasCommunityAuth = false;
}
//
if (summary.authCityCompany != null) {
_hasAuthCityCompanyAuth = true;
_authCityCompanyBenefitActive = summary.authCityCompany!.benefitActive;
_authCityCompanyCurrentTreeCount = summary.authCityCompany!.currentTreeCount;
_authCityCompanyInitialTarget = summary.authCityCompany!.initialTargetTreeCount;
_authCityCompanyMonthlyTarget = summary.authCityCompany!.monthlyTargetTreeCount;
_authCityCompanyMonthIndex = summary.authCityCompany!.currentMonthIndex;
} else {
_hasAuthCityCompanyAuth = false;
}
//
if (summary.authProvinceCompany != null) {
_hasAuthProvinceCompanyAuth = true;
_authProvinceCompanyBenefitActive = summary.authProvinceCompany!.benefitActive;
_authProvinceCompanyCurrentTreeCount = summary.authProvinceCompany!.currentTreeCount;
_authProvinceCompanyInitialTarget = summary.authProvinceCompany!.initialTargetTreeCount;
_authProvinceCompanyMonthlyTarget = summary.authProvinceCompany!.monthlyTargetTreeCount;
_authProvinceCompanyMonthIndex = summary.authProvinceCompany!.currentMonthIndex;
} else {
_hasAuthProvinceCompanyAuth = false;
}
//
if (summary.cityCompany != null) {
_hasCityCompanyAuth = true;
_cityCompanyBenefitActive = summary.cityCompany!.benefitActive;
_cityCompanyCurrentTreeCount = summary.cityCompany!.currentTreeCount;
_cityCompanyInitialTarget = summary.cityCompany!.initialTargetTreeCount;
_cityCompanyMonthlyTarget = summary.cityCompany!.monthlyTargetTreeCount;
_cityCompanyMonthIndex = summary.cityCompany!.currentMonthIndex;
} else {
_hasCityCompanyAuth = false;
}
//
if (summary.provinceCompany != null) {
_hasProvinceCompanyAuth = true;
_provinceCompanyBenefitActive = summary.provinceCompany!.benefitActive;
_provinceCompanyCurrentTreeCount = summary.provinceCompany!.currentTreeCount;
_provinceCompanyInitialTarget = summary.provinceCompany!.initialTargetTreeCount;
_provinceCompanyMonthlyTarget = summary.provinceCompany!.monthlyTargetTreeCount;
_provinceCompanyMonthIndex = summary.provinceCompany!.currentMonthIndex;
} else {
_hasProvinceCompanyAuth = false;
}
});
}
} catch (e, stackTrace) {
@ -1051,6 +1131,62 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
const SizedBox(height: 16),
//
_buildCommunityAssessment(),
//
if (_hasAuthCityCompanyAuth) ...[
const SizedBox(height: 16),
_buildRoleAssessment(
title: '市团队权益考核',
hasAuth: _hasAuthCityCompanyAuth,
benefitActive: _authCityCompanyBenefitActive,
currentTreeCount: _authCityCompanyCurrentTreeCount,
initialTarget: _authCityCompanyInitialTarget,
monthlyTarget: _authCityCompanyMonthlyTarget,
monthIndex: _authCityCompanyMonthIndex,
rewardDescription: '每新增认种 1 棵可获得 30 USDT',
),
],
//
if (_hasAuthProvinceCompanyAuth) ...[
const SizedBox(height: 16),
_buildRoleAssessment(
title: '省团队权益考核',
hasAuth: _hasAuthProvinceCompanyAuth,
benefitActive: _authProvinceCompanyBenefitActive,
currentTreeCount: _authProvinceCompanyCurrentTreeCount,
initialTarget: _authProvinceCompanyInitialTarget,
monthlyTarget: _authProvinceCompanyMonthlyTarget,
monthIndex: _authProvinceCompanyMonthIndex,
rewardDescription: '每新增认种 1 棵可获得 10 USDT',
),
],
//
if (_hasCityCompanyAuth) ...[
const SizedBox(height: 16),
_buildRoleAssessment(
title: '市区域权益考核',
hasAuth: _hasCityCompanyAuth,
benefitActive: _cityCompanyBenefitActive,
currentTreeCount: _cityCompanyCurrentTreeCount,
initialTarget: _cityCompanyInitialTarget,
monthlyTarget: _cityCompanyMonthlyTarget,
monthIndex: _cityCompanyMonthIndex,
rewardDescription: '每新增认种 1 棵可获得 20 USDT',
),
],
//
if (_hasProvinceCompanyAuth) ...[
const SizedBox(height: 16),
_buildRoleAssessment(
title: '省区域权益考核',
hasAuth: _hasProvinceCompanyAuth,
benefitActive: _provinceCompanyBenefitActive,
currentTreeCount: _provinceCompanyCurrentTreeCount,
initialTarget: _provinceCompanyInitialTarget,
monthlyTarget: _provinceCompanyMonthlyTarget,
monthIndex: _provinceCompanyMonthIndex,
rewardDescription: '每新增认种 1 棵可获得 10 USDT',
),
],
const SizedBox(height: 16),
//
_buildSettingsMenu(),
@ -2080,6 +2216,205 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
);
}
///
/// [title] "市团队权益考核"
/// [hasAuth]
/// [benefitActive]
/// [currentTreeCount]
/// [initialTarget]
/// [monthlyTarget]
/// [monthIndex]
/// [rewardDescription]
Widget _buildRoleAssessment({
required String title,
required bool hasAuth,
required bool benefitActive,
required int currentTreeCount,
required int initialTarget,
required int monthlyTarget,
required int monthIndex,
required String rewardDescription,
}) {
//
if (!hasAuth) {
return const SizedBox.shrink();
}
//
final target = benefitActive ? monthlyTarget : initialTarget;
final progressRatio = target > 0
? (currentTreeCount / target).clamp(0.0, 1.0)
: 0.0;
//
final String statusText;
final Color statusColor;
if (benefitActive) {
statusText = '已激活';
statusColor = const Color(0xFF4CAF50); // 绿
} else {
statusText = '待激活';
statusColor = const Color(0xFFFF9800); //
}
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: const Color(0x80FFFFFF),
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: const Color(0x33D4AF37),
width: 1,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
//
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: const TextStyle(
fontSize: 18,
fontFamily: 'Inter',
fontWeight: FontWeight.w700,
height: 1.56,
color: Color(0xFF5D4037),
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: statusColor.withOpacity(0.15),
borderRadius: BorderRadius.circular(4),
),
child: Text(
statusText,
style: TextStyle(
fontSize: 12,
fontFamily: 'Inter',
fontWeight: FontWeight.w600,
color: statusColor,
),
),
),
],
),
const SizedBox(height: 15),
//
if (benefitActive && monthIndex > 0) ...[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'当前考核月份',
style: TextStyle(
fontSize: 14,
fontFamily: 'Inter',
fontWeight: FontWeight.w500,
height: 1.43,
color: Color(0xCC5D4037),
),
),
Text(
'$monthIndex',
style: const TextStyle(
fontSize: 14,
fontFamily: 'Inter',
fontWeight: FontWeight.w700,
height: 1.43,
color: Color(0xFF5D4037),
),
),
],
),
const SizedBox(height: 16),
],
// /
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
benefitActive ? '团队认种 / 月度目标' : '团队认种 / 激活目标',
style: const TextStyle(
fontSize: 14,
fontFamily: 'Inter',
fontWeight: FontWeight.w500,
height: 1.43,
color: Color(0xCC5D4037),
),
),
Text(
'$currentTreeCount / $target',
style: const TextStyle(
fontSize: 14,
fontFamily: 'Inter',
fontWeight: FontWeight.w500,
height: 1.43,
color: Color(0xFF5D4037),
),
),
],
),
const SizedBox(height: 4),
//
Container(
height: 6,
decoration: BoxDecoration(
color: const Color(0x33D4AF37),
borderRadius: BorderRadius.circular(3),
),
child: FractionallySizedBox(
alignment: Alignment.centerLeft,
widthFactor: progressRatio,
child: Container(
decoration: BoxDecoration(
color: const Color(0xFFD4AF37),
borderRadius: BorderRadius.circular(3),
),
),
),
),
const SizedBox(height: 16),
//
Row(
children: [
const Text(
'贡献奖励',
style: TextStyle(
fontSize: 14,
fontFamily: 'Inter',
fontWeight: FontWeight.w500,
height: 1.43,
color: Color(0xCC5D4037),
),
),
const SizedBox(width: 39),
Expanded(
child: Text(
benefitActive
? rewardDescription
: '需团队认种达到 $initialTarget 棵激活',
style: TextStyle(
fontSize: 14,
fontFamily: 'Inter',
fontWeight: FontWeight.w500,
height: 1.43,
color: benefitActive
? const Color(0xFFD4AF37)
: const Color(0x995D4037),
),
),
),
],
),
],
),
);
}
///
Widget _buildSettingsMenu() {
return Container(