From 977c2c24f8c21eb08d2381173e8e78c3368e1f14 Mon Sep 17 00:00:00 2001 From: chenguilong <598604202@qq.com> Date: Wed, 16 Feb 2022 15:59:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E6=92=AD=E6=88=BF=E4=B8=BB=E6=92=AD?= =?UTF-8?q?=E9=AD=85=E5=8A=9B=E5=80=BC=E3=80=81=E9=AD=85=E5=8A=9B=E6=A6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xplan-ios.xcodeproj/project.pbxproj | 6 ++ .../XPRoomFunctionContainerView.m | 82 ++++++++++++-- .../View/CandyTree/View/XPRoomHalfWebView.h | 2 + .../View/CandyTree/View/XPRoomHalfWebView.m | 1 + .../MicroView/Anchor/AnchorGiftValueView.h | 19 ++++ .../MicroView/Anchor/AnchorGiftValueView.m | 102 ++++++++++++++++++ .../Main/Room/View/XPRoomViewController.m | 1 + 7 files changed, 206 insertions(+), 7 deletions(-) create mode 100644 xplan-ios/Main/Room/View/StageView/MicroView/Anchor/AnchorGiftValueView.h create mode 100644 xplan-ios/Main/Room/View/StageView/MicroView/Anchor/AnchorGiftValueView.m diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index e917fb30..a0021d5f 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -112,6 +112,7 @@ 73FFADDC93E195344047A2EC /* Pods_xplan_ios.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CACF623970097D653132D69A /* Pods_xplan_ios.framework */; }; 9B0086C627BA392B0032BD2B /* AnchorStageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0086C527BA392B0032BD2B /* AnchorStageView.m */; }; 9B0086CA27BA4F570032BD2B /* AnchorMicroView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0086C927BA4F570032BD2B /* AnchorMicroView.m */; }; + 9B060B5827BCAEE20001B767 /* AnchorGiftValueView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B060B5727BCAEE20001B767 /* AnchorGiftValueView.m */; }; 9B0E1C5926E77022005D4442 /* BaseNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */; }; 9B7B605B27BB53060070BB72 /* XPAnchorAudienceUpMicView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7B605A27BB53060070BB72 /* XPAnchorAudienceUpMicView.m */; }; 9B7B606227BB96E40070BB72 /* XPRoomAnchorInfoCardView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7B606127BB96E40070BB72 /* XPRoomAnchorInfoCardView.m */; }; @@ -638,6 +639,8 @@ 9B0086C527BA392B0032BD2B /* AnchorStageView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnchorStageView.m; sourceTree = ""; }; 9B0086C827BA4F570032BD2B /* AnchorMicroView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnchorMicroView.h; sourceTree = ""; }; 9B0086C927BA4F570032BD2B /* AnchorMicroView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnchorMicroView.m; sourceTree = ""; }; + 9B060B5627BCAEE20001B767 /* AnchorGiftValueView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnchorGiftValueView.h; sourceTree = ""; }; + 9B060B5727BCAEE20001B767 /* AnchorGiftValueView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnchorGiftValueView.m; sourceTree = ""; }; 9B0E1C5726E77022005D4442 /* BaseNavigationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BaseNavigationController.h; sourceTree = ""; }; 9B0E1C5826E77022005D4442 /* BaseNavigationController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BaseNavigationController.m; sourceTree = ""; }; 9B7B605927BB53060070BB72 /* XPAnchorAudienceUpMicView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XPAnchorAudienceUpMicView.h; sourceTree = ""; }; @@ -1931,6 +1934,8 @@ children = ( 9B0086C827BA4F570032BD2B /* AnchorMicroView.h */, 9B0086C927BA4F570032BD2B /* AnchorMicroView.m */, + 9B060B5627BCAEE20001B767 /* AnchorGiftValueView.h */, + 9B060B5727BCAEE20001B767 /* AnchorGiftValueView.m */, ); path = Anchor; sourceTree = ""; @@ -3815,6 +3820,7 @@ E8EEB91D26FC9D58007C6EBA /* XPMineUserInfoDateView.m in Sources */, E82325E9274CE56A003A3332 /* XPShareItem.m in Sources */, E890BC0D273D09A50007C46B /* XPGiftCountView.m in Sources */, + 9B060B5827BCAEE20001B767 /* AnchorGiftValueView.m in Sources */, E81C1B262770663B0020D1E4 /* XPArrangeMicTableViewCell.m in Sources */, E8AC722F26F49610007D6E91 /* XPMineNotificationItemModel.m in Sources */, E8E70D7A26F2F16600F03460 /* XPMinePresent.m in Sources */, diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m index a611e164..76721f59 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -25,10 +25,12 @@ #import "MicroQueueModel.h" #import "UserInfoModel.h" #import "AttachmentModel.h" +#import "GiftValueInfoModel.h" ///View #import "XPRoomHalfWebView.h" #import "XPAnchorAudienceUpMicView.h" #import "XPRoomAnchorInfoCardView.h" +#import "AnchorGiftValueView.h" @interface XPRoomFunctionContainerView () ///host 代理 @property (nonatomic,weak) iddelegate; @@ -38,6 +40,9 @@ @property (nonatomic,strong) UIButton *datingProgresButton; ///关注个播房主倒计时 @property (nonatomic, strong) dispatch_source_t followAnchorTimer; +///个播房房主魅力值 +@property (nonatomic, strong) AnchorGiftValueView *anchorGiftValueView; + @end @implementation XPRoomFunctionContainerView @@ -54,6 +59,7 @@ #pragma mark - Private Method - (void)initSubViews { [self addSubview:self.contributionButton]; + [self addSubview:self.anchorGiftValueView]; } - (void)initSubViewConstraints { @@ -63,6 +69,11 @@ make.width.mas_equalTo(90); make.height.mas_equalTo(26); }]; + [self.anchorGiftValueView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.contributionButton.mas_right).mas_offset(12); + make.centerY.mas_equalTo(self.contributionButton); + make.height.mas_equalTo(26); + }]; } #pragma mark - RoomGuestDelegate @@ -100,19 +111,34 @@ [self.datingProgresButton removeFromSuperview]; } } + if (roomInfo.type == RoomType_Anchor) { + [self.contributionButton setTitle:@"主播榜" forState:UIControlStateNormal]; + self.anchorGiftValueView.hidden = NO; + } else { + [self.contributionButton setTitle:@"房间榜" forState:UIControlStateNormal]; + self.anchorGiftValueView.hidden = YES; + } } - (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]; + if (roomInfo.type == RoomType_Anchor) {//个播房 + if (![[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]; + } + // 获取礼物值 + [Api roomMicroGiftValue:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if (code == 200) { + [self handleAnchorGiftValue:data.data]; } - } uid:uid isLikeUid:roomUid]; + } roomUid:[NSString stringWithFormat:@"%ld", roomInfo.uid] uid:[AccountInfoStorage instance].getUid]; } } @@ -131,6 +157,12 @@ config.contentView = upMicView; config.style = TTPopupStyleAlert; [TTPopup popupWithConfig:config]; + } else if(attachment.first == CustomMessageType_Room_GiftValue && attachment.second == Custom_Message_Sub_Room_GiftValue_Sync) { + [self handleAnchorGiftValue:attachment.data]; + } else if(attachment.first == CustomMessageType_Gift && (attachment.second == Custom_Message_Sub_Gift_Send || attachment.second == Custom_Message_Sub_Gift_LuckySend || attachment.second == Custom_Message_Sub_Gift_ChannelNotify)) { + [self handleAnchorGiftValue:attachment.data]; + }else if(attachment.first == CustomMessageType_AllMicroSend && (attachment.second == Custom_Message_Sub_AllMicroSend || attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend)) { + [self handleAnchorGiftValue:attachment.data]; } } } @@ -172,6 +204,16 @@ }];} +- (void)tapGiftValueRecognizer { + if (self.anchorGiftValueView.hidden) return; + if (self.delegate.getUserInfo && self.delegate.getUserInfo.uid > 0) { + XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init]; + webView.roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid]; + webView.url = [NSString stringWithFormat:@"%@?uid=%ld", URLWithType(kRoomCharmRankURL), self.delegate.getRoomInfo.uid]; + [TTPopup popupView:webView style:TTPopupStyleActionSheet]; + } +} + #pragma mark - 个播模式弹窗关注主播 - (void)setFollowAnchorTimer { if (self.followAnchorTimer != nil) { @@ -220,6 +262,20 @@ } uid:roomUid]; } +- (void)handleAnchorGiftValue:(NSDictionary *)dict { + if (self.delegate.getRoomInfo.type != RoomType_Anchor) {//个播房房主位置魅力值刷新 + return; + } + GiftValueInfoModel * model = [GiftValueInfoModel modelWithDictionary:dict]; + for (int i = 0; i < model.giftValueVos.count; i++) { + GiftValueDetailModel * giftValueModel = [model.giftValueVos objectAtIndex:i]; + if (![giftValueModel.uid isEqualToString:[NSString stringWithFormat:@"%zd", self.delegate.getRoomInfo.uid]]) { + continue; + } + self.anchorGiftValueView.giftValue = giftValueModel.giftValue; + } +} + #pragma mark - Getters And Setters - (UIButton *)contributionButton { if (!_contributionButton) { @@ -252,4 +308,16 @@ return _datingProgresButton; } +- (AnchorGiftValueView *)anchorGiftValueView { + if (!_anchorGiftValueView) { + _anchorGiftValueView = [[AnchorGiftValueView alloc] init]; + _anchorGiftValueView.hidden = YES; + _anchorGiftValueView.layer.cornerRadius = 13; + _anchorGiftValueView.layer.masksToBounds = YES; + UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGiftValueRecognizer)]; + [_anchorGiftValueView addGestureRecognizer:tap]; + } + return _anchorGiftValueView; +} + @end diff --git a/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.h b/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.h index 63ff53a9..bd3c74da 100644 --- a/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.h +++ b/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.h @@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN @interface XPRoomHalfWebView : UIView ///地址 @property (nonatomic,copy) NSString *url; +///房间uid +@property (nonatomic,copy) NSString *roomUid; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.m b/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.m index 6cfe1390..be31b044 100644 --- a/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.m +++ b/xplan-ios/Main/Room/View/CandyTree/View/XPRoomHalfWebView.m @@ -96,6 +96,7 @@ - (void)setUrl:(NSString *)url { _url = url; if (_url.length > 0) { + self.webVC.roomUid = self.roomUid; self.webVC.url = _url; } } diff --git a/xplan-ios/Main/Room/View/StageView/MicroView/Anchor/AnchorGiftValueView.h b/xplan-ios/Main/Room/View/StageView/MicroView/Anchor/AnchorGiftValueView.h new file mode 100644 index 00000000..ddf177a2 --- /dev/null +++ b/xplan-ios/Main/Room/View/StageView/MicroView/Anchor/AnchorGiftValueView.h @@ -0,0 +1,19 @@ +// +// AnchorGiftValueView.h +// xplan-ios +// +// Created by GreenLand on 2022/2/16. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface AnchorGiftValueView : UIView + +///当前的礼物值 +@property (nonatomic,assign) long long giftValue; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/StageView/MicroView/Anchor/AnchorGiftValueView.m b/xplan-ios/Main/Room/View/StageView/MicroView/Anchor/AnchorGiftValueView.m new file mode 100644 index 00000000..859ceda0 --- /dev/null +++ b/xplan-ios/Main/Room/View/StageView/MicroView/Anchor/AnchorGiftValueView.m @@ -0,0 +1,102 @@ +// +// AnchorGiftValueView.m +// xplan-ios +// +// Created by GreenLand on 2022/2/16. +// + +#import "AnchorGiftValueView.h" +///Third +#import +#import "UIImage+Utils.h" +#import "ThemeColor.h" + +@interface AnchorGiftValueView () +///背景图 +@property (nonatomic, strong) UIImageView *bgImageView; +///心形图标 +@property (nonatomic, strong) UIImageView *iconImageView; +///礼物值 +@property (nonatomic, strong) UILabel *valueLabel; +@end + +@implementation AnchorGiftValueView + +- (instancetype)initWithFrame:(CGRect)frame { + if (self = [super initWithFrame:frame]) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} + +#pragma mark - Private Method +- (void)initSubViews { + [self addSubview:self.bgImageView]; + [self.bgImageView addSubview:self.iconImageView]; + [self.bgImageView addSubview:self.valueLabel]; +} + +- (void)initSubViewConstraints { + [self mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.bgImageView); + }]; + + [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.bottom.mas_equalTo(self); + make.left.mas_equalTo(self.valueLabel.mas_left).mas_offset(-8); + make.right.mas_equalTo(self.iconImageView.mas_right).mas_offset(8); + }]; + [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.mas_equalTo(self.bgImageView); + make.width.height.mas_equalTo(12); + }]; + [self.valueLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerY.mas_equalTo(self.bgImageView); + make.right.mas_equalTo(self.iconImageView.mas_left).mas_offset(-2); + }]; + +} +#pragma mark - Getters And Setters +- (void)setGiftValue:(long long)giftValue { + NSString *value; + if (giftValue < 1000000) { + value = @(giftValue).stringValue; + } else if (giftValue >= 100000000) { + value = @"9999万+"; + } else { + value = [NSString stringWithFormat:@"%lld万", giftValue/10000]; + } + self.valueLabel.text = value; +} + +- (UIImageView *)bgImageView { + if (_bgImageView == nil) { + _bgImageView = [[UIImageView alloc] init]; + _bgImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFF2D7C), UIColorFromRGB(0xFF8BB2)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(20, 50)]; + _bgImageView.userInteractionEnabled = YES; + } + return _bgImageView; +} + +- (UIImageView *)iconImageView { + if (_iconImageView == nil) { + _iconImageView = [[UIImageView alloc] init]; + _iconImageView.userInteractionEnabled = YES; + _iconImageView.image = [UIImage imageNamed:@"room_position_giftValue_heart"]; + } + return _iconImageView; +} + +- (UILabel *)valueLabel { + if (_valueLabel == nil) { + _valueLabel = [[UILabel alloc] init]; + _valueLabel.textColor = UIColor.whiteColor; + _valueLabel.font = [UIFont systemFontOfSize:12]; + _valueLabel.text = @"0"; + } + return _valueLabel; +} + + +@end diff --git a/xplan-ios/Main/Room/View/XPRoomViewController.m b/xplan-ios/Main/Room/View/XPRoomViewController.m index cb65cc62..6533228c 100644 --- a/xplan-ios/Main/Room/View/XPRoomViewController.m +++ b/xplan-ios/Main/Room/View/XPRoomViewController.m @@ -510,6 +510,7 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; AttachmentModel * attachment = obj.attachment; [self.stageView handleNIMCustomMessage:message]; [self.animationView handleNIMCustomMessage:message]; + [self.functionView handleNIMCustomMessage:message]; if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) { RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:attachment.data[@"roomInfo"]]; self.roomInfo.isCloseScreen = roomInfo.isCloseScreen;