邀请房间内粉丝

This commit is contained in:
fengshuo
2021-12-27 15:47:36 +08:00
parent 11b5e15ddd
commit d45b1a615a
10 changed files with 402 additions and 2 deletions

View File

@@ -201,6 +201,8 @@
E83DB481274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB480274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m */; };
E83DB4842746661800D8CBD1 /* XPRoomGiftBroadcastView.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB4832746661800D8CBD1 /* XPRoomGiftBroadcastView.m */; };
E83DB487274670DA00D8CBD1 /* XPRoomGiftBroadCastModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB486274670DA00D8CBD1 /* XPRoomGiftBroadCastModel.m */; };
E8412F9627795E34006E1101 /* XPRoomInviteFansView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8412F9527795E34006E1101 /* XPRoomInviteFansView.m */; };
E8412F9927799249006E1101 /* InviteFansModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8412F9827799249006E1101 /* InviteFansModel.m */; };
E84150B827747B8B00A7F548 /* XPFirstRechargeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E84150B727747B8B00A7F548 /* XPFirstRechargeViewController.m */; };
E84150BB27747BAF00A7F548 /* XPFirstRechargePresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E84150BA27747BAF00A7F548 /* XPFirstRechargePresenter.m */; };
E84150BF27747BD300A7F548 /* Api+FirstRecharge.m in Sources */ = {isa = PBXBuildFile; fileRef = E84150BE27747BD300A7F548 /* Api+FirstRecharge.m */; };
@@ -786,6 +788,10 @@
E83DB4832746661800D8CBD1 /* XPRoomGiftBroadcastView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomGiftBroadcastView.m; sourceTree = "<group>"; };
E83DB485274670DA00D8CBD1 /* XPRoomGiftBroadCastModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomGiftBroadCastModel.h; sourceTree = "<group>"; };
E83DB486274670DA00D8CBD1 /* XPRoomGiftBroadCastModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomGiftBroadCastModel.m; sourceTree = "<group>"; };
E8412F9427795E34006E1101 /* XPRoomInviteFansView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomInviteFansView.h; sourceTree = "<group>"; };
E8412F9527795E34006E1101 /* XPRoomInviteFansView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomInviteFansView.m; sourceTree = "<group>"; };
E8412F9727799249006E1101 /* InviteFansModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InviteFansModel.h; sourceTree = "<group>"; };
E8412F9827799249006E1101 /* InviteFansModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InviteFansModel.m; sourceTree = "<group>"; };
E84150B627747B8B00A7F548 /* XPFirstRechargeViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPFirstRechargeViewController.h; sourceTree = "<group>"; };
E84150B727747B8B00A7F548 /* XPFirstRechargeViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPFirstRechargeViewController.m; sourceTree = "<group>"; };
E84150B927747BAF00A7F548 /* XPFirstRechargePresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPFirstRechargePresenter.h; sourceTree = "<group>"; };
@@ -3076,6 +3082,8 @@
E8DEC9A92764A6AF0078CB70 /* Cell */,
E8DEC99C2764A5B60078CB70 /* XPRoomMoreMenuViewController.h */,
E8DEC99D2764A5B60078CB70 /* XPRoomMoreMenuViewController.m */,
E8412F9427795E34006E1101 /* XPRoomInviteFansView.h */,
E8412F9527795E34006E1101 /* XPRoomInviteFansView.m */,
);
path = View;
sourceTree = "<group>";
@@ -3094,6 +3102,8 @@
children = (
E8DEC99F2764A5D20078CB70 /* XPRoomMoreItemModel.h */,
E8DEC9A02764A5D20078CB70 /* XPRoomMoreItemModel.m */,
E8412F9727799249006E1101 /* InviteFansModel.h */,
E8412F9827799249006E1101 /* InviteFansModel.m */,
);
path = Model;
sourceTree = "<group>";
@@ -3581,6 +3591,7 @@
E8E70D9226F2F60C00F03460 /* XPMineItemModel.m in Sources */,
189DD74A26E21D8400AB55B1 /* SSKeychain.m in Sources */,
E8DACCFE27673F870052092C /* GiftValueInfoModel.m in Sources */,
E8412F9927799249006E1101 /* InviteFansModel.m in Sources */,
E8B846CF26FDD96100A777FE /* XPMineRechageHeadView.m in Sources */,
186A534926FC6ED900D67B2C /* TTAlertMessageAttributedConfig.m in Sources */,
E81C27AE26EF39AB0031E639 /* AppDelegate+ThirdConfig.m in Sources */,
@@ -3773,6 +3784,7 @@
E8AC721626F46B06007D6E91 /* XPMineSettingTableViewCell.m in Sources */,
18EE3FDF2750C1F700A452BF /* SessionListCell.m in Sources */,
E80487652717DDD9008595F2 /* XPRoomMenuItem.m in Sources */,
E8412F9627795E34006E1101 /* XPRoomInviteFansView.m in Sources */,
189DD75026E21D9000AB55B1 /* GCDHelper.m in Sources */,
E82D5C76276AEB5100858D6D /* NameplateModel.m in Sources */,
E84150BF27747BD300A7F548 /* Api+FirstRecharge.m in Sources */,

