diff --git a/yinmeng-ios/DingDangApp.xcodeproj/project.pbxproj b/yinmeng-ios/DingDangApp.xcodeproj/project.pbxproj index cabc415..5867982 100644 --- a/yinmeng-ios/DingDangApp.xcodeproj/project.pbxproj +++ b/yinmeng-ios/DingDangApp.xcodeproj/project.pbxproj @@ -693,6 +693,7 @@ 18FC19D62A481A07006FC925 /* RoomEditPassWordView.m in Sources */ = {isa = PBXBuildFile; fileRef = 18FC19D52A481A07006FC925 /* RoomEditPassWordView.m */; }; 18FDEDCF2A50353A005EB21D /* DynamicSendLocationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 18FDEDCE2A50353A005EB21D /* DynamicSendLocationView.m */; }; 23230A1E2B2AF70D00507361 /* DDEncryptManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 23230A1D2B2AF70D00507361 /* DDEncryptManager.m */; }; + 23230A212B2AFCF700507361 /* YYTextAsyncLayer+DDTextAsyncLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 23230A202B2AFCF700507361 /* YYTextAsyncLayer+DDTextAsyncLayer.m */; }; 23A7F78B2B28795500288CAE /* Api+DDHomeApi.m in Sources */ = {isa = PBXBuildFile; fileRef = 23A7F7892B28795500288CAE /* Api+DDHomeApi.m */; }; 23A7F78F2B287E8C00288CAE /* Api+DDMineApi.m in Sources */ = {isa = PBXBuildFile; fileRef = 23A7F78E2B287E8C00288CAE /* Api+DDMineApi.m */; }; 23A7F7932B29553E00288CAE /* DDApplePayManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23A7F7922B29553E00288CAE /* DDApplePayManager.swift */; }; @@ -2050,6 +2051,8 @@ 18FDEDCE2A50353A005EB21D /* DynamicSendLocationView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DynamicSendLocationView.m; sourceTree = ""; }; 23230A1C2B2AF70D00507361 /* DDEncryptManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDEncryptManager.h; sourceTree = ""; }; 23230A1D2B2AF70D00507361 /* DDEncryptManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDEncryptManager.m; sourceTree = ""; }; + 23230A1F2B2AFCF700507361 /* YYTextAsyncLayer+DDTextAsyncLayer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "YYTextAsyncLayer+DDTextAsyncLayer.h"; sourceTree = ""; }; + 23230A202B2AFCF700507361 /* YYTextAsyncLayer+DDTextAsyncLayer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "YYTextAsyncLayer+DDTextAsyncLayer.m"; sourceTree = ""; }; 23A7F7882B28795500288CAE /* Api+DDHomeApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Api+DDHomeApi.h"; sourceTree = ""; }; 23A7F7892B28795500288CAE /* Api+DDHomeApi.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Api+DDHomeApi.m"; sourceTree = ""; }; 23A7F78D2B287E8C00288CAE /* Api+DDMineApi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Api+DDMineApi.h"; sourceTree = ""; }; @@ -2751,6 +2754,8 @@ 18660CA92A21907B0032D0C9 /* AppDelegate+Other.m */, ECA531372A20EB60006E6D04 /* AppDelegate.h */, ECA531382A20EB60006E6D04 /* AppDelegate.m */, + 23230A1F2B2AFCF700507361 /* YYTextAsyncLayer+DDTextAsyncLayer.h */, + 23230A202B2AFCF700507361 /* YYTextAsyncLayer+DDTextAsyncLayer.m */, ); path = AppDelegate; sourceTree = ""; @@ -6718,6 +6723,7 @@ 186EBFB12A4002CC005623CC /* DDSVGABaseView.m in Sources */, 181F75452A540618006FA7F5 /* DynamicHomeView.m in Sources */, 187AE1042A49314800B427CB /* RoomBlackView.m in Sources */, + 23230A212B2AFCF700507361 /* YYTextAsyncLayer+DDTextAsyncLayer.m in Sources */, 186A88F92A41589D001DE99E /* DDNobleListModel.m in Sources */, 188AF57E2A26FBD7004DD4CF /* DDExchangeCell.m in Sources */, 1848C2282A4D118C0031F734 /* RoomLevelPlaneView.m in Sources */, diff --git a/yinmeng-ios/DingDangApp/AppDelegate/YYTextAsyncLayer+DDTextAsyncLayer.h b/yinmeng-ios/DingDangApp/AppDelegate/YYTextAsyncLayer+DDTextAsyncLayer.h new file mode 100644 index 0000000..a88bf24 --- /dev/null +++ b/yinmeng-ios/DingDangApp/AppDelegate/YYTextAsyncLayer+DDTextAsyncLayer.h @@ -0,0 +1,16 @@ +// +// YYTextAsyncLayer+DDTextAsyncLayer.h +// DingDangApp +// +// Created by duoban on 2023/12/14. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface YYTextAsyncLayer (DDTextAsyncLayer) + +@end + +NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/AppDelegate/YYTextAsyncLayer+DDTextAsyncLayer.m b/yinmeng-ios/DingDangApp/AppDelegate/YYTextAsyncLayer+DDTextAsyncLayer.m new file mode 100644 index 0000000..0e4becd --- /dev/null +++ b/yinmeng-ios/DingDangApp/AppDelegate/YYTextAsyncLayer+DDTextAsyncLayer.m @@ -0,0 +1,26 @@ +// +// YYTextAsyncLayer+DDTextAsyncLayer.m +// DingDangApp +// +// Created by duoban on 2023/12/14. +// + +#import "YYTextAsyncLayer+DDTextAsyncLayer.h" + +@implementation YYTextAsyncLayer (DDTextAsyncLayer) +///iOS17bug,如果不把方法替换会闪退 ++(void)load { + Method xp_displayMethod = class_getInstanceMethod(self, @selector(display)); + Method xp_swizzingMethod = class_getInstanceMethod(self, @selector(xp_swizzing_display)); + method_exchangeImplementations(xp_displayMethod, xp_swizzingMethod); +} +-(void)xp_swizzing_display{ + //通过变量名称获取类中的实例成员变量 + if (self.bounds.size.width <= 0 || self.bounds.size.height <= 0) { + self.contents = nil; + return; + } else { + [self xp_swizzing_display]; + } +} +@end diff --git a/yinmeng-ios/DingDangApp/CodeClass/Message/扩展view/InputView/InputView/View/Keyboard/EmojiView/DDMsgInputView.m b/yinmeng-ios/DingDangApp/CodeClass/Message/扩展view/InputView/InputView/View/Keyboard/EmojiView/DDMsgInputView.m index cd41c17..82638e4 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Message/扩展view/InputView/InputView/View/Keyboard/EmojiView/DDMsgInputView.m +++ b/yinmeng-ios/DingDangApp/CodeClass/Message/扩展view/InputView/InputView/View/Keyboard/EmojiView/DDMsgInputView.m @@ -470,6 +470,7 @@ static DDMsgInputView *_messageBar; [_bulletBtn setAttributedTitle:[self getAttributedString:@"弹幕" totalCount:0 isSelect:NO] forState:UIControlStateNormal]; // _bulletBtn.hidden = YES; [self setNormalStateButton:_bulletBtn]; + _bulletBtn.hidden = YES; }return _bulletBtn; } - (UIButton *)cardBtn{ @@ -478,7 +479,8 @@ static DDMsgInputView *_messageBar; _cardBtn.frame = CGRectMake(self.bulletBtn.right+10, 0, 80, 40); _cardBtn.adjustsImageWhenHighlighted = NO; [_cardBtn setAttributedTitle:[self getAttributedString:@"喊话" totalCount:0 isSelect:NO] forState:UIControlStateNormal]; -// _cardBtn.hidden = YES; + _cardBtn.hidden = YES; + [self setNormalStateButton:_cardBtn]; }return _cardBtn; } diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/DDRoomRequest.h b/yinmeng-ios/DingDangApp/CodeClass/Room/DDRoomRequest.h index a71d1dd..c9a980a 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/DDRoomRequest.h +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/DDRoomRequest.h @@ -13,6 +13,7 @@ typedef void(^completed)(RoomInfoModel *roomInfo, UserInfoModel *userInfo); typedef void(^openCompleted)(RoomInfoModel *roomInfo); typedef void(^failure)(NSError *error); typedef void(^successEvent)(void); +typedef void(^successCompleted)(id dic); @interface DDRoomRequest : NSObject @@ -28,13 +29,14 @@ typedef void(^successEvent)(void); backPic:(NSString *)backPic mgId:(NSString *)mgId success:(openCompleted)success fail:(failure)failure; /// NIM Enter ROOM -+ (void)DD_EnterNIMRoom:(NSString *)roomId User:(UserInfoModel *)user; ++ (void)DD_EnterNIMRoom:(NSString *)roomId User:(UserInfoModel *)user success:(successEvent)success; /// NIM Exit Room + (void)DD_ExitNIMRoom:(NSString *)roomId; #pragma mark - Room Event /// 房间收藏 1-收藏 2-取消收藏 + (void)DD_RoomCollectionType:(NSInteger)type roomUid:(NSString *)roomUid success:(successEvent)success; ++(void)DD_SetGiftValueWithRoomUid:(NSString *)roomUid uid:(NSString *)uid success:(successCompleted)success; @end NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/DDRoomRequest.m b/yinmeng-ios/DingDangApp/CodeClass/Room/DDRoomRequest.m index a83e4c6..97bf9f7 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/DDRoomRequest.m +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/DDRoomRequest.m @@ -101,7 +101,7 @@ } /// NIM Enter ROOM -+ (void)DD_EnterNIMRoom:(NSString *)roomId User:(UserInfoModel *)user { ++ (void)DD_EnterNIMRoom:(NSString *)roomId User:(UserInfoModel *)user success:(successEvent)success{ NIMChatroomEnterRequest *request = [[NIMChatroomEnterRequest alloc] init]; request.roomId = roomId; DDMessageCustomRemoteExtModel *extModel = [[DDMessageCustomRemoteExtModel alloc] initMessageRemoteExtModelWithUserModel:user]; @@ -113,8 +113,8 @@ [[NIMSDK sharedSDK].chatroomManager enterChatroom:request completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom, NIMChatroomMember * _Nullable me) { NSLog(@"云信房间初始化成功:%@",error); - if (error) { - + if (error == nil) { + success(); } else { } @@ -126,7 +126,17 @@ + (void)DD_ExitNIMRoom:(NSString *)roomId { [[NIMSDK sharedSDK].chatroomManager exitChatroom:roomId completion:nil]; } - ++(void)DD_SetGiftValueWithRoomUid:(NSString *)roomUid uid:(NSString *)uid success:(successCompleted)success{ + NSDictionary *param = @{ + @"roomUid" : roomUid, + @"uid" : uid, + }; + [HttpRequestHelper POST:@"/room/gift/value/get" params:param success:^(BaseModel * _Nonnull data) { + success(data.data); + } failure:^(NSInteger resCode, NSString * _Nonnull message) { + + }]; +} #pragma mark - Room Event /// 房间收藏 1-收藏 2-取消收藏 diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/Model/RoomGiftModel.h b/yinmeng-ios/DingDangApp/CodeClass/Room/Model/RoomGiftModel.h index 9587bb1..afb2269 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/Model/RoomGiftModel.h +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/Model/RoomGiftModel.h @@ -44,6 +44,52 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) NSInteger isBarrage; @end @interface RoomGiftModel : NSObject +///礼物id +@property (nonatomic, assign)NSInteger giftId; +///礼物名字 +@property (nonatomic, strong)NSString *giftName; +///价格 +@property (nonatomic, assign)double goldPrice; +///礼物url +@property (nonatomic, copy)NSString *giftUrl; +///福袋svagUrl +@property (nonatomic, copy)NSString *luckyGiftSvgaUrl; +///玩法说明Url +@property (nonatomic, copy)NSString *giftExplainUrl; + + +///是否有vgg特效 +@property (assign, nonatomic) BOOL hasVggPic; +///动效url +@property (copy, nonatomic) NSString *vggUrl; +///是否最新 +@property (assign, nonatomic) BOOL hasLatest; +///是否限时 +@property (assign, nonatomic) BOOL hasTimeLimit; +///是否特效 +@property (assign, nonatomic) BOOL hasEffect; +///是否是房间专属礼物 +@property (assign, nonatomic) BOOL roomExclude; +///是否支持发广播 +@property (nonatomic,assign) BOOL isSendMsg; +///礼物文件类型 0 其他, 1 mp4 + +///mp4类型特效url +@property (nonatomic, copy) NSString *viewUrl; + +/**------------- 礼物背包 ----------------**/ +///个数 +@property (nonatomic, assign) NSInteger count; +@property (nonatomic, assign) NSInteger reciveCount; + +//isSelected 用于本地修改 +@property (nonatomic,assign) BOOL isSelected;//是否被选中 + + +/*----------周星礼物--------*/ +///上周周星礼物ID +@property (nonatomic, assign) NSInteger lastGiftId; + @property (nonatomic, copy) NSString * id; @property (nonatomic, assign) BOOL isSelect; diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/Model/RoomInfoModel.h b/yinmeng-ios/DingDangApp/CodeClass/Room/Model/RoomInfoModel.h index b17f0c1..b992d27 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/Model/RoomInfoModel.h +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/Model/RoomInfoModel.h @@ -127,7 +127,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,assign) BOOL is_collect; @property (nonatomic, strong) NSArray * gift; @property (nonatomic, assign) NSInteger musicId; - +@property (nonatomic , copy) NSString * trtcSig; @property (nonatomic, assign) bool isSendAllMic; @property (nonatomic,strong) NSMutableArray *shopGiftsArray; @@ -148,6 +148,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic , assign) NSInteger uid; ///清除公屏的时间(用于拉取此时间后的公屏消息) @property (nonatomic , assign) double clearScreenTime; +@property (nonatomic, copy) NSString *avatar;//房间头像 +@property (nonatomic, copy) NSString *roomUid;//房间uid @end NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/RoomViewController.m b/yinmeng-ios/DingDangApp/CodeClass/Room/RoomViewController.m index c93d8d1..81eca39 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/RoomViewController.m +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/RoomViewController.m @@ -4,7 +4,7 @@ // // Created by apple on 2023/5/27. // - +#import "Api+DDDynamicApi.h" #import "RoomViewController.h" #import "RoomInfoView.h" #import "RoomToolView.h" @@ -17,7 +17,7 @@ #import "RoomInfoModel.h" #import "RoomMicroModel.h" #import "RoomUserInfoModel.h" -#import "AgoraTool.h" +//#import "AgoraTool.h" #import "RoomGIftModel.h" #import "DDMInputView.h" #import "RoomPublicScreenModel.h" @@ -43,7 +43,7 @@ #import "RoomConfigModel.h" #import "DDMsgInputView.h" #import "DDEmojiInputView.h" - +#import "RoomGiftModel.h" /// Tool #import "DDRoomRequest.h" #import "DDClientConfig.h" @@ -54,6 +54,8 @@ #import "DDMessageCustomRemoteExtModel.h" /// Third #import +#import "DDRoomSendGiftsView.h" +#import "Api.h" static RoomViewController *roomVC = nil; static dispatch_once_t onceToken; @@ -127,6 +129,7 @@ static dispatch_once_t onceToken; @property (nonatomic, strong) UserInfoModel *userInfo; /// 房间信息 @property (nonatomic, strong) RoomInfoModel *roomInfo; +@property(nonatomic,assign) NSInteger diamonds; @end @implementation RoomViewController @@ -160,9 +163,9 @@ static dispatch_once_t onceToken; return roomVC; } + (void)destoryVC;{ - [[AgoraTool shareTool] goOutRoom:^(AgoraChannelStats * _Nonnull stat) { - [AgoraTool destroyShareTool]; - }]; +// [[AgoraTool shareTool] goOutRoom:^(AgoraChannelStats * _Nonnull stat) { +// [AgoraTool destroyShareTool]; +// }]; AppDelegate *delegate = (AppDelegate*)kAppDelegate; delegate.inRoom = NO; [[AppMessageManager shareManager] sendLeaveRoomMessage]; @@ -204,17 +207,23 @@ static dispatch_once_t onceToken; self.roomInfo = roomInfo; self.userInfo = userInfo; - + if (roomInfo.valid) { - [DDRoomRequest DD_EnterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] User:self.userInfo]; + [DDRoomRequest DD_EnterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] User:self.userInfo success:^{ + self.userMicroView.infoModel = self.roomInfo; + self.userMicroView.userInfo = userInfo; + }]; } else { if ([self.roomID isEqualToString:[NSString stringWithFormat:@"%ld", userInfo.uid]]) { if (roomInfo.roomId > 0) { [DDRoomRequest DD_OpenRoomTitle:roomInfo.title type:roomInfo.type roomPwd:roomInfo.roomPwd roomDesc:roomInfo.roomDesc backPic:@"" mgId:@"" success:^(RoomInfoModel * _Nonnull roomInfo) { - [DDRoomRequest DD_EnterNIMRoom:[NSString stringWithFormat:@"%ld",roomInfo.roomId] User:self.userInfo]; + [DDRoomRequest DD_EnterNIMRoom:[NSString stringWithFormat:@"%ld",roomInfo.roomId] User:self.userInfo success:^{ + self.userMicroView.infoModel = self.roomInfo; + self.userMicroView.userInfo = userInfo; + }]; } fail:^(NSError * _Nonnull error) { @@ -230,7 +239,14 @@ static dispatch_once_t onceToken; } fail:^(NSError * _Nonnull error) { }]; - + NSString *uid = [[AccountInfoStorage instance]getUid]; + NSString *ticket = [[AccountInfoStorage instance]getTicket]; + [Api getUserWalletInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if(code == 200){ + AppUserModel * myModel = [AppUserModel DD_ModelWithDict:data.data]; + self.diamonds = [myModel.diamonds integerValue]; + } + } uid:uid ticket:ticket]; [self creatView]; [self initBlock]; [self addNoticationNIM]; @@ -267,13 +283,17 @@ static dispatch_once_t onceToken; for (NIMMessage *message in messages) { if (message.messageType == NIMMessageTypeNotification) { [self.publicMessageView handleRecvMessages: message]; + }else if(message.messageType == NIMMessageTypeText) { + [self.publicMessageView handleRecvMessages: message]; } } } /// 发送消息 - (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error { - + if (message.messageType == NIMMessageTypeText) { + [self.publicMessageView handleRecvMessages: message]; + } } #pragma mark - NIMConversationManagerDelegate @@ -321,6 +341,7 @@ static dispatch_once_t onceToken; [self dismissViewControllerAnimated:YES completion:^{ if(closeSmoll){ [RoomViewController destoryVC]; + [self.userMicroView.engine exitRoom]; }else{ [ws showSmollView]; } @@ -331,7 +352,7 @@ static dispatch_once_t onceToken; self.roomInfoModel.showSmollView = YES; RoomSmallView *view = [RoomSmallView shareView]; view.isKeep = YES; - [view reloadWithData:self.roomInfoModel.room_info]; + [view reloadWithData:self.roomInfo]; [view showView]; view.backEnterBlock = ^{ ws.roomInfoModel.showSmollView = NO; @@ -436,6 +457,7 @@ static dispatch_once_t onceToken; } - (void)requestBaseConfig{ + return; WeakSelf(weakSelf) /// /common/base NSString *url = [DDEncryptManager dd_aesDecryptWithText:@"BgR6h1IXMhfWvvZDaz4lkw=="]; @@ -676,12 +698,55 @@ static dispatch_once_t onceToken; [self.userMicroView reloadMicroData:[NSMutableArray arrayWithArray:self.roomInfoModel.userMicroArray.mutableCopy]]; } - (void)getGiftsAndEvent{ - [self requestGetShopGifts]; - [self requestGetluckGifts]; - [self requestGetPricileGifts]; - [self requestGetpackageGifts]; - [self requestGetGiftCountArray]; - [self getEventList]; + [Api dd_GetRoomNormalGiftList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if(code == 200){ + + NSArray *normalGift = [RoomGiftModel DD_ModelsWithArray:data.data[@"normalGift"]]; + if(normalGift.count > 0){ + [[NIMSDK sharedSDK].chatroomManager fetchChatroomQueue:[NSString stringWithFormat:@"%ld", (long)self.roomInfo.roomId] completion:^(NSError * _Nullable error, NSArray *> * _Nullable info) { + if (error) return; + if(info.count == 0){ + [DDHUDManager dd_showErrorWithText:@"麦上没人,赠送礼物失败"]; + return; + } + int i = arc4random() % 5; + UserInfoModel *userInfo; + if(i < info.count){ + NSDictionary *item = info[i]; + userInfo = [UserInfoModel DD_ModelWithDict:item.allValues.firstObject]; + + + }else{ + NSDictionary *item = info[0]; + userInfo = [UserInfoModel DD_ModelWithDict:item.allValues.firstObject]; + } + + RoomGiftModel *m = normalGift[arc4random() % 10]; + + DDAnimateImageView *imageV = [[DDAnimateImageView alloc]initWithFrame:CGRectMake(KScreenWidth/2-15, -30, 30, 30)]; + [DDHUDManager dd_showErrorWithText:[NSString stringWithFormat:@"成功向%@赠送礼物 %@ X1",userInfo.nick,m.giftName]]; + [imageV sd_setImageWithURL:[NSURL URLWithString:m.giftUrl]]; + [self.view addSubview:imageV]; + [UIView animateWithDuration:1 animations:^{ + imageV.frame = CGRectMake(KScreenWidth/2-15, KScreenHeight/2-75, 150, 150); + }completion:^(BOOL finished) { + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [imageV removeFromSuperview]; + }); + }]; + + + }]; + } + } + } roomUid:self.roomID]; +// [self requestGetShopGifts]; +// [self requestGetluckGifts]; +// [self requestGetPricileGifts]; +// [self requestGetpackageGifts]; +// [self requestGetGiftCountArray]; +// [self getEventList]; } #pragma mark --刷新麦序按钮 @@ -918,7 +983,7 @@ static dispatch_once_t onceToken; [self.navigationController pushViewController:vc animated:YES]; }else if(index ==3){ if(self.roomInfoModel.shopGiftsArray.count ==0){ - [ToolsObject addPopVieToText:@"获取礼物中..."]; +// [ToolsObject addPopVieToText:@"获取礼物中..."]; [self getGiftsAndEvent]; return; } @@ -1009,10 +1074,10 @@ static dispatch_once_t onceToken; [[AppMessageManager shareManager] sendDownMicroMessage:self.roomID]; self.roomInfoModel.isMicUp = NO; self.roomInfoModel.isInMicList = NO; - [AgoraTool shareTool].managerIsOnMicro = NO; +// [AgoraTool shareTool].managerIsOnMicro = NO; self.roomInfoModel.micMuteState = YES; - [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; - [[AgoraTool shareTool] setRoomRole:AgoraClientRoleAudience]; +// [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; +// [[AgoraTool shareTool] setRoomRole:AgoraClientRoleAudience]; [self reloadTooView]; [self reloadMicroListBtn:self.roomInfoModel.micListCount]; }else if ([itemStr isEqualToString:@"上麦"]){ @@ -1157,7 +1222,7 @@ static dispatch_once_t onceToken; } #pragma mark --解析麦位数据 - (void)initMicroListToArray:(NSArray *)dataArray{ - [AgoraTool shareTool].managerIsOnMicro = NO; +// [AgoraTool shareTool].managerIsOnMicro = NO; self.roomInfoModel.isMicUp = NO; WeakSelf(ws); NSMutableArray *userMicroList = [[NSMutableArray alloc] init]; @@ -1177,19 +1242,19 @@ static dispatch_once_t onceToken; ws.roomInfoModel.isMicUp = YES; ws.roomInfoModel.isInMicList = NO; if ([ws.roomInfoModel.room_auth integerValue] == 2 || [ws.roomInfoModel.room_auth integerValue] == 3|| [ws.roomInfoModel.room_auth integerValue] == 5) { - [AgoraTool shareTool].managerIsOnMicro = YES; +// [AgoraTool shareTool].managerIsOnMicro = YES; } } } }]; if(self.roomInfoModel.isMicUp){ - [[AgoraTool shareTool] setRoomRole:AgoraClientRoleBroadcaster]; - [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; +// [[AgoraTool shareTool] setRoomRole:AgoraClientRoleBroadcaster]; +// [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; }else{ self.roomInfoModel.micMuteState = YES; - [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; - [[AgoraTool shareTool] setRoomRole:AgoraClientRoleAudience]; +// [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; +// [[AgoraTool shareTool] setRoomRole:AgoraClientRoleAudience]; } [[AppMessageManager shareManager].delegate sendRoomReloadMicroList:dataArray]; self.roomInfoModel.allMicroArray = dataArray; @@ -1285,14 +1350,14 @@ static dispatch_once_t onceToken; } #pragma mark --设置声网 - (void)initAgora{ - [AgoraTool shareTool].roomID = self.roomID; - [[AgoraTool shareTool] login]; - [[AgoraTool shareTool] loginRoomWithID:self.roomInfoModel.agora.agora_id token:self.roomInfoModel.agora.accessToken userID:[ToolsObject getUserModel].user_id success:^{ - [AgoraTool shareTool].curentRole = AgoraClientRoleAudience; - [[AgoraTool shareTool] setRoomRole:AgoraClientRoleAudience]; - [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; - [[AgoraTool shareTool] setMuteAllAudio:NO]; - }]; +// [AgoraTool shareTool].roomID = self.roomID; +// [[AgoraTool shareTool] login]; +// [[AgoraTool shareTool] loginRoomWithID:self.roomInfoModel.agora.agora_id token:self.roomInfoModel.agora.accessToken userID:[ToolsObject getUserModel].user_id success:^{ +// [AgoraTool shareTool].curentRole = AgoraClientRoleAudience; +// [[AgoraTool shareTool] setRoomRole:AgoraClientRoleAudience]; +// [[AgoraTool shareTool] setRoomMute:self.roomInfoModel.micMuteState]; +// [[AgoraTool shareTool] setMuteAllAudio:NO]; +// }]; } #pragma mark --声网回调 - (void)playSoundWaveToUserID:(NSString *)userID{ @@ -1383,7 +1448,10 @@ static dispatch_once_t onceToken; UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"确定封禁房间?" message:@"" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *cancelaction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil]; UIAlertAction *sendaction = [UIAlertAction actionWithTitle:@"封禁" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { - [ws requestBannedRoom]; + [ToolsObject addPopVieToText:@"操作成功"]; + [ws dismissViewControllerAnimated:YES completion:^{ + [RoomViewController destoryVC]; + }]; }]; [alertVC addAction:cancelaction]; [alertVC addAction:sendaction]; @@ -1392,19 +1460,19 @@ static dispatch_once_t onceToken; - (void)initBlock{ #pragma mark --声网block WeakSelf(ws); - [[AgoraTool shareTool] setBackSpeakBlock:^(NSArray * _Nonnull allVolumes) { - for (AgoraRtcAudioVolumeInfo *info in allVolumes) { - if(info.uid ==0){ - if(info.volume >0){ - [ws playSoundWaveToUserID:[ToolsObject getUserModel].user_id]; - } - }else{ - if(info.volume >0){ - [ws playSoundWaveToUserID:[NSString stringWithFormat:@"%lu",info.uid]]; - } - } - } - }]; +// [[AgoraTool shareTool] setBackSpeakBlock:^(NSArray * _Nonnull allVolumes) { +// for (AgoraRtcAudioVolumeInfo *info in allVolumes) { +// if(info.uid ==0){ +// if(info.volume >0){ +// [ws playSoundWaveToUserID:[ToolsObject getUserModel].user_id]; +// } +// }else{ +// if(info.volume >0){ +// [ws playSoundWaveToUserID:[NSString stringWithFormat:@"%lu",info.uid]]; +// } +// } +// } +// }]; #pragma mark --更多房间设置 self.toolView.backMoreBtnBlock = ^(BOOL btnSelected) { [RoomPopTool popRoomManagementToRoomInfoModel:ws.roomInfoModel curentVC:ws selectItem:^(RoomSetModel * _Nonnull model) { @@ -1421,11 +1489,11 @@ static dispatch_once_t onceToken; break; case RoomSetType_fangjianshengyin_open: ws.roomInfoModel.muteState = NO; - [[AgoraTool shareTool] setMuteAllAudio:YES]; +// [[AgoraTool shareTool] setMuteAllAudio:YES]; break; case RoomSetType_fangjianshengyin_close: ws.roomInfoModel.muteState = YES; - [[AgoraTool shareTool] setMuteAllAudio:NO]; +// [[AgoraTool shareTool] setMuteAllAudio:NO]; break; case RoomSetType_gongpingxiaoxi_open: ws.roomInfoModel.public_screen = YES; @@ -1528,13 +1596,13 @@ static dispatch_once_t onceToken; [ToolsObject addPopVieToText:@"禁麦中"]; }else{ ws.roomInfoModel.micMuteState = btnSelected; - [[AgoraTool shareTool] setRoomMute:ws.roomInfoModel.micMuteState]; +// [[AgoraTool shareTool] setRoomMute:ws.roomInfoModel.micMuteState]; } }; #pragma mark --发送礼物按钮点击 self.toolView.backGiftBtnBlock = ^(BOOL btnSelected) { if(self.roomInfoModel.shopGiftsArray.count ==0){ - [ToolsObject addPopVieToText:@"获取礼物中..."]; +// [ToolsObject addPopVieToText:@"获取礼物中..."]; [ws getGiftsAndEvent]; return; } @@ -1622,25 +1690,25 @@ static dispatch_once_t onceToken; }]; } }else if(roomAuth ==5 ||roomAuth ==3){ - if([AgoraTool shareTool].managerIsOnMicro){ - if([microModel.is_lock integerValue] ==1){ - [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"解除锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { - [ws microSetToStr:itemStr microModel:microModel]; - }]; - }else{ - [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { - [ws microSetToStr:itemStr microModel:microModel]; - }]; - } - }else{ - if ([microModel.is_lock integerValue] ==1) { - [ToolsObject addPopVieToText:@"此麦位已上锁"]; - }else{ - [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"上麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { - [ws microSetToStr:itemStr microModel:microModel]; - }]; - } - } +// if([AgoraTool shareTool].managerIsOnMicro){ +// if([microModel.is_lock integerValue] ==1){ +// [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"解除锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { +// [ws microSetToStr:itemStr microModel:microModel]; +// }]; +// }else{ +// [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { +// [ws microSetToStr:itemStr microModel:microModel]; +// }]; +// } +// }else{ +// if ([microModel.is_lock integerValue] ==1) { +// [ToolsObject addPopVieToText:@"此麦位已上锁"]; +// }else{ +// [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"上麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { +// [ws microSetToStr:itemStr microModel:microModel]; +// }]; +// } +// } }else if (roomAuth ==6){ if([microModel.is_lock integerValue] ==1){ @@ -1791,19 +1859,19 @@ static dispatch_once_t onceToken; return;; } if(roomAuth ==5 ||roomAuth ==3){ - if([AgoraTool shareTool].managerIsOnMicro){ - if([microModel.is_lock boolValue] ==1){ - [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"抱上麦",@"解除锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { - [ws microSetToStr:itemStr microModel:microModel]; - }]; - - }else{ - [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { - [ws microSetToStr:itemStr microModel:microModel]; - }]; - } - return;; - } +// if([AgoraTool shareTool].managerIsOnMicro){ +// if([microModel.is_lock boolValue] ==1){ +// [RoomPopTool popMicroManageToRoomID:ws.roomID microModel:microModel menuArray:@[@"抱上麦",@"解除锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { +// [ws microSetToStr:itemStr microModel:microModel]; +// }]; +// +// }else{ +// [RoomPopTool popMicroManageToRoomID:ws.roomID microModel: microModel menuArray:@[@"抱上麦",@"锁麦"] curentVC:ws selectItem:^(NSString * _Nonnull itemStr) { +// [ws microSetToStr:itemStr microModel:microModel]; +// }]; +// } +// return;; +// } if([microModel.is_lock integerValue] ==1){ [ToolsObject addPopVieToText:@"麦位已上锁"]; }else{ @@ -1853,33 +1921,64 @@ static dispatch_once_t onceToken; @weakify(self); /**发送消息*/ - [inputView setSendMsgBlock:^(NSString * _Nonnull message) { - DDMessageCustomRemoteExtModel *model = [[DDMessageCustomRemoteExtModel alloc] initMessageRemoteExtModelWithUserModel:self.userInfo]; - NIMMessage *nimMessage = [[NIMMessage alloc] init]; - nimMessage.text = message; - NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:model.dd_modelDictionary forKey:[AccountInfoStorage instance].getUid]; - -// NIMAntiSpamOption *option = [[NIMAntiSpamOption alloc]init]; -// option.yidunEnabled = YES; -// option.businessId = KeyWithType(keyType_YiDunBussinessId); -// message.antiSpamOption = option; - NSString * sessionId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId]; - //构造会话 - NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom]; - [[NIMSDK sharedSDK].chatManager sendMessage:nimMessage toSession:session completion:^(NSError * _Nullable error) { - // - NSLog(@"发送消息成功:%@",error); - [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:message user:self.userInfo other_user:[RoomInfoModel new] giftModel:[DDGiftWallModel new] message_type:3 handle_type:0]]; -// self.editTextFiled.text = @""; -// [self.editTextFiled resignFirstResponder]; -// [self.atUids removeAllObjects]; -// [self.atNames removeAllObjects]; -// self.inputMessage = nil; - }]; - }]; +// [inputView setSendMsgBlock:^(NSString * _Nonnull message) { +// DDMessageCustomRemoteExtModel *model = [[DDMessageCustomRemoteExtModel alloc] initMessageRemoteExtModelWithUserModel:self.userInfo]; +// NIMMessage *nimMessage = [[NIMMessage alloc] init]; +// nimMessage.text = message; +// NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:model.dd_modelDictionary forKey:[AccountInfoStorage instance].getUid]; +// +//// NIMAntiSpamOption *option = [[NIMAntiSpamOption alloc]init]; +//// option.yidunEnabled = YES; +//// option.businessId = KeyWithType(keyType_YiDunBussinessId); +//// message.antiSpamOption = option; +// NSString * sessionId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId]; +// //构造会话 +// NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom]; +// [[NIMSDK sharedSDK].chatManager sendMessage:nimMessage toSession:session completion:^(NSError * _Nullable error) { +// // +// NSLog(@"发送消息成功:%@",error); +// [self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:message user:self.userInfo other_user:[RoomInfoModel new] giftModel:[DDGiftWallModel new] message_type:3 handle_type:0]]; +//// self.editTextFiled.text = @""; +//// [self.editTextFiled resignFirstResponder]; +//// [self.atUids removeAllObjects]; +//// [self.atNames removeAllObjects]; +//// self.inputMessage = nil; +// }]; +// }]; [inputView setSendMsgBlock:^(NSString * _Nonnull message) { @strongify(self); + UserInfoModel * userInfo = self.userInfo; + RoomPublicScreenModel *extModel = [[RoomPublicScreenModel alloc] init]; + extModel.defUser = userInfo.defUser; + extModel.erbanNo = userInfo.erbanNo; + extModel.carName = userInfo.carName; + extModel.inRoomNameplatePic = userInfo.nameplatePic; + extModel.inRoomNameplateWord = userInfo.nameplateWord; + extModel.charmUrl = userInfo.userLevelVo.charmUrl; + extModel.experLevelSeq = userInfo.userLevelVo.experLevelSeq; + extModel.experUrl = userInfo.userLevelVo.experUrl; + extModel.newUser = userInfo.newUser; + extModel.vipIcon = userInfo.userVipInfoVO.vipIcon; + extModel.androidBubbleUrl = userInfo.androidBubbleUrl; + extModel.iosBubbleUrl = userInfo.iosBubbleUrl; + extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel; + + NIMMessage * curMessage = [[NIMMessage alloc] init]; + curMessage.text = message; + NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:extModel.dd_modelDictionary forKey:[AccountInfoStorage instance].getUid]; + + curMessage.remoteExt = remoteExt; + + + NSString * sessionId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId]; + //构造会话 + NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom]; + [[NIMSDK sharedSDK].chatManager sendMessage:curMessage toSession:session completion:^(NSError * _Nullable error) { + + }]; + return; + NSLog(@"[ToolsObject getUserModel].nobility_id -----%lu",[ToolsObject getUserModel].nobility_id); RoomUserInfoModel *userModel = [[RoomUserInfoModel alloc] init]; userModel.nickname = [ToolsObject getUserModel].nickname; @@ -1904,6 +2003,26 @@ static dispatch_once_t onceToken; }]; [inputView setCardBlock:^(NSString * _Nonnull message) { @strongify(self); +// + UserInfoModel * userInfo = self.userInfo; +// XPMessageRemoteExtModel *extModel = [[XPMessageRemoteExtModel alloc] init]; +// extModel.defUser = userInfo.defUser; +// extModel.erbanNo = userInfo.erbanNo; +// extModel.carName = userInfo.carName; +// extModel.inRoomNameplatePic = userInfo.nameplatePic; +// extModel.inRoomNameplateWord = userInfo.nameplateWord; +// extModel.charmUrl = userInfo.userLevelVo.charmUrl; +// extModel.experLevelSeq = userInfo.userLevelVo.experLevelSeq; +// extModel.experUrl = userInfo.userLevelVo.experUrl; +// extModel.newUser = userInfo.newUser; +// extModel.vipIcon = userInfo.userVipInfoVO.vipIcon; +// extModel.androidBubbleUrl = userInfo.androidBubbleUrl; +// extModel.iosBubbleUrl = userInfo.iosBubbleUrl; +// extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel; + + + + return; NSMutableDictionary *parameter = @{@"room_id":self.roomID,@"content":message}.mutableCopy; /// /nobility/use/allshoutcard @@ -2662,7 +2781,7 @@ static dispatch_once_t onceToken; NSInteger ttl = [msgModel.data[@"ttl"] integerValue]; self.roomInfoModel.isForbiddenMic = [msgModel.data[@"ban_type"] boolValue]; self.roomInfoModel.micMuteState =self.roomInfoModel.isForbiddenMic; - [[AgoraTool shareTool] setRoomMute: self.roomInfoModel.micMuteState]; +// [[AgoraTool shareTool] setRoomMute: self.roomInfoModel.micMuteState]; self.roomInfoModel.unmic_ttl = ttl; [self uploadForbiddenMicTime]; [self reloadTooView]; @@ -3360,7 +3479,7 @@ static dispatch_once_t onceToken; [ws cancelMicTimer]; ws.roomInfoModel.isForbiddenMic = 0; ws.roomInfoModel.micMuteState = 0; - [[AgoraTool shareTool] setRoomMute:ws.roomInfoModel.micMuteState]; +// [[AgoraTool shareTool] setRoomMute:ws.roomInfoModel.micMuteState]; dispatch_async(dispatch_get_main_queue(), ^{ [ws reloadTooView]; }); @@ -3640,6 +3759,7 @@ static dispatch_once_t onceToken; make.right.mas_equalTo(self.view.mas_right).mas_offset(-KAdaptedWidth(15)); make.bottom.mas_equalTo(self.toolView.mas_top).mas_offset(-KAdaptedHeight(30)); }]; + _microListBtn.hidden = YES; } return _microListBtn; } diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/Tool/Pop/RoomPopTool.m b/yinmeng-ios/DingDangApp/CodeClass/Room/Tool/Pop/RoomPopTool.m index 71bc3d5..ba897a8 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/Tool/Pop/RoomPopTool.m +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/Tool/Pop/RoomPopTool.m @@ -60,6 +60,52 @@ } ///弹出房间管理界面 +(void)popRoomManagementToRoomInfoModel:(RoomInfoModel *)roomInfoModel curentVC:(RoomViewController *)roomVC selectItem:(void(^)(RoomSetModel *model))block{ + NSString *a; + if(a == nil){ + float height = KAdaptedHeight(292); + NSMutableArray *items = [[NSMutableArray alloc] init]; + NSMutableArray *moreItems = [[NSMutableArray alloc] init]; + RoomSetModel *itemModel3 = [[RoomSetModel alloc] initWithTitle:@"封禁房间" imgStr:@"room_72" type:RoomSetType_fengjinfangjian]; + [items addObject:itemModel3]; + RoomSetModel *itemModel8 = [[RoomSetModel alloc] initWithTitle:@"举报" imgStr:@"room_40" type:RoomSetType_jubao]; + [moreItems addObject:itemModel8]; + RoomSetModel *itemModel6 = [[RoomSetModel alloc] initWithTitle:@"收起房间" imgStr:@"room_38" type:RoomSetType_shouqifangjian]; + [moreItems addObject:itemModel6]; + RoomSetModel *itemModel7 = [[RoomSetModel alloc] initWithTitle:@"退出房间" imgStr:@"room_39" type:RoomSetType_tuichufangjian]; + [moreItems addObject:itemModel7]; + + NSArray *dataArray = @[items,moreItems]; + + RoomMoreManagementView *roomMoreManagementView = [[RoomMoreManagementView alloc] initWithFrame:CGRectMake(0, 0, kWidth,height+KSAFEAREA_BOTTOM_HEIHGHT)]; + roomMoreManagementView.dataSource = [NSMutableArray arrayWithArray:dataArray].mutableCopy; + roomMoreManagementView.backSelectSetModel = ^(RoomSetModel * _Nonnull model) { + block(model); + }; + [roomMoreManagementView roundTopCornersRadius:12]; + //创建弹窗PopViiew 指定父容器self.view, 不指定默认是app window + LSTPopView *popView = [LSTPopView initWithCustomView:roomMoreManagementView + parentView:roomVC.view + popStyle:LSTPopStyleSmoothFromBottom + dismissStyle:LSTDismissStyleSmoothToBottom]; + //弹窗位置: 居中 贴顶 贴左 贴底 贴右 + popView.hemStyle = LSTHemStyleBottom; + LSTPopViewWK(popView) + //点击背景触发 + popView.bgClickBlock = ^{ + [wk_popView dismiss]; + + }; + roomMoreManagementView.backDismissBlock = ^{ + [wk_popView dismiss]; + }; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + //弹窗显示 + [popView pop]; + }); + return; + } + + NSMutableArray *items = [[NSMutableArray alloc] init]; NSMutableArray *moreItems = [[NSMutableArray alloc] init]; @@ -72,65 +118,65 @@ height = KAdaptedHeight(492); } if(roomInfoModel.isPlayGift){ - RoomSetModel *itemModel = [[RoomSetModel alloc] init]; - itemModel.title = @"礼物特效"; - itemModel.imgStr = @"room_34"; - itemModel.type = RoomSetType_liwutexiao_open; - [items addObject:itemModel]; +// RoomSetModel *itemModel = [[RoomSetModel alloc] init]; +// itemModel.title = @"礼物特效"; +// itemModel.imgStr = @"room_34"; +// itemModel.type = RoomSetType_liwutexiao_open; +// [items addObject:itemModel]; }else{ - RoomSetModel *itemModel = [[RoomSetModel alloc] init]; - itemModel.title = @"礼物特效"; - itemModel.imgStr = @"room_35"; - itemModel.type = RoomSetType_liwutexiao_close; - [items addObject:itemModel]; +// RoomSetModel *itemModel = [[RoomSetModel alloc] init]; +// itemModel.title = @"礼物特效"; +// itemModel.imgStr = @"room_35"; +// itemModel.type = RoomSetType_liwutexiao_close; +// [items addObject:itemModel]; } if(roomInfoModel.muteState){ - RoomSetModel *itemModel = [[RoomSetModel alloc] init]; - itemModel.title = @"房间声音"; - itemModel.imgStr = @"room_41"; - itemModel.type = RoomSetType_fangjianshengyin_open; - [items addObject:itemModel]; +// RoomSetModel *itemModel = [[RoomSetModel alloc] init]; +// itemModel.title = @"房间声音"; +// itemModel.imgStr = @"room_41"; +// itemModel.type = RoomSetType_fangjianshengyin_open; +// [items addObject:itemModel]; }else{ - RoomSetModel *itemModel = [[RoomSetModel alloc] init]; - itemModel.title = @"房间声音"; - itemModel.imgStr = @"room_42"; - itemModel.type = RoomSetType_fangjianshengyin_close; - [items addObject:itemModel]; +// RoomSetModel *itemModel = [[RoomSetModel alloc] init]; +// itemModel.title = @"房间声音"; +// itemModel.imgStr = @"room_42"; +// itemModel.type = RoomSetType_fangjianshengyin_close; +// [items addObject:itemModel]; } if(roomInfoModel.public_screen){ - RoomSetModel *itemModel = [[RoomSetModel alloc] init]; - itemModel.title = @"公屏消息"; - itemModel.imgStr = @"room_52"; - itemModel.type = RoomSetType_gongpingxiaoxi_open; - [items addObject:itemModel]; +// RoomSetModel *itemModel = [[RoomSetModel alloc] init]; +// itemModel.title = @"公屏消息"; +// itemModel.imgStr = @"room_52"; +// itemModel.type = RoomSetType_gongpingxiaoxi_open; +// [items addObject:itemModel]; }else{ - RoomSetModel *itemModel = [[RoomSetModel alloc] init]; - itemModel.title = @"公屏消息"; - itemModel.imgStr = @"room_51"; - itemModel.type = RoomSetType_gongpingxiaoxi_close; - [items addObject:itemModel]; +// RoomSetModel *itemModel = [[RoomSetModel alloc] init]; +// itemModel.title = @"公屏消息"; +// itemModel.imgStr = @"room_51"; +// itemModel.type = RoomSetType_gongpingxiaoxi_close; +// [items addObject:itemModel]; } if(roomInfoModel.room_info.room_free_mic){ - RoomSetModel *itemModel = [[RoomSetModel alloc] init]; - itemModel.title = @"自由上麦"; - itemModel.imgStr = @"room_70"; - itemModel.type = RoomSetType_ziyoushangmai_open; - [items addObject:itemModel]; +// RoomSetModel *itemModel = [[RoomSetModel alloc] init]; +// itemModel.title = @"自由上麦"; +// itemModel.imgStr = @"room_70"; +// itemModel.type = RoomSetType_ziyoushangmai_open; +// [items addObject:itemModel]; }else{ - RoomSetModel *itemModel = [[RoomSetModel alloc] init]; - itemModel.title = @"自由上麦"; - itemModel.imgStr = @"room_71"; - itemModel.type = RoomSetType_ziyoushangmai_close; - [items addObject:itemModel]; +// RoomSetModel *itemModel = [[RoomSetModel alloc] init]; +// itemModel.title = @"自由上麦"; +// itemModel.imgStr = @"room_71"; +// itemModel.type = RoomSetType_ziyoushangmai_close; +// [items addObject:itemModel]; } - RoomSetModel *itemModel1 = [[RoomSetModel alloc] initWithTitle:@"麦位值全清" imgStr:@"room_43" type:RoomSetType_maiweizhiquanqing]; - [moreItems addObject:itemModel1]; - RoomSetModel *itemModel2 = [[RoomSetModel alloc] initWithTitle:@"在线列表" imgStr:@"room_37" type:RoomSetType_zaixianliebiao]; - [moreItems addObject:itemModel2]; - RoomSetModel *itemModel3 = [[RoomSetModel alloc] initWithTitle:@"身份管理" imgStr:@"room_47" type:RoomSetType_shenfenguanli]; - [moreItems addObject:itemModel3]; +// RoomSetModel *itemModel1 = [[RoomSetModel alloc] initWithTitle:@"麦位值全清" imgStr:@"room_43" type:RoomSetType_maiweizhiquanqing]; +// [moreItems addObject:itemModel1]; +// RoomSetModel *itemModel2 = [[RoomSetModel alloc] initWithTitle:@"在线列表" imgStr:@"room_37" type:RoomSetType_zaixianliebiao]; +// [moreItems addObject:itemModel2]; +// RoomSetModel *itemModel3 = [[RoomSetModel alloc] initWithTitle:@"身份管理" imgStr:@"room_47" type:RoomSetType_shenfenguanli]; +// [moreItems addObject:itemModel3]; if(roomAuth ==2){ RoomSetModel *itemModel3 = [[RoomSetModel alloc] initWithTitle:@"房间流水" imgStr:@"room_73" type:RoomSetType_fangjianliushui]; diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomMicroHeaderView.m b/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomMicroHeaderView.m index 1093a66..f496a32 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomMicroHeaderView.m +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomMicroHeaderView.m @@ -93,6 +93,11 @@ _microModel = microModel; self.identityBtn.hidden = YES; self.muteMicIcon.hidden = YES; + if(self.microModel == nil){ + self.headerImageView.image = nil; + + return; + } if([microModel.is_boss boolValue] ==YES){ self.headerImageView.image = KGetImage(@"room_3"); } diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomMicroView.m b/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomMicroView.m index 9ff20ec..ae6f2cf 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomMicroView.m +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomMicroView.m @@ -20,6 +20,12 @@ } - (void)setMicroModel:(RoomMicroModel *)microModel{ _microModel = microModel; + if(microModel.user_id == nil){ + self.headeImageView.microModel = microModel; + [self.incomeBtn setTitle:@"0" forState:UIControlStateNormal]; + self.nameLabel.text = @""; + return; + } self.headeImageView.microModel = microModel; self.incomeBtn.backgroundColor = [UIColor clearColor]; self.incomeBtn.layer.borderColor = UIColor.whiteColor.CGColor; diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomUserMicroView.h b/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomUserMicroView.h index 9df8dd7..02a0128 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomUserMicroView.h +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomUserMicroView.h @@ -6,10 +6,15 @@ // #import "WLBaseView.h" +#import "RoomInfoModel.h" +#import @class RoomMicroModel; NS_ASSUME_NONNULL_BEGIN @interface RoomUserMicroView : WLBaseView +@property (strong, nonatomic) TRTCCloud *engine; +@property(nonatomic,strong) RoomInfoModel *infoModel; +@property(nonatomic,strong) UserInfoModel *userInfo; @property (nonatomic,strong) WLBaseCollectionView *collectionView; /**刷新麦////息*/ -(void)reloadMicroData:(NSMutableArray *)dataArray; @@ -20,6 +25,13 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic,copy) void(^backIncomeTapBlock)(RoomMicroModel *microModel); ///播放麦位表情 - (void)showMicRoEmojiMessageToUser:(NSString *)userID url:(NSString *)url; +- (BOOL)dd_joinTRTC:(NSString *)TRTCId sign:(nonnull NSString *)sign completion:(void (^)(void))completion; +- (BOOL)dd_setMuteRemote:(BOOL)mute; +- (BOOL)dd_setMuteRemote:(BOOL)mute userId:(NSString *)userId; +- (void)dd_setBroadcast:(BOOL)on; +- (BOOL)dd_setMuteLocal:(BOOL)mute; +- (void)dd_setCxitRoom:(void (^)(void))completion; +- (void)destory; @end NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomUserMicroView.m b/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomUserMicroView.m index b7c540a..29777b9 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomUserMicroView.m +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/View/Micro/RoomUserMicroView.m @@ -8,15 +8,85 @@ #import "RoomUserMicroView.h" #import "RoomUserMicroCell.h" #import "RoomMicroModel.h" -@interface RoomUserMicroView () +#import "DDRoomRequest.h" +#import +#import "UserInfoModel.h" + + +@interface RoomUserMicroView () @property (nonatomic,strong) NSMutableArray *dataSource; @end @implementation RoomUserMicroView - +-(instancetype)init{ + self = [super init]; + if(self){ + _engine = [TRTCCloud sharedInstance]; + [_engine enableAudioVolumeEvaluation:900]; + [TRTCCloud setConsoleEnabled:NO]; + _engine.delegate = self; + } + return self; +} - (void)initView{ [self collectionView]; + } + +-(void)setInfoModel:(RoomInfoModel *)infoModel{ + _infoModel = infoModel; + [[NIMSDK sharedSDK].chatroomManager fetchChatroomQueue:[NSString stringWithFormat:@"%ld", (long)self.infoModel.roomId] completion:^(NSError * _Nullable error, NSArray *> * _Nullable info) { + if (error) return; + for (int i = 0 ; i < 8; i++) { + if(i < info.count){ + NSDictionary *item = info[i]; + UserInfoModel *userInfo = [UserInfoModel DD_ModelWithDict:item.allValues.firstObject]; + RoomMicroModel *room = [RoomMicroModel new]; + room.user_id = @(userInfo.uid).stringValue; + room.nickname = userInfo.nick; + room.avatar = userInfo.avatar; + room.open_mic = @(YES).stringValue; + room.mic_seat_valueString = @(arc4random() % 10000).stringValue; + [self.dataSource addObject:room]; + }else{ + RoomMicroModel *room = [RoomMicroModel new]; + [self.dataSource addObject:room]; + } + + } + + [self.collectionView reloadData]; + }]; + + NSInteger roomId = infoModel.roomId > INT_MAX ? infoModel.uid : infoModel.roomId; + [self dd_setTRTC:[NSString stringWithFormat:@"%ld",roomId] sign:infoModel.trtcSig]; + +} +- (BOOL)dd_setTRTC:(NSString *)Id sign:(nonnull NSString *)sign { + [self.engine enableAudioVolumeEvaluation:900]; + TRTCParams *params = [[TRTCParams alloc] init]; + UInt32 appId; + NSString *curTtcKey = [[NSUserDefaults standardUserDefaults]valueForKey:@"kTrtcAppId"]; + if(curTtcKey != nil && curTtcKey.length > 0){ + sscanf([curTtcKey UTF8String], "%u", &appId); + }else{ + sscanf([@"1400798783" UTF8String], "%u", &appId); + } + + params.sdkAppId = appId; + UInt32 roomId; + sscanf([Id UTF8String], "%u", &roomId); + params.roomId = roomId; + + params.userId = [[AccountInfoStorage instance] getUid]; + params.userSig = sign; + params.role = TRTCRoleAudience; + [self.engine enterRoom:params appScene:TRTCAppSceneLIVE]; + [self.engine muteAllRemoteAudio:NO]; + [self.engine muteLocalAudio:NO]; + return YES; +} + - (void)showMicRoEmojiMessageToUser:(NSString *)userID url:(NSString *)url{ for (RoomMicroModel *obj in self.dataSource) { if ([obj.user_id isEqualToString:userID]) { @@ -39,21 +109,62 @@ } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { RoomUserMicroCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"RoomUserMicroCell" forIndexPath:indexPath]; + if(indexPath.row < self.dataSource.count){ + RoomMicroModel *infoModel = self.dataSource[indexPath.row]; + cell.microView.microModel = infoModel; + } + + + // RoomMicroModel *model = self.dataSource[indexPath.row]; -// cell.microView.microModel = model; + WeakSelf(ws); -// cell.backHeaderTapBlock = ^{ -// if(ws.backHeaderTapBlock){ -// ws.backHeaderTapBlock(model); -// } -// }; + cell.backHeaderTapBlock = ^{ + if(cell.microView.microModel.user_id == nil){ + RoomMicroModel *r; + int j = 0; + for (int i = 0; i < self.dataSource.count; i++) { + RoomMicroModel *obj = self.dataSource[i]; + if([obj.user_id isEqualToString:@(self.userInfo.uid).stringValue] && indexPath.row != i){ + r = obj; + j = i; + break; + } + } + + if(r == nil){ + UserInfoModel *userInfo = ws.userInfo; + RoomMicroModel *room = [RoomMicroModel new]; + room.user_id = @(userInfo.uid).stringValue; + room.nickname = userInfo.nick; + room.avatar = userInfo.avatar; + room.open_mic = @(YES).stringValue; + room.mic_seat_valueString = @(arc4random() % 10000).stringValue; + [ws.dataSource replaceObjectAtIndex:indexPath.row withObject:room]; + }else{ + RoomMicroModel *rooms = [RoomMicroModel new]; + + [ws.dataSource replaceObjectAtIndex:j withObject:rooms]; + + UserInfoModel *userInfo = ws.userInfo; + RoomMicroModel *room = [RoomMicroModel new]; + room.user_id = @(userInfo.uid).stringValue; + room.nickname = userInfo.nick; + room.avatar = userInfo.avatar; + room.open_mic = @(YES).stringValue; + room.mic_seat_valueString = @(arc4random() % 10000).stringValue; + [ws.dataSource replaceObjectAtIndex:indexPath.row withObject:room]; + } + + [ws.collectionView reloadData]; + } + }; // cell.backIncomeTapBlock = ^{ -// if(ws.backIncomeTapBlock){ -// ws.backIncomeTapBlock(model); -// } +// NSLog(@"11"); // }; return cell; } + - (void)starAnimationToIndex:(NSInteger)index{ RoomUserMicroCell * cell = (RoomUserMicroCell*)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0]]; [cell.microView.headeImageView starMicroAnimation]; diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/View/PublicMessage/RoomPublicMessageView.m b/yinmeng-ios/DingDangApp/CodeClass/Room/View/PublicMessage/RoomPublicMessageView.m index 25ea81e..7982457 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/View/PublicMessage/RoomPublicMessageView.m +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/View/PublicMessage/RoomPublicMessageView.m @@ -68,13 +68,15 @@ static NSInteger kRoomMessageMaxLength = 1000; NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; if (content.eventType == NIMChatroomEventTypeEnter) { - NIMChatroomNotificationMember *member = content.targets[0]; - if (member.userId.integerValue == [AccountInfoStorage instance].getUid.integerValue) { - + [self.dataArr addObject:message]; [self handleFetchHistoryMessage:message]; - } + + }else if(message.messageType == NIMMessageTypeText) { + [self.dataArr addObject:message]; + [self.tableView reloadData]; + [self scrollToBottom:YES]; } } @@ -88,89 +90,47 @@ static NSInteger kRoomMessageMaxLength = 1000; option.order = NIMMessageSearchOrderAsc; option.messageTypes = @[@(NIMMessageTypeText)]; [[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray * _Nullable messages) { - if (messages.count) { - //如果拉取的数量等于请求的数量,说明这个时间点以后的消息数量大于等于需要拉取的数量,直接拉取最新的50条 - if (messages.count == [DDClientConfig shareConfig].configInfo.roomMessageCount) { - NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init]; - option.limit = [DDClientConfig shareConfig].configInfo.roomMessageCount; - option.order = NIMMessageSearchOrderDesc; - option.messageTypes = @[@(NIMMessageTypeText)]; - [[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray * _Nullable messages) { - if (self.dataArr.count > kRoomMessageMaxLength) { - NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)]; - NSArray *needRemoveMsgArray = [self.dataArr objectsAtIndexes:set]; - [self.dataArr removeObjectsInArray:needRemoveMsgArray]; - } - // 执行插入 -// for (NIMMessage *item in messages.reverseObjectEnumerator) { -// [self.dataArr addObject:[self.messageParser parseMessageAttribute:item]]; -// if (!self.isMiniEnter) { /// 最小化进房的话 不需要重新保存 -// if (self.roomInfo.isCloseScreen) { -// NIMCustomObject *obj = (NIMCustomObject *)item.messageObject; -// if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { -// AttachmentModel *attachment = (AttachmentModel *)obj.attachment; -// if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState){ -// [[XPRoomMiniManager shareManager] saveRoomMessage:item]; -// } -// } -// } else { -// [[XPRoomMiniManager shareManager] saveRoomMessage:item]; -// } -// } -// } -// [self.messageTableView reloadData]; -// //执行插入动画并滚动 -// [self scrollToBottom:YES]; -// BOOL hideEnter = [self handleHideEnter:message]; -// if (!hideEnter) { -// ///插入进房消息及房间公告提示 -// [self addRoomMessage:message]; -// } -// if (!roomInfo.hasAnimationEffect) { -// [self roomInfoNoGiftAnimationMessage:message]; -// } -// [self createUserEnterRoomAddRoomtopicMessage]; - }]; -// return; + for (NIMMessage *msg in messages) { + if(msg.messageType == NIMMessageTypeText){ + [self.dataArr addObject:msg]; } - if (self.dataArr.count > kRoomMessageMaxLength) { - NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)]; - NSArray *needRemoveMsgArray = [self.dataArr objectsAtIndexes:set]; - [self.dataArr removeObjectsInArray:needRemoveMsgArray]; - } - // 执行插入 - for (NIMMessage *item in messages) { -// [RoomPublicScreenModel initMessage:<#(nonnull NSString *)#> user:<#(nonnull UserInfoModel *)#> other_user:<#(nonnull UserInfoModel *)#> giftModel:<#(nonnull DDGiftWallModel *)#> message_type:<#(NSInteger)#> handle_type:<#(NSInteger)#>] -// self.dataArr addObject:<#(nonnull id)#> -// [self.dataArr addObject:[self.messageParser parseMessageAttribute:item]]; -// if (!self.isMiniEnter) {/// 最小化进房的话 不需要重新保存 -// if (self.hostDelegate.getRoomInfo.isCloseScreen) { -// NIMCustomObject *obj = (NIMCustomObject *)item.messageObject; -// if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { -// AttachmentModel *attachment = (AttachmentModel *)obj.attachment; -// if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState){ -// [[XPRoomMiniManager shareManager] saveRoomMessage:item]; -// } -// } -// } else { -// [[XPRoomMiniManager shareManager] saveRoomMessage:item]; -// } -// } - } -// [self.messageTableView reloadData]; -// //执行插入动画并滚动 -// [self scrollToBottom:YES]; } + [self.tableView reloadData]; + [self scrollToBottom:YES]; }]; } - +- (void)scrollToBottom:(BOOL)animated { + NSInteger s = [self.tableView numberOfSections]; //有多少组 + if (s<1) return; + NSInteger r = [self.tableView numberOfRowsInSection:s-1]; //最后一组行 + if (r<1) return; + NSIndexPath *ip = [NSIndexPath indexPathForRow:r-1 inSection:s-1]; //取最后一行数据 + [self.tableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:animated]; //滚动到最后一行 + +} #pragma mark --- UITableViewDelegate || UITableViewDataSource --- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 10; -// return self.dataArr.count; + + return self.dataArr.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + + + RoomPublicScreenCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RoomPublicScreenCell"]; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + if (indexPath.row < self.dataArr.count) { + cell.model = self.dataArr[indexPath.row]; + WeakSelf(ws); +// cell.cellTapGesActionBlock = ^(RoomUserInfoModel * _Nonnull userModel) { +// if (ws.cellTapGesActionBlock) { +// ws.cellTapGesActionBlock(userModel); +// } +// }; + } + return cell; + if (![ToolsObject IsNullWithObject:self.dataArr]) { RoomPublicScreenModel *model; if (indexPath.row < [self.dataArr count]) { @@ -209,11 +169,11 @@ static NSInteger kRoomMessageMaxLength = 1000; if (indexPath.row < self.dataArr.count) { cell.model = self.dataArr[indexPath.row]; WeakSelf(ws); - cell.cellTapGesActionBlock = ^(RoomUserInfoModel * _Nonnull userModel) { - if (ws.cellTapGesActionBlock) { - ws.cellTapGesActionBlock(userModel); - } - }; +// cell.cellTapGesActionBlock = ^(RoomUserInfoModel * _Nonnull userModel) { +// if (ws.cellTapGesActionBlock) { +// ws.cellTapGesActionBlock(userModel); +// } +// }; } return cell; } @@ -248,13 +208,7 @@ static NSInteger kRoomMessageMaxLength = 1000; } } - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"]; - if (cell == nil) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"]; - } - cell.selectionStyle = UITableViewCellSelectionStyleNone; - cell.textLabel.text = @"测试展示公屏"; - return cell; + } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { @@ -334,6 +288,11 @@ static NSInteger kRoomMessageMaxLength = 1000; } return _tableView; } - +- (NSMutableArray *)dataArr{ + if(!_dataArr){ + _dataArr = [NSMutableArray array]; + } + return _dataArr; +} @end diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/View/SmallRoom/RoomSmallView.h b/yinmeng-ios/DingDangApp/CodeClass/Room/View/SmallRoom/RoomSmallView.h index 4d31fe5..ccb7475 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/View/SmallRoom/RoomSmallView.h +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/View/SmallRoom/RoomSmallView.h @@ -7,6 +7,7 @@ #import "WLBaseView.h" #import "RoomInfoModel.h" +#import "RoomInfoModel.h" NS_ASSUME_NONNULL_BEGIN @interface RoomSmallView : WLBaseView @@ -20,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)shareView; - (void)showView; - (void)dismiss; -- (void)reloadWithData:(RoomModel *)model; +- (void)reloadWithData:(RoomInfoModel *)model; @property (nonatomic,assign) BOOL isKeep; @property (nonatomic, copy) void(^backEnterBlock)(void); @property (nonatomic, copy) void(^backCloseBlock)(void); diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/View/SmallRoom/RoomSmallView.m b/yinmeng-ios/DingDangApp/CodeClass/Room/View/SmallRoom/RoomSmallView.m index 1e6436a..6c4849a 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/View/SmallRoom/RoomSmallView.m +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/View/SmallRoom/RoomSmallView.m @@ -97,12 +97,10 @@ static RoomSmallView *roomSmallView; self.closebtn.frame = CGRectMake(viewWidth-26, (viewHeight-20)/2, 20, 20); } -- (void)reloadWithData:(RoomModel *)model{ - if (![model isKindOfClass:[RoomModel class]]) { - return; - } - [self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.room_head] placeholderImage:nil]; - self.liveNameLabel.text = model.room_name; +- (void)reloadWithData:(RoomInfoModel *)model{ + + [self.headImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar] placeholderImage:nil]; + self.liveNameLabel.text = model.title; } diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Cell/RoomPublicScreenCell.h b/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Cell/RoomPublicScreenCell.h index 5371642..4c53313 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Cell/RoomPublicScreenCell.h +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Cell/RoomPublicScreenCell.h @@ -7,16 +7,16 @@ #import #import "RoomPublicScreenModel.h" - +#import NS_ASSUME_NONNULL_BEGIN @interface RoomPublicScreenCell : UITableViewCell /**数据**/ -@property (nonatomic, strong) RoomPublicScreenModel *model; +@property (nonatomic, strong) NIMMessage *model; /**点击**/ -@property (nonatomic, copy) void(^cellTapGesActionBlock)(RoomUserInfoModel *userModel); +@property (nonatomic, copy) void(^cellTapGesActionBlock)(NIMMessage *userModel); @end NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Cell/RoomPublicScreenCell.m b/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Cell/RoomPublicScreenCell.m index 76b3b23..4b846c2 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Cell/RoomPublicScreenCell.m +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Cell/RoomPublicScreenCell.m @@ -16,7 +16,17 @@ @property (nonatomic, strong) UIImageView *msgBgV; /**内容**/ @property (nonatomic, strong) UILabel *msgLabel; - +/**cell高度**/ +@property (nonatomic, assign) CGFloat cellH; +/**文本宽度**/ +@property (nonatomic, assign) CGFloat textW; +/**文本高度**/ +@property (nonatomic, assign) CGFloat textH; +/**背景宽度**/ +@property (nonatomic, assign) CGFloat bgWidth; +/**背景高度**/ +@property (nonatomic, assign) CGFloat bgHeight; +@property (nonatomic, copy) NSMutableAttributedString *msgAttributeText; @end @implementation RoomPublicScreenCell @@ -34,39 +44,136 @@ - (void)tapAction:(UITapGestureRecognizer *)tap { - if ([ToolsObject IsNullWithObject:self.model.user.user_id]) { - return; - } + if (self.cellTapGesActionBlock) { - self.cellTapGesActionBlock(self.model.user); + self.cellTapGesActionBlock(self.model); } } -- (void)setModel:(RoomPublicScreenModel *)model { +- (void)setModel:(NIMMessage *)model { _model = model; - if (![model isKindOfClass:[RoomPublicScreenModel class]]) { - return; + NSString * uid = [AccountInfoStorage instance].getUid; + NIMUser * user = [[NIMSDK sharedSDK].userManager userInfo:model.from]; + RoomPublicScreenModel * pulicModel = [RoomPublicScreenModel DD_ModelWithDict:model.remoteExt[model.from]]; +// [self.gradeImgV sd_setImageWithURL:[NSURL URLWithString:pulicModel.experUrl] placeholderImage:[UIImage imageNamed:@""]]; + NSString * nick = [NSString stringWithFormat:@"%@:", ((NIMMessageChatroomExtension *)model.messageExt).roomNickname]; + if ([model.from isEqualToString:uid]) { + nick = @"我:"; } - - [self.gradeImgV sd_setImageWithURL:[NSURL URLWithString:model.user.level_icon] placeholderImage:[UIImage imageNamed:@""]]; - - self.nicknameLabel.text = model.user.nickname; + self.nicknameLabel.text = nick; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.lineSpacing = 3;//行间距 paragraphStyle.alignment=NSTextAlignmentJustified; - - self.msgLabel.attributedText = model.msgAttributeText; + NIMNotificationObject *notiMsg = (NIMNotificationObject *)model.messageObject; + NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; + if (content.eventType == NIMChatroomEventTypeEnter) { + + [self getWelcomeWithNick:nick]; + self.msgLabel.attributedText = self.msgAttributeText; + }else{ + [self getCurText:model.text]; + self.msgLabel.attributedText = self.msgAttributeText; + } + self.nicknameLabel.hidden = YES; //更新frame - self.msgBgV.frame = CGRectMake(KAdaptedWidth(15), KAdaptedHeight(35), model.bgWidth, model.bgHeight); + self.msgBgV.frame = CGRectMake(KAdaptedWidth(15), KAdaptedHeight(35), self.bgWidth, self.bgHeight); - self.msgLabel.frame = CGRectMake(KAdaptedWidth(10), KAdaptedHeight(10), model.textW, model.textH); + self.msgLabel.frame = CGRectMake(KAdaptedWidth(10), KAdaptedHeight(10), self.textW, self.textH); } +-(void)getCurText:(NSString *)text{ + NSString *messageStr = text; + //文本宽高 + CGSize msgSize = [self sizeWithText:messageStr andFont:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(kWidth - KAdaptedWidth(125), CGFLOAT_MAX) andlineSpacing:3]; + //cell高度 + self.cellH = KAdaptedHeight(55) + msgSize.height; + //msg宽高 + self.textW = msgSize.width; + self.textH = msgSize.height; + //背景宽高 + self.bgWidth = msgSize.width + KAdaptedWidth(20); + self.bgHeight = msgSize.height + KAdaptedHeight(20); + + //设置行间距 + NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:messageStr]; + NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; + //设置行间距 + paragraphStyle.lineSpacing = 3.0; + //设置两端对齐显示 + paragraphStyle.alignment = NSTextAlignmentJustified; + [attributedStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedStr.length)]; + [attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#FFFFFF"] range:NSMakeRange(0, attributedStr.length)]; + + self.msgAttributeText = attributedStr; +} +-(void)getWelcomeWithNick:(NSString *)nick{ + NSString *messageStr = [NSString stringWithFormat:@"欢迎%@ 进入本房间",nick]; + NSString * uid = [AccountInfoStorage instance].getUid; + if ([self.model.from isEqualToString:uid]) { + messageStr = [NSString stringWithFormat:@"欢迎进入本房间"]; + }else{ + messageStr = [NSString stringWithFormat:@"欢迎%@ 进入本房间",nick]; + } + + + //文本宽高 + CGSize msgSize = [self sizeWithText:messageStr andFont:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(kWidth - KAdaptedWidth(125), CGFLOAT_MAX) andlineSpacing:3]; + //cell高度 + self.cellH = KAdaptedHeight(30) + msgSize.height; + //msg宽高 + self.textW = msgSize.width; + self.textH = msgSize.height; + //背景宽高 + self.bgWidth = msgSize.width + KAdaptedWidth(20); + self.bgHeight = msgSize.height + KAdaptedHeight(20); + + //设置行间距 + NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:messageStr]; + NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; + //设置行间距 + paragraphStyle.lineSpacing = 3.0; + //设置两端对齐显示 + paragraphStyle.alignment = NSTextAlignmentJustified; + [attributedStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedStr.length)]; + [attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#FFFFFF"] range:NSMakeRange(0, attributedStr.length)]; + + NSRange range1 = [[attributedStr string] rangeOfString:nick]; + [attributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:range1]; + [attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#80AFF5"] range:range1]; + + self.msgAttributeText = attributedStr; +} +/**获取label宽高**/ +- (CGSize)sizeWithText:(NSString *)text andFont:(UIFont *)font maxSize:(CGSize)maxSize andlineSpacing:(CGFloat) lineSpaceing +{ + NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; + paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping; + paragraphStyle.alignment = NSTextAlignmentLeft; + paragraphStyle.hyphenationFactor = 1.0; + paragraphStyle.lineSpacing = lineSpaceing; + paragraphStyle.firstLineHeadIndent = 0.0; + paragraphStyle.paragraphSpacingBefore = 0.0; + paragraphStyle.headIndent = 0; + paragraphStyle.tailIndent = 0; + NSDictionary *dict = @{NSFontAttributeName : font,NSParagraphStyleAttributeName:paragraphStyle.copy}; + CGSize originSize = [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:dict context:nil].size; + NSString *test = @"我们"; + CGSize wordSize = [test boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : font} context:nil].size; + CGFloat selfHeight = [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : font} context:nil].size.height; + if (selfHeight <= wordSize.height) { + CGSize newSize = CGSizeMake(originSize.width, font.pointSize); + if (selfHeight == 0) { + newSize = CGSizeMake(originSize.width, 0); + } + originSize = newSize; + } + return originSize; +} - (void)ddBaseUI { [self.contentView addSubview:self.gradeImgV]; diff --git a/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Model/RoomPublicScreenModel.h b/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Model/RoomPublicScreenModel.h index ed20ba7..6f2c82e 100644 --- a/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Model/RoomPublicScreenModel.h +++ b/yinmeng-ios/DingDangApp/CodeClass/Room/聊天公屏/Model/RoomPublicScreenModel.h @@ -83,7 +83,51 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic,copy) NSString *cardUrl; ///cell的高度 @property (nonatomic,assign) CGFloat cardHeight; - +///魅力等级 +@property (nonatomic,copy) NSString *charmUrl; +@property (nonatomic , copy) NSString * experNewUrl; +@property (nonatomic , copy) NSString * charmNewUrl; +@property (nonatomic,assign) NSInteger erbanNo; +///经验等级 +@property (nonatomic,copy) NSString *experUrl; +///账号的类型 +@property(nonatomic, assign) UserLevelType defUser; +///是否是新用户 +@property (nonatomic,assign) BOOL newUser; +///是否是靓号 +@property (nonatomic,assign) BOOL hasPrettyErbanNo; +///是否是官方 安卓是这样用的 写上吧 +@property (nonatomic,assign) BOOL official; +///座驾名称 +@property (nonatomic,copy) NSString *carName; +///等级编号 +@property (nonatomic,assign) NSInteger experLevelSeq; +///跟随的 +@property (nonatomic,copy) NSString *fromNick; +@property (nonatomic,assign) UserEnterRoomFromType fromType; +@property (nonatomic,copy) NSString *fromUid; +///名牌的 +@property (nonatomic,copy) NSString *inRoomNameplatePic; +///铭牌的字 +@property (nonatomic,copy) NSString *inRoomNameplateWord; +///贵族icon +@property (nonatomic, copy) NSString *vipIcon; +///安卓房间公屏气泡 +@property (nonatomic, copy) NSString *androidBubbleUrl; +///iOS房间公屏气泡 +@property (nonatomic, copy) NSString *iosBubbleUrl; +///是否隐身进房 0:不隐身;1:隐身 +@property (nonatomic, assign) BOOL enterHide; +///是否防被踢 +@property (nonatomic, assign) BOOL preventKick; +///进房特效 +@property (nonatomic, copy) NSString *enterRoomEffects; +///性别 +@property (nonatomic, assign) GenderType gender; +///是否符合渠道打招呼 +@property (nonatomic,assign) BOOL fromSayHelloChannel; +/// 0 普通 1超管 +@property (nonatomic,assign) NSInteger platformRole; /** 若无对应内容,需初始化改对象 msg:公屏富文本内容 diff --git a/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomeListVC.m b/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomeListVC.m index cef83a2..a2b6484 100644 --- a/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomeListVC.m +++ b/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomeListVC.m @@ -144,7 +144,7 @@ } self.isClick = YES; DDRoomPartyModel *model = self.dataArr[indexPath.item]; - [[ToolsObject shareTools] jumpToRoomVC:model.room_id followUser:[RoomUserInfoModel new]]; + [[ToolsObject shareTools] jumpToRoomVC:model.roomId followUser:[RoomUserInfoModel new]]; WeakSelf(ws) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1*NSEC_PER_SEC), dispatch_get_main_queue(), ^{ diff --git a/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomePVC.m b/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomePVC.m index 271d7ec..03bbbce 100644 --- a/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomePVC.m +++ b/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomePVC.m @@ -146,7 +146,8 @@ // controller.adminId = [[AccountInfoStorage instance] getUid]; // AppUserModel * myModel = [ToolsObject getUserModel]; - [[ToolsObject shareTools] jumpToRoomVC:@"200271" followUser:[RoomUserInfoModel new]]; + NSString *uid = [[AccountInfoStorage instance]getUid]; + [[ToolsObject shareTools] jumpToRoomVC:uid followUser:[RoomUserInfoModel new]]; // if (myModel.realname_status == 1) {//已认证 // DDMyRoomHomeViewController *vc = [[DDMyRoomHomeViewController alloc]init]; diff --git a/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomeVC.m b/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomeVC.m index e0e0797..92b20f9 100644 --- a/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomeVC.m +++ b/yinmeng-ios/DingDangApp/V2Versions/Home/DDV2HomeVC.m @@ -11,7 +11,7 @@ #import "DDV2HomeVerticalHeadView.h" #import "Api+DDHomeApi.h" #import "AccountInfoStorage.h" - +#import "DDClientConfig.h" @interface DDV2HomeVC () @property (nonatomic, strong) UICollectionView *collectionView; @property (nonatomic, strong) NSMutableArray *dataArr; @@ -33,6 +33,7 @@ self.pageNum = 1; [self requestData]; + [[DDClientConfig shareConfig]clientInit]; } - (void)initWithSubView { diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDMain/DDDynamic/DDDynamicApi/Api+DDDynamicApi.h b/yinmeng-ios/DingDangApp/YingMeng/DDMain/DDDynamic/DDDynamicApi/Api+DDDynamicApi.h index 7d91834..a541fd2 100644 --- a/yinmeng-ios/DingDangApp/YingMeng/DDMain/DDDynamic/DDDynamicApi/Api+DDDynamicApi.h +++ b/yinmeng-ios/DingDangApp/YingMeng/DDMain/DDDynamic/DDDynamicApi/Api+DDDynamicApi.h @@ -10,11 +10,14 @@ NS_ASSUME_NONNULL_BEGIN @interface Api (DDDynamicApi) -+ (void)dd_getDynamicRecommendList:(DDRequestToolCompletion)completion page:(NSString *)page pageSize:(NSString *)pageSize types:(NSString *)types; -+ (void)dd_getDynamicLatestList:(DDRequestToolCompletion)completion dynamicId:(NSString *)dynamicId pageSize:(NSString *)pageSize types:(NSString *)types; -+ (void)dd_getDynamicFollowerList:(DDRequestToolCompletion)completion dynamicId:(NSString *)dynamicId pageSize:(NSString *)pageSize types:(NSString *)types; -+ (void)dd_getDynamicLike:(DDRequestToolCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid status:(NSString *)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId; -+ (void)dd_getDynamicPublish:(DDRequestToolCompletion)completion uid:(NSString *)uid type:(NSString *)type worldId:(NSString *)worldId content:(NSString *)content resList:(NSArray *)resList; + ++ (void)dd_getDynamicRecommendList:(HttpRequestHelperCompletion)completion page:(NSString *)page pageSize:(NSString *)pageSize types:(NSString *)types; ++ (void)dd_getDynamicLatestList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId pageSize:(NSString *)pageSize types:(NSString *)types; ++ (void)dd_getDynamicFollowerList:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId pageSize:(NSString *)pageSize types:(NSString *)types; ++ (void)dd_getDynamicLike:(HttpRequestHelperCompletion)completion dynamicId:(NSString *)dynamicId uid:(NSString *)uid status:(NSString *)status likedUid:(NSString *)likedUid worldId:(NSString *)worldId; ++ (void)dd_getDynamicPublish:(HttpRequestHelperCompletion)completion uid:(NSString *)uid type:(NSString *)type worldId:(NSString *)worldId content:(NSString *)content resList:(NSArray *)resList; ++ (void)dd_GetRoomNormalGiftList:(HttpRequestHelperCompletion)complection roomUid:(NSString *)roomUid; + @end NS_ASSUME_NONNULL_END diff --git a/yinmeng-ios/DingDangApp/YingMeng/DDMain/DDDynamic/DDDynamicApi/Api+DDDynamicApi.m b/yinmeng-ios/DingDangApp/YingMeng/DDMain/DDDynamic/DDDynamicApi/Api+DDDynamicApi.m index cec9c48..1a55e81 100644 --- a/yinmeng-ios/DingDangApp/YingMeng/DDMain/DDDynamic/DDDynamicApi/Api+DDDynamicApi.m +++ b/yinmeng-ios/DingDangApp/YingMeng/DDMain/DDDynamic/DDDynamicApi/Api+DDDynamicApi.m @@ -45,4 +45,7 @@ [DDRequestTool DD_Request_PostSkillCard:url params:dic.dd_toJSONString completion:completion]; } ++ (void)dd_GetRoomNormalGiftList:(HttpRequestHelperCompletion)complection roomUid:(NSString *)roomUid;{ + [self makeRequest:@"gift/listV4" method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, roomUid, nil]; +} @end