fix: 处理order_status异步
This commit is contained in:
@@ -102,9 +102,19 @@ class KROrderStatusView extends GetView<KROrderStatusController> {
|
||||
width: double.infinity,
|
||||
height: 48.h,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
onPressed: () async {
|
||||
// 1. 先触发业务层的数据刷新请求(确保内存数据是最新的)
|
||||
// 假设 kr_subscribeService.kr_fetchAvailableSubscribes() 返回 Future
|
||||
await controller.kr_subscribeService.kr_fetchAvailableSubscribes();
|
||||
|
||||
// 2. 发送事件总线通知
|
||||
KREventBus().kr_sendMessage(KRMessageType.kr_payment);
|
||||
// 返回到首页(清空导航栈)
|
||||
|
||||
// 3. 关键:稍微延迟一下再执行 offAllNamed
|
||||
// 这样可以确保 EventBus 的消息被其他观察者消费完毕,并让网络请求有时间在内存中沉淀
|
||||
await Future.delayed(const Duration(milliseconds: 100));
|
||||
|
||||
// 4. 返回到首页(清空导航栈)
|
||||
Get.offAllNamed(Routes.KR_HOME);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
|
||||
Reference in New Issue
Block a user