View File

@@ -29,6 +29,15 @@ NS_ASSUME_NONNULL_BEGIN
/// @param ticket ticket
/// @param uid uid
+ (void)updateRoomInfoMessageState:(HttpRequestHelperCompletion)complection roomId:(NSString *)roomId isCloseScreen:(NSString *)isCloseScreen ticket:(NSString *)ticket uid:(NSString *)uid;
/// 邀请粉丝的
/// @param completion 完成
/// @param roomUid 房间的uid
+ (void)inviteRoomFans:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid;
/// 获取当前邀请粉丝的状态
/// @param completion 完成
/// @param roomUid 房间的uid
+ (void)checkInviteRoomFans:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid;
@end

View File

@@ -35,4 +35,18 @@
[self makeRequest:@"room/setCloseScreen" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, roomId, isCloseScreen, ticket, uid, nil];
}
///
/// @param completion
/// @param roomUid uid
+ (void)inviteRoomFans:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid {
[self makeRequest:@"room/inviteFans" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, roomUid, nil];
}
///
/// @param completion
/// @param roomUid uid
+ (void)checkInviteRoomFans:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid {
[self makeRequest:@"room/inviteFans" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, roomUid, nil];
}
@end

View File

@@ -0,0 +1,21 @@
//
// InviteFansModel.h
// xplan-ios
//
// Created by 冯硕 on 2021/12/27.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface InviteFansModel : NSObject
///粉丝数
@property (nonatomic,assign) NSInteger fansNum;
///下次邀请的时间
@property (nonatomic,assign) int inviteInterval;
///邀请次数
@property (nonatomic,assign) int inviteTimes;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// InviteFansModel.m
// xplan-ios
//
// Created by on 2021/12/27.
//
#import "InviteFansModel.h"
@implementation InviteFansModel
@end

View File

@@ -25,7 +25,7 @@ typedef NS_ENUM(NSInteger, RoomMoreMenuType) {
///房间设置
RoomMoreMenuType_Room_Setting = 7,
///邀请粉丝
RoomMoreMenuType_Invite_Friend = 8,
RoomMoreMenuType_Invite_Fans = 8,
};
@interface XPRoomMoreItemModel : NSObject

View File

@@ -45,7 +45,7 @@
XPRoomMoreItemModel * inviteFriend = [[XPRoomMoreItemModel alloc] init];
inviteFriend.title = @"邀请粉丝";
inviteFriend.imageName = @"room_more_menu_invite_friend";
inviteFriend.type = RoomMoreMenuType_Invite_Friend;
inviteFriend.type = RoomMoreMenuType_Invite_Fans;
inviteFriend.titleColor = [ThemeColor roomMoreMenuTextColor];
NSString * uid = [AccountInfoStorage instance].getUid;

View File

