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 295468d3..170e1718 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 @@ -62,38 +62,50 @@ class _PendingActionsPageState extends ConsumerState { /// 执行当前待办操作 Future _executeCurrentAction() async { + debugPrint('[PendingActionsPage] _executeCurrentAction: 开始执行, currentIndex=$_currentIndex, total=${_pendingActions.length}'); if (_currentIndex >= _pendingActions.length) { + debugPrint('[PendingActionsPage] _executeCurrentAction: 已完成所有操作,跳转'); _completeAllActions(); return; } final action = _pendingActions[_currentIndex]; + debugPrint('[PendingActionsPage] _executeCurrentAction: 执行操作 ${action.actionCode} (id=${action.id})'); setState(() => _isExecuting = true); try { // 根据不同的操作类型执行不同的逻辑 final result = await _executeAction(action); + debugPrint('[PendingActionsPage] _executeCurrentAction: _executeAction 返回 $result'); if (result) { // 操作执行成功,标记为完成 + debugPrint('[PendingActionsPage] _executeCurrentAction: 调用后端 completeAction'); final service = ref.read(pendingActionServiceProvider); await service.completeAction(action.id); + debugPrint('[PendingActionsPage] _executeCurrentAction: completeAction 成功'); // 移动到下一个操作 setState(() { _currentIndex++; _isExecuting = false; }); + debugPrint('[PendingActionsPage] _executeCurrentAction: 移动到下一个操作, currentIndex=$_currentIndex'); // 检查是否所有操作都完成 if (_currentIndex >= _pendingActions.length) { + debugPrint('[PendingActionsPage] _executeCurrentAction: 所有操作完成,跳转'); _completeAllActions(); + } else { + debugPrint('[PendingActionsPage] _executeCurrentAction: 还有 ${_pendingActions.length - _currentIndex} 个待办操作'); } } else { // 用户取消或操作失败,保持在当前操作 + debugPrint('[PendingActionsPage] _executeCurrentAction: 操作未完成(result=false),保持当前操作'); setState(() => _isExecuting = false); } } catch (e) { + debugPrint('[PendingActionsPage] _executeCurrentAction: 发生异常: $e'); setState(() { _isExecuting = false; _errorMessage = '操作失败: $e'; @@ -114,11 +126,19 @@ class _PendingActionsPageState extends ConsumerState { switch (action.actionCode) { case 'ADOPTION_WIZARD': // 跳转到认种向导 + debugPrint('[PendingActionsPage] ADOPTION_WIZARD: push 到认种向导页面'); final result = await context.push(RoutePaths.plantingQuantity); - if (result == true) return true; + debugPrint('[PendingActionsPage] ADOPTION_WIZARD: 认种向导返回,result=$result'); + if (result == true) { + debugPrint('[PendingActionsPage] ADOPTION_WIZARD: 返回 true,标记完成'); + return true; + } // 认种向导完成后会跳转到合同签署页面,不会返回 true // 通过检查是否有待签合同来判断是否完成认种 - return await _checkIfAlreadyCompleted(action); + debugPrint('[PendingActionsPage] ADOPTION_WIZARD: 返回不是 true,检查是否已完成'); + final alreadyDone = await _checkIfAlreadyCompleted(action); + debugPrint('[PendingActionsPage] ADOPTION_WIZARD: _checkIfAlreadyCompleted 返回 $alreadyDone'); + return alreadyDone; case 'SETTLE_REWARDS': // 直接调用结算 API 将可结算收益转入钱包余额 diff --git a/frontend/mobile-app/lib/features/planting/presentation/pages/planting_location_page.dart b/frontend/mobile-app/lib/features/planting/presentation/pages/planting_location_page.dart index bb7693f0..ea61dc4f 100644 --- a/frontend/mobile-app/lib/features/planting/presentation/pages/planting_location_page.dart +++ b/frontend/mobile-app/lib/features/planting/presentation/pages/planting_location_page.dart @@ -293,6 +293,7 @@ class _PlantingLocationPageState extends ConsumerState { } } else if (mounted) { // 已完成实名认证 - 直接跳转到合同签署页面 + debugPrint('[PlantingLocation] 已完成实名认证,准备跳转到合同签署页面'); ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('认种成功!请在24小时内完成合同签署'), @@ -300,8 +301,17 @@ class _PlantingLocationPageState extends ConsumerState { ), ); - // 跳转到合同签署页面 - context.go('${RoutePaths.contractSigning}/${widget.orderNo}'); + // 跳转到合同签署页面(使用 push 保留导航栈,以便返回待办页面) + debugPrint('[PlantingLocation] push 到合同签署页面: ${RoutePaths.contractSigning}/${widget.orderNo}'); + final signResult = await context.push('${RoutePaths.contractSigning}/${widget.orderNo}'); + debugPrint('[PlantingLocation] 合同签署页面返回,signResult=$signResult, mounted=$mounted, canPop=${context.canPop()}'); + // 签署完成后,返回 true 给调用方(待办页面) + if (mounted && context.canPop()) { + debugPrint('[PlantingLocation] pop 返回上一页,返回值: ${signResult == true}'); + context.pop(signResult == true); + } else { + debugPrint('[PlantingLocation] 无法 pop,mounted=$mounted, canPop=${mounted ? context.canPop() : "N/A"}'); + } return; } } else {