fix(mining-app): C2C"我的"列表待接单订单增加取消按钮
在我的订单卡片上直接显示取消按钮(PENDING状态), 弹出确认对话框后调用 cancelOrder API Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
7c416adecd
commit
9e83127113
|
|
@ -509,10 +509,30 @@ class _C2cMarketPageState extends ConsumerState<C2cMarketPage>
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
// 时间
|
// 时间 + 操作按钮
|
||||||
Text(
|
Row(
|
||||||
'创建于 ${_formatDateTime(order.createdAt)}',
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
style: TextStyle(fontSize: 12, color: AppColors.textSecondaryOf(context)),
|
children: [
|
||||||
|
Text(
|
||||||
|
'创建于 ${_formatDateTime(order.createdAt)}',
|
||||||
|
style: TextStyle(fontSize: 12, color: AppColors.textSecondaryOf(context)),
|
||||||
|
),
|
||||||
|
if (order.status == C2cOrderStatus.pending)
|
||||||
|
GestureDetector(
|
||||||
|
onTap: () => _handleCancelOrder(order),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(color: _red.withOpacity(0.5)),
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
'取消',
|
||||||
|
style: TextStyle(fontSize: 12, color: _red),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -962,6 +982,45 @@ class _C2cMarketPageState extends ConsumerState<C2cMarketPage>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _handleCancelOrder(C2cOrderModel order) async {
|
||||||
|
final confirmed = await showDialog<bool>(
|
||||||
|
context: context,
|
||||||
|
builder: (ctx) => AlertDialog(
|
||||||
|
title: const Text('确认取消'),
|
||||||
|
content: const Text('确定要取消此订单吗?'),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(ctx, false),
|
||||||
|
child: const Text('暂不'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(ctx, true),
|
||||||
|
child: Text('确认取消', style: TextStyle(color: _red)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (confirmed != true) return;
|
||||||
|
|
||||||
|
final notifier = ref.read(c2cTradingNotifierProvider.notifier);
|
||||||
|
final success = await notifier.cancelOrder(order.orderNo);
|
||||||
|
|
||||||
|
if (success && mounted) {
|
||||||
|
ref.invalidate(myC2cOrdersProvider);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('订单已取消'), backgroundColor: _green),
|
||||||
|
);
|
||||||
|
} else if (mounted) {
|
||||||
|
final error = ref.read(c2cTradingNotifierProvider).error;
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text('取消失败: ${error ?? '未知错误'}'),
|
||||||
|
backgroundColor: _red,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _takeOrder(
|
Future<void> _takeOrder(
|
||||||
C2cOrderModel order, {
|
C2cOrderModel order, {
|
||||||
String? quantity,
|
String? quantity,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue