Commit 3ebaedd6 by pidan

进直播间提示语的逻辑

parent 8b5e0347
Showing with 242 additions and 47 deletions
......@@ -62,6 +62,10 @@
/// 开播相关配置
@property (nonatomic, strong) FUSLiveStartConfigModel *startLiveConfig;
@property (nonatomic, copy) NSDictionary<NSString *, NSString *> *roomRemindDict;
- (void)fus_setupRoomRemindListWithDict:(NSDictionary *)roomRemindDict;
#pragma mark -- 热更新数据
// 热数据MD5信息
......
......@@ -67,6 +67,20 @@
#pragma mark -- 实例化属性
- (void)fus_setupRoomRemindListWithDict:(NSDictionary *)roomRemindDict {
NSMutableDictionary<NSString *, NSString *> *resultDict = [NSMutableDictionary dictionary];
for (NSString *key in roomRemindDict.allKeys) {
NSDictionary *value = roomRemindDict[key];
NSString *text = value[@"text"];
NSString *color = value[@"color"];
NSString *htmlText = [NSString stringWithFormat:@"<font color=%@>%@</font>",color, text];
resultDict[key] = htmlText;
}
self.roomRemindDict = resultDict;
}
- (FUSUserVerifyModel *)userVerifyInfo
{
if (!_userVerifyInfo) {
......
......@@ -91,6 +91,8 @@
/// 直播主题信息
@property (nonatomic, strong) FUSLiveThemeModel *theme;
@property (nonatomic, copy) NSArray<NSString *> *reminderKeys;
- (void)fus_setModelWithMyRoomInfos;
@end
......@@ -123,6 +123,9 @@ NS_ASSUME_NONNULL_BEGIN
// 沙盒-账号相关-用户首次发布动态协议提示
+ (NSString *)fus_UDKEY_ACCOUNT_FIRST_PUBLISH_AND_SHARE_PROTOCOL;
// 房间公告提醒配置
+ (NSString *)fus_ROOM_REMINDLIST_UDKEY;
@end
@interface FUSUserNotificationKeys : NSObject
......
......@@ -198,6 +198,11 @@
return @"UDKEY_ACCOUNT_FIRST_PUBLISH_AND_SHARE_PROTOCOL";
}
// 房间公告提醒配置
+ (NSString *)fus_ROOM_REMINDLIST_UDKEY {
return @"fus_ROOM_REMINDLIST_UDKEY";
}
@end
......
......@@ -1179,10 +1179,66 @@
*/
- (void)fus_audienceJoinRoomWithStreamUrl:(NSString *)originalStreamUrl roomId:(NSString *)currentRoomId
{
// 持有当前 roomid 以便判断
// NSString *currentRoomId = [FUSLiveHelper shareInstance].roomInfoModel.roomId;
__weak typeof(self) weakSelf = self;
[FUSLiveHttpHelper fus_enterRoomGetPredataWithRoomId:currentRoomId success:^(NSDictionary *dataDict) {
NSString *pullUrl = dataDict[@"pullUrl"];
NSString *pullUrlPk = dataDict[@"pullUrlPk"];
NSString *pkUid = dataDict[@"pkUid"];
NSArray *reminderKey = dataDict[@"reminderKey"];
NSDictionary *roomInfo = dataDict[@"roomInfo"];
if (![currentRoomId isEqualToString:[FUSLiveHelper shareInstance].roomInfoModel.roomId]) {
FUSLogInfo(@"不是当前包房");
return;
}
if ([NSString isNull:originalStreamUrl]) {
// 播放live
[[[self liveVC] playView] fus_playWithUID:currentRoomId Url:pullUrl];
}
if (![NSString isNullWithString:pkUid]) {
[[[self liveVC] playView] fus_playWithUID:pkUid Url:pullUrlPk];
}
[self.roomInfoModel fus_setValueWithDict:roomInfo];
self.roomInfoModel.reminderKeys = reminderKey;
[self.currentFunctionView.chatTableView fus_addEnterRoomSystemTipMessage];
[self fus_audienceJoinRoomWithRoomId:currentRoomId];
} failure:^(NSDictionary * _Nonnull errorDict, NSString * _Nonnull msg, int code) {
if (![currentRoomId isEqualToString:[FUSLiveHelper shareInstance].roomInfoModel.roomId]) {
FUSLogInfo(@"不是当前包房");
return;
}
// 其他情况
[FUSAlertView showAlertWithTitle:nil message:[NSString fus_localString:@"网络出错,是否重新进入包房?"] cancelButtonTitle:nil otherButtonTitles:@[[NSString fus_localString:@"确定"], [NSString fus_localString:@"退出"]] clickBlock:^(NSInteger buttonIndex) {
if (buttonIndex == 0) {
[self fus_audienceJoinRoomWithStreamUrl:originalStreamUrl roomId:currentRoomId];
}else{
[FUSLiveHelper fus_quitLiveWithCompletion:nil];
}
}];
if(weakSelf.enterRoomFailureBlock){
weakSelf.enterRoomFailureBlock();
}
}];
}
FUSLogDebug(@"");
/**
观众端加入包房
1. 调用获取 Socket 接口
2. 调用 JoinRoom 接口
*/
- (void)fus_audienceJoinRoomWithRoomId:(NSString *)currentRoomId {
__weak typeof(self) weakSelf = self;
[FUSLiveHttpHelper fus_enterRoomWithRoomId:[FUSLiveHelper shareInstance].roomInfoModel.roomId vdoid:[FUSLiveHelper shareInstance].streamModel.vdoid success:^(FUSRoomInfoModel *roomInfoModel,BOOL micMode, NSString *streamUrl, NSString *pkInfo) {
......@@ -1262,11 +1318,6 @@
if ([[[[FUSLiveHelper shareInstance] liveVC] playView] fus_statusForUID:roomInfoModel.roomId] != FUSStreamPlayStatusPlaying) {
[self fus_showLiveLoadingViewWithType:liveLoadingEntering];
}
if ([NSString isNull:originalStreamUrl]) {
// 播放live
// [[[FUSLiveHelper shareInstance] liveVC] initPlayView];
[[[[FUSLiveHelper shareInstance] liveVC] playView] fus_playWithUID:roomInfoModel.roomId Url:streamUrl];
}
}
if(weakSelf.enterRoomSuccessBlock){
......@@ -1357,7 +1408,7 @@
[FUSAlertView showAlertWithTitle:nil message:[NSString fus_localString:@"网络出错,是否重新进入包房?"] cancelButtonTitle:nil otherButtonTitles:@[[NSString fus_localString:@"确定"], [NSString fus_localString:@"退出"]] clickBlock:^(NSInteger buttonIndex) {
if (buttonIndex == 0) {
[self fus_audienceJoinRoomWithStreamUrl:originalStreamUrl roomId:currentRoomId];
[self fus_audienceJoinRoomWithRoomId:currentRoomId];
}else{
[FUSLiveHelper fus_quitLiveWithCompletion:nil];
}
......
......@@ -79,25 +79,17 @@ NS_ASSUME_NONNULL_BEGIN
success:(void(^)(FUSRoomInfoModel *))success
failure:(void(^)(NSString *msg, int code, NSDictionary *errorDict))failure;
/**
加入房间
进入房间预加载数据
@param roomId 房间 Id
@param livingType 直播类型(0:普通直播,1:视讯)
@param vdoid 直播签名,视讯状态下必须传
@param roomId 直播间 ID
@param success 成功回调
@param failure 失败回调 1:正常
-1: 未捕获的异常
-20060:您已被移除直播,暂时不能进入
-20019:包房已满
-20036:直播已经结束了
@param failure 失败回调
*/
//+ (void)fus_joinRoomWithRoomId:(NSString *)roomId
// livingType:(NSString *)livingType
// vdoid:(NSString *)vdoid
// success:(void(^)(FUSRoomInfoModel *, NSArray <FUSOnlineUserModel *>*, NSString *))success
// failure:(void(^)(NSString *msg, int code, NSDictionary *errorDict))failure;
+ (void)fus_enterRoomGetPredataWithRoomId:(NSString *)roomId
success:(void(^)(NSDictionary *dataDict))success
failure:(void(^)(NSDictionary *errorDict, NSString *msg, int code))failure;
/**
加入直播间
v3.9.0
......
......@@ -327,6 +327,43 @@
}
/**
进入房间预加载数据
@param roomId 直播间 ID
@param success 成功回调
@param failure 失败回调
*/
+ (void)fus_enterRoomGetPredataWithRoomId:(NSString *)roomId
success:(void(^)(NSDictionary *dataDict))success
failure:(void(^)(NSDictionary *errorDict, NSString *msg, int code))failure {
// 空值校验
if ([NSString isNullWithString:roomId]) {
if (failure) {
failure(nil, @"参数错误", ERROR_CODE);
}
return;
}
NSDictionary *params = @{@"roomId":roomId};
[FUSHttpHelper postRequestBinaryWithUrl:FUSShowRoomURLs.fus_URL_LIVE_ROOM_GET_PREDATA params:params success:^(NSDictionary *dataDict, int code) {
if (success) {
success(dataDict);
}
} failure:^(NSDictionary *dataDict, int code) {
if (failure) {
failure(dataDict, FAILURE_MESSAGE, code);
}
}];
}
/**
加入直播间
v3.9.0
......
......@@ -15,6 +15,7 @@
#define CID_SYSTEM_TIP -19998 // 系统提示 cell
#define CID_SYSTEM_WARNING -19999 // 直播提示消息
#define CID_SYSTEM_WARM_TIP -19996 // 温馨提示
#define CID_ACTIVE_SYSTEM_WARNING -199961 // 后台自定义的直播提示消息
#define CID_RED_PACKET -19995 // 红包消息
#define CID_CHARACTER_HYPERLINK -19994 // 文字链消息
......@@ -117,7 +118,7 @@
/**
添加一条系统温馨提示
*/
- (void)fus_addSystemTipMessage;
- (void)fus_addEnterRoomSystemTipMessage;
// 创建一个系统消息
- (void)fus_addSystemTip:(NSString *)tip;
......
......@@ -128,7 +128,7 @@
// 获取等级字典
// self.levelDict = [[FUSCacheDataShare shareStore]levelModelDict];
[self fus_addSystemTipMessage];
// [self fus_addEnterRoomSystemTipMessage];
_refreshTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:[YYWeakProxy proxyWithTarget:self] selector:@selector(fus_refreshNewDatas:) userInfo:nil repeats:YES];
}
......@@ -541,7 +541,7 @@
self.dataNumber = 0;
// 重新添加系统提示消息
[self fus_addSystemTipMessage];
// [self fus_addEnterRoomSystemTipMessage];
}
#pragma mark -- 取出数据
......@@ -1688,24 +1688,47 @@
{
FUSLiveChatModel *model = [[FUSLiveChatModel alloc]init];
model.ID = [FUSTimeHelper fus_getTimeStampString];
model.nickname = [NSString fus_localString:@"直播消息"];
// 取本地数据
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:FUSLiveUDKeys.fus_ROOM_TIP_MESSAGE];
NSMutableString *message;
if ([dict isKindOfClass:[NSDictionary class]]) {
message = [[NSMutableString alloc] initWithString:[dict objectForKey:@"content"]];
}else if ([dict isKindOfClass:[NSString class]]){
message = [[NSMutableString alloc] initWithString:(NSString *)dict];
}
if ([message containsString:@"fusi:"]) {
[message replaceCharactersInRange:[message rangeOfString:@"fusi:"] withString:@"FusiYa:"];
}
if (!message || FUSConfig.sharedInstanced.devConfigs.appStatus) {
message = [[NSMutableString alloc] initWithString:[NSString fus_localString:@"请维护聊天秩序,勿传播低俗、引诱、暴露图片、敏感内容及广告等,违者将封停帐号。"]];
if (FUSLiveHelper.shareInstance.roomInfoModel.reminderKeys.count > 0) {
model.nickname = @"";
NSString *anchornick = FUSLiveHelper.shareInstance.roomInfoModel.nickName;
NSString *usernick = FUSCacheDataShare.shareStore.userDetailInfo.nickname;
message = [[NSMutableString alloc] init];
for (NSString *remindKey in FUSLiveHelper.shareInstance.roomInfoModel.reminderKeys) {
NSString *remindStr = FUSCacheDataShare.shareStore.roomRemindDict[remindKey];
NSString *shownStr = [remindStr stringByReplacingOccurrencesOfString:@"{anchornick}" withString:anchornick];
shownStr = [shownStr stringByReplacingOccurrencesOfString:@"{usernick}" withString:usernick];
[message appendString:shownStr];
[message appendString:@"<br>"];
}
model.type = STR(CID_ACTIVE_SYSTEM_WARNING);
} else {
model.nickname = [NSString fus_localString:@"直播消息"];
// 取本地数据
NSDictionary *dict = [[NSUserDefaults standardUserDefaults] objectForKey:FUSLiveUDKeys.fus_ROOM_TIP_MESSAGE];
if ([dict isKindOfClass:[NSDictionary class]]) {
message = [[NSMutableString alloc] initWithString:[dict objectForKey:@"content"]];
}else if ([dict isKindOfClass:[NSString class]]){
message = [[NSMutableString alloc] initWithString:(NSString *)dict];
}
if ([message containsString:@"fusi:"]) {
[message replaceCharactersInRange:[message rangeOfString:@"fusi:"] withString:@"FusiYa:"];
}
if (!message || FUSConfig.sharedInstanced.devConfigs.appStatus) {
message = [[NSMutableString alloc] initWithString:[NSString fus_localString:@"请维护聊天秩序,勿传播低俗、引诱、暴露图片、敏感内容及广告等,违者将封停帐号。"]];
}
model.type = STR(CID_SYSTEM_WARNING);
}
model.msg = message;
model.type = STR(CID_SYSTEM_WARNING);
model.content = message;
return model;
}
......@@ -1722,7 +1745,7 @@
// 添加一条系统温馨提示
- (void)fus_addSystemTipMessage
- (void)fus_addEnterRoomSystemTipMessage
{
FUSLiveChatModel *systemModel = [self systemWarnModel];
[self fus_addMessageWithModel:systemModel];
......
......@@ -64,6 +64,11 @@
- (void)fus_UpdataMessageWithModel:(FUSLiveChatModel *)model;
/**
添加一条系统温馨提示
*/
- (void)fus_addEnterRoomSystemTipMessage;
/**
滚动到底部
@param animate 是否动画展现
......
......@@ -126,7 +126,7 @@
{
self.dataSourceHelper = [[FUSLiveChatDataSourceHelper alloc]initWithTableView:self];
self.dataSourceHelper.delegate = self;
// [self.dataSourceHelper fus_addSystemTipMessage];
// [self.dataSourceHelper fus_addEnterRoomSystemTipMessage];
}
#pragma mark - tableView delegate
......@@ -409,6 +409,13 @@
[self.dataSourceHelper fus_updateMessageWithModel:model];
}
/**
添加一条系统温馨提示
*/
- (void)fus_addEnterRoomSystemTipMessage {
[self.dataSourceHelper fus_addEnterRoomSystemTipMessage];
}
#pragma mark - method
- (void)fus_scrollToBottom{
......
......@@ -1873,7 +1873,7 @@ UIGestureRecognizerDelegate
self.treasureBoxListIcon.hidden = YES;
[[self fus_viewWithLayer:FUSLiveFunctionLayerFloatButtons] addSubview:self.treasureBoxListIcon];
[self fus_updateTreasureBoxListIconType:1];
// [self fus_updateTreasureBoxListIconType:1];
__weak typeof(self) weakSelf = self;
self.treasureBoxListIcon.clickLiveTreasureBoxListIconViewHandler = ^(FUSTreasureBoxInfoModel *treasureBoxModel, BOOL isAutoShow) {
......@@ -4240,8 +4240,10 @@ UIGestureRecognizerDelegate
@"sign":sign
}];
// 获取拉流地址播放
[liveVC.playView fus_playWithUID:remoteAnchorModel.uid Url:remoteAnchorModel.publishUrl];
if ([[liveVC.playView fus_streamUrlForUID:remoteAnchorModel.uid] isEqualToString:remoteAnchorModel.publishUrl] == NO) {
// 获取拉流地址播放
[liveVC.playView fus_playWithUID:remoteAnchorModel.uid Url:remoteAnchorModel.publishUrl];
}
// 设置frame
CGRect anchorViewFrame = [liveVC.playView fus_frameForUID:ourAnchorModel.uid];
self.pkViewFrame = anchorViewFrame;
......
......@@ -46,6 +46,9 @@ NS_ASSUME_NONNULL_BEGIN
// 批量追踪
+ (NSString *)fus_URL_LIKE_USERS;
// 进入房间预加载数据
+ (NSString *)fus_URL_LIVE_ROOM_GET_PREDATA;
// 加入直播间 v3.9.0 启用新接口
+ (NSString *)fus_URL_LIVE_ENTER_ROOM;
......
......@@ -68,6 +68,11 @@
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/room/likes.html"];
}
// 进入房间预加载数据
+ (NSString *)fus_URL_LIVE_ROOM_GET_PREDATA {
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/room/predata/get"];
}
// 加入直播间 v3.9.0 启用新接口
+ (NSString *)fus_URL_LIVE_ENTER_ROOM {
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/live/v2/enterRoom"];
......
......@@ -373,7 +373,7 @@
[self setupGetVerifyCodeBtnContent:[NSString fus_localString:@"发送验证码"]];
// _inviteCodeTextField.placeholder = [NSString fus_localString:@"输入邀请码(选填)"];
_inviteCodeTextField.attributedText = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
_inviteCodeTextField.attributedPlaceholder = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
make.append([NSString fus_localString:@"输入邀请码(选填)"]).textColor([UIColor fus_textColorMedium]);
}];
_registCodeTextField.attributedPlaceholder = [NSAttributedString sj_UIKitText:^(id<SJUIKitTextMakerProtocol> _Nonnull make) {
......
......@@ -409,6 +409,8 @@
// 拉取充值点
[FUSCommonCacheOperate fus_getUpdateRechargeWithType:ReadServerBegin success:nil failure:nil];
[FUSLoginHttpHelper fus_requestRoomRemindList];
[FUSNewsFeedNoticeShownHelper fus_checkIfHasNewsFeedPublished];
[FUSRouter.userRouter fus_updateBlackListArr];
......
......@@ -411,4 +411,7 @@ typedef NS_ENUM(NSInteger, Platform) {
/// 打开app只调用一次,进入后台再进入前台不需要调用
+ (void)fus_requestSettingInitData;
/// 获取房间公告提醒配置
+ (void)fus_requestRoomRemindList;
@end
......@@ -1123,4 +1123,31 @@
}];
}
/// 获取房间公告提醒配置
+ (void)fus_requestRoomRemindList {
NSUserDefaults *userDefault = [[NSUserDefaults alloc] initWithSuiteName:FUSCacheDataShare.shareStore.userDetailInfo.uid];
NSDictionary *roomRemindDict = [userDefault objectForKey:FUSUserUDKeys.fus_ROOM_REMINDLIST_UDKEY];
NSString *md5 = @"";
if (![NSDictionary isNullWithDictionary:roomRemindDict]) {
md5 = roomRemindDict[@"dataMd5"];
[FUSCacheDataShare.shareStore fus_setupRoomRemindListWithDict:roomRemindDict[@"dataMaps"]];
}
[FUSHttpHelper postRequestBinaryWithUrl:FUSUserCenterURLs.fus_URL_GET_ROOM_REMINDER_LIST params:@{@"md5":md5} success:^(NSDictionary * _Nullable dataDict, int code) {
if ([NSDictionary isNullWithDictionary:dataDict]) {
return;
}
[userDefault setObject:dataDict forKey:FUSUserUDKeys.fus_ROOM_REMINDLIST_UDKEY];
[userDefault synchronize];
[FUSCacheDataShare.shareStore fus_setupRoomRemindListWithDict:dataDict[@"dataMaps"]];
} failure:^(NSDictionary * _Nullable dataDict, int code) {
}];
}
@end
......@@ -20,6 +20,9 @@ NS_ASSUME_NONNULL_BEGIN
// 打开app只调用一次,进入后台再进入前台不需要调用
+ (NSString *)fus_URL_SETTING_INIT_DATA;
// 获取房间公告提醒配置
+ (NSString *)fus_URL_GET_ROOM_REMINDER_LIST;
// 修改密码
+ (NSString *)fus_URL_SETTING_CHANGE_PWD;
......
......@@ -22,6 +22,12 @@
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/setting/initData"];
}
// 获取房间公告提醒配置
+ (NSString *)fus_URL_GET_ROOM_REMINDER_LIST {
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/setting/data/room/reminder/getList"];
}
// 修改密码
+ (NSString *)fus_URL_SETTING_CHANGE_PWD {
return [FUSConfig.sharedInstanced.pathConfigs apiUrl:@"/setting/updatecode.html"];
......
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