diff --git a/YuMi.xcodeproj/project.pbxproj b/YuMi.xcodeproj/project.pbxproj index cc12566a..80eb8f0b 100644 --- a/YuMi.xcodeproj/project.pbxproj +++ b/YuMi.xcodeproj/project.pbxproj @@ -320,6 +320,9 @@ 23FF25682ABC3BC00064E904 /* XPHomeGameCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF25672ABC3BC00064E904 /* XPHomeGameCell.m */; }; 23FF256E2ABC48810064E904 /* XPSessionMainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF256C2ABC48810064E904 /* XPSessionMainViewController.m */; }; 23FF25702ABD456C0064E904 /* pi_home_new_play.svga in Resources */ = {isa = PBXBuildFile; fileRef = 23FF256F2ABD456C0064E904 /* pi_home_new_play.svga */; }; + 23FF25762ABD66B90064E904 /* XPFreeGiftsObtainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF25742ABD66B90064E904 /* XPFreeGiftsObtainView.m */; }; + 23FF25792ABD67CD0064E904 /* XPFreeGiftModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF25772ABD67CD0064E904 /* XPFreeGiftModel.m */; }; + 23FF257C2ABD68020064E904 /* XPGiftFreeItemCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF257B2ABD68020064E904 /* XPGiftFreeItemCell.m */; }; 23FF42632AA5861E0055733C /* XPNewHomePartyCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 23FF42622AA5861E0055733C /* XPNewHomePartyCollectionViewCell.m */; }; 23FF42652AA5AC040055733C /* home_heat.gif in Resources */ = {isa = PBXBuildFile; fileRef = 23FF42642AA5AC040055733C /* home_heat.gif */; }; 23FF42672AA5CFBB0055733C /* home_sound_wave.gif in Resources */ = {isa = PBXBuildFile; fileRef = 23FF42662AA5CFBB0055733C /* home_sound_wave.gif */; }; @@ -2022,6 +2025,12 @@ 23FF256C2ABC48810064E904 /* XPSessionMainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPSessionMainViewController.m; sourceTree = ""; }; 23FF256D2ABC48810064E904 /* XPSessionMainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPSessionMainViewController.h; sourceTree = ""; }; 23FF256F2ABD456C0064E904 /* pi_home_new_play.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = pi_home_new_play.svga; sourceTree = ""; }; + 23FF25742ABD66B90064E904 /* XPFreeGiftsObtainView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPFreeGiftsObtainView.m; sourceTree = ""; }; + 23FF25752ABD66B90064E904 /* XPFreeGiftsObtainView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPFreeGiftsObtainView.h; sourceTree = ""; }; + 23FF25772ABD67CD0064E904 /* XPFreeGiftModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPFreeGiftModel.m; sourceTree = ""; }; + 23FF25782ABD67CD0064E904 /* XPFreeGiftModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPFreeGiftModel.h; sourceTree = ""; }; + 23FF257A2ABD68020064E904 /* XPGiftFreeItemCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPGiftFreeItemCell.h; sourceTree = ""; }; + 23FF257B2ABD68020064E904 /* XPGiftFreeItemCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XPGiftFreeItemCell.m; sourceTree = ""; }; 23FF42612AA5861E0055733C /* XPNewHomePartyCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNewHomePartyCollectionViewCell.h; sourceTree = ""; }; 23FF42622AA5861E0055733C /* XPNewHomePartyCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNewHomePartyCollectionViewCell.m; sourceTree = ""; }; 23FF42642AA5AC040055733C /* home_heat.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = home_heat.gif; sourceTree = ""; }; @@ -5423,6 +5432,31 @@ path = PIIAPTool; sourceTree = ""; }; + 23FF25712ABD66B90064E904 /* FreeGiftsView */ = { + isa = PBXGroup; + children = ( + 23FF25722ABD66B90064E904 /* View */, + ); + path = FreeGiftsView; + sourceTree = ""; + }; + 23FF25722ABD66B90064E904 /* View */ = { + isa = PBXGroup; + children = ( + 23FF25732ABD66B90064E904 /* SubViews */, + ); + path = View; + sourceTree = ""; + }; + 23FF25732ABD66B90064E904 /* SubViews */ = { + isa = PBXGroup; + children = ( + 23FF25752ABD66B90064E904 /* XPFreeGiftsObtainView.h */, + 23FF25742ABD66B90064E904 /* XPFreeGiftsObtainView.m */, + ); + path = SubViews; + sourceTree = ""; + }; 9B0086C727BA4F4A0032BD2B /* Anchor */ = { isa = PBXGroup; children = ( @@ -8152,6 +8186,8 @@ E8788935273A540400BF1D57 /* Model */ = { isa = PBXGroup; children = ( + 23FF25782ABD67CD0064E904 /* XPFreeGiftModel.h */, + 23FF25772ABD67CD0064E904 /* XPFreeGiftModel.m */, E890BC02273CF0500007C46B /* XPGiftCountModel.h */, E890BC03273CF0500007C46B /* XPGiftCountModel.m */, E890BC0E273D23F00007C46B /* GiftInfoModel.h */, @@ -8231,6 +8267,8 @@ E8788949273A594C00BF1D57 /* Cell */ = { isa = PBXGroup; children = ( + 23FF257A2ABD68020064E904 /* XPGiftFreeItemCell.h */, + 23FF257B2ABD68020064E904 /* XPGiftFreeItemCell.m */, E878894A273A607C00BF1D57 /* XPGiftUserCollectionViewCell.h */, E878894B273A607C00BF1D57 /* XPGiftUserCollectionViewCell.m */, E890BC05273CF1800007C46B /* XPGiftCountCollectionViewCell.h */, @@ -9106,6 +9144,7 @@ 2331C1822A60F32D00E1D940 /* CandyTree */, 9B208A372779C1EF00F9E54A /* FaceView */, E84150B027747A7400A7F548 /* FirstRecharge */, + 23FF25712ABD66B90064E904 /* FreeGiftsView */, 236B2E202AA07D06003967A8 /* LittleGame */, E8AEAEE927141ACC0017FCE0 /* MenuContainerView */, E8AEAEE627141ACC0017FCE0 /* MessageContainerView */, @@ -10391,6 +10430,7 @@ 23E9EA412A837BE400B792F2 /* XPTreasureFairyFriendCell.m in Sources */, 23E9EA472A837BE400B792F2 /* XPTreasureFairyShopingExchangeCell.m in Sources */, E8664EDF27E45EC7000171BA /* XPRoomPKRecordPresenter.m in Sources */, + 23FF25762ABD66B90064E904 /* XPFreeGiftsObtainView.m in Sources */, E81C27A226EF23490031E639 /* YUMINNNN.h in Sources */, E80E900C27E0358900434B90 /* XPRoomTopicAlertView.m in Sources */, 9BDA3E7A27FD43EF00517FE6 /* XPAnchorFansTeamEntranceView.m in Sources */, @@ -10653,6 +10693,7 @@ 18AAF3F0279EA59300CD7DAD /* MessageContentTextClickable.m in Sources */, E8C6FFCC27548120004DC9F0 /* Api+Home.m in Sources */, E8778AF52988EF2B00CF139B /* XPSessionSayHelloTableViewCell.m in Sources */, + 23FF257C2ABD68020064E904 /* XPGiftFreeItemCell.m in Sources */, 236B2E532AA08757003967A8 /* LittleGameStageView.m in Sources */, 186A534E26FC6ED900D67B2C /* TTPopupService.m in Sources */, E85E7B3A2A4EB0D300B6D00A /* XPGuildSuperAdminSetTableViewCell.m in Sources */, @@ -10974,6 +11015,7 @@ 18F404BB2760982000A6C548 /* ChatLimitModel.m in Sources */, E8A30BE828534A63003B4873 /* XPSessionFindNewTableViewCell.m in Sources */, 9BE9F10527FF04CF00667200 /* XPAnchorFansTaskTableViewCell.m in Sources */, + 23FF25792ABD67CD0064E904 /* XPFreeGiftModel.m in Sources */, 9B92A33C2797E38100AD168F /* XPMineHeadItemTableViewCell.m in Sources */, E854103928646A00005CFD9F /* XPMonentsReplyMoreTableViewCell.m in Sources */, 9B8DE0E1289CF02900FB6EC2 /* XPGiftCompoundModel.m in Sources */, diff --git a/YuMi/Assets.xcassets/yna/FreeGiftsView/Contents.json b/YuMi/Assets.xcassets/yna/FreeGiftsView/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/YuMi/Assets.xcassets/yna/FreeGiftsView/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/yna/FreeGiftsView/free_gifts_view_close.imageset/Contents.json b/YuMi/Assets.xcassets/yna/FreeGiftsView/free_gifts_view_close.imageset/Contents.json new file mode 100644 index 00000000..b415ea1b --- /dev/null +++ b/YuMi/Assets.xcassets/yna/FreeGiftsView/free_gifts_view_close.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "free_gifts_view_close@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "free_gifts_view_close@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/yna/FreeGiftsView/free_gifts_view_close.imageset/free_gifts_view_close@2x.png b/YuMi/Assets.xcassets/yna/FreeGiftsView/free_gifts_view_close.imageset/free_gifts_view_close@2x.png new file mode 100644 index 00000000..cf93a1f5 Binary files /dev/null and b/YuMi/Assets.xcassets/yna/FreeGiftsView/free_gifts_view_close.imageset/free_gifts_view_close@2x.png differ diff --git a/YuMi/Assets.xcassets/yna/FreeGiftsView/free_gifts_view_close.imageset/free_gifts_view_close@3x.png b/YuMi/Assets.xcassets/yna/FreeGiftsView/free_gifts_view_close.imageset/free_gifts_view_close@3x.png new file mode 100644 index 00000000..88d6b109 Binary files /dev/null and b/YuMi/Assets.xcassets/yna/FreeGiftsView/free_gifts_view_close.imageset/free_gifts_view_close@3x.png differ diff --git a/YuMi/Global/YUMIConstant.m b/YuMi/Global/YUMIConstant.m index 66277809..e8047312 100644 --- a/YuMi/Global/YUMIConstant.m +++ b/YuMi/Global/YUMIConstant.m @@ -42,6 +42,10 @@ NSString * const kUpdateSoundInfo = @"kUpdateSoundInfo"; NSString * const kMineInfoDelTag = @"kMineInfoDelTag"; NSString * const kOpenRoomNotification = @"kOpenRoomNotification";///进房 NSString * const kRoomRoomLittleGameMiniStageNotificationKey = @"kRoomRoomLittleGameMiniStageNotificationKey";///小游戏最小化坑位的通知的健 + + +NSString * const kFreeGiftCountdownNotification = @"kFreeGiftCountdownNotification";///免费礼物倒计时 + ///在里面进行判断当前环境是什么 NSString * const KeyWithType(Pi_KeyType type) { BOOL isRelase = NO; diff --git a/YuMi/Modules/YMMessage/Model/AttachmentModel.h b/YuMi/Modules/YMMessage/Model/AttachmentModel.h index a811eeca..b3c21a97 100644 --- a/YuMi/Modules/YMMessage/Model/AttachmentModel.h +++ b/YuMi/Modules/YMMessage/Model/AttachmentModel.h @@ -98,6 +98,8 @@ typedef NS_ENUM(NSUInteger, CustomMessageType) { CustomMessageType_Graffiti_Gift = 94, ///星级厨房飘屏 CustomMessageType_Graffiti_Star_Kitchen = 95, + ///免费礼物倒计时重置时间 + CustomMessageType_Free_Gift_Star_Reset_Time = 96, ///精灵密藏 CustomMessageType_Treasure_Fairy = 97, ///寻爱之旅 @@ -372,7 +374,14 @@ typedef NS_ENUM(NSUInteger, CustomMessageSubLuckyBag) { /// 提醒用户收藏房间 Custom_Message_Sub_Collect_Room_Remind_User = 592, }; - +//first = CustomMessageType_Free_Gift_Star_Reset_Time +typedef NS_ENUM(NSUInteger, CustomMessageFreeGiftStarResetTime) { + ///免费礼物倒计时重置时间 + Custom_Message_Sub_Free_Gift_Star_Reset_Time = 960, + ///更新礼物信息 + Custom_Message_Sub_Update_Gift_Information = 961, + +}; ///CustomMessageType_Tarot typedef NS_ENUM(NSUInteger, CustomMessageSubTarot) { /// 塔罗中奖消息 diff --git a/YuMi/Modules/YMRoom/Api/Api+Room.h b/YuMi/Modules/YMRoom/Api/Api+Room.h index 364e3906..cd321a64 100644 --- a/YuMi/Modules/YMRoom/Api/Api+Room.h +++ b/YuMi/Modules/YMRoom/Api/Api+Room.h @@ -210,6 +210,8 @@ NS_ASSUME_NONNULL_BEGIN /// @param completion 完成 /// @param type type为0 => 屏蔽动态, objId 为 动态id, type为1 => 屏蔽房间, objId 为 用户uid + (void)requesstShielding:(HttpRequestHelperCompletion)completion type:(NSString *)type objId:(NSString *)objId; +///得到免费礼物数据 ++(void)requestFreeGiftData:(HttpRequestHelperCompletion)completion; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/Api/Api+Room.m b/YuMi/Modules/YMRoom/Api/Api+Room.m index 913db777..642f0f67 100644 --- a/YuMi/Modules/YMRoom/Api/Api+Room.m +++ b/YuMi/Modules/YMRoom/Api/Api+Room.m @@ -286,4 +286,7 @@ + (void)requesstShielding:(HttpRequestHelperCompletion)completion type:(NSString *)type objId:(NSString *)objId{ [self makeRequest:@"user/black/add" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, type,objId, nil]; } ++(void)requestFreeGiftData:(HttpRequestHelperCompletion)completion{ + [self makeRequest:@"roomFreeGift/get" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__,nil]; +} @end diff --git a/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.h b/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.h index 14544b1b..e1f39e7b 100644 --- a/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.h +++ b/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.h @@ -63,6 +63,12 @@ NS_ASSUME_NONNULL_BEGIN -(void)getRoomFirstCharegWindow:(NSString *)roomUid; ///更新首充弹窗次数 -(void)updateRoomFirstCharegWindow:(NSString *)roomUid; + +///屏蔽 +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId; +///获取免费礼物 +-(void)getFreeGiftData; + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m b/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m index f715bf5e..08d0473d 100644 --- a/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m +++ b/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m @@ -22,6 +22,7 @@ #import "XPRoomRecommendModel.h" #import "XPRedPacketModel.h" #import "FirstChargeRoomWindowModel.h" +#import "XPFreeGiftModel.h" ///P #import "XPRoomProtocol.h" @@ -253,5 +254,15 @@ [Api updateRoomFirstCharegWindow:[self createHttpCompletion:^(BaseModel * _Nonnull data) { }showLoading:NO errorToast:NO] roomUid:roomUid]; } - +- (void)requesstShieldingWtihType:(NSString *)type objId:(NSString *)objId{ + [Api requesstShielding:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + [[self getView] requesstShieldingSuccess]; + }] type:type objId:objId]; +} +-(void)getFreeGiftData{ + [Api requestFreeGiftData:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + XPFreeGiftModel *freeModel = [XPFreeGiftModel modelWithDictionary:data.data]; + [[self getView]getFreeGiftDataSuccess:freeModel]; + }]]; +} @end diff --git a/YuMi/Modules/YMRoom/Protocol/XPRoomProtocol.h b/YuMi/Modules/YMRoom/Protocol/XPRoomProtocol.h index b35f593a..1074784b 100644 --- a/YuMi/Modules/YMRoom/Protocol/XPRoomProtocol.h +++ b/YuMi/Modules/YMRoom/Protocol/XPRoomProtocol.h @@ -31,6 +31,10 @@ NS_ASSUME_NONNULL_BEGIN - (void)getRedPacketSuccess:(NSArray *)list; ///获取首充弹窗 -(void)getRoomFirstChargeWindowSuccess:(FirstChargeRoomWindowModel*)model; +///屏蔽 +-(void)requesstShieldingSuccess; +///获取免费礼物成功 +-(void)getFreeGiftDataSuccess:(XPFreeGiftModel *)freeModel; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/FreeGiftsView/View/SubViews/XPFreeGiftsObtainView.h b/YuMi/Modules/YMRoom/View/FreeGiftsView/View/SubViews/XPFreeGiftsObtainView.h new file mode 100644 index 00000000..5087e080 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/FreeGiftsView/View/SubViews/XPFreeGiftsObtainView.h @@ -0,0 +1,16 @@ +// +// XPFreeGiftsObtainView.h +// xplan-ios +// +// Created by duoban on 2022/12/6. +// + +#import +#import "XPFreeGiftModel.h" +NS_ASSUME_NONNULL_BEGIN + +@interface XPFreeGiftsObtainView : UIView +@property (nonatomic,strong) XPFreeGiftModel *freeModel; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/FreeGiftsView/View/SubViews/XPFreeGiftsObtainView.m b/YuMi/Modules/YMRoom/View/FreeGiftsView/View/SubViews/XPFreeGiftsObtainView.m new file mode 100644 index 00000000..9b6c542b --- /dev/null +++ b/YuMi/Modules/YMRoom/View/FreeGiftsView/View/SubViews/XPFreeGiftsObtainView.m @@ -0,0 +1,147 @@ +// +// XPFreeGiftsObtainView.m +// xplan-ios +// +// Created by duoban on 2022/12/6. +// + +#import "XPFreeGiftsObtainView.h" +@interface XPFreeGiftsObtainView() +///背景view +@property (nonatomic,strong) UIView *bgView; +///返回 +@property (nonatomic,strong) UIButton *backBtn; +///标题 +@property (nonatomic,strong) UILabel *titleView; +///icon图 +@property (nonatomic,strong) NetImageView *iconView; +///说明 +@property (nonatomic,strong) UILabel *instructionsView; +///确认 +@property (nonatomic,strong) UIButton *knowBtn; + +@end +@implementation XPFreeGiftsObtainView + +-(instancetype)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self){ + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} + +#pragma mark - Private Method +- (void)initSubViews { + [self addSubview:self.bgView]; + [self.bgView addSubview:self.backBtn]; + [self.bgView addSubview:self.titleView]; + [self.bgView addSubview:self.iconView]; + [self.bgView addSubview:self.instructionsView]; + [self.bgView addSubview:self.knowBtn]; + +} +- (void)initSubViewConstraints { + [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(kGetScaleWidth(349)); + make.left.right.equalTo(self); + make.bottom.equalTo(self); + }]; + [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.height.mas_equalTo(kGetScaleWidth(26)); + make.top.mas_equalTo(kGetScaleWidth(10)); + make.right.mas_equalTo(-kGetScaleWidth(15)); + }]; + [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(kGetScaleWidth(41)); + make.height.mas_equalTo(kGetScaleWidth(21)); + make.left.right.equalTo(self.bgView).inset(kGetScaleWidth(0)); + }]; + [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(kGetScaleWidth(78)); + make.width.mas_equalTo(kGetScaleWidth(120)); + make.height.mas_equalTo(kGetScaleWidth(106)); + make.centerX.equalTo(self.bgView); + }]; + [self.instructionsView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(kGetScaleWidth(206)); + make.left.right.equalTo(self.bgView).inset(kGetScaleWidth(23)); + }]; + [self.knowBtn mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.instructionsView.mas_bottom).mas_offset(kGetScaleWidth(14)); + make.width.mas_equalTo(kGetScaleWidth(200)); + make.height.mas_equalTo(kGetScaleWidth(46)); + make.centerX.equalTo(self.bgView); + }]; +} +-(void)setFreeModel:(XPFreeGiftModel *)freeModel{ + _freeModel = freeModel; + _instructionsView.text = [NSString stringWithFormat:YMLocalizedString(@"XPFreeGiftsObtainView2"),_freeModel.giftName,_freeModel.maxStage]; + _iconView.imageUrl = _freeModel.giftUrl; + int hours = (_freeModel.firstSecond.integerValue)%(24*3600)/3600; + int minutes = (_freeModel.firstSecond.integerValue)%3600/60; + int second = (_freeModel.firstSecond.integerValue)%60; + NSString *hoursStr = hours > 0 ? [NSString stringWithFormat:@"%d%@",hours,YMLocalizedString(@"XPFreeGiftsObtainView5")] : @""; + NSString *minutesStr = minutes > 0 ? [NSString stringWithFormat:@"%d%@",minutes,YMLocalizedString(@"XPFreeGiftsObtainView4")] : @""; + NSString *secondStr = second > 0 ? [NSString stringWithFormat:@"%d%@",second,YMLocalizedString(@"XPFreeGiftsObtainView3")] : @""; + NSString *time = [NSString stringWithFormat:@"%@%@%@",hoursStr,minutesStr,secondStr]; + _titleView.text = [NSString stringWithFormat:YMLocalizedString(@"XPFreeGiftsObtainView1"),time]; +} +-(void)backAction{ + [self removeFromSuperview]; +} +#pragma mark -懒加载 +- (UIView *)bgView{ + if (!_bgView){ + _bgView = [UIView new]; + _bgView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.9]; + [_bgView setCornerWithLeftTopCorner:kGetScaleWidth(25) rightTopCorner:kGetScaleWidth(25) bottomLeftCorner:0 bottomRightCorner:0 size:CGSizeMake(KScreenWidth, kGetScaleWidth(349))]; + } + return _bgView; +} +- (UIButton *)backBtn{ + if (!_backBtn){ + _backBtn = [UIButton new]; + [_backBtn setBackgroundImage:kImage(@"free_gifts_view_close") forState:UIControlStateNormal]; + [_backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; + } + return _backBtn; +} +- (UILabel *)titleView{ + if (!_titleView){ + _titleView = [UILabel labelInitWithText:@"" font:kFontMedium(15) textColor:[UIColor whiteColor]]; + _titleView.textAlignment = NSTextAlignmentCenter; + } + return _titleView; +} +- (NetImageView *)iconView{ + if (!_iconView){ + NetImageConfig *config = [[NetImageConfig alloc]init]; + config.placeHolder = [UIImageConstant defalutEmptyPlaceholder]; + _iconView = [[NetImageView alloc]initWithConfig:config]; + + } + return _iconView; +} + +- (UILabel *)instructionsView{ + if (!_instructionsView){ + _instructionsView = [UILabel labelInitWithText:@"" font:kFontRegular(12) textColor:[DJDKMIMOMColor disableButtonTextColor]]; + _instructionsView.textAlignment = NSTextAlignmentCenter; + _instructionsView.numberOfLines = 0; + } + return _instructionsView; +} +-(UIButton *)knowBtn{ + if (!_knowBtn){ + UIImage *image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(200), kGetScaleWidth(46))]; + _knowBtn = [UIButton buttonInitWithText:YMLocalizedString(@"XPFreeGiftsObtainView0") font:kFontRegular(16) textColor:[UIColor whiteColor] image:nil bgImage:image]; + _knowBtn.layer.cornerRadius = kGetScaleWidth(23); + _knowBtn.layer.masksToBounds = YES; + [_knowBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; + } + return _knowBtn; +} + +@end diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.h b/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.h index 3b111214..6c9097f6 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.h +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.h @@ -9,10 +9,11 @@ #import "RoomHostDelegate.h" #import "RoomGuestDelegate.h" #import "XPArrangeMicViewController.h" +#import "XPFreeGiftModel.h" NS_ASSUME_NONNULL_BEGIN @interface XPRoomMenuContainerView : UIView - +@property (nonatomic,strong) XPFreeGiftModel *freeModel; - (instancetype)initWithDelegate:(id)delegate; - (void)menuResignFirstResponder; diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.m b/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.m index 3c53a13c..b82544dc 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.m +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomMenuContainerView.m @@ -118,6 +118,7 @@ NSString * const kRoomPlayEnterKey = @"kRoomPlayEnterKey"; NSString * roomUid = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].uid]; XPSendGiftView * giftView = [[XPSendGiftView alloc] initWithType:SendGiftType_Room uid:roomUid]; giftView.delegate = self.delegate; + giftView.freeModel = self.freeModel; NSArray * giftUses = [self configGiftUsers:[self.delegate getMicroQueue]]; [giftView configGiftUsers:giftUses]; [self.delegate.getCurrentNav presentViewController:giftView animated:YES completion:nil]; diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.m b/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.m index e1daa54b..fd65fa30 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/Api/Api+Gift.m @@ -16,8 +16,7 @@ /// @param uid 用户uid /// @param ticket 用户ticket + (void)requestPackGiftList:(HttpRequestHelperCompletion)complection uid:(NSString *)uid ticket:(NSString *)ticket { - NSString * fang = [NSString stringFromBase64String:@"YmFja3BhY2svbGlzdFVzZXJCYWNrcGFja1Yy"];///backpack/listUserBackpackV2 - [self makeRequest:fang method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, uid, ticket, nil]; + [self makeRequest:@"backpack/listUserBackpackV3" method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__, uid, ticket, nil]; } /// 请求普通礼物列表 diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/Model/XPFreeGiftModel.h b/YuMi/Modules/YMRoom/View/SendGiftView/Model/XPFreeGiftModel.h new file mode 100644 index 00000000..60f2cd9d --- /dev/null +++ b/YuMi/Modules/YMRoom/View/SendGiftView/Model/XPFreeGiftModel.h @@ -0,0 +1,25 @@ +// +// XPFreeGiftModel.h +// xplan-ios +// +// Created by duoban on 2022/12/13. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface XPFreeGiftModel : NSObject +@property (nonatomic,copy) NSString *uid; +@property (nonatomic,copy) NSString *giftId; +@property (nonatomic,copy) NSString *giftName; +@property (nonatomic,copy) NSString *goldPrice; +@property (nonatomic,copy) NSString *giftUrl; +@property (nonatomic,copy) NSString *curStage; +@property (nonatomic,copy) NSString *curStageSecond; +@property (nonatomic,copy) NSString *maxStage; +@property (nonatomic,copy) NSString *resetTime; +@property (nonatomic,copy) NSString *firstSecond; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/Model/XPFreeGiftModel.m b/YuMi/Modules/YMRoom/View/SendGiftView/Model/XPFreeGiftModel.m new file mode 100644 index 00000000..313972cf --- /dev/null +++ b/YuMi/Modules/YMRoom/View/SendGiftView/Model/XPFreeGiftModel.m @@ -0,0 +1,12 @@ +// +// XPFreeGiftModel.m +// xplan-ios +// +// Created by duoban on 2022/12/13. +// + +#import "XPFreeGiftModel.h" + +@implementation XPFreeGiftModel + +@end diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/Cell/XPGiftFreeItemCell.h b/YuMi/Modules/YMRoom/View/SendGiftView/View/Cell/XPGiftFreeItemCell.h new file mode 100644 index 00000000..83bdb63d --- /dev/null +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/Cell/XPGiftFreeItemCell.h @@ -0,0 +1,23 @@ +// +// XPGiftFreeItemCell.h +// xplan-ios +// +// Created by duoban on 2022/12/6. +// + +#import +#import "XPFreeGiftModel.h" +#import "GiftInfoModel.h" +NS_ASSUME_NONNULL_BEGIN + + + + +@interface XPGiftFreeItemCell : UICollectionViewCell +@property (nonatomic,strong) GiftInfoModel * giftInfo; ; +@property (nonatomic,strong) XPFreeGiftModel *freeModel; + + +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/Cell/XPGiftFreeItemCell.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/Cell/XPGiftFreeItemCell.m new file mode 100644 index 00000000..23ad88d6 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/Cell/XPGiftFreeItemCell.m @@ -0,0 +1,193 @@ +// +// XPGiftFreeItemCell.m +// xplan-ios +// +// Created by duoban on 2022/12/6. +// + +#import "XPGiftFreeItemCell.h" +#import "ThemeColor+SendGift.h" +UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; + +@interface XPGiftFreeItemCell() +///背景 +@property (nonatomic,strong) UIView *bgView; +///数量 +@property (nonatomic,strong) UILabel *numView; +///倒计时 +@property (nonatomic,strong) UILabel *timeView; +///礼物图 +@property (nonatomic,strong) NetImageView *iconView; +///礼物 +@property (nonatomic,strong) UILabel *nameView; +///礼物标题 +@property (nonatomic,strong) UILabel *titleView; + +@end +@implementation XPGiftFreeItemCell +-(void)dealloc{ + [[NSNotificationCenter defaultCenter]removeObserver:self]; +} +-(instancetype)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self){ + [self initSubViews]; + [self initSubViewConstraints]; + [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getFreeGiftCountdownNotification:) name:kFreeGiftCountdownNotification object:nil]; + } + return self; +} +-(void)getFreeGiftCountdownNotification:(NSNotification *)not{ + NSDictionary *freeDic = not.userInfo; + BOOL isCountdownFinish = [freeDic[@"isCountdownFinish"] boolValue];///倒计时完成 + BOOL isReset = [freeDic[@"isReset"] boolValue];///礼物清零 + id updateGiftInfo = freeDic[@"updateGiftInfo"];///更新礼物消息 + BOOL isHiddenCountdown = [freeDic[@"isHiddenCountdown"]boolValue]; + if(isHiddenCountdown == YES){ + self.timeView.hidden = YES; + return; + } + if(updateGiftInfo != nil){ + if([updateGiftInfo isKindOfClass:[NSString class]]){return;} + NSDictionary *giftInfo = (NSDictionary *)updateGiftInfo; + NSString *giftId = giftInfo[@"giftId"]; + NSString *giftNamed = giftInfo[@"giftName"]; + NSString *giftUrl = giftInfo[@"giftUrl"]; + self.giftInfo.giftId = giftId.integerValue; + self.giftInfo.giftName = giftNamed; + self.giftInfo.giftUrl = giftUrl; + self.freeModel.giftId = giftId; + self.freeModel.giftName = giftNamed; + self.freeModel.giftUrl = giftUrl; + self.iconView.imageUrl = self.freeModel.giftUrl; + self.nameView.text = self.freeModel.giftName; + return; + } + + if(isReset == YES){ + self.numView.text = [NSString stringWithFormat:@"x%d",0]; + return; + } + if(isCountdownFinish == YES){ + self.timeView.hidden = YES; + self.giftInfo.count = self.giftInfo.count + 1; + self.numView.text = [NSString stringWithFormat:@"x%ld",_giftInfo.count]; + return; + } + if(self.timeView.hidden == YES){ + self.timeView.hidden = NO; + } + NSString *text = freeDic[@"text"]; + self.timeView.text = text; +} +#pragma mark - Private Method +- (void)initSubViews { + + + [self.contentView addSubview:self.bgView]; + [self.bgView addSubview:self.numView]; + [self.bgView addSubview:self.timeView]; + [self.bgView addSubview:self.iconView]; + [self.bgView addSubview:self.nameView]; + [self.bgView addSubview:self.titleView]; + +} +- (void)initSubViewConstraints { + [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.equalTo(self.contentView); + }]; + [self.timeView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(4); + make.right.mas_equalTo(-6); + make.width.mas_equalTo(37); + make.height.mas_equalTo(11); + }]; + [self.numView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(6); + make.centerY.equalTo(self.timeView); + make.right.equalTo(self.timeView.mas_left).mas_offset(-5); + }]; + [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(17); + make.width.mas_equalTo(48); + make.height.mas_equalTo(48); + make.centerX.equalTo(self.bgView); + }]; + [self.nameView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.iconView.mas_bottom).mas_offset(5); + make.height.mas_equalTo(14); + make.left.right.equalTo(self.bgView); + }]; + [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.equalTo(self.nameView.mas_bottom).mas_offset(1); + make.right.left.equalTo(self.bgView); + }]; +} +-(void)setGiftInfo:(GiftInfoModel *)giftInfo{ + _giftInfo = giftInfo; + _numView.text = [NSString stringWithFormat:@"x%ld",_giftInfo.count]; + if(_giftInfo.isSelected == YES){ + _bgView.backgroundColor = [DJDKMIMOMColor giftSelectBgColor]; + _bgView.layer.borderWidth = 1; + }else{ + _bgView.layer.borderWidth = 0; + _bgView.backgroundColor = [UIColor clearColor]; + } +} +-(void)setFreeModel:(XPFreeGiftModel *)freeModel{ + _freeModel = freeModel; + _iconView.imageUrl = _freeModel.giftUrl; + _nameView.text = _freeModel.giftName; + + +} + +#pragma mark -懒加载 +- (UIView *)bgView{ + if (!_bgView){ + _bgView = [UIView new]; + _bgView.backgroundColor = [DJDKMIMOMColor giftSelectBgColor]; + _bgView.layer.cornerRadius = 5; + _bgView.layer.borderColor = [DJDKMIMOMColor appMainColor].CGColor; + _bgView.layer.masksToBounds = YES; + } + return _bgView; +} +- (UILabel *)numView{ + if (!_numView){ + _numView = [UILabel labelInitWithText:@"x0" font:[UIFont systemFontOfSize:8 weight:UIFontWeightRegular] textColor:UIColorFromRGB(0x9E9E9E)]; + } + return _numView; +} +- (UILabel *)timeView{ + if (!_timeView){ + _timeView = [UILabel labelInitWithText:@"00:00:00" font:[UIFont systemFontOfSize:8 weight:UIFontWeightRegular] textColor:[UIColor whiteColor]]; + _timeView.textAlignment = NSTextAlignmentRight; + _timeView.hidden = YES; + } + return _timeView; +} +- (NetImageView *)iconView{ + if (!_iconView){ + NetImageConfig *config = [[NetImageConfig alloc]init]; + config.placeHolder = [UIImageConstant defalutEmptyPlaceholder]; + _iconView = [[NetImageView alloc]initWithConfig:config]; + + } + return _iconView; +} +- (UILabel *)nameView{ + if (!_nameView){ + _nameView = [UILabel labelInitWithText:YMLocalizedString(@"XPGiftFreeItemCell1") font:[UIFont systemFontOfSize:10 weight:UIFontWeightRegular] textColor:[UIColor whiteColor]]; + _nameView.textAlignment = NSTextAlignmentCenter; + } + return _nameView; +} +-(UILabel *)titleView{ + if (!_titleView){ + _titleView = [UILabel labelInitWithText:YMLocalizedString(@"XPGiftFreeItemCell0") font:[UIFont systemFontOfSize:8 weight:UIFontWeightRegular] textColor:[UIColor colorWithWhite:1 alpha:0.8]]; + _titleView.textAlignment = NSTextAlignmentCenter; + } + return _titleView; +} +@end diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.h b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.h index 2ebd33e2..3032ebf7 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.h +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.h @@ -54,6 +54,11 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) { @property (nonatomic, copy) NSString *defaultSelectGiftId; ///房间类型 @property (nonatomic,assign) RoomType roomType; +///免费礼物送完删除了,不能出现在背包,防止数据更新时重新加进来 +@property (nonatomic,assign) BOOL isDelFreeGift; +///免费礼物 + +@property (nonatomic,strong) XPFreeGiftModel *freeModel; ///头部礼物类型变更 /// - Parameter headType: 1:礼物 2:互动 - (void)giftHeadTypeHadChange:(NSInteger)headType; diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m index 90f7dc2b..307e87ba 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m @@ -9,11 +9,13 @@ ///Third #import ///Tool +///#import "CountDownHelper.h" #import "YUMIMacroUitls.h" #import "YUMIHtmlUrl.h" #import "ThemeColor+SendGift.h" #import "NSArray+Safe.h" #import "UIImage+Utils.h" +#import "CountDownHelper.h" ///Model #import "GiftInfoModel.h" #import "GiftReceiveInfoModel.h" @@ -23,7 +25,7 @@ #import "XPGiftEmptyCollectionViewCell.h" #import "XPGiftWeekStarCollectionViewCell.h" #import "XPGiftCollectionViewFlowLayout.h" - +#import "XPGiftFreeItemCell.h" static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIcon";///是否隐藏惩罚礼物“新”标识 @interface XPGiftInfoView () @@ -119,7 +121,14 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc GiftInfoModel * giftInfo = [self findGiftInfoByGiftId:giftReceiveInfo.giftId.integerValue]; giftInfo.count -= giftReceiveInfo.giftNum * numberUser; if (giftInfo.count == 0) { - [self.datasource removeObject:giftInfo]; + if(self.freeModel.giftId.integerValue == giftInfo.giftId){ + if([CountDownHelper shareHelper].isCountdownFinish == YES){ + self.isDelFreeGift = YES; + [self.datasource removeObject:giftInfo]; + } + }else{ + [self.datasource removeObject:giftInfo]; + } } [self.giftcollectionView reloadData]; } @@ -235,7 +244,9 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc [self.packOriginArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj isKindOfClass:GiftInfoModel.class]) { GiftInfoModel *gift = (GiftInfoModel *)obj; - giftTotal += gift.count * gift.goldPrice; + if(gift.giftId != self.freeModel.giftId.integerValue){ + giftTotal += gift.count * gift.goldPrice; + } } }]; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPGiftInfoView0" ) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10],NSForegroundColorAttributeName:[DJDKMIMOMColor textThirdColor]}]; @@ -336,10 +347,17 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc cell.weekStarGiftList = self.datasource; return cell; } - + GiftInfoModel * giftInfo; + giftInfo= [self.datasource safeObjectAtIndex1:indexPath.item]; + if(self.freeModel != nil && self.segmentType == GiftSegmentType_Pack && giftInfo.giftId == self.freeModel.giftId.integerValue){ + XPGiftFreeItemCell *itemCell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftFreeItemCell class]) forIndexPath:indexPath]; + itemCell.giftInfo = giftInfo; + itemCell.freeModel = self.freeModel; + return itemCell; + + } XPGiftItemCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class]) forIndexPath:indexPath]; - GiftInfoModel * giftInfo; - giftInfo= [self.datasource safeObjectAtIndex1:indexPath.item]; + cell.usingplaceType = self.usingplaceType; cell.curUserNobleLevel = self.curUserNobleLevel; cell.giftInfo = giftInfo; @@ -408,9 +426,19 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc break; case GiftSegmentType_Pack: { - [self.datasource addObjectsFromArray:self.packOriginArray]; - self.totalValueLabel.hidden = NO; - self.totalValueLabel.attributedText= self.totalAttribute; + if(self.isDelFreeGift == YES){ + NSMutableArray *originArray = [NSMutableArray array]; + for (GiftInfoModel *giftModel in self.packOriginArray) { + if(giftModel.giftId != self.freeModel.giftId.integerValue){ + [originArray addObject:giftModel]; + } + } + [self.datasource addObjectsFromArray:originArray]; + }else{ + [self.datasource addObjectsFromArray:self.packOriginArray]; + } + self.totalValueLabel.hidden = NO; + self.totalValueLabel.attributedText= self.totalAttribute; } break; case GiftSegmentType_Graffiti: @@ -774,6 +802,7 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc [_giftcollectionView registerClass:[XPGiftItemCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class])]; [_giftcollectionView registerClass:[XPGiftEmptyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftEmptyCollectionViewCell class])]; [_giftcollectionView registerClass:[XPGiftWeekStarCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftWeekStarCollectionViewCell class])]; + [_giftcollectionView registerClass:[XPGiftFreeItemCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftFreeItemCell class])]; _giftcollectionView.showsHorizontalScrollIndicator = NO; } return _giftcollectionView; diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.h b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.h index d6e98759..6d15bfba 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.h +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.h @@ -8,6 +8,7 @@ #import "MvpViewController.h" #import "RoomHostDelegate.h" #import "XPGiftUserInfoModel.h" +#import "XPFreeGiftModel.h" NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger, SendGiftType) { SendGiftType_Room = 1, ///房间内送礼物 @@ -15,6 +16,7 @@ typedef NS_ENUM(NSInteger, SendGiftType) { }; @interface XPSendGiftView : MvpViewController +@property (nonatomic,strong) XPFreeGiftModel *freeModel; ///房间内才需要 @property (nonatomic,weak) id delegate; /// 送礼物的 diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m index 166b78fe..0edbb268 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m @@ -46,7 +46,7 @@ #import "XPMineRechargeViewController.h" #import "XPIAPRechargeViewController.h" #import "XPWebViewController.h" - +UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; UIKIT_EXTERN NSString * kShowFirstRechargeView; @interface XPSendGiftView ()< XPGiftBarViewDelegate, XPGiftProtocol, XPGiftInfoViewDelegate, XPGraffitiGiftViewDelegate, XPGiftUsersViewDelegate, XPGiftHeadTypeViewDelegate, XPGiftLuckyGiftBroadcastViewDelegate, XPGiftTwelveStarBroadcastViewDelegate> @@ -89,6 +89,8 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; @property (nonatomic,assign) GiftSegmentType segmentType; ///福袋礼物全服记录 @property (nonatomic,strong) NSArray *records; +///背包礼物数据 +@property (nonatomic,copy) NSArray * packGiftList; @end @implementation XPSendGiftView @@ -97,7 +99,9 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; return [[XPGiftPresenter alloc] init]; } - +-(void)dealloc{ + [[NSNotificationCenter defaultCenter]removeObserver:self]; +} - (instancetype)initWithType:(SendGiftType)type uid:(NSString * __nullable)uid{ if (self = [super init]) { self.modalPresentationStyle = UIModalPresentationOverFullScreen; @@ -125,8 +129,17 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; [self.stackView addArrangedSubview:self.giftInfoView]; [self.stackView addArrangedSubview:self.giftBarView]; [self.stackView addArrangedSubview:self.bottomView]; + [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getFreeGiftCountdownNotification:) name:kFreeGiftCountdownNotification object:nil]; +} +-(void)getFreeGiftCountdownNotification:(NSNotification *)not{ + NSDictionary *freeDic = not.userInfo; + BOOL isReset = [freeDic[@"isReset"] boolValue];///礼物清零 + + if(isReset == YES){ + [self.presenter getPackGiftList]; + self.giftInfoView.isDelFreeGift = NO; + } } - - (void)initSubViewConstraints { [self.topView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.top.mas_equalTo(self.view); @@ -614,7 +627,28 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; } ///背包礼物 - (void)getPacketGiftListSuccess:(NSArray *)giftList { - self.giftInfoView.packOriginArray = giftList; + self.packGiftList = giftList; + NSMutableArray *giftArray = [NSMutableArray arrayWithArray:self.packGiftList]; + BOOL isHaveFreeGift = NO; + for (int i = 0 ; i < self.packGiftList.count; i++) { + GiftInfoModel *infoModel = self.packGiftList[i]; + if(infoModel.giftId == self.freeModel.giftId.integerValue){ + [giftArray removeObjectAtIndex:i]; + [giftArray insertObject:infoModel atIndex:0]; + isHaveFreeGift = YES; + break; + } + } + if(isHaveFreeGift == NO && self.freeModel.curStage != nil && self.freeModel.curStage.integerValue == 0 ){ + GiftInfoModel *infoModel = [GiftInfoModel new]; + infoModel.giftId = self.freeModel.giftId.integerValue; + infoModel.count = 0; + infoModel.giftUrl = self.freeModel.giftUrl; + infoModel.giftName = self.freeModel.giftName; + [giftArray insertObject:infoModel atIndex:0]; + } + self.giftInfoView.freeModel = self.freeModel; + self.giftInfoView.packOriginArray = giftArray; } - (void)getPacketGiftListFail:(NSString *)message { diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index 89144306..b54eb364 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -24,6 +24,7 @@ #import "NSMutableDictionary+Saft.h" #import "XPSkillCardPlayerManager.h" #import "XCCurrentVCStackManager.h" +#import "CountDownHelper.h" ///Model #import "RoomInfoModel.h" #import "UserInfoModel.h" @@ -36,6 +37,7 @@ #import "XPReceiveRedPacketModel.h" #import "XPRedPacketModel.h" #import "FirstChargeRoomWindowModel.h" +#import "XPFreeGiftModel.h" ///View #import "BaseNavigationController.h" #import "XPRoomActivityContainerView.h" @@ -58,6 +60,7 @@ #import "XPFirstRechargeView.h" #import "XPWebViewController.h" #import "SessionViewController.h" +#import "XPFreeGiftsObtainView.h" ///P #import "XPRoomPresenter.h" #import "XPRoomProtocol.h" @@ -75,11 +78,11 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey; UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; UIKIT_EXTERN NSString * kNewUserRechargeKey; UIKIT_EXTERN NSString * kShowFirstRechargeView; - +UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; NSString * const kHadShowAnchorRoomTipKey = @"kHadShowAnchorRoomTipKey";//是否展示过个播房上划用户引导 NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出过非自己房间 -@interface XPRoomViewController () +@interface XPRoomViewController () ///背景 @property (nonatomic,strong) XPRoomBackContainerView *backContainerView; @@ -134,6 +137,10 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 @property (nonatomic,assign) NSInteger anchorIndex; @property (nonatomic,strong) XPFirstRechargeView *firstRechargeView; @property (nonatomic,assign) BOOL isShowFirstRecharge; +///免费礼物数量 +@property (nonatomic,strong) XPFreeGiftModel *freeModel; +///免费礼物弹窗 +@property (nonatomic,strong) XPFreeGiftsObtainView *freeView; @end @implementation XPRoomViewController @@ -207,6 +214,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 if([[XPRoomMiniManager shareManager] getRoomInfo]==nil){ [XPSkillCardPlayerManager shareInstance].isMineInMic = NO; } + [[CountDownHelper shareHelper] stopCountDown]; + [CountDownHelper shareHelper].delegate = nil; [[NIMSDK sharedSDK].chatroomManager removeDelegate:self]; [[NIMSDK sharedSDK].chatManager removeDelegate:self]; [[NIMSDK sharedSDK].loginManager removeDelegate:self]; @@ -239,6 +248,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [self.presenter getNormalGiftList:self.roomUid]; ///获取房间超管列表 [self.presenter getRoomSuperAdmin:self.roomUid]; + ///获取免费礼物 + [self.presenter getFreeGiftData]; ///获取首充次数 [self.presenter getRoomFirstCharegWindow:self.roomUid]; //监听云信消息x @@ -247,6 +258,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [[NIMSDK sharedSDK].loginManager addDelegate:self]; [[NIMSDK sharedSDK].conversationManager addDelegate:self]; [[NIMSDK sharedSDK].broadcastManager addDelegate:self]; + [CountDownHelper shareHelper].delegate = self; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myGiftEffectUpdate:) name:kRoomGiftEffectUpdateNotificationKey object:nil]; [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showRoomFirstChargeWindowFormNot:) name:kShowFirstRechargeView object:nil]; [XPSkillCardPlayerManager shareInstance].isInRoom = YES; @@ -260,12 +272,18 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [super viewWillAppear:animated]; [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent; } +-(void)viewWillDisappear:(BOOL)animated{ + [super viewWillDisappear:animated]; + self.freeView.hidden = YES; +} - (void)viewDidDisappear:(BOOL)animated{ [super viewDidDisappear:animated]; + [XPSkillCardPlayerManager shareInstance].isInRoomVC = NO; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + self.freeView.hidden = NO; [XPSkillCardPlayerManager shareInstance].isInRoomVC = YES; if([XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge == YES && self.isShowFirstRecharge == NO){ [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge = NO; @@ -569,6 +587,29 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 }]; } +#pragma mark - CountDownHelperDelegate +- (void)onCountdownFinish { + [[NSNotificationCenter defaultCenter]postNotificationName:kFreeGiftCountdownNotification object:nil userInfo:@{@"isCountdownFinish":@(YES)}]; + if(self.freeModel.curStage.integerValue < self.freeModel.maxStage.integerValue){ + [self.presenter getFreeGiftData]; + } + if(self.freeModel.curStage.intValue == 0){ + self.freeView.freeModel = self.freeModel; + if(!self.freeView.superview){ + [kWindow addSubview:self.freeView]; + } + } + +} +- (void)onCountdownOpen:(int)time { + NSInteger seconds = time; + int hours = (seconds)%(24*3600)/3600; + int minutes = (seconds)%3600/60; + int second = (seconds)%60; + [[NSNotificationCenter defaultCenter]postNotificationName:kFreeGiftCountdownNotification object:nil userInfo:@{@"text":[NSString stringWithFormat:@"%02d:%02d:%02d",hours,minutes,second],@"isCountdownFinish":@(NO)}]; + + +} -(void)showRoomFirstChargeWindowFormNot:(NSNotification *)not{ if(not != nil){ NSDictionary *parameter = not.object; @@ -1115,7 +1156,29 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [self.view bringSubviewToFront:view]; } } - +-(void)getFreeGiftDataSuccess:(XPFreeGiftModel *)freeModel{ + self.freeModel = freeModel; + self.menuContainerView.freeModel = freeModel; + if(self.freeModel.curStage.integerValue < self.freeModel.maxStage.integerValue){ + [CountDownHelper shareHelper].isCountdownFinish = NO; + [[CountDownHelper shareHelper] openCountdownWithTime:freeModel.curStageSecond.intValue]; + }else{ + if([CountDownHelper shareHelper].isCountdownFinish == NO){ + [CountDownHelper shareHelper].isCountdownFinish = YES; + } + [[NSNotificationCenter defaultCenter]postNotificationName:kFreeGiftCountdownNotification object:nil userInfo:@{@"isHiddenCountdown":@(YES)}]; + [[CountDownHelper shareHelper] stopCountDown]; + } + + if(self.freeModel.curStage.intValue > 0 && [[XPRoomMiniManager shareManager].curState isEqualToString:@"0"]){ + self.freeView.freeModel = self.freeModel; + if(!self.freeView.superview){ + [kWindow addSubview:self.freeView]; + } + [XPRoomMiniManager shareManager].curState = nil; + } + +} - (void)getRoomFirstChargeWindowSuccess:(FirstChargeRoomWindowModel *)model{ if(model.needToShow == NO || model.showAfterSecond <= 0 || self.isShowFirstRecharge == YES)return; self.isShowFirstRecharge = YES; @@ -1358,7 +1421,16 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [self.view addSubview:view]; [self.view bringSubviewToFront:view]; } - } + }else if(attachment.first == CustomMessageType_Free_Gift_Star_Reset_Time){ + if(attachment.second == Custom_Message_Sub_Free_Gift_Star_Reset_Time){ + [self.presenter getFreeGiftData]; + [[NSNotificationCenter defaultCenter]postNotificationName:kFreeGiftCountdownNotification object:nil userInfo:@{@"isReset":@(YES)}]; + }else if(attachment.second == Custom_Message_Sub_Update_Gift_Information){ + [self.presenter getFreeGiftData]; + [[NSNotificationCenter defaultCenter]postNotificationName:kFreeGiftCountdownNotification object:nil userInfo:@{@"updateGiftInfo":attachment.data ?: @""}]; + } + + } [self.messageContainerView handleNIMCustomMessage:message]; } } else if(message.messageType == NIMMessageTypeText) { @@ -1579,7 +1651,9 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } - (void)miniRoom { - + if(self.freeModel != nil){ + [XPRoomMiniManager shareManager].curState = self.freeModel.curStage; + } [self.menuContainerView menuResignFirstResponder]; [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(showRoomFirstChargeWindow) object:nil]; NSDictionary *roomInfoDic = self.roomInfo.model2dictionary != nil ? self.roomInfo.model2dictionary : @{}; @@ -1945,5 +2019,10 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } return _firstRechargeView; } - +-(XPFreeGiftsObtainView *)freeView{ + if (!_freeView){ + _freeView = [[XPFreeGiftsObtainView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + } + return _freeView; +} @end diff --git a/YuMi/zh-Hans.lproj/Localizable.strings b/YuMi/zh-Hans.lproj/Localizable.strings index 646d4d9b..813423ac 100644 --- a/YuMi/zh-Hans.lproj/Localizable.strings +++ b/YuMi/zh-Hans.lproj/Localizable.strings @@ -3054,6 +3054,16 @@ "XPSessionMainViewController1" = "好友"; "XPSessionMainViewController2" = "关注"; "XPSessionMainViewController3" = "粉丝"; +///XPFreeGiftsObtainView +"XPFreeGiftsObtainView0"="我知道啦"; +"XPFreeGiftsObtainView1"="今天观看直播满%@啦,送你一个礼物"; +"XPFreeGiftsObtainView2"="每天观看直播达到特定时长,即可获得一个\"%@\",每日上限%@个,礼物当日有效"; +"XPFreeGiftsObtainView3"="秒"; +"XPFreeGiftsObtainView4"="分钟"; +"XPFreeGiftsObtainView5"="小时"; +///XPGiftFreeItemCell +"XPGiftFreeItemCell0"="免费礼物"; +"XPGiftFreeItemCell1"="礼物名称"; ///不能脚本生成的 "App_Common_And" = "和"; "App_Common_Male" = "男"; diff --git a/YuMi/zh-Hant.lproj/Localizable.strings b/YuMi/zh-Hant.lproj/Localizable.strings index a594ecc5..0cae38be 100644 --- a/YuMi/zh-Hant.lproj/Localizable.strings +++ b/YuMi/zh-Hant.lproj/Localizable.strings @@ -3064,6 +3064,16 @@ "XPSessionMainViewController1" = "好友"; "XPSessionMainViewController2" = "關註"; "XPSessionMainViewController3" = "粉絲"; +///XPFreeGiftsObtainView +"XPFreeGiftsObtainView0"="我知道啦"; +"XPFreeGiftsObtainView1"="今天觀看直播滿%@啦,送你一個禮物"; +"XPFreeGiftsObtainView2"="每天觀看直播達到特定時長,即可獲得一個\"%@\",每日上限%@個,禮物當日有效"; +"XPFreeGiftsObtainView3"="秒"; +"XPFreeGiftsObtainView4"="分鐘"; +"XPFreeGiftsObtainView5"="小時"; +///XPGiftFreeItemCell +"XPGiftFreeItemCell0"="免費禮物"; +"XPGiftFreeItemCell1"="禮物名稱"; ///不能腳本生成的 "App_Common_And" = "和"; "App_Common_Male" = "男";