diff --git a/lib/controller/message/call_controller.dart b/lib/controller/message/call_controller.dart index da44f39..291bbea 100644 --- a/lib/controller/message/call_controller.dart +++ b/lib/controller/message/call_controller.dart @@ -168,6 +168,7 @@ class CallController extends GetxController { if (!response.data.data!.success && response.data.data!.code == 'E0002') { // 玫瑰不足,显示 toast 并弹出充值弹框 SmartDialog.showToast('玫瑰不足请充值'); + isCreatingChannel.value = false; Get.log('❌ 送礼失败: ${response.data.data}'); // 使用 addPostFrameCallback 确保在下一帧显示弹框,避免与 toast 冲突 WidgetsBinding.instance.addPostFrameCallback((_) { @@ -259,15 +260,17 @@ class CallController extends GetxController { type: type, toUserId: targetUserId, ); - _callUid = channelData?.uid; - _callChannelId = channelData?.channelId; - if (channelData == null) { + if (channelData == null) { + return false; + } + if (!channelData.success) { print('❌ [CallController] 创建RTC频道失败,无法发起通话'); SmartDialog.showToast('创建通话频道失败'); return false; } - - print('✅ [CallController] RTC频道创建成功: ${channelData.channelId}'); + _callUid = channelData?.uid; + _callChannelId = channelData?.channelId; + print('✅ [CallController] RTC频道创建成功: ${channelData!.channelId}'); // 创建通话会话 final session = CallSession( @@ -447,6 +450,9 @@ class CallController extends GetxController { // 接收方接听后,立即调用一次消费接口并启动定时器 // 确保 _callChannelId 已设置 if (_callChannelId != null && _callChannelId!.isNotEmpty) { + Future .delayed(Duration(seconds: 1), () async { + await _consumeOneOnOneRtcChannel(); + }); _startConsumeTimer(); print('✅ [CallController] 接收方接听后已启动消费定时器'); } diff --git a/lib/widget/message/call_type_selection_dialog.dart b/lib/widget/message/call_type_selection_dialog.dart index 21658d4..96072fe 100644 --- a/lib/widget/message/call_type_selection_dialog.dart +++ b/lib/widget/message/call_type_selection_dialog.dart @@ -38,11 +38,18 @@ class CallTypeSelectionDialog extends StatelessWidget { /// 格式化价格显示 String _formatPrice(ChatAudioProductModel? product) { if (product == null) return '35玫瑰/分钟'; + + // 如果是免费产品,不显示分钟 + if (product.isFreeProduct) { + return ''; + } + return '${product.unitSellingPrice.toInt()}玫瑰/分钟'; } @override Widget build(BuildContext context) { + String price = _formatPrice(voiceProduct); return Container( decoration: BoxDecoration( color: Colors.white, @@ -65,7 +72,7 @@ class CallTypeSelectionDialog extends StatelessWidget { padding: EdgeInsets.symmetric(vertical: 16.w), child: Center( child: Text( - '语音通话 (${_formatPrice(voiceProduct)})', + price.isNotEmpty ? '语音通话 ($price)' : '语音通话', style: TextStyle( fontSize: 16.sp, color: const Color.fromRGBO(51, 51, 51, 1), @@ -91,7 +98,7 @@ class CallTypeSelectionDialog extends StatelessWidget { padding: EdgeInsets.symmetric(vertical: 16.w), child: Center( child: Text( - '视频通话 (${_formatPrice(videoProduct)})', + price.isNotEmpty ? '视频通话 ($price)' : '视频通话', style: TextStyle( fontSize: 16.sp, color: const Color.fromRGBO(51, 51, 51, 1),