From b7bf36307cc4646b8b1ad46fa5a7c7f8079bfe73 Mon Sep 17 00:00:00 2001 From: Jolie <412895109@qq.com> Date: Wed, 31 Dec 2025 20:20:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(live):=20=E5=AE=9E=E7=8E=B0=E7=A4=BC?= =?UTF-8?q?=E7=89=A9=E5=BC=B9=E7=AA=97=E6=97=B6=E5=88=B7=E6=96=B0=E7=8E=AB?= =?UTF-8?q?=E7=91=B0=E6=95=B0=E9=87=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将多个礼物弹窗方法改为异步函数以支持数据刷新 - 在礼物弹窗显示前调用虚拟账户信息更新接口 - 修复房间控制器中直播状态检查逻辑 - 在消费成功后自动刷新玫瑰数量显示 --- lib/controller/discover/room_controller.dart | 7 +++---- lib/pages/discover/live_room_page.dart | 4 +++- lib/widget/live/live_room_anchor_showcase.dart | 5 ++++- lib/widget/live/live_room_chat_item.dart | 5 ++++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/controller/discover/room_controller.dart b/lib/controller/discover/room_controller.dart index 7029b7e..1cd07c1 100644 --- a/lib/controller/discover/room_controller.dart +++ b/lib/controller/discover/room_controller.dart @@ -334,10 +334,6 @@ class RoomController extends GetxController with WidgetsBindingObserver { } Future leaveChannel() async { - if(!isLive.value){ - // 如果是非直播中,不需要处理 - return; - } // 如果是主播,先销毁 RTC 频道,然后发送结束直播消息 if (currentRole == CurrentRole.broadcaster) { try { @@ -440,6 +436,9 @@ class RoomController extends GetxController with WidgetsBindingObserver { return; } + // 消费成功后刷新玫瑰数量 + await getVirtualAccount(); + // 消费成功后再添加到本地播放队列 final svgaManager = SvgaPlayerManager.instance; svgaManager.addToQueue( diff --git a/lib/pages/discover/live_room_page.dart b/lib/pages/discover/live_room_page.dart index a39219e..7927790 100644 --- a/lib/pages/discover/live_room_page.dart +++ b/lib/pages/discover/live_room_page.dart @@ -177,9 +177,11 @@ class _LiveRoomPageState extends State { message = ''; } - void _showGiftPopup() { + void _showGiftPopup() async { // 隐藏键盘 FocusScope.of(context).unfocus(); + // 刷新玫瑰数量 + await _roomController.getVirtualAccount(); SmartDialog.show( alignment: Alignment.bottomCenter, maskColor: TDTheme.of(context).fontGyColor2, diff --git a/lib/widget/live/live_room_anchor_showcase.dart b/lib/widget/live/live_room_anchor_showcase.dart index 413fdfe..d83f04a 100644 --- a/lib/widget/live/live_room_anchor_showcase.dart +++ b/lib/widget/live/live_room_anchor_showcase.dart @@ -387,7 +387,7 @@ class _LiveRoomAnchorShowcaseState extends State { ); } - void _showGiftPopupForUser(RtcSeatUserInfo? userInfo, int type) { + void _showGiftPopupForUser(RtcSeatUserInfo? userInfo, int type) async { if (userInfo == null) { return; } @@ -400,6 +400,9 @@ class _LiveRoomAnchorShowcaseState extends State { return; } + // 刷新玫瑰数量 + await _roomController.getVirtualAccount(); + // 创建必要的 ValueNotifier final activeGift = ValueNotifier(null); final giftNum = ValueNotifier(1); diff --git a/lib/widget/live/live_room_chat_item.dart b/lib/widget/live/live_room_chat_item.dart index 031fcd2..4205b43 100644 --- a/lib/widget/live/live_room_chat_item.dart +++ b/lib/widget/live/live_room_chat_item.dart @@ -16,9 +16,12 @@ class LiveRoomChatItem extends StatelessWidget { final LiveChatMessage message; - void _showGiftPopup(BuildContext context, int type) { + void _showGiftPopup(BuildContext context, int type) async { final roomController = Get.find(); + // 刷新玫瑰数量 + await roomController.getVirtualAccount(); + // 尝试从频道详情中根据 userId 找到对应的用户信息 int? targetUid = message.uid;