新用户进房礼物
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
#import "XPRoomNewUserGreetView.h"
|
||||
#import "XPRoomHalfMessageView.h"
|
||||
#import "XPAcrossRoomPKCountDownView.h"
|
||||
#import "XPNewUserRoomGiftView.h"
|
||||
///个播PK
|
||||
#import "XPAnchorFansTeamEntranceView.h"
|
||||
#import "XPAnchorFansTeamViewController.h"
|
||||
@@ -130,6 +131,9 @@
|
||||
@property (nonatomic,strong) RoomPKDetailInfoModel *pkDetailInfo;
|
||||
///是否正在加载打招呼
|
||||
@property (nonatomic,assign) BOOL isLoadGreet;
|
||||
///获取新用户礼物倒计时3s
|
||||
@property (nonatomic, strong) dispatch_source_t userGiftTimer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPRoomFunctionContainerView
|
||||
@@ -141,6 +145,9 @@
|
||||
if (self.trumpetTimer != nil) {
|
||||
dispatch_source_cancel(self.trumpetTimer);
|
||||
}
|
||||
if (self.userGiftTimer != nil) {
|
||||
dispatch_source_cancel(self.userGiftTimer);
|
||||
}
|
||||
}
|
||||
|
||||
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate {
|
||||
@@ -355,6 +362,42 @@
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - 新用户房间礼物
|
||||
- (void)handleNewUserRoomGift {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
BOOL hadShow = [defaults boolForKey:kHadShowNewUserGiftKey];
|
||||
if (self.delegate.getUserInfo.newUser && !hadShow && self.delegate.getUserInfo.uid != self.delegate.getRoomInfo.uid) {
|
||||
if (self.userGiftTimer != nil) {
|
||||
dispatch_source_cancel(self.userGiftTimer);
|
||||
}
|
||||
NSInteger totalTime = 3;
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
self.userGiftTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
|
||||
dispatch_source_set_timer(self.userGiftTimer,dispatch_walltime(NULL, totalTime*NSEC_PER_SEC), totalTime*NSEC_PER_SEC, 0); //每秒执行
|
||||
@weakify(self);
|
||||
dispatch_source_set_event_handler(self.userGiftTimer, ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@strongify(self);
|
||||
if (self.userGiftTimer != nil) {
|
||||
dispatch_source_cancel(self.userGiftTimer);
|
||||
self.userGiftTimer = nil;
|
||||
}
|
||||
[Api requestNewUserInRoomGift:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200 && data.data != nil) {
|
||||
GiftInfoModel *giftInfo = [GiftInfoModel modelWithJSON:data.data];
|
||||
XPNewUserRoomGiftView *view = [[XPNewUserRoomGiftView alloc] init];
|
||||
view.giftInfo = giftInfo;
|
||||
[TTPopup popupView:view style:TTPopupStyleAlert];
|
||||
[defaults setBool:YES forKey:kHadShowNewUserGiftKey];
|
||||
[defaults synchronize];
|
||||
}
|
||||
} roomUid:[NSString stringWithFormat:@"%zd", self.delegate.getRoomInfo.uid]];
|
||||
});
|
||||
});
|
||||
dispatch_resume(self.userGiftTimer);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - 房间PK
|
||||
- (void)configRoomPKPanelView:(BOOL)isEnter {
|
||||
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
|
||||
@@ -533,6 +576,8 @@
|
||||
[self configLittleGameState];
|
||||
[self configRoomPKPanelView:YES];
|
||||
[self handleNewUserGreet];
|
||||
///新用户房间礼物
|
||||
[self handleNewUserRoomGift];
|
||||
}
|
||||
|
||||
- (void)onRoomMiniEntered {
|
||||
|
Reference in New Issue
Block a user