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:
parent
090c8b747e
commit
13d1bedb73
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue