diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 727cba60..66d999a8 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -203,6 +203,7 @@ 9B86D8802817F4A300494FCD /* XPNobleSettingNavView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B86D87F2817F4A300494FCD /* XPNobleSettingNavView.m */; }; 9B86D88328192DC000494FCD /* XPRoomRankEntranceView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B86D88228192DC000494FCD /* XPRoomRankEntranceView.m */; }; 9B86D886281942D200494FCD /* SocialMicroView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B86D885281942D200494FCD /* SocialMicroView.m */; }; + 9B88E20C28C5EB8300D26FBA /* MessageContentRedPacketView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B88E20B28C5EB8300D26FBA /* MessageContentRedPacketView.m */; }; 9B8DE0E1289CF02900FB6EC2 /* XPGiftCompoundModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B8DE0E0289CF02900FB6EC2 /* XPGiftCompoundModel.m */; }; 9B8DE0E4289CF7AA00FB6EC2 /* XPRoomGiftCompoundView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B8DE0E3289CF7AA00FB6EC2 /* XPRoomGiftCompoundView.m */; }; 9B8DE0E8289CFE8100FB6EC2 /* compound_gift_banner.svga in Resources */ = {isa = PBXBuildFile; fileRef = 9B8DE0E7289CFE8100FB6EC2 /* compound_gift_banner.svga */; }; @@ -1562,6 +1563,8 @@ 9B86D88228192DC000494FCD /* XPRoomRankEntranceView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomRankEntranceView.m; sourceTree = ""; }; 9B86D884281942D200494FCD /* SocialMicroView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SocialMicroView.h; sourceTree = ""; }; 9B86D885281942D200494FCD /* SocialMicroView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SocialMicroView.m; sourceTree = ""; }; + 9B88E20A28C5EB8300D26FBA /* MessageContentRedPacketView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageContentRedPacketView.h; sourceTree = ""; }; + 9B88E20B28C5EB8300D26FBA /* MessageContentRedPacketView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageContentRedPacketView.m; sourceTree = ""; }; 9B8DE0DF289CF02900FB6EC2 /* XPGiftCompoundModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftCompoundModel.h; sourceTree = ""; }; 9B8DE0E0289CF02900FB6EC2 /* XPGiftCompoundModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftCompoundModel.m; sourceTree = ""; }; 9B8DE0E2289CF7AA00FB6EC2 /* XPRoomGiftCompoundView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomGiftCompoundView.h; sourceTree = ""; }; @@ -4013,6 +4016,8 @@ E85E3FA628B7A6F000268DC8 /* MessageContentMonentsView.m */, E80A63DA28B86B9700690914 /* MessageContentMonentsAutoView.h */, E80A63DB28B86B9700690914 /* MessageContentMonentsAutoView.m */, + 9B88E20A28C5EB8300D26FBA /* MessageContentRedPacketView.h */, + 9B88E20B28C5EB8300D26FBA /* MessageContentRedPacketView.m */, ); path = Content; sourceTree = ""; @@ -9490,6 +9495,7 @@ 9B8DE0E4289CF7AA00FB6EC2 /* XPRoomGiftCompoundView.m in Sources */, 1808072D2731598F001FD836 /* XPNetImageYYLabel.m in Sources */, E818E348286ECA4B005EDF68 /* XPMonentsPublishViewController.m in Sources */, + 9B88E20C28C5EB8300D26FBA /* MessageContentRedPacketView.m in Sources */, E800806827FD3B520055A8AB /* XPClanMenuView.m in Sources */, E896EFAF2771AF0F00AD2CC1 /* XPMineFriendEmptyTableViewCell.m in Sources */, E8E859E928264F4500EE4857 /* XPRoomTransferMusicViewController.m in Sources */, diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_entrance.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_entrance.imageset/Contents.json new file mode 100644 index 00000000..1d8af2b3 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_entrance.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "redPacket_entrance.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_entrance.imageset/redPacket_entrance.png b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_entrance.imageset/redPacket_entrance.png new file mode 100644 index 00000000..51b7d2e9 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_entrance.imageset/redPacket_entrance.png differ diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_icon.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_icon.imageset/Contents.json new file mode 100644 index 00000000..af388111 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_icon.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "redPacket_msg_icon@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "redPacket_msg_icon@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_icon.imageset/redPacket_msg_icon@2x.png b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_icon.imageset/redPacket_msg_icon@2x.png new file mode 100644 index 00000000..9ab64756 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_icon.imageset/redPacket_msg_icon@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_icon.imageset/redPacket_msg_icon@3x.png b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_icon.imageset/redPacket_msg_icon@3x.png new file mode 100644 index 00000000..3d0c66bd Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_icon.imageset/redPacket_msg_icon@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_inValid_bg.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_inValid_bg.imageset/Contents.json new file mode 100644 index 00000000..0d88003a --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_inValid_bg.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "redPacket_msg_inValid_bg@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "redPacket_msg_inValid_bg@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_inValid_bg.imageset/redPacket_msg_inValid_bg@2x.png b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_inValid_bg.imageset/redPacket_msg_inValid_bg@2x.png new file mode 100644 index 00000000..d3dcd181 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_inValid_bg.imageset/redPacket_msg_inValid_bg@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_inValid_bg.imageset/redPacket_msg_inValid_bg@3x.png b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_inValid_bg.imageset/redPacket_msg_inValid_bg@3x.png new file mode 100644 index 00000000..9c722cc8 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_inValid_bg.imageset/redPacket_msg_inValid_bg@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_valid_bg.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_valid_bg.imageset/Contents.json new file mode 100644 index 00000000..1ac19cf1 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_valid_bg.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "redPacket_msg_valid_bg@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "redPacket_msg_valid_bg@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_valid_bg.imageset/redPacket_msg_valid_bg@2x.png b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_valid_bg.imageset/redPacket_msg_valid_bg@2x.png new file mode 100644 index 00000000..87e237e2 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_valid_bg.imageset/redPacket_msg_valid_bg@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_valid_bg.imageset/redPacket_msg_valid_bg@3x.png b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_valid_bg.imageset/redPacket_msg_valid_bg@3x.png new file mode 100644 index 00000000..a1a16c0d Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/RedPacket/redPacket_msg_valid_bg.imageset/redPacket_msg_valid_bg@3x.png differ diff --git a/xplan-ios/Global/XPConstant.h b/xplan-ios/Global/XPConstant.h index 4f9f36b1..48f9eecf 100644 --- a/xplan-ios/Global/XPConstant.h +++ b/xplan-ios/Global/XPConstant.h @@ -16,6 +16,7 @@ UIKIT_EXTERN NSString * const kTeenagerAlertDatekey; UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; UIKIT_EXTERN NSString * const kVisitorUnReadCountNotificationKey; UIKIT_EXTERN NSString * const kHadShowNewUserGiftKey; +UIKIT_EXTERN NSString * const kRedPacketHistory; typedef NS_ENUM(NSUInteger, KeyType) { KeyType_PasswordEncode,///密码 des 加密的 diff --git a/xplan-ios/Global/XPConstant.m b/xplan-ios/Global/XPConstant.m index 2b25c889..478c9614 100644 --- a/xplan-ios/Global/XPConstant.m +++ b/xplan-ios/Global/XPConstant.m @@ -25,6 +25,7 @@ NSString * const kHadShowNewUserGiftKey = @"kHadShowNewUserGiftKey";//新用户 NSString * const kNewUserRechargeKey = @"kNewUserRechargeKey";//新用户充值优惠 不同于房间内首充 NSString * const kFromSearchToHomeViewKey = @"kFromSearchToHomeViewKey";//用户第一次从搜索页返回首页 NSString * const kTabShowAnchorCardKey = @"kTabShowAnchorCardKey"; //tab展示主播卡片 +NSString * const kRedPacketHistory = @"kRedPacketHistory"; ///在里面进行判断当前环境是什么 NSString * const KeyWithType(KeyType type) { diff --git a/xplan-ios/Main/IM/Model/AttachmentModel.h b/xplan-ios/Main/IM/Model/AttachmentModel.h index 2357aa7d..ee77a6fd 100644 --- a/xplan-ios/Main/IM/Model/AttachmentModel.h +++ b/xplan-ios/Main/IM/Model/AttachmentModel.h @@ -321,8 +321,8 @@ typedef NS_ENUM(NSUInteger, Custom_Noti_Sub_Dynamic) { typedef NS_ENUM(NSUInteger, CustomMessageSubRedPacket) { Custom_Message_Sub_RoomGiftRedPacket = 601, //房间礼物红包 Custom_Message_Sub_RoomDiamandRedPacket = 602, //房间钻石红包 - Custom_Message_Sub_AllDiamandRedPacket = 603, //全服礼物红包 - Custom_Message_Sub_AllGiftRedPacket = 604, //全服钻石红包 + Custom_Message_Sub_AllGiftRedPacket = 603, //全服礼物红包 + Custom_Message_Sub_AllDiamandRedPacket = 604, //全服钻石红包 Custom_Message_Sub_OpenRedPacketSuccess = 605,//抢红包成功 }; diff --git a/xplan-ios/Main/Message/View/NIMMessageUtils.m b/xplan-ios/Main/Message/View/NIMMessageUtils.m index 5fc126d4..eef9dd26 100644 --- a/xplan-ios/Main/Message/View/NIMMessageUtils.m +++ b/xplan-ios/Main/Message/View/NIMMessageUtils.m @@ -60,7 +60,9 @@ return text.length > 0 ? text : @"[消息]"; } else if(attachment.first == CustomMessageType_Monents && attachment.second == Custom_Message_Sub_Monents_Share) { return @"[分享了一条动态]"; - } else{ + } else if(attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket) { + return @"[你收到一个全服红包]"; + } else { text = @"[消息]"; } if (!text) { diff --git a/xplan-ios/Main/Message/View/Session/Content/MessageContentRedPacketView.h b/xplan-ios/Main/Message/View/Session/Content/MessageContentRedPacketView.h new file mode 100644 index 00000000..a04cc3d3 --- /dev/null +++ b/xplan-ios/Main/Message/View/Session/Content/MessageContentRedPacketView.h @@ -0,0 +1,16 @@ +// +// MessageContentRedPacketView.h +// xplan-ios +// +// Created by GreenLand on 2022/9/5. +// + +#import "MessageContentCustomView.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MessageContentRedPacketView : MessageContentCustomView + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Message/View/Session/Content/MessageContentRedPacketView.m b/xplan-ios/Main/Message/View/Session/Content/MessageContentRedPacketView.m new file mode 100644 index 00000000..60e07db4 --- /dev/null +++ b/xplan-ios/Main/Message/View/Session/Content/MessageContentRedPacketView.m @@ -0,0 +1,214 @@ +// +// MessageContentRedPacketView.m +// xplan-ios +// +// Created by GreenLand on 2022/9/5. +// + +#import "MessageContentRedPacketView.h" +///Third +#import +#import "ThemeColor.h" +#import "XPReceiveRedPacketModel.h" +#import "NSObject+MJExtension.h" +#import "XPConstant.h" +#import "XCCurrentVCStackManager.h" +#import "XPRoomViewController.h" +#import "RoomHostDelegate.h" + +#define MESSAGE_MAX_WIDTH 260 + +@interface MessageContentRedPacketView () + +@property (nonatomic, strong) UIImageView *bgImageView; +///红包icon +@property (nonatomic, strong) UIImageView *redPacketImageView; +///显示标题 +@property (nonatomic,strong) UILabel *titleLabel; +///发出一个全服红包 +@property (nonatomic,strong) UILabel *subLabel; +///分割线 +@property (nonatomic, strong) UIView *devideView; +///领取说明 +@property (nonatomic, strong) UILabel *descLabel; +///消息的信息 +@property (nonatomic,strong) XPReceiveRedPacketModel *messageInfo; +@property (nonatomic,strong) AttachmentModel *attachment; +@property (nonatomic,strong) NIMMessage *message; + +@end + +@implementation MessageContentRedPacketView + ++ (CGFloat)measureHeight:(NIMMessage *)message { + return 95 + CONTENT_PADDING_V_TOTAL; +} + +- (void)initSubViews { + [super initSubViews]; + [self.backView addSubview:self.bgImageView]; + [self.backView addSubview:self.redPacketImageView]; + [self.backView addSubview:self.titleLabel]; + [self.backView addSubview:self.subLabel]; + [self.backView addSubview:self.devideView]; + [self.backView addSubview:self.descLabel]; + + UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(event:)]; + [self.bgImageView addGestureRecognizer:tapGesture]; +} + +- (void)initSubViewConstraints { + [super initSubViewConstraints]; + [self.backView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(MESSAGE_MAX_WIDTH); + make.height.mas_equalTo(95); + make.edges.mas_equalTo(self).insets(UIEdgeInsetsMake(0, 0, 0, 0)); + }]; + [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(MESSAGE_MAX_WIDTH); + make.top.mas_equalTo(self.backView); + make.height.mas_equalTo(95); + make.left.mas_equalTo(self.backView); + }]; + [self.redPacketImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.backView).mas_offset(16); + make.width.mas_equalTo(31); + make.height.mas_equalTo(40); + make.top.mas_equalTo(self.backView).mas_offset(13); + }]; + + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.redPacketImageView.mas_right).mas_offset(6); + make.height.mas_equalTo(16); + make.top.mas_equalTo(self.redPacketImageView).mas_offset(12); + }]; + + [self.subLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.titleLabel); + make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(8); + make.height.mas_equalTo(13); + }]; + [self.devideView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(16); + make.right.mas_equalTo(-8); + make.top.mas_equalTo(self.redPacketImageView.mas_bottom).offset(11); + make.height.mas_equalTo(0.5); + }]; + [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(16); + make.top.mas_equalTo(self.devideView.mas_bottom).offset(9); + make.height.mas_equalTo(13); + }]; +} + +- (void)render:(NIMMessage *)message { + self.message = message; + NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; + AttachmentModel * attach = obj.attachment; + self.attachment = attach; + XPReceiveRedPacketModel * info = [XPReceiveRedPacketModel modelWithJSON:attach.data]; + self.messageInfo = info; + //超过半小时就是失效 + NSTimeInterval now = [[NSDate date] timeIntervalSince1970]; + if (now - message.timestamp > 60*30) { + self.titleLabel.text = @"红包已失效"; + self.descLabel.text = @"下次要快点来哦~"; + self.subLabel.hidden = YES; + self.bgImageView.image = [UIImage imageNamed:@"redPacket_msg_inValid_bg"]; + self.bgImageView.userInteractionEnabled = NO; + } else { + NSArray *redPacketHistory = [[NSUserDefaults standardUserDefaults] objectForKey:kRedPacketHistory]; + if (info) { + if ([redPacketHistory containsObject:info.redEnvelopeId]) { + self.subLabel.hidden = YES; + self.titleLabel.text = @"红包已领取"; + self.bgImageView.image = [UIImage imageNamed:@"redPacket_msg_inValid_bg"]; + self.descLabel.text = @"可前往账单查看详情"; + self.bgImageView.userInteractionEnabled = NO; + } else { + self.titleLabel.text = info.sendUserNick; + self.descLabel.text = @"点击进房领取>"; + self.subLabel.hidden = NO; + self.bgImageView.image = [UIImage imageNamed:@"redPacket_msg_valid_bg"]; + self.bgImageView.userInteractionEnabled = YES; + [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.redPacketImageView).mas_offset(5); + }]; + } + } + } +} + +- (void)event:(UITapGestureRecognizer *)gesture { + UIViewController * controllerView = [XCCurrentVCStackManager shareManager].getCurrentVC; + //退出原来的房间 如果有的话 TODO 总感觉这种处理不太优雅 进房入口多了 怎么办 进房需要整合 + [controllerView.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj isKindOfClass:[XPRoomViewController class]]) { + [controllerView.navigationController popToRootViewControllerAnimated:NO]; + XPRoomViewController * rooomVC = obj; + [rooomVC exitRoom]; + *stop = YES; + } + }]; + dispatch_after(1.0, dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:self.messageInfo.roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); +} + +#pragma mark - Getters And Setters +- (UIImageView *)bgImageView { + if (!_bgImageView) { + _bgImageView = [[UIImageView alloc] init]; + _bgImageView.image = [UIImage imageNamed:@"redPacket_msg_valid_bg"]; + self.bgImageView.userInteractionEnabled = YES; + } + return _bgImageView; +} + +- (UIImageView *)redPacketImageView { + if (!_redPacketImageView) { + _redPacketImageView = [[UIImageView alloc] init]; + _redPacketImageView.contentMode = UIViewContentModeScaleAspectFit; + _redPacketImageView.image = [UIImage imageNamed:@"redPacket_msg_icon"]; + } + return _redPacketImageView; +} + +- (UILabel *)titleLabel { + if (!_titleLabel) { + _titleLabel = [[UILabel alloc] init]; + _titleLabel.textAlignment= NSTextAlignmentCenter; + _titleLabel.font = [UIFont systemFontOfSize:16]; + _titleLabel.textColor = [UIColor whiteColor]; + } + return _titleLabel; +} + +- (UILabel *)subLabel { + if (!_subLabel) { + _subLabel = [[UILabel alloc] init]; + _subLabel.text = @"发出了一个全服红包"; + _subLabel.font = [UIFont systemFontOfSize:13]; + _subLabel.textColor = [UIColor whiteColor]; + } + return _subLabel; +} + +- (UILabel *)descLabel { + if (!_descLabel) { + _descLabel = [[UILabel alloc] init]; + _descLabel.font = [UIFont systemFontOfSize:13]; + _descLabel.textColor = [UIColor whiteColor]; + } + return _descLabel; +} + +- (UIView *)devideView { + if (!_devideView) { + _devideView = [[UIView alloc] init]; + _devideView.backgroundColor = [UIColor whiteColor]; + } + return _devideView; +} + +@end diff --git a/xplan-ios/Main/Message/View/Session/MessageCell.m b/xplan-ios/Main/Message/View/Session/MessageCell.m index af018a5d..d5a7f0ac 100644 --- a/xplan-ios/Main/Message/View/Session/MessageCell.m +++ b/xplan-ios/Main/Message/View/Session/MessageCell.m @@ -24,6 +24,7 @@ #import "MessageContentRiskAlertView.h" #import "MessageContentMonentsView.h" #import "MessageContentMonentsAutoView.h" +#import "MessageContentRedPacketView.h" #import "AttachmentModel.h" #import "NetImageView.h" @@ -264,7 +265,9 @@ return @"MessageContentMonentsAutoView"; } else if(attachment.first == CustomMessageType_Message_Handle && attachment.second == Custom_Message_Sub_Message_Handle_Content) { return @"MessageContentMonentsAutoView"; - }else { + } else if (attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket) { + return @"MessageContentRedPacketView"; + } else { return @"MessageContentUnSupportView"; } } else { @@ -313,7 +316,9 @@ return [MessageContentMonentsAutoView measureHeight:message]; }else if(attachment.first == CustomMessageType_Message_Handle && attachment.second == Custom_Message_Sub_Message_Handle_Content) { return [MessageContentMonentsAutoView measureHeight:message]; - } else { + } else if (attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket){ + return [MessageContentRedPacketView measureHeight:message]; + } else { return [MessageContentUnSupportView measureHeight:message]; } } @@ -388,7 +393,13 @@ return self.messageContent; } return [[MessageContentMonentsAutoView alloc] init]; - } else { + } else if(attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket) { + self.messageBackground.backgroundColor = [UIColor clearColor]; + if ([self.messageContent isKindOfClass:[MessageContentRedPacketView class]]) { + return self.messageContent; + } + return [[MessageContentRedPacketView alloc] init]; + } else { if ([self.messageContent isKindOfClass:[MessageContentUnSupportView class]]) { return self.messageContent; } diff --git a/xplan-ios/Main/Room/Api/Api+Room.h b/xplan-ios/Main/Room/Api/Api+Room.h index 83b4ca66..fc9a3627 100644 --- a/xplan-ios/Main/Room/Api/Api+Room.h +++ b/xplan-ios/Main/Room/Api/Api+Room.h @@ -194,6 +194,11 @@ NS_ASSUME_NONNULL_BEGIN /// @param roomUid 房间uid + (void)requestNewUserInRoomGift:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid; +/// 获取红包信息 +/// @param completion 完成 +/// @param roomUid 房间Uid ++ (void)requestRedPacket:(HttpRequestHelperCompletion)completion uid:(NSString *)roomUid; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/Api/Api+Room.m b/xplan-ios/Main/Room/Api/Api+Room.m index f45b99d0..3f58121b 100644 --- a/xplan-ios/Main/Room/Api/Api+Room.m +++ b/xplan-ios/Main/Room/Api/Api+Room.m @@ -233,5 +233,11 @@ [self makeRequest:@"gift/newUser/inRoom" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, roomUid, nil]; } +/// 获取红包信息 +/// @param completion 完成 +/// @param roomUid 房间Uid ++ (void)requestRedPacket:(HttpRequestHelperCompletion)completion uid:(NSString *)roomUid { + [self makeRequest:@"room/red-envelop" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, roomUid, nil]; +} @end diff --git a/xplan-ios/Main/Room/Presenter/XPRoomPresenter.h b/xplan-ios/Main/Room/Presenter/XPRoomPresenter.h index 1e4074a2..6100004e 100644 --- a/xplan-ios/Main/Room/Presenter/XPRoomPresenter.h +++ b/xplan-ios/Main/Room/Presenter/XPRoomPresenter.h @@ -57,6 +57,9 @@ NS_ASSUME_NONNULL_BEGIN ///获取当前房间是否有效 - (void)getCurrentRoomInfo:(NSString *)roomUid; +///获取红包信息 +- (void)getRedPacket:(NSString *)roomUid; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/Presenter/XPRoomPresenter.m b/xplan-ios/Main/Room/Presenter/XPRoomPresenter.m index 71326a84..fa60ba19 100644 --- a/xplan-ios/Main/Room/Presenter/XPRoomPresenter.m +++ b/xplan-ios/Main/Room/Presenter/XPRoomPresenter.m @@ -20,6 +20,7 @@ #import "XPMessageRemoteExtModel.h" #import "RoomNewUserGreetModel.h" #import "XPRoomRecommendModel.h" +#import "XPRedPacketModel.h" ///P #import "XPRoomProtocol.h" @@ -228,4 +229,12 @@ }] uid:roomUid intoUid:uid]; } +///获取房间红包 +- (void)getRedPacket:(NSString *)roomUid { + [Api requestRedPacket:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + NSArray *array = [XPRedPacketModel modelsWithArray:data.data]; + [[self getView] getRedPacketSuccess:array]; + }] uid:roomUid]; +} + @end diff --git a/xplan-ios/Main/Room/Protocol/XPRoomProtocol.h b/xplan-ios/Main/Room/Protocol/XPRoomProtocol.h index 890876c4..a8069499 100644 --- a/xplan-ios/Main/Room/Protocol/XPRoomProtocol.h +++ b/xplan-ios/Main/Room/Protocol/XPRoomProtocol.h @@ -27,6 +27,9 @@ NS_ASSUME_NONNULL_BEGIN - (void)getNextAnchorRoomSuccess:(RoomInfoModel *)roomInfo; ///获取当前房间的信息 - (void)getCurrentRoomInfoSuccess:(RoomInfoModel *_Nullable)roomInfo; +///获取红包成功 +- (void)getRedPacketSuccess:(NSArray *)list; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/MoreView/Presenter/XPMoreMenuPresenter.m b/xplan-ios/Main/Room/View/MoreView/Presenter/XPMoreMenuPresenter.m index d835bde8..5508934d 100644 --- a/xplan-ios/Main/Room/View/MoreView/Presenter/XPMoreMenuPresenter.m +++ b/xplan-ios/Main/Room/View/MoreView/Presenter/XPMoreMenuPresenter.m @@ -109,7 +109,7 @@ XPRoomMoreItemModel * redPacket = [[XPRoomMoreItemModel alloc] init]; redPacket.title = @"红包"; - redPacket.imageName = @"room_more_menu_trumpet"; + redPacket.imageName = @"redPacket_entrance"; redPacket.type = RoomMoreMenuType_Room_redPacket; redPacket.titleColor = [ThemeColor roomMoreMenuTextColor]; diff --git a/xplan-ios/Main/Room/View/SendRedPacket/Model/XPRedPacketModel.h b/xplan-ios/Main/Room/View/SendRedPacket/Model/XPRedPacketModel.h index 93be977b..fce89a63 100644 --- a/xplan-ios/Main/Room/View/SendRedPacket/Model/XPRedPacketModel.h +++ b/xplan-ios/Main/Room/View/SendRedPacket/Model/XPRedPacketModel.h @@ -29,7 +29,7 @@ typedef enum : NSUInteger { @property (nonatomic, copy) NSString *roomUId; ///发红包用户id @property (nonatomic, copy) NSString *userId; - +///发送者信息 @property (nonatomic, strong) UserInfoModel *userVO; /// 红包总数 @property (nonatomic, copy) NSString *totalNum; diff --git a/xplan-ios/Main/Room/View/SendRedPacket/XPReceiveRedPacketView.h b/xplan-ios/Main/Room/View/SendRedPacket/XPReceiveRedPacketView.h index a49ce81a..d8ecfee4 100644 --- a/xplan-ios/Main/Room/View/SendRedPacket/XPReceiveRedPacketView.h +++ b/xplan-ios/Main/Room/View/SendRedPacket/XPReceiveRedPacketView.h @@ -9,9 +9,17 @@ NS_ASSUME_NONNULL_BEGIN +@class XPReceiveRedPacketModel, XPRedPacketModel; @interface XPReceiveRedPacketView : UIView -@property (nonatomic, strong) NSDictionary *dict; +///是否在全服红包的房间内 +@property (nonatomic, assign) BOOL inAllPacketRoom; +///红包信息 +@property (nonatomic, strong) XPReceiveRedPacketModel *redPacketModel; + +@property (nonatomic, strong) XPRedPacketModel *receiveModel; + +//@property (nonatomic, strong) NSDictionary *dict; @end diff --git a/xplan-ios/Main/Room/View/SendRedPacket/XPReceiveRedPacketView.m b/xplan-ios/Main/Room/View/SendRedPacket/XPReceiveRedPacketView.m index 7b57c8d2..68a6c303 100644 --- a/xplan-ios/Main/Room/View/SendRedPacket/XPReceiveRedPacketView.m +++ b/xplan-ios/Main/Room/View/SendRedPacket/XPReceiveRedPacketView.m @@ -16,11 +16,16 @@ #import "XCHUDTool.h" #import "XPRedPacketResultModel.h" #import "XPOpenRedPacketCell.h" +#import "XCCurrentVCStackManager.h" +#import "XPRoomViewController.h" +#import "RoomHostDelegate.h" +#import "XPRoomMiniManager.h" +#import "RoomInfoModel.h" +#import "XPRedPacketModel.h" +#import "XPConstant.h" @interface XPReceiveRedPacketView() -@property (nonatomic, strong) XPReceiveRedPacketModel *redPacketModel; - @property (nonatomic, strong) XPRedPacketResultModel *resultData; @property (nonatomic, strong) UIView *alphaView; @@ -94,7 +99,7 @@ make.centerX.mas_equalTo(self.bgImageView); make.top.mas_equalTo(self.sendAvatar.mas_bottom).mas_offset(9); make.height.mas_equalTo(18); - make.left.mas_equalTo(30); + make.left.mas_equalTo(self.bgImageView).mas_offset(16); }]; [self.sendWishLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.bgImageView); @@ -108,28 +113,97 @@ }]; } -- (void)setDict:(NSDictionary *)dict { - XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithDictionary:dict]; - self.redPacketModel = data; - self.sendAvatar.imageUrl = data.sendUserAvatar; - self.sendWishLabel.text = data.redEnvelopeMessage; - if (data.redEnvelopeType == 1) { - self.sendNickLabel.text = data.sendUserNick; +- (void)setInAllPacketRoom:(BOOL)inAllPacketRoom { + _inAllPacketRoom = inAllPacketRoom; +} + +- (void)setRedPacketModel:(XPReceiveRedPacketModel *)redPacketModel { + _redPacketModel = redPacketModel; + self.sendAvatar.imageUrl = redPacketModel.sendUserAvatar; + self.sendWishLabel.text = redPacketModel.redEnvelopeMessage; + if (redPacketModel.redEnvelopeType == 1) { + self.sendNickLabel.text = redPacketModel.sendUserNick; } else { - NSString *nick = data.sendUserNick; - if (data.sendUserNick.length > 6) { - nick = [NSString stringWithFormat:@"%@...", [data.sendUserNick substringToIndex:6]]; + if (self.inAllPacketRoom) { + self.sendNickLabel.text = redPacketModel.sendUserNick; + } else { + NSString *nick = redPacketModel.sendUserNick; + if (redPacketModel.sendUserNick.length > 6) { + nick = [NSString stringWithFormat:@"%@...", [redPacketModel.sendUserNick substringToIndex:6]]; + } + NSString *roomTitle = redPacketModel.roomTitle; + if (redPacketModel.roomTitle.length > 6) { + roomTitle = [NSString stringWithFormat:@"%@...", [redPacketModel.roomTitle substringToIndex:6]]; + } + + NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] init]; + NSMutableAttributedString *roomAttr = [[NSMutableAttributedString alloc] initWithString:roomTitle attributes:@{NSForegroundColorAttributeName : UIColorFromRGB(0xFDCD00)}]; + NSMutableAttributedString *redPacketStr = [[NSMutableAttributedString alloc] initWithString:@"厅内的" attributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}]; + NSMutableAttributedString *nickAttr = [[NSMutableAttributedString alloc] initWithString:nick attributes:@{NSForegroundColorAttributeName : UIColorFromRGB(0xFDCD00)}]; + [attribute appendAttributedString:roomAttr]; + [attribute appendAttributedString:redPacketStr]; + [attribute appendAttributedString:nickAttr]; + self.sendNickLabel.attributedText = attribute; + + [self.openButton setImage:[UIImage imageNamed:@"redPacket_openRoom"] forState:UIControlStateNormal]; + [self.openButton mas_remakeConstraints:^(MASConstraintMaker *make) { + make.centerX.mas_equalTo(self.bgImageView); + make.width.mas_equalTo(147); + make.height.mas_equalTo(67); + make.bottom.mas_equalTo(self.bgImageView).mas_offset(-97); + }]; } - self.sendNickLabel.text = [NSString stringWithFormat:@"%@厅内的%@", data.roomTitle, nick]; - - [self.openButton setImage:[UIImage imageNamed:@"redPacket_openRoom"] forState:UIControlStateNormal]; } } +- (void)setReceiveModel:(XPRedPacketModel *)receiveModel { + _receiveModel = receiveModel; + self.sendAvatar.imageUrl = receiveModel.userVO.avatar; + self.sendWishLabel.text = receiveModel.message; + self.sendNickLabel.text = receiveModel.userVO.nick; +} + #pragma mark - action - (void)onOpenButtonClick:(UIButton *)sender { - //判断是否为房内红包 - //1、房内红包 + if (!self.redPacketModel) { + [self openRoomRedPacket:sender redEnvelopeId:self.receiveModel.redEnvelopeId]; + } else { + //判断是否为房内红包 + if (self.redPacketModel.redEnvelopeType == 1) { + //1、房内红包 + [self openRoomRedPacket:sender redEnvelopeId:self.redPacketModel.redEnvelopeId]; + } else { + //2、全服红包 + if (self.inAllPacketRoom) {//在全服红包的房间内,直接打开 + [self openRoomRedPacket:sender redEnvelopeId:self.redPacketModel.redEnvelopeId]; + } else {//不在房内,进入发红包的房间 + if ([XPRoomMiniManager shareManager].getRoomInfo) { + RoomInfoModel *roomInfo = [XPRoomMiniManager shareManager].getRoomInfo; + if (roomInfo.uid == self.redPacketModel.roomUid.integerValue) { + [XPRoomViewController openMiniRoom:[NSString stringWithFormat:@"%ld", roomInfo.uid] viewController:[[XCCurrentVCStackManager shareManager] getCurrentVC]]; + } else { + [XPRoomViewController openRoom:self.redPacketModel.roomUid viewController:[[XCCurrentVCStackManager shareManager] getCurrentVC]]; + } + } else { + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj isKindOfClass:[XPRoomViewController class]]) { + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController popToRootViewControllerAnimated:NO]; + XPRoomViewController * rooomVC = obj; + [rooomVC exitRoom]; + *stop = YES; + } + }]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [XPRoomViewController openRoom:self.redPacketModel.roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; + }); + } + [self removeFromSuperview]; + } + } + } +} + +- (void)openRoomRedPacket:(UIButton *)sender redEnvelopeId:(NSString *)redEnvelopeId { //1.1 开红包动画 CABasicAnimation *transformAnima = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"]; transformAnima.toValue = [NSNumber numberWithFloat:M_PI]; @@ -150,7 +224,16 @@ XPRedPacketResultModel *model = [XPRedPacketResultModel modelWithJSON:data.data]; self.resultData = model; [self showRedPacketResultViewWithResultData:model]; - } redEnvelopeId:self.redPacketModel.redEnvelopeId]; + // 如果打开红包成功 则记录当前红包状态 + NSArray *history = [[NSUserDefaults standardUserDefaults] objectForKey:kRedPacketHistory]; + NSMutableArray *tempArray = [NSMutableArray arrayWithArray:history]; + if (![tempArray containsObject:self.resultData.redEnvelopeVO.redEnvelopeId]) { + [tempArray addObject:self.resultData.redEnvelopeVO.redEnvelopeId]; + [[NSUserDefaults standardUserDefaults] setObject:tempArray forKey:kRedPacketHistory]; + [[NSUserDefaults standardUserDefaults] synchronize]; + } + + } redEnvelopeId:redEnvelopeId]; } ///显示红包结果 diff --git a/xplan-ios/Main/Room/View/XPRoomViewController.m b/xplan-ios/Main/Room/View/XPRoomViewController.m index 9e50d1d1..fabfc285 100644 --- a/xplan-ios/Main/Room/View/XPRoomViewController.m +++ b/xplan-ios/Main/Room/View/XPRoomViewController.m @@ -29,6 +29,8 @@ #import "GuildSuperAdminInfoModel.h" #import "XPKickUserModel.h" #import "ContentLevelUpgradeModel.h" +#import "XPReceiveRedPacketModel.h" +#import "XPRedPacketModel.h" ///View #import "BaseNavigationController.h" #import "XPRoomActivityContainerView.h" @@ -769,6 +771,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 if (self.giftId.length) { [[NSNotificationCenter defaultCenter] postNotificationName:@"kShowGiftView" object:@{@"giftId": self.giftId}]; } + //获取一下红包信息 + [self.presenter getRedPacket:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]]; } - (void)enterRoomFail:(NSInteger)code { @@ -949,6 +953,18 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } } +- (void)getRedPacketSuccess:(NSArray *)list { + if (list.count == 0) { + return; + } + for (XPRedPacketModel *data in list) { + XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + view.receiveModel = data; + [self.view addSubview:view]; + [self.view bringSubviewToFront:view]; + } +} + #pragma mark - NIMChatroomManagerDelegate - (void)chatroomBeKicked:(NIMChatroomBeKickedResult *)result { if (result.reason == 2) { @@ -1159,7 +1175,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } else if (attachment.first == CustomMessageType_RedPacket) { if (attachment.second == Custom_Message_Sub_RoomDiamandRedPacket) { XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; - view.dict = attachment.data; + XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data]; + view.redPacketModel = data; [self.view addSubview:view]; [self.view bringSubviewToFront:view]; } diff --git a/xplan-ios/Main/Tabbar/View/TabbarViewController.m b/xplan-ios/Main/Tabbar/View/TabbarViewController.m index 961b10c5..6372d2e0 100644 --- a/xplan-ios/Main/Tabbar/View/TabbarViewController.m +++ b/xplan-ios/Main/Tabbar/View/TabbarViewController.m @@ -40,6 +40,7 @@ #import "XPTabAnchorCardModel.h" #import "FirstRechargeModel.h" #import "MonentsUnReadModel.h" +#import "XPReceiveRedPacketModel.h" ///VC #import "TabbarViewController.h" #import "BaseViewController.h" @@ -96,6 +97,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; @property (nonatomic, strong) XPAnchorCardView *anchorCardView; ///任务完成提示 @property (nonatomic, strong) XPTaskCompleteTipView *taskTipView; +///代理 +@property (nonatomic,weak) iddelegate; @end @@ -361,53 +364,41 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; service.style = TTPopupStyleAlert; [TTPopup popupWithConfig:service]; } - } else if (attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllGiftRedPacket) { + } else if (attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket) { + XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithDictionary:attachment.data]; //判断是否在房间 - if ([XPRoomMiniManager shareManager].getRoomInfo) { - - } else { -// if ([rootViewController presentedViewController]) { //有一个被present出来的控制器 要先dismiss -// [[rootViewController presentedViewController] dismissViewControllerAnimated:YES completion:^{ -// if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) { -// [[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES]; -// } -// if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) { -// UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController; -// if (tabVC.selectedViewController.navigationController) { -// [tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES]; -// } -// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ -// [tabVC setSelectedIndex:0]; -// }); -// } -// }]; -// }else { //不是被present出来的 就有可能是rootvc或者是被push出来的 所以要判断nav是不是只有一个vc 如果有多个就pop -// if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) { -// [[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES]; -// } -// if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) { -// UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController; -// if (tabVC.selectedViewController) { -// if ([tabVC.selectedViewController isKindOfClass:[UINavigationController class]]) { -// [tabVC.selectedViewController popToRootViewControllerAnimated:YES]; -// } else { -// [tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES]; -// } -// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ -// [tabVC setSelectedIndex:0]; -// }); -// } -// } -// } + __block BOOL isInRoom; + [[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj isKindOfClass:[XPRoomViewController class]]) { + XPRoomViewController * roomVC = obj; + RoomInfoModel *roomInfo = [roomVC getRoomInfo]; + XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + if (roomInfo.uid == data.roomUid.integerValue) { + view.inAllPacketRoom = YES; + } else { + view.inAllPacketRoom = NO; + } + XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data]; + view.redPacketModel = data; + [roomVC.view addSubview:view]; + [roomVC.view bringSubviewToFront:view]; + *stop = YES; + isInRoom = YES; + } + }]; + if (!isInRoom) { + UIViewController *currentVc = [[XCCurrentVCStackManager shareManager] getCurrentVC]; + XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + view.inAllPacketRoom = NO; + XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data]; + view.redPacketModel = data; + [currentVc.view addSubview:view]; + [currentVc.view bringSubviewToFront:view]; } - XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; - view.dict = attachment.data; - [self.view addSubview:view]; - [self.view bringSubviewToFront:view]; } } } - } + } } }