Browse Source

fix(call): 修复通话状态处理逻辑并更新直播间界面显示

- 重构通话状态处理逻辑,将 cancelled 和 terminated 状态提前处理
- 添加 channelId 验证机制,避免不同频道的通话状态冲突
- 修复通话小窗口在通话取消时未正确关闭的问题
- 更新直播间连麦提示文本,根据卡片价格动态显示价格
- 修改直播间连麦按钮文本,根据用户性别显示不同文案
master
Jolie 2 months ago
parent
commit
b2c2aa9c11
2 changed files with 59 additions and 39 deletions
  1. 92
      lib/controller/message/call_controller.dart
  2. 6
      lib/widget/live/live_room_notice_chat_panel.dart

92
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<OverlayController>()) {
final overlayController = Get.find<OverlayController>();
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<OverlayController>()) {
final overlayController = Get.find<OverlayController>();
overlayController.hideVideoCall();
print('✅ [CallController] 已关闭通话小窗口');
}
// 退 VideoCallPage VideoCallPage
if (Get.currentRoute.contains('VideoCallPage')) {
Get.back();
print('✅ [CallController] 已退出 VideoCallPage');
}
}
// cancelled terminated
} catch (e) {
print('❌ [CallController] 处理callStatus变化失败: $e');
}

6
lib/widget/live/live_room_notice_chat_panel.dart

@ -56,7 +56,7 @@ class _LiveRoomNoticeChatPanelState extends State<LiveRoomNoticeChatPanel> {
// 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<LiveRoomNoticeChatPanel> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
controller.isLive.value ? '下麦结束' : '免费连麦',
controller.isLive.value
? '下麦结束'
: (GlobalData().userData?.genderCode == 0 ? '视频相亲' : '免费相亲'),
style: TextStyle(
fontSize: 13.w,
color: Colors.white,

Loading…
Cancel
Save