Commit 654c3e0e by suolong

添加开始表演的api

parent 4a360abd
......@@ -954,6 +954,21 @@ NS_ASSUME_NONNULL_BEGIN
succeed:(void (^)(FUSTicketShowCollectTicketToggleResultModel *model))succeed
failure:(void (^)(NSString *msg, NSInteger code))failure;
/// Ticket Show - 功能 - 主播端开始/取消表演
/// 接口:POST /ticketshow/show/toggle
/// @param roomId 房间ID
/// @param channelId 频道ID
/// @param roundId 回合ID
/// @param toggleType 操作类型(-1:取消表演 1:开始表演)
/// @param succeed 成功回调(复用 TicketShow 返回模型字段进行存储)
/// @param failure 失败回调(参数错误 code=-3)
+ (void)fus_ticketShowShowToggleWithRoomId:(NSString *)roomId
channelId:(NSString *)channelId
roundId:(NSString *)roundId
toggleType:(NSInteger)toggleType
succeed:(void (^)(FUSTicketShowCollectTicketToggleResultModel *model))succeed
failure:(void (^)(NSString *msg, NSInteger code))failure;
/// Ticket Show - 视图 - 获取表演票的集票信息(观众端进房刷新)
/// @param roomId 房间ID
/// @param channelId 频道ID
......
......@@ -3121,6 +3121,42 @@
}];
}
+ (void)fus_ticketShowShowToggleWithRoomId:(NSString *)roomId
channelId:(NSString *)channelId
roundId:(NSString *)roundId
toggleType:(NSInteger)toggleType
succeed:(void (^)(FUSTicketShowCollectTicketToggleResultModel *model))succeed
failure:(void (^)(NSString *msg, NSInteger code))failure {
NSString *uid = FUSCacheDataShare.shareStore.userDetailInfo.uid;
if ([NSString isNull:uid]
|| [NSString isNull:roomId]
|| [NSString isNull:channelId]
|| [NSString isNull:roundId]) {
if (failure) failure([NSString fus_localString:@"参数错误"], -3);
return;
}
if (toggleType != 1 && toggleType != -1) {
if (failure) failure([NSString fus_localString:@"参数错误"], -3);
return;
}
NSDictionary *params = @{
@"uid": uid,
@"roomId": roomId,
@"channelId": channelId,
@"roundId": roundId,
@"toggleType": @(toggleType)
};
[FUSHttpHelper postRequestBinaryWithUrl:FUSShowRoomURLs.fus_URL_TicketShow_Show_Toggle params:params success:^(NSDictionary * _Nullable dataDict, int code) {
FUSTicketShowCollectTicketToggleResultModel *model = [FUSTicketShowCollectTicketToggleResultModel fus_modelWithDict:dataDict];
if (succeed) succeed(model);
} failure:^(NSDictionary * _Nullable dataDict, int code) {
if (failure) failure(dataDict[@"msg"], code);
}];
}
+ (void)fus_ticketShowProgressGetInfoWithRoomId:(NSString *)roomId
channelId:(NSString *)channelId
roundId:(NSString *)roundId
......
......@@ -406,44 +406,6 @@
if (onView) {
__weak typeof(strongSelf) innerWeakSelf = strongSelf;
void (^cancelCollectTicket)(FUSLiveShowTimeCancelConfirmPopView * _Nullable) = ^(FUSLiveShowTimeCancelConfirmPopView * _Nullable popToDismiss) {
__strong typeof(innerWeakSelf) innerStrongSelf = innerWeakSelf;
if (!innerStrongSelf) {
return;
}
NSString *cancelRoundId = innerStrongSelf.showTimeRoundId;
FUSRoomInfoModel *roomInfoModel = FUSLiveHelper.shareInstance.roomInfoModel;
NSString *cancelRoomId = (respModel.stageData.roomId.length > 0 ? respModel.stageData.roomId : (respModel.roomId.length > 0 ? respModel.roomId : roomInfoModel.roomId));
NSString *cancelChannelId = (respModel.stageData.channelId.length > 0 ? respModel.stageData.channelId : (respModel.channelId.length > 0 ? respModel.channelId : roomInfoModel.channelId));
if ([NSString isNull:cancelRoundId] || [NSString isNull:cancelRoomId] || [NSString isNull:cancelChannelId]) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"当前房间信息异常"]];
return;
}
[FUSLoadingView fus_showProgressViewWithMessage:@""];
[FUSLiveHttpHelper fus_ticketShowCollectTicketToggleWithRoomId:cancelRoomId channelId:cancelChannelId toggleType:-1 roundId:cancelRoundId ticketTargetNum:0 showTheme:nil succeed:^(FUSTicketShowCollectTicketToggleResultModel * _Nonnull cancelModel) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLoadingView fus_dismissProgressView];
if (popToDismiss) {
[popToDismiss fus_dismiss];
}
[innerStrongSelf fus_destroyShowTimeFrostedIfNeeded];
innerStrongSelf.showTimeRoundId = @"";
innerStrongSelf.showTimeLastFinalTicketNum = -1;
innerStrongSelf.showTimeReadyShowStartRequestedRoundId = @"";
innerStrongSelf.isRequestingShowTimeReadyShowStart = NO;
innerStrongSelf.showTimeAnchorPopupRemainingSeconds = -1;
});
} failure:^(NSString * _Nonnull msg, NSInteger code) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLoadingView fus_dismissProgressView];
NSString *toastMsg = ([NSString isNull:msg] ? [NSString fus_localString:@"取消失败"] : msg);
[FUSDialogView fus_showDialog:toastMsg];
});
}];
};
__block void (^showReadyToPerformPopView)(NSInteger);
__block void (^showCancelConfirmPopView)(NSInteger);
......@@ -457,23 +419,12 @@
__weak typeof(cancelConfirmPopView) weakCancelConfirmPopView = cancelConfirmPopView;
cancelConfirmPopView.continueHandler = ^{
__strong typeof(innerWeakSelf) innerStrongSelf2 = innerWeakSelf;
__strong typeof(weakCancelConfirmPopView) strongCancelConfirmPopView = weakCancelConfirmPopView;
if (!innerStrongSelf2) {
return;
}
NSInteger remainSeconds = (strongCancelConfirmPopView ? [strongCancelConfirmPopView fus_currentRemainingSeconds] : 0);
innerStrongSelf2.showTimeAnchorPopupRemainingSeconds = remainSeconds;
if (strongCancelConfirmPopView) {
[strongCancelConfirmPopView fus_dismiss];
}
if (showReadyToPerformPopView) {
showReadyToPerformPopView(remainSeconds);
}
[innerStrongSelf fus_ticketShowStartPerformanceWithModel:respModel popToDismiss:strongCancelConfirmPopView];
};
cancelConfirmPopView.confirmHandler = ^{
__strong typeof(weakCancelConfirmPopView) strongCancelConfirmPopView = weakCancelConfirmPopView;
cancelCollectTicket(strongCancelConfirmPopView);
[innerStrongSelf fus_ticketShowCancelPerformanceWithModel:respModel popToDismiss:strongCancelConfirmPopView];
};
};
......@@ -505,13 +456,10 @@
readyPopView.confirmHandler = ^{
__strong typeof(innerWeakSelf) innerStrongSelf3 = innerWeakSelf;
__strong typeof(weakReadyPopView) strongReadyPopView = weakReadyPopView;
if (strongReadyPopView) {
[strongReadyPopView fus_dismiss];
}
if (innerStrongSelf3) {
innerStrongSelf3.showTimeAnchorPopupRemainingSeconds = -1;
if (!innerStrongSelf3) {
return;
}
[FUSDialogView fus_showDialog:[NSString fus_localString:@"开始表演功能待接入"]];
[innerStrongSelf3 fus_ticketShowStartPerformanceWithModel:respModel popToDismiss:strongReadyPopView];
};
readyPopView.autoCancelHandler = ^{
......@@ -522,8 +470,8 @@
}
if (innerStrongSelf4) {
innerStrongSelf4.showTimeAnchorPopupRemainingSeconds = -1;
[innerStrongSelf4 fus_ticketShowCancelPerformanceWithModel:respModel popToDismiss:nil];
}
cancelCollectTicket(nil);
};
};
......@@ -1511,4 +1459,130 @@
}];
}
/// Ticket Show:统一解析 roomId/channelId/roundId
/// 说明:
/// - 该模块的接口返回字段既可能平铺在 model 上,也可能在 stageData 内;同时 roundId 也可能以本地状态 showTimeRoundId 为准
/// - 这里做一次统一兜底,避免各处回调里重复写解析逻辑,导致取值不一致
/// - 解析失败时返回 NO,调用方负责 toast 并提前返回
/// @param model 接口/推送解析后的数据模型(用于兜底取 stageData 与平铺字段)
/// @param roomId 解析后的房间ID(非空)
/// @param channelId 解析后的频道ID(非空)
/// @param roundId 解析后的回合ID(非空)
- (BOOL)fus_ticketShowResolveIdentifiersWithModel:(FUSTicketShowCollectTicketToggleResultModel *)model
roomId:(NSString * _Nullable * _Nonnull)roomId
channelId:(NSString * _Nullable * _Nonnull)channelId
roundId:(NSString * _Nullable * _Nonnull)roundId {
FUSRoomInfoModel *roomInfoModel = FUSLiveHelper.shareInstance.roomInfoModel;
NSString *resolvedRoomId = (model.stageData.roomId.length > 0 ? model.stageData.roomId : (model.roomId.length > 0 ? model.roomId : roomInfoModel.roomId));
NSString *resolvedChannelId = (model.stageData.channelId.length > 0 ? model.stageData.channelId : (model.channelId.length > 0 ? model.channelId : roomInfoModel.channelId));
NSString *resolvedRoundId = self.showTimeRoundId;
if ([NSString isNull:resolvedRoundId]) {
resolvedRoundId = (model.stageData.roundId.length > 0 ? model.stageData.roundId : model.roundId);
}
if ([NSString isNull:resolvedRoomId] || [NSString isNull:resolvedChannelId] || [NSString isNull:resolvedRoundId]) {
return NO;
}
*roomId = resolvedRoomId;
*channelId = resolvedChannelId;
*roundId = resolvedRoundId;
return YES;
}
/// Ticket Show:开始表演(主播端)
/// 接口:POST /ticketshow/show/toggle(toggleType=1)
/// 行为:
/// - 统一走网络层 FUSLiveHttpHelper 发起请求
/// - 成功后关闭弹窗(如有)、清空弹窗倒计时缓存,并同步更新磨砂条阶段状态
/// - 失败时 toast 服务端 msg(为空则使用兜底文案)
/// @param model 用于解析 roomId/channelId/roundId 的数据模型
/// @param popToDismiss 需要关闭的弹窗(允许为空)
- (void)fus_ticketShowStartPerformanceWithModel:(FUSTicketShowCollectTicketToggleResultModel *)model
popToDismiss:(FUSLiveShowTimeCancelConfirmPopView * _Nullable)popToDismiss {
NSString *roomId = nil;
NSString *channelId = nil;
NSString *roundId = nil;
if (![self fus_ticketShowResolveIdentifiersWithModel:model roomId:&roomId channelId:&channelId roundId:&roundId]) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"当前房间信息异常"]];
return;
}
[FUSLoadingView fus_showProgressViewWithMessage:@""];
__weak typeof(self) weakSelf = self;
[FUSLiveHttpHelper fus_ticketShowShowToggleWithRoomId:roomId channelId:channelId roundId:roundId toggleType:1 succeed:^(FUSTicketShowCollectTicketToggleResultModel * _Nonnull startModel) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLoadingView fus_dismissProgressView];
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
if (popToDismiss) {
[popToDismiss fus_dismiss];
}
strongSelf.showTimeAnchorPopupRemainingSeconds = -1;
NSInteger stageStatus = MAX(0, (startModel.stageData ? startModel.stageData.showStatus : startModel.showStatus));
strongSelf.showTimeStageStatus = stageStatus;
if (strongSelf.showTimeFrostedView) {
strongSelf.showTimeFrostedView.stageStatus = stageStatus;
}
[FUSDialogView fus_showDialog:[NSString fus_localString:@"已开始表演"]];
});
} failure:^(NSString * _Nonnull msg, NSInteger code) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLoadingView fus_dismissProgressView];
[FUSDialogView fus_showDialog:([NSString isNull:msg] ? [NSString fus_localString:@"开始表演失败"] : msg)];
});
}];
}
/// Ticket Show:取消表演(主播端)
/// 接口:POST /ticketshow/show/toggle(toggleType=-1)
/// 行为:
/// - 统一走网络层 FUSLiveHttpHelper 发起请求
/// - 成功后关闭弹窗(如有)、销毁集票磨砂条,并清理本地回合/票数/阶段/倒计时等状态,避免影响下一轮
/// - 失败时 toast 服务端 msg(为空则使用兜底文案)
/// @param model 用于解析 roomId/channelId/roundId 的数据模型
/// @param popToDismiss 需要关闭的弹窗(允许为空)
- (void)fus_ticketShowCancelPerformanceWithModel:(FUSTicketShowCollectTicketToggleResultModel *)model
popToDismiss:(FUSLiveShowTimeCancelConfirmPopView * _Nullable)popToDismiss {
NSString *roomId = nil;
NSString *channelId = nil;
NSString *roundId = nil;
if (![self fus_ticketShowResolveIdentifiersWithModel:model roomId:&roomId channelId:&channelId roundId:&roundId]) {
[FUSDialogView fus_showDialog:[NSString fus_localString:@"当前房间信息异常"]];
return;
}
[FUSLoadingView fus_showProgressViewWithMessage:@""];
__weak typeof(self) weakSelf = self;
[FUSLiveHttpHelper fus_ticketShowShowToggleWithRoomId:roomId channelId:channelId roundId:roundId toggleType:-1 succeed:^(FUSTicketShowCollectTicketToggleResultModel * _Nonnull cancelModel) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLoadingView fus_dismissProgressView];
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
if (popToDismiss) {
[popToDismiss fus_dismiss];
}
[strongSelf fus_destroyShowTimeFrostedIfNeeded];
strongSelf.showTimeRoundId = @"";
strongSelf.showTimeLastFinalTicketNum = -1;
strongSelf.showTimeCountdownRemainSeconds = -1;
strongSelf.showTimeTargetTicketNum = -1;
strongSelf.showTimeStageStatus = -1;
strongSelf.showTimeMvpNeedTicketCount = -1;
strongSelf.showTimeReadyShowStartRequestedRoundId = @"";
strongSelf.isRequestingShowTimeReadyShowStart = NO;
strongSelf.showTimeAnchorPopupRemainingSeconds = -1;
});
} failure:^(NSString * _Nonnull msg, NSInteger code) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLoadingView fus_dismissProgressView];
[FUSDialogView fus_showDialog:([NSString isNull:msg] ? [NSString fus_localString:@"取消失败"] : msg)];
});
}];
}
@end
......@@ -593,6 +593,9 @@ NS_ASSUME_NONNULL_BEGIN
/// Ticket Show - 功能 - 主播端进入待表演
+ (NSString *)fus_URL_TicketShow_ReadyShow_Start;
/// Ticket Show - 功能 - 主播端开始/取消表演
+ (NSString *)fus_URL_TicketShow_Show_Toggle;
/// Ticket Show - 视图 - 获取表演票的集票信息(观众端进房刷新)
+ (NSString *)fus_URL_TicketShow_Progress_GetInfo;
......
......@@ -976,6 +976,12 @@
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/ticketshow/readyShow/start"];
}
/// Ticket Show - 功能 - 主播端开始/取消表演
+ (NSString *)fus_URL_TicketShow_Show_Toggle
{
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/ticketshow/show/toggle"];
}
/// Ticket Show - 视图 - 获取表演票的集票信息(观众端进房刷新)
+ (NSString *)fus_URL_TicketShow_Progress_GetInfo
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment