From ef68b7b9c0349cb536cddbcadb8c72e389387a24 Mon Sep 17 00:00:00 2001 From: hailin Date: Thu, 26 Feb 2026 23:11:53 -0800 Subject: [PATCH] =?UTF-8?q?fix(pre-planting):=20=E9=A2=84=E7=A7=8D?= =?UTF-8?q?=E5=BC=80=E5=85=B3=E5=85=B3=E9=97=AD=E6=97=B6=E9=9A=90=E8=97=8F?= =?UTF-8?q?"=E6=88=91=E7=9A=84"=E9=A1=B5=E9=9D=A2=E9=A2=84=E7=A7=8D?= =?UTF-8?q?=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - profile_page: 加载预种配置,根据 isActive 控制预种按钮显隐 - 开关关闭时不显示「预种购买」「预种明细」按钮 - 默认不显示(_isPrePlantingActive = false),加载成功后更新 Co-Authored-By: Claude Opus 4.6 --- .../presentation/pages/profile_page.dart | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart b/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart index 9aadf541..4580b191 100644 --- a/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart +++ b/frontend/mobile-app/lib/features/profile/presentation/pages/profile_page.dart @@ -191,6 +191,9 @@ class _ProfilePageState extends ConsumerState { Timer? _walletDebounceTimer; static const int _debounceDelayMs = 300; // 300ms 防抖延迟 + // 预种计划开关状态(后台管理端控制) + bool _isPrePlantingActive = false; + // 隐藏"我的团队"功能的秘密点击计数器 int _teamPlantingTapCount = 0; DateTime? _lastTeamPlantingTapTime; @@ -212,6 +215,8 @@ class _ProfilePageState extends ConsumerState { }); // 启动定时刷新(可见区域的数据) _startAutoRefreshTimer(); + // 加载预种开关状态(控制预种按钮显隐) + _loadPrePlantingConfig(); } /// 加载应用信息 @@ -1234,6 +1239,20 @@ class _ProfilePageState extends ConsumerState { context.push(RoutePaths.plantingQuantity); } + /// 加载预种开关配置(控制预种按钮显隐) + Future _loadPrePlantingConfig() async { + try { + final prePlantingService = ref.read(prePlantingServiceProvider); + final config = await prePlantingService.getConfig(); + if (mounted) { + setState(() => _isPrePlantingActive = config.isActive); + } + } catch (e) { + debugPrint('[ProfilePage] 加载预种配置失败: $e'); + // 失败时保持 false,不显示预种按钮 + } + } + /// [2026-02-17] 进入预种计划购买页 void _goToPrePlantingPurchase() { context.push(RoutePaths.prePlantingPurchase); @@ -1440,8 +1459,11 @@ class _ProfilePageState extends ConsumerState { _buildPlantingButton(), const SizedBox(height: 8), // [2026-02-17] 预种计划按钮(购买 + 查看持仓) - _buildPrePlantingButtons(), - const SizedBox(height: 8), + // 仅在后台管理端预种开关开启时显示 + if (_isPrePlantingActive) ...[ + _buildPrePlantingButtons(), + const SizedBox(height: 8), + ], // [2026-02-19] 纯新增:树转让按钮(发起转让 + 转让记录) _buildTransferButtons(), const SizedBox(height: 16),