@@ -0,0 +1,18 @@
//
// XPRoomInviteFriendView.h
// xplan-ios
//
// Created by 冯硕 on 2021/12/27.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomInviteFansView : UIView
- (instancetype)initWithRoomUid:(NSString *)roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,305 @@
//
// XPRoomInviteFriendView.m
// xplan-ios
//
// Created by on 2021/12/27.
//
#import "XPRoomInviteFansView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor+Room.h"
#import "UIImage+Utils.h"
#import "Api+MoreMenu.h"
#import "XCHudTool.h"
#import "XPMacro.h"
///Model
#import "InviteFansModel.h"
@interface XPRoomInviteFriendTitleView : UIView
///
@property (nonatomic,strong) UIView * circleView;
///
@property (nonatomic,strong) UILabel *titleLabel;
@end
@implementation XPRoomInviteFriendTitleView
- (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.circleView];
[self addSubview:self.titleLabel];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.titleLabel.mas_right);
}];
[self.circleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(4, 4));
make.centerY.left.mas_equalTo(self);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.circleView.mas_right).offset(8);
make.centerY.mas_equalTo(self);
}];
}
#pragma mark - Getters And Setters
- (UIView *)circleView {
if (!_circleView) {
_circleView = [[UIView alloc] init];
_circleView.backgroundColor = UIColorFromRGB(0xCAC2FF);
_circleView.layer.masksToBounds = YES;
_circleView.layer.cornerRadius = 2;
}
return _circleView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:13];
_titleLabel.textColor = [ThemeColor secondTextColor];
}
return _titleLabel;
}
@end
@interface XPRoomInviteFansView ()
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) XPRoomInviteFriendTitleView *firstView;
///
@property (nonatomic,strong) XPRoomInviteFriendTitleView *secondView;
///
@property (nonatomic,strong) XPRoomInviteFriendTitleView *thirdView;
///
@property (nonatomic,strong) UIButton *inviteButton;
///
@property (nonatomic,strong) UILabel *residueLabel;
///uid
@property (nonatomic,copy) NSString *roomUid;
///
@property (nonatomic,strong) InviteFansModel *fansInfoModel;
///
@property (nonatomic,strong) dispatch_source_t timer;
@end
@implementation XPRoomInviteFansView
- (instancetype)initWithRoomUid:(NSString *)roomUid {
self = [super init];
if (self) {
self.roomUid = roomUid;
[self getInviteFansState];
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.titleLabel];
[self addSubview:self.firstView];
[self addSubview:self.secondView];
[self addSubview:self.thirdView];
[self addSubview:self.inviteButton];
[self addSubview:self.residueLabel];
self.backgroundColor = [UIColor whiteColor];
CAShapeLayer * layer = [CAShapeLayer layer];
layer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, KScreenWidth, 273) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(15, 15)].CGPath;
self.layer.mask = layer;
}
- (void)initSubViewConstraints {
self.frame = CGRectMake(0, 0, KScreenWidth, 273);
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(20);
make.right.left.mas_equalTo(self);
}];
[self.firstView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(16);
make.left.mas_equalTo(self).offset(30);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(23);
}];
[self.secondView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.left.mas_equalTo(self.firstView);
make.top.mas_equalTo(self.firstView.mas_bottom).offset(15);
}];
[self.thirdView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.left.mas_equalTo(self.firstView);
make.top.mas_equalTo(self.secondView.mas_bottom).offset(15);
}];
[self.inviteButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(160, 38));
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self.thirdView.mas_bottom).offset(40);
}];
[self.residueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.left.mas_equalTo(self);
make.top.mas_equalTo(self.inviteButton.mas_bottom).offset(16);
}];
}
- (void)getInviteFansState {
[Api checkInviteRoomFans:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
InviteFansModel * model = [InviteFansModel modelWithDictionary:data.data];
self.fansInfoModel = model;
[self configFansView:model];
[self openCutDownTimer];
} else {
[XCHUDTool showErrorWithMessage:msg];
}
} roomUid:self.roomUid];
}
- (void)configFansView:(InviteFansModel *)model {
NSString * residueTitle = [NSString stringWithFormat:@"今日剩余%d次", model.inviteTimes];
NSMutableAttributedString * residueAttribute = [[NSMutableAttributedString alloc] initWithString:residueTitle attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13], NSForegroundColorAttributeName:[ThemeColor secondTextColor]}];
NSRange range = [residueTitle rangeOfString:[NSString stringWithFormat:@"%d", model.inviteTimes]];
[residueAttribute addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:range];
[residueAttribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor appEmphasizeColor] range:range];
self.residueLabel.attributedText = residueAttribute;
self.residueLabel.textAlignment = NSTextAlignmentCenter;
self.inviteButton.enabled = model.inviteInterval <= 0;
if (model.inviteTimes <= 0) {
[self.inviteButton setTitle:@"今日次数已用完" forState:UIControlStateDisabled];
self.inviteButton.enabled = NO;
}
NSString * fansNumberTitle = [NSString stringWithFormat:@"确认邀请后会给收藏该房间的%ld位用户发送提醒", model.fansNum];
NSMutableAttributedString * fansAttribute = [[NSMutableAttributedString alloc] initWithString:fansNumberTitle attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13], NSForegroundColorAttributeName:[ThemeColor secondTextColor]}];
NSRange fansRange = [fansNumberTitle rangeOfString:[NSString stringWithFormat:@"%ld", model.fansNum]];
[fansAttribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor appEmphasizeColor] range:fansRange];
self.firstView.titleLabel.attributedText = fansAttribute;
}
- (void)openCutDownTimer {
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(0, 0));
dispatch_source_set_timer(_timer, DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
dispatch_source_set_event_handler(_timer, ^{
dispatch_async(dispatch_get_main_queue(), ^{
self.fansInfoModel.inviteInterval --;
if (self.fansInfoModel.inviteInterval <= 0) {
dispatch_source_cancel(_timer);
self.timer = nil;
[self.inviteButton setTitle:@"确认邀请" forState:UIControlStateNormal];
self.inviteButton.enabled = YES;
} else {
int seconds = self.fansInfoModel.inviteInterval % 60;
int minutes = (self.fansInfoModel.inviteInterval / 60) % 60;
NSString * title = [NSString stringWithFormat:@"%02d分%02d秒后可邀请",minutes, seconds];
[self.inviteButton setTitle:title forState:UIControlStateDisabled];
}
});
});
self.timer = _timer;
dispatch_resume(_timer);
}
#pragma mark - Event Response
- (void)inviteButtonAction:(UIButton *)sender {
sender.enabled = NO;
[Api inviteRoomFans:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
InviteFansModel * model = [InviteFansModel modelWithDictionary:data.data];
self.fansInfoModel = model;
[self configFansView:model];
[self openCutDownTimer];
} else {
[XCHUDTool showErrorWithMessage:msg];
sender.enabled = YES;
}
} roomUid:self.roomUid];
}
#pragma mark - Getters And Setters
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = @"邀请房间粉丝";
_titleLabel.font = [UIFont boldSystemFontOfSize:16];
_titleLabel.textColor = [ThemeColor mainTextColor];
_titleLabel.textAlignment = NSTextAlignmentCenter;
}
return _titleLabel;
}
- (XPRoomInviteFriendTitleView *)firstView {
if (!_firstView) {
_firstView = [[XPRoomInviteFriendTitleView alloc] init];
}
return _firstView;
}
- (XPRoomInviteFriendTitleView *)secondView {
if (!_secondView) {
_secondView = [[XPRoomInviteFriendTitleView alloc] init];
_secondView.titleLabel.text= @"每日发送次数不可超过5次";
}
return _secondView;
}
- (XPRoomInviteFriendTitleView *)thirdView {
if (!_thirdView) {
_thirdView = [[XPRoomInviteFriendTitleView alloc] init];
_thirdView.titleLabel.text = @"1小时内限发送一次邀请";
}
return _thirdView;
}
- (UIButton *)inviteButton {
if (!_inviteButton) {
_inviteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_inviteButton setTitle:@"确认邀请" forState:UIControlStateNormal];
[_inviteButton setTitleColor:[ThemeColor confirmButtonTextColor] forState:UIControlStateNormal];
[_inviteButton setTitleColor:[ThemeColor disableButtonTextColor] forState:UIControlStateDisabled];
_inviteButton.titleLabel.font = [UIFont systemFontOfSize:15];
[_inviteButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor],[ThemeColor confirmButtonGradientEndColor] ] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_inviteButton setBackgroundImage:[UIImage imageWithColor:[ThemeColor disableButtonColor]] forState:UIControlStateDisabled];
_inviteButton.layer.masksToBounds = YES;
_inviteButton.layer.cornerRadius = 38 / 2;
[_inviteButton addTarget:self action:@selector(inviteButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _inviteButton;
}
- (UILabel *)residueLabel {
if (!_residueLabel) {
_residueLabel = [[UILabel alloc] init];
}
return _residueLabel;
}
@end

View File

@@ -18,6 +18,7 @@
#import "AttachmentModel.h"
///View
#import "XPRoomMoreMenuCollectionViewCell.h"
#import "XPRoomInviteFansView.h"
///P
#import "XPMoreMenuPresenter.h"
#import "XPMoreMenuProtocol.h"
@@ -180,6 +181,14 @@
[self dismissViewControllerAnimated:YES completion:nil];
}
break;
case RoomMoreMenuType_Invite_Fans:
{
[self dismissViewControllerAnimated:YES completion:nil];
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid];
XPRoomInviteFansView * inviteFansView = [[XPRoomInviteFansView alloc]initWithRoomUid:roomUid];
[TTPopup popupView:inviteFansView style:TTPopupStyleActionSheet];
}
break;
default:
break;
}