|
|
|
@ -5,8 +5,10 @@ import 'package:dating_touchme_app/controller/global.dart'; |
|
|
|
import 'package:dating_touchme_app/controller/overlay_controller.dart'; |
|
|
|
import 'package:dating_touchme_app/extension/ex_widget.dart'; |
|
|
|
import 'package:dating_touchme_app/generated/assets.dart'; |
|
|
|
import 'package:dating_touchme_app/im/im_manager.dart'; |
|
|
|
import 'package:dating_touchme_app/model/discover/task_data.dart'; |
|
|
|
import 'package:dating_touchme_app/model/live/gift_product_model.dart'; |
|
|
|
import 'package:dating_touchme_app/model/mine/chat_static_data.dart'; |
|
|
|
import 'package:dating_touchme_app/model/rtc/link_mic_card_model.dart'; |
|
|
|
import 'package:dating_touchme_app/model/rtc/rtc_channel_data.dart'; |
|
|
|
import 'package:dating_touchme_app/model/rtc/rtc_channel_detail.dart'; |
|
|
|
@ -108,6 +110,49 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
chatMessages.clear(); |
|
|
|
} |
|
|
|
|
|
|
|
final durationMins = 0.obs; |
|
|
|
|
|
|
|
getDurationMins() async { |
|
|
|
try { |
|
|
|
final channelId = RTCManager.instance.currentChannelId; |
|
|
|
final response = await _networkService.rtcApi.userGetRtcChannelAbstract(channelId: channelId ?? ""); |
|
|
|
if (response.data.isSuccess && response.data.data != null) { |
|
|
|
durationMins.value = response.data.data?.durationMins ?? 0; |
|
|
|
} else { |
|
|
|
|
|
|
|
// 响应失败,抛出异常 |
|
|
|
throw Exception(response.data.message ?? '获取数据失败'); |
|
|
|
} |
|
|
|
} catch(e){ |
|
|
|
print('钱包数据获取失败: $e'); |
|
|
|
SmartDialog.showToast('钱包数据获取失败'); |
|
|
|
rethrow; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final consumption = ChatStaticData(todayLiveDurationMins: 0).obs; |
|
|
|
|
|
|
|
getLiveData() async { |
|
|
|
try { |
|
|
|
final channelId = RTCManager.instance.currentChannelId; |
|
|
|
final response = await _networkService.userApi.getChatStaticsInfo(); |
|
|
|
if (response.data.isSuccess && response.data.data != null) { |
|
|
|
consumption.value = response.data.data!; |
|
|
|
} else { |
|
|
|
|
|
|
|
// 响应失败,抛出异常 |
|
|
|
throw Exception(response.data.message ?? '获取数据失败'); |
|
|
|
} |
|
|
|
} catch(e){ |
|
|
|
print('钱包数据获取失败: $e'); |
|
|
|
SmartDialog.showToast('钱包数据获取失败'); |
|
|
|
rethrow; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
final tab = 0.obs; |
|
|
|
|
|
|
|
changeTab(int i) async { |
|
|
|
@ -126,6 +171,7 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
audienceList.clear(); |
|
|
|
await getFriendList(); |
|
|
|
} |
|
|
|
update(); |
|
|
|
listRefreshController.finishRefresh(IndicatorResult.success); |
|
|
|
listRefreshController.finishLoad(IndicatorResult.none); |
|
|
|
} |
|
|
|
@ -155,6 +201,7 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
} else { |
|
|
|
listRefreshController.finishLoad(IndicatorResult.noMore); |
|
|
|
} |
|
|
|
update(); |
|
|
|
} else { |
|
|
|
|
|
|
|
// 响应失败,抛出异常 |
|
|
|
@ -186,6 +233,7 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
} else { |
|
|
|
listRefreshController.finishLoad(IndicatorResult.noMore); |
|
|
|
} |
|
|
|
update(); |
|
|
|
} else { |
|
|
|
|
|
|
|
// 响应失败,抛出异常 |
|
|
|
@ -232,6 +280,7 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
} else { |
|
|
|
listRefreshController.finishLoad(IndicatorResult.noMore); |
|
|
|
} |
|
|
|
update(); |
|
|
|
} else { |
|
|
|
|
|
|
|
// 响应失败,抛出异常 |
|
|
|
@ -1211,13 +1260,37 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
inviteMic(List<String> selectUserId) async { |
|
|
|
|
|
|
|
int calculateAge(String birthdayStr) { |
|
|
|
final birthday = DateTime.parse(birthdayStr); // 自动识别 1996-1-20 |
|
|
|
final today = DateTime.now(); |
|
|
|
|
|
|
|
int age = today.year - birthday.year; |
|
|
|
|
|
|
|
// 如果今年生日还没过,年龄要减 1 |
|
|
|
if (today.month < birthday.month || |
|
|
|
(today.month == birthday.month && today.day < birthday.day)) { |
|
|
|
age--; |
|
|
|
} |
|
|
|
|
|
|
|
return age; |
|
|
|
} |
|
|
|
|
|
|
|
inviteMic(List<Map<String, dynamic>> selectUserId) async { |
|
|
|
try { |
|
|
|
final channelName = RTCManager.instance.currentChannelId; |
|
|
|
if (channelName != null && channelName.isNotEmpty) { |
|
|
|
|
|
|
|
final idIsNull = selectUserId |
|
|
|
.where((e) => e["uid"] == 0) |
|
|
|
.toList(); |
|
|
|
final idNotNull = selectUserId |
|
|
|
.where((e) => e["uid"] != 0) |
|
|
|
.toList(); |
|
|
|
final userIds = idNotNull.map((e) => e["userId"]).toList(); |
|
|
|
final messageData = { |
|
|
|
'type': 'invite_to_mic', |
|
|
|
'userId': selectUserId, |
|
|
|
'userId': userIds, |
|
|
|
'operatorId': GlobalData().userData?.id ?? '', |
|
|
|
'operatorName': GlobalData().userData?.nickName ?? '', |
|
|
|
}; |
|
|
|
@ -1226,6 +1299,58 @@ class RoomController extends GetxController with WidgetsBindingObserver { |
|
|
|
channelName: channelName, |
|
|
|
message: json.encode(messageData), |
|
|
|
); |
|
|
|
|
|
|
|
final others = idIsNull.map((e) => e["userId"]).toList(); |
|
|
|
|
|
|
|
final channelId = RTCManager.instance.currentChannelId; |
|
|
|
if (channelId == null || channelId.isEmpty) { |
|
|
|
SmartDialog.showToast('频道ID不存在'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 获取房间详情 |
|
|
|
final channelDetail = rtcChannelDetail.value; |
|
|
|
final anchorName = channelDetail?.anchorInfo?.nickName ?? '主持人'; |
|
|
|
final anchorAvatar = channelDetail?.anchorInfo?.profilePhoto ?? ''; |
|
|
|
|
|
|
|
// 确保头像和封面URL不为空且格式正确 |
|
|
|
final cleanedAvatar = anchorAvatar.trim().replaceAll('`', ''); |
|
|
|
final cleanedCover = cleanedAvatar; // 封面使用主持人头像 |
|
|
|
|
|
|
|
// 构建消息参数,包含房间信息(不需要 type 字段,因为 event 已经是 'live_room_invite') |
|
|
|
final messageParams = <String, String>{ |
|
|
|
'channelId': channelId, |
|
|
|
'anchorAvatar': cleanedAvatar, |
|
|
|
'anchorName': anchorName, |
|
|
|
'coverImage': cleanedCover, // 封面使用主持人头像 |
|
|
|
'genderCode': GlobalData().userData?.genderCode.toString() ?? "", |
|
|
|
"age": calculateAge( |
|
|
|
(GlobalData().userData?.birthDate != null && GlobalData().userData!.birthDate!.isNotEmpty) ? |
|
|
|
(GlobalData().userData?.birthDate ?? "") : GlobalData().userData?.birthYear != null && GlobalData().userData!.birthYear!.isNotEmpty ? |
|
|
|
"${GlobalData().userData?.birthYear}-01-01" : "").toString(), |
|
|
|
"provinceName": GlobalData().userData?.provinceName ?? "", |
|
|
|
}; |
|
|
|
|
|
|
|
print('📤 [LiveRoomGuestListDialog] 发送房间邀请消息: anchorAvatar=$cleanedAvatar, coverImage=$cleanedCover'); |
|
|
|
|
|
|
|
others.forEach((e) async { |
|
|
|
// 发送自定义消息 |
|
|
|
final result = await IMManager.instance.sendCustomMessage( |
|
|
|
e, |
|
|
|
'live_room_invite', |
|
|
|
messageParams, |
|
|
|
); |
|
|
|
|
|
|
|
if (result != null) { |
|
|
|
SmartDialog.showToast('邀请已发送'); |
|
|
|
SmartDialog.dismiss(); |
|
|
|
} else { |
|
|
|
SmartDialog.showToast('邀请发送失败,id$e'); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print('✅ 邀请消息已发送: 邀请用户ID $selectUserId'); |
|
|
|
|
|
|
|
// 刷新频道详情 |
|
|
|
|