From e08959263aede3eb00b6e9d25c5e5cee0d7fc1a8 Mon Sep 17 00:00:00 2001 From: hailin Date: Sat, 3 Jan 2026 18:21:26 -0800 Subject: [PATCH] =?UTF-8?q?fix(mobile-app):=20=E4=BF=AE=E5=A4=8D=E5=BE=85?= =?UTF-8?q?=E5=8A=9E=E6=93=8D=E4=BD=9C=E5=AE=8C=E6=88=90=E5=90=8E=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=AD=A3=E7=A1=AE=E8=BF=94=E5=9B=9E=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题: - 合同签署成功后使用 context.go('/profile') 直接跳转 - 导致从待办操作或待签合同列表 push 进来时收不到返回值 - 认种向导完成后同样使用 go 跳转,不会返回 修复: 1. contract_signing_page.dart - 签署成功后检查 canPop() 判断是否可以返回 - 如果可以 pop(从待办操作/待签列表进入),返回 pop(true) - 否则(从认种流程/KYC流程进入),跳转 go('/profile') 2. pending_actions_page.dart - ADOPTION_WIZARD 添加后置检查(通过待签合同判断认种是否完成) - 在 _checkIfAlreadyCompleted 中添加 ADOPTION_WIZARD 检查逻辑 兼容性: - 不影响正常的认种流程(使用 go 进入合同签署) - 不影响 KYC 流程(使用 go 进入合同签署) - 待签合同列表页面正常工作 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../pages/contract_signing_page.dart | 17 +++++++++++++---- .../pages/pending_actions_page.dart | 16 +++++++++++++++- 2 files changed, 28 insertions(+), 5 deletions(-) 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;