diff --git a/frontend/mobile-app/lib/features/contract_signing/presentation/pages/contract_signing_page.dart b/frontend/mobile-app/lib/features/contract_signing/presentation/pages/contract_signing_page.dart index b4aa3b17..fd7768e3 100644 --- a/frontend/mobile-app/lib/features/contract_signing/presentation/pages/contract_signing_page.dart +++ b/frontend/mobile-app/lib/features/contract_signing/presentation/pages/contract_signing_page.dart @@ -354,11 +354,15 @@ class _ContractSigningPageState extends ConsumerState { }); if (mounted) { + // 保存外层 context 的 canPop 状态(对话框内的 context 不同) + final outerContext = context; + final canPopBack = outerContext.canPop(); + // 显示成功对话框 await showDialog( context: context, barrierDismissible: false, - builder: (context) => AlertDialog( + builder: (dialogContext) => AlertDialog( title: const Row( children: [ Icon(Icons.check_circle, color: Colors.green, size: 28), @@ -370,9 +374,14 @@ class _ContractSigningPageState extends ConsumerState { actions: [ TextButton( onPressed: () { - Navigator.of(context).pop(); // 关闭对话框 - // 跳转到"我的"页面 - context.go('/profile'); + Navigator.of(dialogContext).pop(); // 关闭对话框 + // 如果可以 pop(说明是从待办操作或待签合同列表 push 进来的),返回 true + // 否则跳转到个人页面 + if (canPopBack) { + outerContext.pop(true); + } else { + outerContext.go('/profile'); + } }, child: const Text('完成'), ), diff --git a/frontend/mobile-app/lib/features/pending_actions/presentation/pages/pending_actions_page.dart b/frontend/mobile-app/lib/features/pending_actions/presentation/pages/pending_actions_page.dart index 4689ba58..9a08a36f 100644 --- a/frontend/mobile-app/lib/features/pending_actions/presentation/pages/pending_actions_page.dart +++ b/frontend/mobile-app/lib/features/pending_actions/presentation/pages/pending_actions_page.dart @@ -114,7 +114,10 @@ class _PendingActionsPageState extends ConsumerState { case 'ADOPTION_WIZARD': // 跳转到认种向导 final result = await context.push(RoutePaths.plantingQuantity); - return result == true; + if (result == true) return true; + // 认种向导完成后会跳转到合同签署页面,不会返回 true + // 通过检查是否有待签合同来判断是否完成认种 + return await _checkIfAlreadyCompleted(action); case 'SETTLE_REWARDS': // 直接调用结算 API 将可结算收益转入钱包余额 @@ -258,6 +261,17 @@ class _PendingActionsPageState extends ConsumerState { } return false; + case 'ADOPTION_WIZARD': + // 检查是否有待签署的合同(认种完成后会生成合同) + // 如果有待签合同,说明认种已完成 + final contractService = ref.read(contractSigningServiceProvider); + final pendingTasks = await contractService.getPendingTasks(); + if (pendingTasks.isNotEmpty) { + debugPrint('[PendingActionsPage] 存在待签合同,认种向导已完成'); + return true; + } + return false; + // 其他操作类型目前不做预检查 default: return false;