新人专享优惠弹窗优化
This commit is contained in:
@@ -281,6 +281,8 @@
|
||||
9BE01AE728938AB600B50299 /* XPDressUpShopCardTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE01AE628938AB600B50299 /* XPDressUpShopCardTableViewCell.m */; };
|
||||
9BE01AEA2893CB4400B50299 /* XPDressSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE01AE92893CB4400B50299 /* XPDressSearchViewController.m */; };
|
||||
9BE01AED2893D0DF00B50299 /* XPDressShopSearchTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE01AEC2893D0DF00B50299 /* XPDressShopSearchTableViewCell.m */; };
|
||||
9BE01AF02893E31700B50299 /* NewUserRechargeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE01AEF2893E31700B50299 /* NewUserRechargeModel.m */; };
|
||||
9BE01AF72893E7F500B50299 /* XPNewUserRechargeCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE01AF62893E7F500B50299 /* XPNewUserRechargeCollectionViewCell.m */; };
|
||||
9BE29A6B27D1BFF700446AB5 /* anchor_room_speak.svga in Resources */ = {isa = PBXBuildFile; fileRef = 9BE29A6927D1BFF700446AB5 /* anchor_room_speak.svga */; };
|
||||
9BE29A6D27D210A500446AB5 /* anchor_room_bg.svga in Resources */ = {isa = PBXBuildFile; fileRef = 9BE29A6C27D210A500446AB5 /* anchor_room_bg.svga */; };
|
||||
9BE2FA90288010D300EF3D83 /* AnchorRoomSrollTipView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BE2FA8F288010D300EF3D83 /* AnchorRoomSrollTipView.m */; };
|
||||
@@ -1448,6 +1450,10 @@
|
||||
9BE01AE92893CB4400B50299 /* XPDressSearchViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPDressSearchViewController.m; sourceTree = "<group>"; };
|
||||
9BE01AEB2893D0DF00B50299 /* XPDressShopSearchTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPDressShopSearchTableViewCell.h; sourceTree = "<group>"; };
|
||||
9BE01AEC2893D0DF00B50299 /* XPDressShopSearchTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPDressShopSearchTableViewCell.m; sourceTree = "<group>"; };
|
||||
9BE01AEE2893E31700B50299 /* NewUserRechargeModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NewUserRechargeModel.h; sourceTree = "<group>"; };
|
||||
9BE01AEF2893E31700B50299 /* NewUserRechargeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NewUserRechargeModel.m; sourceTree = "<group>"; };
|
||||
9BE01AF52893E7F500B50299 /* XPNewUserRechargeCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNewUserRechargeCollectionViewCell.h; sourceTree = "<group>"; };
|
||||
9BE01AF62893E7F500B50299 /* XPNewUserRechargeCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPNewUserRechargeCollectionViewCell.m; sourceTree = "<group>"; };
|
||||
9BE29A6927D1BFF700446AB5 /* anchor_room_speak.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = anchor_room_speak.svga; sourceTree = "<group>"; };
|
||||
9BE29A6C27D210A500446AB5 /* anchor_room_bg.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = anchor_room_bg.svga; sourceTree = "<group>"; };
|
||||
9BE2FA8E288010D300EF3D83 /* AnchorRoomSrollTipView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AnchorRoomSrollTipView.h; sourceTree = "<group>"; };
|
||||
@@ -4163,6 +4169,15 @@
|
||||
path = Protocol;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
9BE01AF42893E7E000B50299 /* Cell */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9BE01AF52893E7F500B50299 /* XPNewUserRechargeCollectionViewCell.h */,
|
||||
9BE01AF62893E7F500B50299 /* XPNewUserRechargeCollectionViewCell.m */,
|
||||
);
|
||||
path = Cell;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BFB922F5D81845AC32D1E1ED /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -6089,6 +6104,7 @@
|
||||
E8B3E8042848B842009746AB /* View */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9BE01AF42893E7E000B50299 /* Cell */,
|
||||
E8B3E7FC28489232009746AB /* XPNewUserGreetRoomAlertView.h */,
|
||||
E8B3E7FD28489232009746AB /* XPNewUserGreetRoomAlertView.m */,
|
||||
9BE01AC328913B2500B50299 /* XPNewUserRechargeSuccessView.h */,
|
||||
@@ -6117,6 +6133,8 @@
|
||||
E8B3E8082848B871009746AB /* InviteUserInfoModel.m */,
|
||||
E8B3E80A2848BA40009746AB /* NewUserGreetModel.h */,
|
||||
E8B3E80B2848BA40009746AB /* NewUserGreetModel.m */,
|
||||
9BE01AEE2893E31700B50299 /* NewUserRechargeModel.h */,
|
||||
9BE01AEF2893E31700B50299 /* NewUserRechargeModel.m */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@@ -7427,6 +7445,7 @@
|
||||
9BD9A18727A120FD004186FE /* XPMineVisitorUnReadModel.m in Sources */,
|
||||
E824543D26F58C3A00BE8163 /* XPLoginBindSuccessView.m in Sources */,
|
||||
E8A6C29527CF441200AC7442 /* XPHomeAttentionCollectionViewCell.m in Sources */,
|
||||
9BE01AF72893E7F500B50299 /* XPNewUserRechargeCollectionViewCell.m in Sources */,
|
||||
E8EEB8F726FC2673007C6EBA /* UserPhoto.m in Sources */,
|
||||
E8664EDF27E45EC7000171BA /* XPRoomPKRecordPresenter.m in Sources */,
|
||||
E81C27A226EF23490031E639 /* XPEnum.h in Sources */,
|
||||
@@ -7576,6 +7595,7 @@
|
||||
E884C36F2743AAC800E1EBED /* AttachmentModel.m in Sources */,
|
||||
E8AC721926F46E0B007D6E91 /* XPMineSettingItemModel.m in Sources */,
|
||||
E8E859D428264C2300EE4857 /* DDASLLogger.m in Sources */,
|
||||
9BE01AF02893E31700B50299 /* NewUserRechargeModel.m in Sources */,
|
||||
E82325E6274CCAFA003A3332 /* XPShareInfoModel.m in Sources */,
|
||||
9B32A04728881845002009D2 /* XPRoomTagListView.m in Sources */,
|
||||
189DD55A26DE39D200AB55B1 /* BaseMvpPresenter.m in Sources */,
|
||||
|
||||
@@ -33,22 +33,9 @@
|
||||
}
|
||||
return self;
|
||||
}
|
||||
#pragma mark - Public Method
|
||||
//- (void)configRoomMiniView:(RoomInfoModel *)roomInfo userInfo:(UserInfoModel *)userInfo micQueue:(NSMutableDictionary *)micQueue {
|
||||
// self.hidden = NO;
|
||||
// self.currentRoomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
|
||||
// self.currentRoomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
|
||||
// self.roomInfo = roomInfo;
|
||||
// self.userInfo = userInfo;
|
||||
// self.micQueue = micQueue;
|
||||
// [self startAvatarAnimation];
|
||||
// [self.noteView startAnimation];
|
||||
//}
|
||||
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
// self.frame = CGRectMake(KScreenWidth - 140 * 1.2, KScreenHeight - kSafeAreaBottomHeight - 150, 140 * 1.2, 34 * 1.2);
|
||||
[self addSubview:self.backImageView];
|
||||
[self.backImageView addSubview:self.nickLabel];
|
||||
}
|
||||
@@ -147,18 +134,26 @@
|
||||
}
|
||||
|
||||
- (void)countTimeWithTime:(long)time {
|
||||
NSInteger minute = time / 60;
|
||||
NSInteger second = (time % 60);
|
||||
NSInteger hour = time/3600;
|
||||
NSInteger day = time / 24 * 3600;
|
||||
NSString *timeStr;
|
||||
if (hour > 0) {
|
||||
minute = minute % 60;
|
||||
timeStr = [NSString stringWithFormat:@"%02zd:%02zd:%02zd", hour, minute, second];
|
||||
NSInteger minute;
|
||||
NSInteger hour;
|
||||
NSInteger day = time / 24 / 3600;
|
||||
time = time - day * 24 * 3600;
|
||||
hour = time / 3600;
|
||||
time = time - hour * 3600;
|
||||
minute = time / 60;
|
||||
if (day > 0) {
|
||||
if (hour > 0) {
|
||||
self.nickLabel.text = [NSString stringWithFormat:@"%zd天%zd小时%zd分", day, hour, minute];
|
||||
} else {
|
||||
self.nickLabel.text = [NSString stringWithFormat:@"%zd天%zd分", day, minute];
|
||||
}
|
||||
} else {
|
||||
timeStr = [NSString stringWithFormat:@"%02zd:%02zd", minute, second];
|
||||
if (hour > 0) {
|
||||
self.nickLabel.text = [NSString stringWithFormat:@"%zd小时%zd分", hour, minute];
|
||||
} else {
|
||||
self.nickLabel.text = [NSString stringWithFormat:@"%zd分", minute];
|
||||
}
|
||||
}
|
||||
self.nickLabel.text = timeStr;
|
||||
}
|
||||
|
||||
- (UIImageView *)backImageView {
|
||||
@@ -172,8 +167,9 @@
|
||||
- (UILabel *)nickLabel {
|
||||
if (!_nickLabel) {
|
||||
_nickLabel = [[UILabel alloc] init];
|
||||
_nickLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
|
||||
_nickLabel.font = [UIFont systemFontOfSize:8 weight:UIFontWeightMedium];
|
||||
_nickLabel.textColor = [UIColor whiteColor];
|
||||
_nickLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _nickLabel;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
#import "XPMineGuildViewController.h"
|
||||
#import "XPMineFootPrintViewController.h"
|
||||
#import "XPMineCollectRoomListViewController.h"
|
||||
#import "XPNewUserRechargeViewController.h"
|
||||
|
||||
@interface XPMineViewController ()<UITableViewDelegate, UITableViewDataSource, XPMineProtocol, XPMineHeadItemTableViewCellDelegate, XPMineHeadViewDelegate, XPMineGameTableViewCellDelegate, XPHomeBannerTableViewCellDelegate>
|
||||
///顶部背景
|
||||
@@ -568,6 +569,12 @@
|
||||
self.headView.visitorUnReadCount = model.visitNum;
|
||||
}
|
||||
|
||||
#pragma mark - 新用户充值优惠
|
||||
- (void)onNewUserRechargeTap:(UITapGestureRecognizer *)ges {
|
||||
XPNewUserRechargeViewController *vc = [[XPNewUserRechargeViewController alloc] initWithNavigation:self.navigationController];
|
||||
[self.navigationController presentViewController:vc animated:YES completion:nil];
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UITableView *)tableView {
|
||||
if (!_tableView) {
|
||||
@@ -636,6 +643,8 @@
|
||||
- (XPMineNewUserRechargeView *)userRechargeView {
|
||||
if (!_userRechargeView) {
|
||||
_userRechargeView = [[XPMineNewUserRechargeView alloc] init];
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onNewUserRechargeTap:)];
|
||||
[_userRechargeView addGestureRecognizer:tap];
|
||||
}
|
||||
return _userRechargeView;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property(nonatomic, strong) NSArray<FirstRechargeRewardModel *> *firstChargeRewardList;
|
||||
@property (nonatomic, assign) NSInteger giveMoney;
|
||||
|
||||
///新用户充值优惠使用----
|
||||
///是否完成当前档位的充值
|
||||
@property (nonatomic, assign) BOOL finishCharge;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -1335,11 +1335,11 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
|
||||
#pragma mark - 首次退出非自己的房间,处理是否需要弹新用户充值优惠
|
||||
- (void)handleFirstOutRoom {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
// if (![defaults boolForKey:kHadQuitOtherRoomKey] && self.userInfo.uid != self.roomInfo.uid) {
|
||||
// [defaults setBool:YES forKey:kHadQuitOtherRoomKey];
|
||||
// [defaults synchronize];
|
||||
if (![defaults boolForKey:kHadQuitOtherRoomKey] && self.userInfo.uid != self.roomInfo.uid) {
|
||||
[defaults setBool:YES forKey:kHadQuitOtherRoomKey];
|
||||
[defaults synchronize];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kNewUserRechargeKey object:nil];
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - XPRoomLittleGameContainerViewDelegate
|
||||
|
||||
21
xplan-ios/Main/Tabbar/Model/NewUserRechargeModel.h
Normal file
21
xplan-ios/Main/Tabbar/Model/NewUserRechargeModel.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// NewUserRechargeModel.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/7/29.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "FirstRechargeModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NewUserRechargeModel : NSObject
|
||||
|
||||
@property (nonatomic, assign) long limitEndTime;
|
||||
|
||||
@property (nonatomic, strong) NSArray<FirstRechargeModel *> *limitFirstChargeTaskList;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
16
xplan-ios/Main/Tabbar/Model/NewUserRechargeModel.m
Normal file
16
xplan-ios/Main/Tabbar/Model/NewUserRechargeModel.m
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// NewUserRechargeModel.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/7/29.
|
||||
//
|
||||
|
||||
#import "NewUserRechargeModel.h"
|
||||
|
||||
@implementation NewUserRechargeModel
|
||||
|
||||
+ (NSDictionary *)objectClassInArray {
|
||||
return @{@"limitFirstChargeTaskList": FirstRechargeModel.class};
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -15,6 +15,7 @@
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import "InviteUserInfoModel.h"
|
||||
#import "NewUserGreetModel.h"
|
||||
#import "NewUserRechargeModel.h"
|
||||
|
||||
@implementation MainPresenter
|
||||
|
||||
@@ -105,9 +106,9 @@
|
||||
|
||||
///获取新用户充值优惠
|
||||
- (void)getNewUserRechargeList {
|
||||
NSString * uid = [AccountInfoStorage instance].getUid;
|
||||
[Api requestNewUserRechargeList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
||||
NSLog(@"%@", data.data);
|
||||
NewUserRechargeModel *model = [NewUserRechargeModel modelWithDictionary:data.data];
|
||||
[[self getView] getNewUserRechargeInfoSuccess:model];
|
||||
}]];
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "UserInfoModel.h"
|
||||
@class InviteUserInfoModel, NewUserGreetModel;
|
||||
@class InviteUserInfoModel, NewUserGreetModel, NewUserRechargeModel;
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol MainProtocol <NSObject>
|
||||
@@ -21,6 +21,10 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)getNewUserGreetInfoSucces:(NewUserGreetModel *)greetInfo;
|
||||
///快捷推荐进房成功
|
||||
- (void)getShortCutRecommendRoomSuccces:(NSString *)roomUid;
|
||||
|
||||
///获取新用户充值列表成功
|
||||
- (void)getNewUserRechargeInfoSuccess:(NewUserRechargeModel *)rechargeInfo;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// XPNewUserRechargeCollectionViewCell.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/7/29.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class FirstRechargeRewardModel;
|
||||
@interface XPNewUserRechargeCollectionViewCell : UICollectionViewCell
|
||||
|
||||
///奖励的模型
|
||||
@property (nonatomic,strong) FirstRechargeRewardModel *rewardInfo;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,113 @@
|
||||
//
|
||||
// XPNewUserRechargeCollectionViewCell.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by GreenLand on 2022/7/29.
|
||||
//
|
||||
|
||||
#import "XPNewUserRechargeCollectionViewCell.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "ThemeColor+FirstRecharge.h"
|
||||
#import "NetImageView.h"
|
||||
#import "UIImage+Utils.h"
|
||||
///Model
|
||||
#import "FirstRechargeRewardModel.h"
|
||||
|
||||
@interface XPNewUserRechargeCollectionViewCell ()
|
||||
///奖励的图片
|
||||
@property (nonatomic, strong) NetImageView *iconImageView;
|
||||
///显示奖励图片
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
///显示奖励的时间
|
||||
@property (nonatomic, strong) UIButton *timeButton;
|
||||
@end
|
||||
|
||||
|
||||
@implementation XPNewUserRechargeCollectionViewCell
|
||||
|
||||
- (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.iconImageView];
|
||||
[self addSubview:self.titleLabel];
|
||||
[self addSubview:self.timeButton];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints{
|
||||
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(0);
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
make.width.height.mas_equalTo(56);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self);
|
||||
make.height.mas_equalTo(17);
|
||||
make.top.mas_equalTo(self.iconImageView.mas_bottom).mas_offset(6);
|
||||
make.left.mas_equalTo(0);
|
||||
}];
|
||||
|
||||
[self.timeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.titleLabel.mas_bottom);
|
||||
make.height.mas_equalTo(14);
|
||||
make.centerX.mas_equalTo(self);
|
||||
make.left.mas_equalTo(0);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - setupData
|
||||
- (void)setRewardInfo:(FirstRechargeRewardModel *)rewardInfo {
|
||||
_rewardInfo = rewardInfo;
|
||||
self.timeButton.hidden = !(_rewardInfo.showTime > 0);
|
||||
[self.timeButton setTitle:[NSString stringWithFormat:@"(%@)", _rewardInfo.showTime] forState:UIControlStateNormal];
|
||||
self.titleLabel.text = _rewardInfo.showText;
|
||||
self.iconImageView.imageUrl = _rewardInfo.showPir;
|
||||
}
|
||||
|
||||
|
||||
- (UIImageView *)iconImageView {
|
||||
if (!_iconImageView) {
|
||||
NetImageConfig * config = [[NetImageConfig alloc] init];
|
||||
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
||||
config.imageType = ImageTypeUserIcon;
|
||||
_iconImageView = [[NetImageView alloc] initWithConfig:config];
|
||||
_iconImageView.backgroundColor = UIColorRGBAlpha(0x000000, 0.1);
|
||||
_iconImageView.layer.cornerRadius = 8;
|
||||
_iconImageView.layer.masksToBounds = YES;
|
||||
_iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
}
|
||||
return _iconImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel{
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.textColor = [ThemeColor mainTextColor];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
|
||||
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
- (UIButton *)timeButton{
|
||||
if (!_timeButton) {
|
||||
_timeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_timeButton setTitleColor:[ThemeColor textThirdColor] forState:UIControlStateNormal];
|
||||
_timeButton.titleLabel.font = [UIFont systemFontOfSize:10 weight:UIFontWeightMedium];
|
||||
_timeButton.hidden = YES;
|
||||
}
|
||||
return _timeButton;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -13,10 +13,11 @@
|
||||
#import "ThemeColor+FirstRecharge.h"
|
||||
#import "UIImage+Utils.h"
|
||||
#import "XPFirstRechargeFlowLayout.h"
|
||||
#import "Timestamp.h"
|
||||
///Model
|
||||
#import "FirstRechargeModel.h"
|
||||
#import "NewUserRechargeModel.h"
|
||||
///View
|
||||
#import "XPFirstRechargeCollectionViewCell.h"
|
||||
#import "XPNewUserRechargeCollectionViewCell.h"
|
||||
///P
|
||||
#import "MainPresenter.h"
|
||||
#import "MainProtocol.h"
|
||||
@@ -44,6 +45,8 @@
|
||||
@property (nonatomic,strong) UICollectionView *collectionView;
|
||||
///立即充值
|
||||
@property (nonatomic, strong) UIButton *rechargeButton;
|
||||
///总数据
|
||||
@property (nonatomic, strong) NewUserRechargeModel *rechargeInfo;
|
||||
///数据源
|
||||
@property (nonatomic,strong) NSArray<FirstRechargeRewardModel *> *rewardArray;
|
||||
///初始数据源
|
||||
@@ -136,43 +139,48 @@
|
||||
}];
|
||||
|
||||
[self.extraButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(245, 17));
|
||||
make.size.mas_equalTo(CGSizeMake(266, 17));
|
||||
make.top.mas_equalTo(self.segmentView.mas_bottom).offset(12);
|
||||
make.centerX.mas_equalTo(self.rewardBackView);
|
||||
}];
|
||||
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.extraButton.mas_bottom).offset(12);
|
||||
make.left.right.mas_equalTo(self.rewardBackView);
|
||||
make.bottom.mas_equalTo(self.rewardBackView);
|
||||
make.left.mas_equalTo(self.rewardBackView);
|
||||
make.centerX.mas_equalTo(self.rewardBackView);
|
||||
make.height.mas_equalTo(94);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)createExtraRewardAttrebute:(FirstRechargeModel *)model {
|
||||
NSString * title = model.chargeProdTitle;
|
||||
NSString * giveMoneyStr = [NSString stringWithFormat:@"%ld", model.giveMoney];
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:UIColorFromRGB(0x845DFF)}];
|
||||
[attribute addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xFFA027) range:[title rangeOfString:giveMoneyStr]];
|
||||
[attribute addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:[title rangeOfString:giveMoneyStr]];
|
||||
[self.extraButton setAttributedTitle:attribute forState:UIControlStateNormal];
|
||||
}
|
||||
|
||||
#pragma mark - XPFirstRechargeProtocol
|
||||
- (void)getFirstRechargeListSuccess:(NSArray *)array {
|
||||
if (array.count <= 0) return;
|
||||
self.originArray = array;
|
||||
#pragma mark - MainProtocol
|
||||
///获取新用户充值列表成功
|
||||
- (void)getNewUserRechargeInfoSuccess:(NewUserRechargeModel *)rechargeInfo {
|
||||
_rechargeInfo = rechargeInfo;
|
||||
[Timestamp getInternetDateWithSuccess:^(NSTimeInterval timeInterval) {
|
||||
timeInterval = timeInterval * 1000;
|
||||
long aTime = (rechargeInfo.limitEndTime - timeInterval) / 1000;
|
||||
self.countDownLabel.text = [NSString stringWithFormat:@"限时%@", [self countTimeWithTime:aTime]];
|
||||
} failure:^(NSError * _Nonnull error) {
|
||||
NSDate *datenow = [NSDate date];//现在时间
|
||||
long time2 = (long)([datenow timeIntervalSince1970]*1000);
|
||||
long aTime = (rechargeInfo.limitEndTime - time2) / 1000;
|
||||
self.countDownLabel.text = [NSString stringWithFormat:@"限时%@", [self countTimeWithTime:aTime]];
|
||||
}];
|
||||
|
||||
self.originArray = rechargeInfo.limitFirstChargeTaskList;
|
||||
if (self.segmentView.arrangedSubviews.count > 0) {
|
||||
[[self.segmentView arrangedSubviews] enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
[obj removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
for (int i = 0 ; i < array.count; i++) {
|
||||
FirstRechargeModel * modelInfo = [array objectAtIndex:i];
|
||||
NSInteger defaultIndex = -1;
|
||||
for (int i = 0 ; i < self.originArray.count; i++) {
|
||||
FirstRechargeModel * modelInfo = [self.originArray objectAtIndex:i];
|
||||
NSString * title = [NSString stringWithFormat:@"%ld元", modelInfo.chargeMoney];
|
||||
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[button setTitleColor:[ThemeColor rewardSegmentTextColor] forState:UIControlStateSelected];
|
||||
[button setTitleColor:[ThemeColor rewardSegmentNormalTextColor] forState:UIControlStateNormal];
|
||||
button.titleLabel.font = [UIFont systemFontOfSize:18];
|
||||
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
|
||||
[button setTitleColor:[ThemeColor textThirdColor] forState:UIControlStateNormal];
|
||||
button.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightBold];
|
||||
[button setTitle:title forState:UIControlStateNormal];
|
||||
[button setTitle:title forState:UIControlStateSelected];
|
||||
button.adjustsImageWhenHighlighted = NO;
|
||||
@@ -180,23 +188,55 @@
|
||||
[button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[button setBackgroundImage:[UIImage imageNamed:@"NewUserRecharge_segment_normal_bg"] forState:UIControlStateNormal];
|
||||
[button setBackgroundImage:[[UIImage imageNamed:@"NewUserRecharge_segment_selected_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 30, 0, 30) resizingMode:UIImageResizingModeStretch] forState:UIControlStateSelected];
|
||||
if (i == 0) {
|
||||
if (modelInfo.finishCharge) {
|
||||
button.userInteractionEnabled = NO;
|
||||
}
|
||||
if (!modelInfo.finishCharge && defaultIndex < 0) {
|
||||
button.selected = YES;
|
||||
[self createExtraRewardAttrebute:modelInfo];
|
||||
defaultIndex = i;
|
||||
[self.extraButton setTitle:modelInfo.chargeProdTitle forState:UIControlStateNormal];
|
||||
self.rewardArray = modelInfo.firstChargeRewardList;
|
||||
if (self.rewardArray.count < 4) {
|
||||
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(64*self.rewardArray.count);
|
||||
}];
|
||||
}
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
[self.segmentView addArrangedSubview:button];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)countTimeWithTime:(long)time {
|
||||
NSInteger minute;
|
||||
NSInteger hour;
|
||||
NSInteger day = time / 24 / 3600;
|
||||
time = time - day * 24 * 3600;
|
||||
hour = time / 3600;
|
||||
time = time - hour * 3600;
|
||||
minute = time / 60;
|
||||
if (day > 0) {
|
||||
if (hour > 0) {
|
||||
return [NSString stringWithFormat:@"%zd天%zd小时%zd分", day, hour, minute];
|
||||
} else {
|
||||
return [NSString stringWithFormat:@"%zd天%zd分", day, minute];
|
||||
}
|
||||
} else {
|
||||
if (hour > 0) {
|
||||
return [NSString stringWithFormat:@"%zd小时%zd分", hour, minute];
|
||||
} else {
|
||||
return [NSString stringWithFormat:@"%zd分", minute];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDelegate And UICollectionViewDatasource
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
||||
return self.rewardArray.count;
|
||||
}
|
||||
|
||||
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
||||
XPFirstRechargeCollectionViewCell * cell= [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPFirstRechargeCollectionViewCell class]) forIndexPath:indexPath];
|
||||
XPNewUserRechargeCollectionViewCell * cell= [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPNewUserRechargeCollectionViewCell class]) forIndexPath:indexPath];
|
||||
cell.rewardInfo = [self.rewardArray objectAtIndex:indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
@@ -215,8 +255,17 @@
|
||||
- (void)buttonAction:(UIButton *)sender {
|
||||
if (sender.tag <= self.originArray.count) {
|
||||
FirstRechargeModel * model = [self.originArray objectAtIndex:sender.tag];
|
||||
[self createExtraRewardAttrebute:model];
|
||||
[self.extraButton setTitle:model.chargeProdTitle forState:UIControlStateNormal];
|
||||
self.rewardArray = model.firstChargeRewardList;
|
||||
if (self.rewardArray.count < 4) {
|
||||
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(64*self.rewardArray.count);
|
||||
}];
|
||||
} else {
|
||||
[self.collectionView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.rewardBackView);
|
||||
}];
|
||||
}
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
|
||||
@@ -230,15 +279,14 @@
|
||||
#pragma mark - Getters And Setters
|
||||
- (UICollectionView *)collectionView{
|
||||
if (!_collectionView) {
|
||||
XPFirstRechargeFlowLayout *layout = [[XPFirstRechargeFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake(60, 60+ 16);
|
||||
layout.minimumLineSpacing = 12;
|
||||
layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake(64, 94);
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
_collectionView.showsHorizontalScrollIndicator = NO;
|
||||
_collectionView.dataSource = self;
|
||||
_collectionView.delegate = self;
|
||||
_collectionView.backgroundColor = [UIColor clearColor];
|
||||
[_collectionView registerClass:[XPFirstRechargeCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPFirstRechargeCollectionViewCell class])];
|
||||
[_collectionView registerClass:[XPNewUserRechargeCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPNewUserRechargeCollectionViewCell class])];
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
@@ -293,7 +341,6 @@
|
||||
if (!_rewardBackView) {
|
||||
_rewardBackView = [[UIImageView alloc] init];
|
||||
_rewardBackView.userInteractionEnabled = YES;
|
||||
_rewardBackView.backgroundColor = UIColorFromRGB(0xFCE9FC);
|
||||
}
|
||||
return _rewardBackView;
|
||||
}
|
||||
@@ -301,6 +348,8 @@
|
||||
- (UIButton *)extraButton {
|
||||
if (!_extraButton) {
|
||||
_extraButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_extraButton setTitleColor:UIColorFromRGB(0xFF3987) forState:UIControlStateNormal];
|
||||
_extraButton.titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightBold];
|
||||
}
|
||||
return _extraButton;
|
||||
}
|
||||
@@ -320,7 +369,6 @@
|
||||
_segmentView.distribution = UIStackViewDistributionFillEqually;
|
||||
_segmentView.alignment = UIStackViewAlignmentFill;
|
||||
_segmentView.spacing = 4;
|
||||
_segmentView.backgroundColor = UIColorFromRGB(0xE0B4FF);
|
||||
}
|
||||
return _segmentView;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user