fix(mobile-app): 修复待办操作完成后无法正确返回的问题
问题:
- 合同签署成功后使用 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 <noreply@anthropic.com>
This commit is contained in:
parent
d81e230639
commit
e08959263a
|
|
@ -354,11 +354,15 @@ class _ContractSigningPageState extends ConsumerState<ContractSigningPage> {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
|
// 保存外层 context 的 canPop 状态(对话框内的 context 不同)
|
||||||
|
final outerContext = context;
|
||||||
|
final canPopBack = outerContext.canPop();
|
||||||
|
|
||||||
// 显示成功对话框
|
// 显示成功对话框
|
||||||
await showDialog(
|
await showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (context) => AlertDialog(
|
builder: (dialogContext) => AlertDialog(
|
||||||
title: const Row(
|
title: const Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.check_circle, color: Colors.green, size: 28),
|
Icon(Icons.check_circle, color: Colors.green, size: 28),
|
||||||
|
|
@ -370,9 +374,14 @@ class _ContractSigningPageState extends ConsumerState<ContractSigningPage> {
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.of(context).pop(); // 关闭对话框
|
Navigator.of(dialogContext).pop(); // 关闭对话框
|
||||||
// 跳转到"我的"页面
|
// 如果可以 pop(说明是从待办操作或待签合同列表 push 进来的),返回 true
|
||||||
context.go('/profile');
|
// 否则跳转到个人页面
|
||||||
|
if (canPopBack) {
|
||||||
|
outerContext.pop(true);
|
||||||
|
} else {
|
||||||
|
outerContext.go('/profile');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: const Text('完成'),
|
child: const Text('完成'),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,10 @@ class _PendingActionsPageState extends ConsumerState<PendingActionsPage> {
|
||||||
case 'ADOPTION_WIZARD':
|
case 'ADOPTION_WIZARD':
|
||||||
// 跳转到认种向导
|
// 跳转到认种向导
|
||||||
final result = await context.push<bool>(RoutePaths.plantingQuantity);
|
final result = await context.push<bool>(RoutePaths.plantingQuantity);
|
||||||
return result == true;
|
if (result == true) return true;
|
||||||
|
// 认种向导完成后会跳转到合同签署页面,不会返回 true
|
||||||
|
// 通过检查是否有待签合同来判断是否完成认种
|
||||||
|
return await _checkIfAlreadyCompleted(action);
|
||||||
|
|
||||||
case 'SETTLE_REWARDS':
|
case 'SETTLE_REWARDS':
|
||||||
// 直接调用结算 API 将可结算收益转入钱包余额
|
// 直接调用结算 API 将可结算收益转入钱包余额
|
||||||
|
|
@ -258,6 +261,17 @@ class _PendingActionsPageState extends ConsumerState<PendingActionsPage> {
|
||||||
}
|
}
|
||||||
return false;
|
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:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue