个播房请求上麦,弹出关注主播窗口
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#import "XPRoomFunctionContainerView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <ReactiveObjC/ReactiveObjC.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
///Tool
|
||||
#import "XPMacro.h"
|
||||
#import "AccountInfoStorage.h"
|
||||
@@ -17,12 +19,16 @@
|
||||
#import "Api+Room.h"
|
||||
#import "XCHudTool.h"
|
||||
#import "XPHtmlUrl.h"
|
||||
#import "Api+Mine.h"
|
||||
///Model
|
||||
#import "RoomInfoModel.h"
|
||||
#import "MicroQueueModel.h"
|
||||
#import "UserInfoModel.h"
|
||||
#import "AttachmentModel.h"
|
||||
///View
|
||||
#import "XPRoomHalfWebView.h"
|
||||
#import "XPAnchorAudienceUpMicView.h"
|
||||
#import "XPRoomAnchorInfoCardView.h"
|
||||
@interface XPRoomFunctionContainerView ()
|
||||
///host 代理
|
||||
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
|
||||
@@ -30,6 +36,8 @@
|
||||
@property (nonatomic,strong) UIButton *contributionButton;
|
||||
///相亲阶段的按钮
|
||||
@property (nonatomic,strong) UIButton *datingProgresButton;
|
||||
///关注个播房主倒计时
|
||||
@property (nonatomic, strong) dispatch_source_t followAnchorTimer;
|
||||
@end
|
||||
|
||||
@implementation XPRoomFunctionContainerView
|
||||
@@ -94,6 +102,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onRoomEntered {
|
||||
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
|
||||
if (roomInfo.type == RoomType_Anchor && ![[AccountInfoStorage instance].getUid isEqualToString:roomUid]) {//个播房且非房主
|
||||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||||
[Api attentionStatusCompletion:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {//是否关注了个播房主
|
||||
BOOL isLike = ((NSNumber *)data.data).boolValue;
|
||||
if (!isLike) {
|
||||
[self setFollowAnchorTimer];
|
||||
}
|
||||
} uid:uid isLikeUid:roomUid];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)handleNIMCustomMessage:(NIMMessage *)message {
|
||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||||
if (attachment.first == CustomMessageType_AnchorRoom_AudienceUpMic) {
|
||||
UserInfoModel *model = [UserInfoModel modelWithJSON:attachment.data];
|
||||
XPAnchorAudienceUpMicView *upMicView = [[XPAnchorAudienceUpMicView alloc] initWithFrame:CGRectMake(0, 0, 300, 226) delegate:self.delegate];
|
||||
upMicView.info = model;
|
||||
TTPopupConfig *config = [[TTPopupConfig alloc] init];
|
||||
config.filterIdentifier = @"audienceRequestUpMic";
|
||||
config.shouldFilterPopup = YES;
|
||||
config.contentView = upMicView;
|
||||
config.style = TTPopupStyleAlert;
|
||||
[TTPopup popupWithConfig:config];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Event Response
|
||||
- (void)contributionButtonAction:(UIButton *)sender {
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid];
|
||||
@@ -131,6 +172,54 @@
|
||||
|
||||
}];}
|
||||
|
||||
#pragma mark - 个播模式弹窗关注主播
|
||||
- (void)setFollowAnchorTimer {
|
||||
if (self.followAnchorTimer != nil) {
|
||||
dispatch_source_cancel(self.followAnchorTimer);
|
||||
}
|
||||
#ifdef DEBUG
|
||||
NSInteger totalTime = 5;
|
||||
#else
|
||||
NSInteger totalTime = 420;
|
||||
#endif
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
self.followAnchorTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
|
||||
dispatch_source_set_timer(self.followAnchorTimer,dispatch_walltime(NULL, totalTime*NSEC_PER_SEC), totalTime*NSEC_PER_SEC, 0); //每秒执行
|
||||
@weakify(self);
|
||||
dispatch_source_set_event_handler(self.followAnchorTimer, ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@strongify(self);
|
||||
dispatch_source_cancel(self.followAnchorTimer);
|
||||
RoomInfoModel* roomInfo = self.delegate.getRoomInfo;
|
||||
NSString *roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid];
|
||||
NSString * uid = [[AccountInfoStorage instance] getUid];
|
||||
[Api attentionStatusCompletion:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
BOOL isLike = ((NSNumber *)data.data).boolValue;
|
||||
if (!isLike) { // 还没有关注
|
||||
if (self.window) {
|
||||
[self showFollowAnchorView];
|
||||
}
|
||||
}
|
||||
} uid:uid isLikeUid:roomUid];
|
||||
});
|
||||
});
|
||||
dispatch_resume(self.followAnchorTimer);
|
||||
}
|
||||
|
||||
//弹出关注主播的窗口
|
||||
- (void)showFollowAnchorView {
|
||||
RoomInfoModel* roomInfo = self.delegate.getRoomInfo;
|
||||
NSString *roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid];
|
||||
[Api getUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
UserInfoModel *userInfo = [UserInfoModel modelWithDictionary:data.data];
|
||||
XPRoomAnchorInfoCardView *view = [[XPRoomAnchorInfoCardView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 300)];
|
||||
view.userInfo = self.delegate.getUserInfo;
|
||||
view.targetUserInfo = userInfo;
|
||||
view.roomId =roomInfo.roomId;
|
||||
[TTPopup popupView:view style:TTPopupStyleActionSheet];
|
||||
} uid:roomUid];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UIButton *)contributionButton {
|
||||
if (!_contributionButton) {
|
||||
|
Reference in New Issue
Block a user