diff --git a/lib/controller/message/call_controller.dart b/lib/controller/message/call_controller.dart index fe5a865..12609f1 100644 --- a/lib/controller/message/call_controller.dart +++ b/lib/controller/message/call_controller.dart @@ -829,6 +829,60 @@ class CallController extends GetxController { '📞 [CallController] 处理callStatus变化: callStatus=$callStatus, channelId=$channelId', ); + // 对于 cancelled 和 terminated 状态,即使没有 currentCall,也要处理(关闭小窗口等) + if (callStatus == 'cancelled' || callStatus == 'terminated') { + final callSession = currentCall.value; + // 如果有 channelId,验证是否匹配当前通话(如果存在) + if (callSession != null && channelId != null && channelId.isNotEmpty && _callChannelId != channelId) { + print( + '⚠️ [CallController] channelId不匹配,忽略callStatus变化: 当前=$_callChannelId, 消息=$channelId', + ); + return; + } + + // 处理取消/终止状态(即使没有 callSession 也要关闭小窗口) + print( + '📞 [CallController] 通话被取消/终止,callStatus=$callStatus, hasCallSession=${callSession != null}', + ); + + // 关闭视频通话邀请弹框(如果正在显示) + SmartDialog.dismiss(); + print('✅ [CallController] 已关闭视频通话邀请弹框'); + + // 取消超时计时器 + _stopCallTimeoutTimer(); + + // 停止播放来电铃声 + stopCallAudio(); + + // 停止通话计时器 + _stopCallTimer(); + + // 离开RTC频道 + await RTCManager.instance.leaveChannel(); + + // 如果有通话会话,结束通话 + if (callSession != null) { + await endCall(callDuration: callDuration ?? callDurationSeconds.value); + } + + // 关闭通话小窗口 + if (Get.isRegistered()) { + final overlayController = Get.find(); + overlayController.hideVideoCall(); + print('✅ [CallController] 已关闭通话小窗口'); + } + + // 退出 VideoCallPage(如果当前在 VideoCallPage) + if (Get.currentRoute.contains('VideoCallPage')) { + Get.back(); + print('✅ [CallController] 已退出 VideoCallPage'); + } + + return; + } + + // 对于其他状态,需要检查是否有进行中的通话 final callSession = currentCall.value; if (callSession == null) { print('⚠️ [CallController] 当前没有进行中的通话,忽略callStatus变化'); @@ -898,44 +952,8 @@ class CallController extends GetxController { // 结束通话 await endCall(callDuration: callDurationSeconds.value); } - } else if (callStatus == 'cancelled' || callStatus == 'terminated') { - // 通话被取消或终止 - print( - '📞 [CallController] 通话被取消/终止,callStatus=$callStatus, isInitiator=${callSession.isInitiator}', - ); - - // 关闭视频通话邀请弹框(如果正在显示) - SmartDialog.dismiss(); - print('✅ [CallController] 已关闭视频通话邀请弹框'); - - // 取消超时计时器 - _stopCallTimeoutTimer(); - - // 停止播放来电铃声 - stopCallAudio(); - - // 停止通话计时器 - _stopCallTimer(); - - // 离开RTC频道 - await RTCManager.instance.leaveChannel(); - - // 结束通话 - await endCall(callDuration: callDuration ?? callDurationSeconds.value); - - // 关闭通话小窗口 - if (Get.isRegistered()) { - final overlayController = Get.find(); - overlayController.hideVideoCall(); - print('✅ [CallController] 已关闭通话小窗口'); - } - - // 退出 VideoCallPage(如果当前在 VideoCallPage) - if (Get.currentRoute.contains('VideoCallPage')) { - Get.back(); - print('✅ [CallController] 已退出 VideoCallPage'); - } } + // 注意:cancelled 和 terminated 状态已在方法开头处理,这里不再重复处理 } catch (e) { print('❌ [CallController] 处理callStatus变化失败: $e'); } diff --git a/lib/widget/live/live_room_notice_chat_panel.dart b/lib/widget/live/live_room_notice_chat_panel.dart index 23261e1..8cc4d72 100644 --- a/lib/widget/live/live_room_notice_chat_panel.dart +++ b/lib/widget/live/live_room_notice_chat_panel.dart @@ -56,7 +56,7 @@ class _LiveRoomNoticeChatPanelState extends State { // 如果 cardNum 为 0,显示"上麦20玫瑰" if (cardNum == 0) { return Text( - '上麦20玫瑰', + '上麦${linkMicCard?.unitSellingPrice}玫瑰', style: TextStyle( fontSize: 9.w, color: Colors.white.withOpacity(0.8), @@ -154,7 +154,9 @@ class _LiveRoomNoticeChatPanelState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - controller.isLive.value ? '下麦结束' : '免费连麦', + controller.isLive.value + ? '下麦结束' + : (GlobalData().userData?.genderCode == 0 ? '视频相亲' : '免费相亲'), style: TextStyle( fontSize: 13.w, color: Colors.white,