红包逻辑
This commit is contained in:
@@ -597,37 +597,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
if (broadcastMessage.content) {
|
||||
NSDictionary *msgDictionary = [broadcastMessage.content toJSONObject];
|
||||
AttachmentModel *attachment = [AttachmentModel modelWithJSON:msgDictionary[@"body"]];
|
||||
if (attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket) {
|
||||
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithDictionary:attachment.data];
|
||||
//判断是否在房间
|
||||
__block BOOL isInRoom;
|
||||
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj isKindOfClass:[XPRoomViewController class]]) {
|
||||
XPRoomViewController<RoomHostDelegate> * 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];
|
||||
}
|
||||
if (attachment.first == CustomMessageType_RedPacket) {
|
||||
[self receiveRedPacketDealWithData:attachment];
|
||||
} else if (attachment.first == CustomMessageType_Gift && attachment.second == Custom_Message_Sub_Gift_ChannelNotify){///广播 年度飘屏
|
||||
[self receiveBroadcastGift:attachment];
|
||||
}else if(attachment.first == CustomMessageType_Version_Update && attachment.second == Custom_Message_Version_Update_Value){
|
||||
@@ -664,7 +635,44 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///收到红包,处理数据
|
||||
-(void)receiveRedPacketDealWithData:(AttachmentModel *)attachment{
|
||||
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithDictionary:attachment.data];
|
||||
if(attachment.second == Custom_Message_Sub_AllDiamandRedPacket ){
|
||||
data.validityType = 0;
|
||||
data.kind = 1;
|
||||
}
|
||||
|
||||
//判断是否在房间
|
||||
__block BOOL isInRoom;
|
||||
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
if ([obj isKindOfClass:[XPRoomViewController class]]) {
|
||||
XPRoomViewController<RoomHostDelegate> * 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];
|
||||
}
|
||||
}
|
||||
///判断是否在房间
|
||||
-(BOOL)isInRoomWithData{
|
||||
//判断是否在房间
|
||||
|
||||
Reference in New Issue
Block a user