fix(mobile-app): 修复认种向导完成后无法返回待办页面的问题

问题:认种向导完成后使用 context.go() 跳转到合同签署页面,
替换了整个导航栈,导致合同签署完成后无法返回待办页面继续处理其他待办。

修复:改用 context.push() 跳转到合同签署页面,保留导航栈,
合同签署完成后可以正确返回待办页面。

同时添加了详细的调试日志,便于排查问题。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-09 02:43:23 -08:00
parent 1a617e02f8
commit 96a84cc281
2 changed files with 34 additions and 4 deletions

View File

@ -62,38 +62,50 @@ class _PendingActionsPageState extends ConsumerState<PendingActionsPage> {
/// ///
Future<void> _executeCurrentAction() async { Future<void> _executeCurrentAction() async {
debugPrint('[PendingActionsPage] _executeCurrentAction: 开始执行, currentIndex=$_currentIndex, total=${_pendingActions.length}');
if (_currentIndex >= _pendingActions.length) { if (_currentIndex >= _pendingActions.length) {
debugPrint('[PendingActionsPage] _executeCurrentAction: 已完成所有操作,跳转');
_completeAllActions(); _completeAllActions();
return; return;
} }
final action = _pendingActions[_currentIndex]; final action = _pendingActions[_currentIndex];
debugPrint('[PendingActionsPage] _executeCurrentAction: 执行操作 ${action.actionCode} (id=${action.id})');
setState(() => _isExecuting = true); setState(() => _isExecuting = true);
try { try {
// //
final result = await _executeAction(action); final result = await _executeAction(action);
debugPrint('[PendingActionsPage] _executeCurrentAction: _executeAction 返回 $result');
if (result) { if (result) {
// //
debugPrint('[PendingActionsPage] _executeCurrentAction: 调用后端 completeAction');
final service = ref.read(pendingActionServiceProvider); final service = ref.read(pendingActionServiceProvider);
await service.completeAction(action.id); await service.completeAction(action.id);
debugPrint('[PendingActionsPage] _executeCurrentAction: completeAction 成功');
// //
setState(() { setState(() {
_currentIndex++; _currentIndex++;
_isExecuting = false; _isExecuting = false;
}); });
debugPrint('[PendingActionsPage] _executeCurrentAction: 移动到下一个操作, currentIndex=$_currentIndex');
// //
if (_currentIndex >= _pendingActions.length) { if (_currentIndex >= _pendingActions.length) {
debugPrint('[PendingActionsPage] _executeCurrentAction: 所有操作完成,跳转');
_completeAllActions(); _completeAllActions();
} else {
debugPrint('[PendingActionsPage] _executeCurrentAction: 还有 ${_pendingActions.length - _currentIndex} 个待办操作');
} }
} else { } else {
// //
debugPrint('[PendingActionsPage] _executeCurrentAction: 操作未完成(result=false),保持当前操作');
setState(() => _isExecuting = false); setState(() => _isExecuting = false);
} }
} catch (e) { } catch (e) {
debugPrint('[PendingActionsPage] _executeCurrentAction: 发生异常: $e');
setState(() { setState(() {
_isExecuting = false; _isExecuting = false;
_errorMessage = '操作失败: $e'; _errorMessage = '操作失败: $e';
@ -114,11 +126,19 @@ class _PendingActionsPageState extends ConsumerState<PendingActionsPage> {
switch (action.actionCode) { switch (action.actionCode) {
case 'ADOPTION_WIZARD': case 'ADOPTION_WIZARD':
// //
debugPrint('[PendingActionsPage] ADOPTION_WIZARD: push 到认种向导页面');
final result = await context.push<bool>(RoutePaths.plantingQuantity); final result = await context.push<bool>(RoutePaths.plantingQuantity);
if (result == true) return true; debugPrint('[PendingActionsPage] ADOPTION_WIZARD: 认种向导返回result=$result');
if (result == true) {
debugPrint('[PendingActionsPage] ADOPTION_WIZARD: 返回 true标记完成');
return true;
}
// 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': case 'SETTLE_REWARDS':
// API // API

View File

@ -293,6 +293,7 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
} }
} else if (mounted) { } else if (mounted) {
// - // -
debugPrint('[PlantingLocation] 已完成实名认证,准备跳转到合同签署页面');
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
const SnackBar( const SnackBar(
content: Text('认种成功请在24小时内完成合同签署'), content: Text('认种成功请在24小时内完成合同签署'),
@ -300,8 +301,17 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
), ),
); );
// // 使 push 便
context.go('${RoutePaths.contractSigning}/${widget.orderNo}'); debugPrint('[PlantingLocation] push 到合同签署页面: ${RoutePaths.contractSigning}/${widget.orderNo}');
final signResult = await context.push<bool>('${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] 无法 popmounted=$mounted, canPop=${mounted ? context.canPop() : "N/A"}');
}
return; return;
} }
} else { } else {