diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 4d626578..d70c1d1e 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -212,6 +212,7 @@ 9B92A37027981F5B00AD168F /* XPSkillCardEditViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B92A36F27981F5B00AD168F /* XPSkillCardEditViewController.m */; }; 9B92C02227E0BD040044C5EA /* XPNobleTrumpetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B92C02127E0BD040044C5EA /* XPNobleTrumpetModel.m */; }; 9B9BBF7F288F8D4E004E2E74 /* XPFootPrintNavView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9BBF7E288F8D4E004E2E74 /* XPFootPrintNavView.m */; }; + 9B9BBF83288FBFB3004E2E74 /* XPNewUserRoomGiftView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9BBF82288FBFB3004E2E74 /* XPNewUserRoomGiftView.m */; }; 9B9DD94A281BC17600DBA903 /* XPCandyTreeMoreRuleCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9DD949281BC17600DBA903 /* XPCandyTreeMoreRuleCell.m */; }; 9B9DFD9A27DB2194000F95B3 /* XPSessionMessageHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9DFD9927DB2194000F95B3 /* XPSessionMessageHeadView.m */; }; 9B9EEF4E27C8755C006B0EB3 /* XPSkillCardResourcePropModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B9EEF4D27C8755C006B0EB3 /* XPSkillCardResourcePropModel.m */; }; @@ -1289,6 +1290,8 @@ 9B92C02127E0BD040044C5EA /* XPNobleTrumpetModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNobleTrumpetModel.m; sourceTree = ""; }; 9B9BBF7D288F8D4E004E2E74 /* XPFootPrintNavView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPFootPrintNavView.h; sourceTree = ""; }; 9B9BBF7E288F8D4E004E2E74 /* XPFootPrintNavView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPFootPrintNavView.m; sourceTree = ""; }; + 9B9BBF81288FBFB3004E2E74 /* XPNewUserRoomGiftView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNewUserRoomGiftView.h; sourceTree = ""; }; + 9B9BBF82288FBFB3004E2E74 /* XPNewUserRoomGiftView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNewUserRoomGiftView.m; sourceTree = ""; }; 9B9DD948281BC17600DBA903 /* XPCandyTreeMoreRuleCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeMoreRuleCell.h; sourceTree = ""; }; 9B9DD949281BC17600DBA903 /* XPCandyTreeMoreRuleCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeMoreRuleCell.m; sourceTree = ""; }; 9B9DFD9827DB2194000F95B3 /* XPSessionMessageHeadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPSessionMessageHeadView.h; sourceTree = ""; }; @@ -3809,6 +3812,15 @@ path = Model; sourceTree = ""; }; + 9B9BBF80288FBF93004E2E74 /* NewUserGift */ = { + isa = PBXGroup; + children = ( + 9B9BBF81288FBFB3004E2E74 /* XPNewUserRoomGiftView.h */, + 9B9BBF82288FBFB3004E2E74 /* XPNewUserRoomGiftView.m */, + ); + path = NewUserGift; + sourceTree = ""; + }; 9B9DFDA227DB4F68000F95B3 /* Recovered References */ = { isa = PBXGroup; children = ( @@ -5869,6 +5881,7 @@ E8AEAED8271413530017FCE0 /* View */ = { isa = PBXGroup; children = ( + 9B9BBF80288FBF93004E2E74 /* NewUserGift */, 9B7D904A287BC4FC0033A45E /* AnchorCycleView */, E87AE8C2284E1A6B00CAFBB3 /* NewUserGreet */, E8E859E628264F0000EE4857 /* BackMusic */, @@ -7304,6 +7317,7 @@ E84CBCE128436D3C00D43221 /* XPMineContactViewController.m in Sources */, E8D48253278D8228003C1D08 /* AcrossRoomPKPanelModel.m in Sources */, E824545C26F5EEBA00BE8163 /* XPMineVerifIdentityPresenter.m in Sources */, + 9B9BBF83288FBFB3004E2E74 /* XPNewUserRoomGiftView.m in Sources */, 9B92A3562798096000AD168F /* XPSkillCardPresenter.m in Sources */, E8A1E44E2761F98600B294CA /* XPCandyTreeViewController.m in Sources */, 9B86D8802817F4A300494FCD /* XPNobleSettingNavView.m in Sources */, diff --git a/xplan-ios/Assets.xcassets/Room/NewUserGift/Contents.json b/xplan-ios/Assets.xcassets/Room/NewUserGift/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/NewUserGift/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/NewUserGift/room_newUser_gift_bg.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/NewUserGift/room_newUser_gift_bg.imageset/Contents.json new file mode 100644 index 00000000..83527b22 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/NewUserGift/room_newUser_gift_bg.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "room_newUser_gift_bg@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "room_newUser_gift_bg@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/NewUserGift/room_newUser_gift_bg.imageset/room_newUser_gift_bg@2x.png b/xplan-ios/Assets.xcassets/Room/NewUserGift/room_newUser_gift_bg.imageset/room_newUser_gift_bg@2x.png new file mode 100644 index 00000000..3ca3843e Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/NewUserGift/room_newUser_gift_bg.imageset/room_newUser_gift_bg@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/NewUserGift/room_newUser_gift_bg.imageset/room_newUser_gift_bg@3x.png b/xplan-ios/Assets.xcassets/Room/NewUserGift/room_newUser_gift_bg.imageset/room_newUser_gift_bg@3x.png new file mode 100644 index 00000000..84d53b98 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/NewUserGift/room_newUser_gift_bg.imageset/room_newUser_gift_bg@3x.png differ diff --git a/xplan-ios/Global/XPConstant.h b/xplan-ios/Global/XPConstant.h index 197b78bc..4f9f36b1 100644 --- a/xplan-ios/Global/XPConstant.h +++ b/xplan-ios/Global/XPConstant.h @@ -15,6 +15,7 @@ UIKIT_EXTERN NSString * const kWeChatNumber; UIKIT_EXTERN NSString * const kTeenagerAlertDatekey; UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; UIKIT_EXTERN NSString * const kVisitorUnReadCountNotificationKey; +UIKIT_EXTERN NSString * const kHadShowNewUserGiftKey; typedef NS_ENUM(NSUInteger, KeyType) { KeyType_PasswordEncode,///密码 des 加密的 diff --git a/xplan-ios/Global/XPConstant.m b/xplan-ios/Global/XPConstant.m index e217c8c9..66dababa 100644 --- a/xplan-ios/Global/XPConstant.m +++ b/xplan-ios/Global/XPConstant.m @@ -21,6 +21,8 @@ NSString * const kRoomBackMusicAudioMixingVolumeKey = @"kRoomBackMusicAudioMixin NSString * const kRoomBackMusicPlayMusicOrderKey = @"kRoomBackMusicPlayMusicOrderKey";///房间背景音乐 播放顺序 单曲 顺序 1 0 NSString * const kRoomBackMusicPlayMusicFinishKey = @"kRoomBackMusicPlayMusicFinishKey";///房间背景音乐 播放完毕的key NSString * const kUserCompleteInfoFinishKey = @"kUserCompleteInfoFinishKey";///补全资料完成 +NSString * const kHadShowNewUserGiftKey = @"kHadShowNewUserGiftKey";//新用户房间礼物 + ///在里面进行判断当前环境是什么 NSString * const KeyWithType(KeyType type) { BOOL isRelase = NO; diff --git a/xplan-ios/Main/Room/Presenter/XPRoomPresenter.h b/xplan-ios/Main/Room/Presenter/XPRoomPresenter.h index ce10ee56..46b232e5 100644 --- a/xplan-ios/Main/Room/Presenter/XPRoomPresenter.h +++ b/xplan-ios/Main/Room/Presenter/XPRoomPresenter.h @@ -54,10 +54,6 @@ NS_ASSUME_NONNULL_BEGIN /// @param roomUid 房间的uid - (void)getCycleAnchorRoomList:(NSString *)roomUid; -/// 获取新用户进房礼物 -/// @param roomUid 房间uid -- (void)getNewUserInRoomGift:(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 d52792cd..634ca03e 100644 --- a/xplan-ios/Main/Room/Presenter/XPRoomPresenter.m +++ b/xplan-ios/Main/Room/Presenter/XPRoomPresenter.m @@ -216,13 +216,4 @@ } roomUid:roomUid]; } -/// 获取新用户进房礼物 -/// @param roomUid 房间uid -- (void)getNewUserInRoomGift:(NSString *)roomUid { - [Api requestNewUserInRoomGift:[self createHttpCompletion:^(BaseModel * _Nonnull data) { - NSLog(@"%@", data.data); -// [[self getView] getNewUserInRoomGiftSuccess]; - }] roomUid:roomUid]; -} - @end diff --git a/xplan-ios/Main/Room/Protocol/XPRoomProtocol.h b/xplan-ios/Main/Room/Protocol/XPRoomProtocol.h index 8a274379..8e31095f 100644 --- a/xplan-ios/Main/Room/Protocol/XPRoomProtocol.h +++ b/xplan-ios/Main/Room/Protocol/XPRoomProtocol.h @@ -25,8 +25,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)getRoomSuperAdminScuccess:(NSArray *)list; ///获取下一个个播房成功 - (void)getNextAnchorRoomSuccess:(RoomInfoModel *)roomInfo; -///获取新用户进房礼物成功 -- (void)getNewUserInRoomGiftSuccess; @end diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m index 31837a88..32fa2522 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -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)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 { diff --git a/xplan-ios/Main/Room/View/NewUserGift/XPNewUserRoomGiftView.h b/xplan-ios/Main/Room/View/NewUserGift/XPNewUserRoomGiftView.h new file mode 100644 index 00000000..31069f03 --- /dev/null +++ b/xplan-ios/Main/Room/View/NewUserGift/XPNewUserRoomGiftView.h @@ -0,0 +1,19 @@ +// +// XPNewUserRoomGiftView.h +// xplan-ios +// +// Created by GreenLand on 2022/7/26. +// + +#import +#import "GiftInfoModel.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface XPNewUserRoomGiftView : UIView + +@property (nonatomic, strong) GiftInfoModel *giftInfo; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/NewUserGift/XPNewUserRoomGiftView.m b/xplan-ios/Main/Room/View/NewUserGift/XPNewUserRoomGiftView.m new file mode 100644 index 00000000..497b05a4 --- /dev/null +++ b/xplan-ios/Main/Room/View/NewUserGift/XPNewUserRoomGiftView.m @@ -0,0 +1,149 @@ +// +// XPNewUserRoomGiftView.m +// xplan-ios +// +// Created by GreenLand on 2022/7/26. +// + +#import "XPNewUserRoomGiftView.h" +///Third +#import +#import "NetImageView.h" +///Tool +#import "ThemeColor.h" +#import "UIImage+Utils.h" +#import "TTPopup.h" +#import "XPMacro.h" + +@interface XPNewUserRoomGiftView () + +@property (nonatomic, strong) UIImageView *bgImageView; +///显示标题 +@property (nonatomic,strong) UILabel *titleLabel; +@property (nonatomic, strong) NetImageView *iconImageView; +@property (nonatomic, strong) UILabel *descLabel; +///关闭按钮 +@property (nonatomic,strong) UIButton *closeButton; + +@end + + +@implementation XPNewUserRoomGiftView + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} + +#pragma mark - Private Method +- (void)initSubViews { + self.layer.masksToBounds = YES; + self.layer.cornerRadius = 15; + self.backgroundColor = [UIColor clearColor]; + [self addSubview:self.bgImageView]; + [self addSubview:self.titleLabel]; + [self addSubview:self.iconImageView]; + [self addSubview:self.descLabel]; + [self addSubview:self.closeButton]; +} + +- (void)initSubViewConstraints { + [self mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(260); + make.height.mas_equalTo(376); + }]; + [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.left.right.mas_equalTo(0); + make.height.mas_equalTo(320); + }]; + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(130); + make.left.right.mas_equalTo(self).inset(15); + make.height.mas_equalTo(17); + }]; + + [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerX.mas_equalTo(self); + make.width.height.mas_equalTo(100); + make.top.mas_equalTo(self.titleLabel.mas_bottom).mas_offset(13); + }]; + + [self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.iconImageView.mas_bottom).mas_offset(19); + make.height.mas_equalTo(17); + make.left.right.mas_equalTo(self).inset(15); + }]; + [self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(32, 32)); + make.top.mas_equalTo(self.bgImageView.mas_bottom).offset(24); + make.centerX.mas_equalTo(self); + }]; +} + +#pragma mark - Event Response +- (void)closeButtonAction:(UIButton *)sender { + [TTPopup dismiss]; +} + +#pragma mark - Getters And Setters +- (void)setGiftInfo:(GiftInfoModel *)giftInfo { + NSString *giftStr = [NSString stringWithFormat:@"%@*%zd", giftInfo.giftName, giftInfo.count]; + NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"获得新人礼物 " attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:UIColorFromRGB(0xEEFEEC)}]; + [str appendAttributedString:[[NSMutableAttributedString alloc] initWithString:giftStr attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12 weight:UIFontWeightHeavy],NSForegroundColorAttributeName:UIColorFromRGB(0xEEFEEC)}]]; + self.titleLabel.attributedText = str; + self.iconImageView.imageUrl = giftInfo.giftUrl; +} + +- (UILabel *)titleLabel { + if (!_titleLabel) { + _titleLabel = [[UILabel alloc] init]; + _titleLabel.textAlignment = NSTextAlignmentCenter; + _titleLabel.font = [UIFont systemFontOfSize:12]; + _titleLabel.textColor = UIColorFromRGB(0xEEFEEC); + } + return _titleLabel; +} + +- (UILabel *)descLabel { + if (!_descLabel) { + _descLabel = [[UILabel alloc] init]; + _descLabel.textAlignment = NSTextAlignmentCenter; + _descLabel.font = [UIFont systemFontOfSize:12]; + _descLabel.textColor = UIColorFromRGB(0xEEFEEC); + _descLabel.text = @"已放入背包,尽快使用吧~"; + } + return _descLabel; +} + +- (NetImageView *)iconImageView { + if (!_iconImageView) { + _iconImageView = [[NetImageView alloc] init]; + _iconImageView.layer.cornerRadius = 12; + _iconImageView.layer.masksToBounds = YES; + } + return _iconImageView; +} + +- (UIImageView *)bgImageView { + if (!_bgImageView) { + _bgImageView = [[UIImageView alloc] init]; + _bgImageView.image = [UIImage imageNamed:@"room_newUser_gift_bg"]; + } + return _bgImageView; +} + +- (UIButton *)closeButton { + if (!_closeButton) { + _closeButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_closeButton setImage:[UIImage imageNamed:@"anchorPk_result_close"] forState:UIControlStateNormal]; + [_closeButton addTarget:self action:@selector(closeButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _closeButton; +} + +@end diff --git a/xplan-ios/Main/Room/View/XPRoomViewController.m b/xplan-ios/Main/Room/View/XPRoomViewController.m index 697c44b3..954eda99 100644 --- a/xplan-ios/Main/Room/View/XPRoomViewController.m +++ b/xplan-ios/Main/Room/View/XPRoomViewController.m @@ -735,12 +735,6 @@ NSString * const kHadShowAnchorRoomTipKey = @"kHadShowAnchorRoomTipKey";//是否 if (self.roomInfo != nil) { [self.presenter reportUserInterRoom:[NSString stringWithFormat:@"%zd", self.roomInfo.uid]]; } - ///获取新用户礼物 - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - if (self.roomInfo.uid != [[AccountInfoStorage instance].getUid integerValue]) {///不是自己房间 - [self.presenter getNewUserInRoomGift:[NSString stringWithFormat:@"%zd", self.roomInfo.uid]]; - } - }); } - (void)enterRoomFail:(NSInteger)code {