Commit 7175d0cc by suolong

添加-20065的判断

parent 95d8a6b4
......@@ -954,12 +954,8 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_BaoFang_Did_End_Live_Notification object:currentRoomId];
[[NSNotificationCenter defaultCenter] postNotificationName:FUSLiveNotificationKeys.fus_BaoFang_Refresh object:nil];
} else if (code == -20065) {
NSString *uid = [[FUSCacheDataShare shareStore].userVerifyInfo.uid description];
NSString *roomId = [currentRoomId description];
if ([NSString isNull:uid] || [NSString isNull:roomId]) {
[FUSLiveHelper fus_quitLiveWithCompletion:nil];
return;
}
NSString *uid = [[FUSCacheDataShare shareStore].userVerifyInfo.uid description] ?: @"";
NSString *roomId = [currentRoomId description] ?: @"";
__weak typeof(self) weakSelf = self;
[FUSLiveHttpHelper fus_requestGetPayRoomFrostedGlassDataWithUid:uid RoomId:roomId succeed:^(NSDictionary *dataDict) {
......@@ -968,13 +964,7 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor
return;
}
NSDictionary *payload = nil;
if ([dataDict[@"data"] isKindOfClass:NSDictionary.class]) {
payload = dataDict[@"data"];
} else {
payload = dataDict;
}
NSDictionary *payload = ([dataDict[@"data"] isKindOfClass:NSDictionary.class] ? dataDict[@"data"] : dataDict);
FUSPayRoomFrostedGlassDataModel *dataModel = [FUSPayRoomFrostedGlassDataModel fus_modelWithDict:(payload ?: @{})];
FUSPayRoomEntryMainViewModel *viewModel = [[FUSPayRoomEntryMainViewModel alloc] init];
......@@ -982,13 +972,8 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor
NSString *nick = [dataModel.roomData.nickName description];
viewModel.liveTitle = (![NSString isNull:introduce] ? introduce : (nick ?: @""));
NSInteger liveSeconds = dataModel.roomData.liveTime;
if (liveSeconds > 0) {
double hoursValue = ((double)liveSeconds / 3600.0);
NSInteger hours = (NSInteger)llround(hoursValue);
viewModel.liveTotalDurationText = [NSString stringWithFormat:[NSString fus_localString:@"直播总时长:%ld小时"], (long)MAX(0, hours)];
} else {
viewModel.liveTotalDurationText = @"";
}
NSInteger hours = (liveSeconds > 0 ? (NSInteger)llround(((double)liveSeconds / 3600.0)) : 0);
viewModel.liveTotalDurationText = (liveSeconds > 0 ? [NSString stringWithFormat:[NSString fus_localString:@"直播总时长:%ld小时"], (long)MAX(0, hours)] : @"");
viewModel.anchorName = nick;
viewModel.anchorFacePath = [dataModel.roomData.face description];
viewModel.anchorLevel = 0;
......@@ -1007,60 +992,39 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor
NSInteger canCompanionTime = dataModel.userData.canCompanionTime;
NSInteger previewTime = dataModel.payRoomConfigData.previewTime;
BOOL diamondEnough = (dataModel.userData.isDiamondEnough > 0);
viewModel.primaryButtonTitle = (diamondEnough ? [NSString fus_localString:@"进入陪伴"] : [NSString fus_localString:@"马上储值进入陪伴"]);
if (diamondEnough) {
viewModel.primaryButtonTitle = [NSString fus_localString:@"进入陪伴"];
} else {
viewModel.primaryButtonTitle = [NSString fus_localString:@"马上储值进入陪伴"];
}
viewModel.trialButtonHidden = previewTime <= 0;
viewModel.trialButtonHidden = (previewTime <= 0);
if (previewTime > 0) {
viewModel.trialButtonTitle = [NSString stringWithFormat:[NSString fus_localString:@"试看%ldS"], (long)previewTime];
}
if (canCompanionTime > 0 && pricePerMinute > 0) {
viewModel.bottomTipText = [NSString stringWithFormat:[NSString fus_localString:@"您可陪伴%ld分钟,%ld/分钟"], (long)canCompanionTime, (long)pricePerMinute];
} else if (pricePerMinute > 0) {
viewModel.bottomTipText = [NSString stringWithFormat:[NSString fus_localString:@"%ld/分钟"], (long)pricePerMinute];
if (pricePerMinute > 0) {
viewModel.bottomTipText = (canCompanionTime > 0 ? [NSString stringWithFormat:[NSString fus_localString:@"您可陪伴%ld分钟,%ld/分钟"], (long)canCompanionTime, (long)pricePerMinute] : [NSString stringWithFormat:[NSString fus_localString:@"%ld/分钟"], (long)pricePerMinute]);
}
dispatch_async(dispatch_get_main_queue(), ^{
UIView *rootView = strongSelf.liveVC.view ?: [UIViewController fus_topViewController].view;
__block __weak FUSPayRoomEntryMainView *weakEntryView = nil;
FUSPayRoomEntryMainView *entryView = [FUSPayRoomEntryMainView fus_showOnView:rootView viewModel:viewModel actionHandler:^(FUSPayRoomEntryMainViewAction action) {
if (action == FUSPayRoomEntryMainViewActionDismiss) {
[FUSLiveHelper fus_quitLiveWithCompletion:nil];
return;
}
NSString *channelId = [dataModel.roomData.channelId description] ?: @"";
NSString *roundId = [dataModel.roomData.roundId description] ?: @"";
if (action == FUSPayRoomEntryMainViewActionPrimary) {
[weakEntryView fus_dismissAnimated:YES];
if (diamondEnough) {
[strongSelf fus_audienceJoinRoomWithRoomId:roomId password:(password ?: @"") behaviorSrc:behaviorSrc otherInfo:otherInfo];
} else {
[FUSLiveGiftHalfChargeView fus_createWithDismissHandle:^(NSInteger type) {
}];
__weak typeof(strongSelf) weakStrongSelf = strongSelf;
[FUSPayRoomEntryMainView fus_showOnView:rootView viewModel:viewModel actionHandler:^(FUSPayRoomEntryMainViewAction action) {
__strong typeof(weakStrongSelf) strongSelf = weakStrongSelf;
if (!strongSelf) {
return;
}
if (action == FUSPayRoomEntryMainViewActionDismiss) {
[FUSLiveHelper fus_quitLiveWithCompletion:nil];
return;
}
if (action == FUSPayRoomEntryMainViewActionTrial) {
[weakEntryView fus_dismissAnimated:YES];
[strongSelf fus_audienceJoinRoomWithRoomId:roomId password:(password ?: @"") behaviorSrc:behaviorSrc otherInfo:otherInfo];
[strongSelf fus_requestPayRoomPreviewWithUid:uid roomId:roomId channelId:channelId roundId:roundId];
return;
}
}];
weakEntryView = entryView;
});
} failure:^(NSString *msg, NSInteger code) {
__strong typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
dispatch_async(dispatch_get_main_queue(), ^{
[FUSLiveHelper fus_quitLiveWithCompletion:nil];
});
}];
return;
} else if (code == -20060) {
......@@ -1094,6 +1058,19 @@ static NSString *const KLiveDataCenter_store_liveRTCData = @"LiveDataCenter_stor
}
}
- (void)fus_requestPayRoomPreviewWithUid:(NSString *)uid
roomId:(NSString *)roomId
channelId:(NSString *)channelId
roundId:(NSString *)roundId
{
[FUSLiveHttpHelper fus_requestPayRoomPreviewWithUid:(uid ?: @"") RoomId:(roomId ?: @"") previewType:@"1" channelId:(channelId ?: @"") roundId:(roundId ?: @"") succeed:^(NSDictionary *dataDict) {
} failure:^(NSString *msg, NSInteger code) {
dispatch_async(dispatch_get_main_queue(), ^{
[FUSDialogView fus_showDialog:(msg ?: @"")];
});
}];
}
/**
结束观看直播
*/
......
......@@ -1072,6 +1072,21 @@ NS_ASSUME_NONNULL_BEGIN
RoomId:(NSString *)roomId
succeed:(void (^)(NSDictionary *dataDict))succeed
failure:(void(^)(NSString *msg,NSInteger code))failure;
/// 视图-付费房试看预览
/// @param uid 用户ID
/// @param roomId 房间ID
/// @param previewType 预览类型(1:试看预览)
/// @param channelId 直播频道ID
/// @param roundId 付费房回合ID
/// @param succeed 成功回调
/// @param failure 失败回调
+(void)fus_requestPayRoomPreviewWithUid:(NSString *)uid
RoomId:(NSString *)roomId
previewType:(NSString *)previewType
channelId:(NSString *)channelId
roundId:(NSString *)roundId
succeed:(void (^)(NSDictionary *dataDict))succeed
failure:(void(^)(NSString *msg,NSInteger code))failure;
/// 切换付费模式V2
/// @param uid 用户ID
/// @param fid 主播ID
......
......@@ -2996,6 +2996,42 @@
if (failure) failure(dataDict[@"msg"],code);
}];
}
/// 视图-付费房试看预览
/// @param uid 用户ID
/// @param roomId 房间ID
/// @param previewType 预览类型(1:试看预览)
/// @param channelId 直播频道ID
/// @param roundId 付费房回合ID
/// @param succeed 成功回调
/// @param failure 失败回调
+(void)fus_requestPayRoomPreviewWithUid:(NSString *)uid
RoomId:(NSString *)roomId
previewType:(NSString *)previewType
channelId:(NSString *)channelId
roundId:(NSString *)roundId
succeed:(void (^)(NSDictionary *dataDict))succeed
failure:(void(^)(NSString *msg,NSInteger code))failure
{
/// 视图-付费房试看预览(用户端)
/// 参数:uid/roomId/channelId/roundId,previewType=1 表示试看
/// 成功:回调 dataDict;失败:回调 msg、code(不弹框,由调用方决定)
NSDictionary *parm = @{@"uid": uid ?: @"",
@"roomId": roomId ?: @"",
@"previewType": previewType ?: @"",
@"channelId": channelId ?: @"",
@"roundId": roundId ?: @""};
[FUSHttpHelper postRequestBinaryWithUrl:FUSShowRoomURLs.fus_URL_livePayRoomPreview params:parm success:^(NSDictionary * _Nullable dataDict, int code) {
if (succeed) {
succeed(dataDict);
}
} failure:^(NSDictionary * _Nullable dataDict, int code) {
if (failure) {
failure(dataDict[@"msg"], code);
}
}];
}
/// 切换付费模式V2
/// @param uid 用户ID
/// @param fid 主播ID
......
......@@ -81,20 +81,6 @@
return nil;
}
for (UIView *subview in rootView.subviews) {
if ([subview isKindOfClass:[FUSPayRoomEntryMainView class]]) {
FUSPayRoomEntryMainView *existView = (FUSPayRoomEntryMainView *)subview;
[rootView bringSubviewToFront:existView];
existView.actionHandler = actionHandler;
[existView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(rootView);
}];
[existView fus_updateWithViewModel:viewModel];
[existView fus_showAnimated:YES];
return existView;
}
}
FUSPayRoomEntryMainView *view = [[FUSPayRoomEntryMainView alloc] initWithFrame:rootView.bounds];
view.actionHandler = actionHandler;
[rootView addSubview:view];
......@@ -102,7 +88,10 @@
make.edges.equalTo(rootView);
}];
[view fus_updateWithViewModel:viewModel];
[view fus_showAnimated:YES];
view.hidden = NO;
view.userInteractionEnabled = YES;
view.alpha = 1;
view.cardView.transform = CGAffineTransformIdentity;
return view;
}
......@@ -169,7 +158,7 @@
#pragma mark - Private: UI
- (void)fus_buildUI {
self.alpha = 0;
self.alpha = 1;
self.backgroundColor = UIColor.clearColor;
self.backgroundButton = [UIButton buttonWithType:UIButtonTypeCustom];
......@@ -336,22 +325,6 @@
[self.trialButton addTarget:self action:@selector(fus_onTapTrial) forControlEvents:UIControlEventTouchUpInside];
}
- (void)fus_showAnimated:(BOOL)animated {
if (!animated) {
self.alpha = 1;
self.cardView.transform = CGAffineTransformIdentity;
return;
}
self.alpha = 0;
self.cardView.transform = CGAffineTransformMakeScale(1.02, 1.02);
__weak typeof(self) weakSelf = self;
[UIView animateWithDuration:0.25 animations:^{
weakSelf.alpha = 1;
weakSelf.cardView.transform = CGAffineTransformIdentity;
}];
}
#pragma mark - Private: Data -> UI
- (void)fus_updateTrialButtonHidden:(BOOL)hidden {
......
......@@ -545,6 +545,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)fus_URL_liveGetPayRoomData;
/// 视图-用户端未付费时退出到毛玻璃状态的弹窗数据
+ (NSString *)fus_URL_liveGetPayRoomFrostedGlassData;
+ (NSString *)fus_URL_livePayRoomPreview;
/// 获取首页自动跳转直播间
+ (NSString *)fus_URL_indexGetSuccessRecommendResult;
/// 切换付费模式V2
......
......@@ -892,6 +892,11 @@
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/payRoom/getFrostedGlassData"];
}
+ (NSString *)fus_URL_livePayRoomPreview
{
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/payRoom/preview"];
}
/// 切换付费模式V2
+ (NSString *)fus_URL_liveChangePay
{
......
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