feat: 调整 UI 效果,调整剩余日期计算
This commit is contained in:
@@ -186,7 +186,6 @@
|
|||||||
@interface VIPCardCyclePagerCell : UICollectionViewCell
|
@interface VIPCardCyclePagerCell : UICollectionViewCell
|
||||||
|
|
||||||
@property (nonatomic, assign) NSInteger cellIndex;
|
@property (nonatomic, assign) NSInteger cellIndex;
|
||||||
@property (nonatomic, copy) NSString *placeHolderPath;
|
|
||||||
@property (nonatomic, copy) NSString *svgaPath;
|
@property (nonatomic, copy) NSString *svgaPath;
|
||||||
|
|
||||||
@property (nonatomic, strong) UIImageView *levelBgImageView;
|
@property (nonatomic, strong) UIImageView *levelBgImageView;
|
||||||
@@ -235,21 +234,23 @@
|
|||||||
_svgaImageView.clearsAfterStop = NO;
|
_svgaImageView.clearsAfterStop = NO;
|
||||||
_svgaImageView.loops = INT_MAX;
|
_svgaImageView.loops = INT_MAX;
|
||||||
_svgaImageView.contentMode = UIViewContentModeScaleAspectFill;
|
_svgaImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||||
|
NSInteger offset = 80;
|
||||||
[self.contentView addSubview:_svgaImageView];
|
[self.contentView addSubview:_svgaImageView];
|
||||||
[_svgaImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[_svgaImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.edges.mas_equalTo(self.placeHolderImageView);
|
make.centerX.mas_equalTo(_placeHolderImageView);
|
||||||
|
make.bottom.mas_equalTo(_placeHolderImageView).offset(offset/2);
|
||||||
|
make.width.height.mas_equalTo(kGetScaleWidth(130 + offset));
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setCellIndex:(NSInteger)cellIndex {
|
- (void)setCellIndex:(NSInteger)cellIndex {
|
||||||
_cellIndex = cellIndex;
|
_cellIndex = cellIndex;
|
||||||
NSString *imageName = [NSString stringWithFormat:@"vip_center_level_%ld", (long)(cellIndex+1)];
|
NSString *imageName = [NSString stringWithFormat:@"vip_center_level_%ld", (long)(cellIndex+1)];
|
||||||
[self.levelBgImageView setImage:kImage(imageName)];
|
UIImage *image = kImage(imageName);
|
||||||
}
|
if (image == nil) {
|
||||||
|
image = kImage(@"vip_center_level_6");
|
||||||
- (void)setPlaceHolderPath:(NSString *)placeHolderPath {
|
}
|
||||||
_placeHolderPath = placeHolderPath;
|
[self.levelBgImageView setImage:image];
|
||||||
_placeHolderImageView.imageUrl = placeHolderPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setSvgaPath:(NSString *)svgaPath {
|
- (void)setSvgaPath:(NSString *)svgaPath {
|
||||||
@@ -272,7 +273,7 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
@interface VIPCenterViewController () <TYCyclePagerViewDataSource, TYCyclePagerViewDelegate, XPNobleCenterPayViewDelegate, XPNobleCenterProtocol>
|
@interface VIPCenterViewController () <TYCyclePagerViewDataSource, TYCyclePagerViewDelegate, XPNobleCenterPayViewDelegate, XPNobleCenterProtocol, NIMSystemNotificationManagerDelegate>
|
||||||
|
|
||||||
@property (nonatomic, strong) UIButton *backButton;
|
@property (nonatomic, strong) UIButton *backButton;
|
||||||
@property (nonatomic, strong) UILabel *titleLabel;
|
@property (nonatomic, strong) UILabel *titleLabel;
|
||||||
@@ -285,6 +286,7 @@
|
|||||||
@property (nonatomic, strong) UIView *scrollContentView;
|
@property (nonatomic, strong) UIView *scrollContentView;
|
||||||
|
|
||||||
@property (nonatomic, strong) UserInfoModel *userInfo;
|
@property (nonatomic, strong) UserInfoModel *userInfo;
|
||||||
|
@property (nonatomic, strong) UserVipInfoVo *userVIPInfo;
|
||||||
@property (nonatomic, strong) NobleInfo *currentVIPInfo;
|
@property (nonatomic, strong) NobleInfo *currentVIPInfo;
|
||||||
@property (nonatomic, strong) NobleCenterModel *vipModel;
|
@property (nonatomic, strong) NobleCenterModel *vipModel;
|
||||||
@property (nonatomic, strong) WalletInfoModel *walletInfo;
|
@property (nonatomic, strong) WalletInfoModel *walletInfo;
|
||||||
@@ -679,7 +681,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.rechargeModel = nil;
|
self.rechargeModel = nil;
|
||||||
// NSInteger currentLevel = self.vipModel.currentLevel == 0 ? 1 : self.vipModel.currentLevel;
|
NSInteger currentLevel = self.userVIPInfo.vipLevel;
|
||||||
NSInteger currentPage = self.vipCardCyclePager.curIndex;
|
NSInteger currentPage = self.vipCardCyclePager.curIndex;
|
||||||
for (RechargeListModel *model in self.rechargeList) {
|
for (RechargeListModel *model in self.rechargeList) {
|
||||||
if (model.prodDesc.integerValue == currentPage + 1) {
|
if (model.prodDesc.integerValue == currentPage + 1) {
|
||||||
@@ -692,20 +694,27 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 已经是当前等级的显示?
|
|
||||||
NSInteger userLevel = self.userInfo.userVipInfoVO.vipLevel;
|
|
||||||
|
|
||||||
self.purchasePriceLabel.text = [NSString stringWithFormat:@"%.0f/30Days", self.rechargeModel.money.floatValue * 1000];
|
self.purchasePriceLabel.text = [NSString stringWithFormat:@"%.0f/30Days", self.rechargeModel.money.floatValue * 1000];
|
||||||
if (self.purchaseExpiresLabel.text.length == 0) {
|
|
||||||
|
if (currentLevel >= self.vipCardCyclePager.curIndex+1) {
|
||||||
|
self.purchaseExpiresLabel.text = [NSString stringWithFormat:@"%@ Expires", [self calNextVIPExpiredSeconds:self.vipModel.remainSeconds]];
|
||||||
|
} else {
|
||||||
self.purchaseExpiresLabel.text = [NSString stringWithFormat:@"%@ Expires", [self calNext30Day]];
|
self.purchaseExpiresLabel.text = [NSString stringWithFormat:@"%@ Expires", [self calNext30Day]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *)calNextVIPExpiredSeconds:(NSInteger)seconds {
|
||||||
|
NSDate *date = [NSDate date];
|
||||||
|
NSDate *nextDate = [date dateByAddingSeconds:seconds];
|
||||||
|
return [NSDate timestampSwitchTime:nextDate.timeIntervalSince1970
|
||||||
|
formatter:@"yyyy/MM/dd 00:00"];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString *)calNext30Day {
|
- (NSString *)calNext30Day {
|
||||||
NSDate *date = [NSDate date];
|
NSDate *date = [NSDate date];
|
||||||
NSDate *next30Date = [date dateByAddingDays:30];
|
NSDate *next30Date = [date dateByAddingDays:30];
|
||||||
return [NSDate timestampSwitchTime:next30Date.timeIntervalSince1970
|
return [NSDate timestampSwitchTime:next30Date.timeIntervalSince1970
|
||||||
formatter:@"yyyy/MM/dd hh:mm"];
|
formatter:@"yyyy/MM/dd 00:00"];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Load Data from API
|
#pragma mark - Load Data from API
|
||||||
@@ -723,8 +732,13 @@
|
|||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
UserInfoModel *infoModel = [UserInfoModel modelWithDictionary:data.data];
|
UserInfoModel *infoModel = [UserInfoModel modelWithDictionary:data.data];
|
||||||
self.userInfo = infoModel;
|
self.userInfo = infoModel;
|
||||||
|
self.userVIPInfo = infoModel.userVipInfoVO;
|
||||||
[self loadVIPCenterInfo];
|
[self loadVIPCenterInfo];
|
||||||
[self updatePurchaseArea];
|
[self updatePurchaseArea];
|
||||||
|
|
||||||
|
if (self.userVIPInfo) {
|
||||||
|
[self.vipCardCyclePager scrollToItemAtIndex:self.userVIPInfo.vipLevel-1 animate:NO];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} uid:uid];
|
} uid:uid];
|
||||||
}
|
}
|
||||||
@@ -766,6 +780,7 @@
|
|||||||
[self configVIPCards];
|
[self configVIPCards];
|
||||||
[self configIdentificationCards];
|
[self configIdentificationCards];
|
||||||
[self configExclusivePrivilegesArea];
|
[self configExclusivePrivilegesArea];
|
||||||
|
[self updatePurchaseArea];
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@@ -816,6 +831,7 @@
|
|||||||
layout.layoutType = TYCyclePagerTransformLayoutLinear;
|
layout.layoutType = TYCyclePagerTransformLayoutLinear;
|
||||||
layout.itemSize = CGSizeMake(kGetScaleWidth(320), kGetScaleWidth(136));
|
layout.itemSize = CGSizeMake(kGetScaleWidth(320), kGetScaleWidth(136));
|
||||||
layout.itemSpacing = 15;
|
layout.itemSpacing = 15;
|
||||||
|
layout.sectionInset = UIEdgeInsetsMake(0, 40, 0, 40);
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -826,7 +842,6 @@
|
|||||||
if (self.vipModel) {
|
if (self.vipModel) {
|
||||||
NobleInfo *info = [self.vipModel.vipInfos xpSafeObjectAtIndex:index];
|
NobleInfo *info = [self.vipModel.vipInfos xpSafeObjectAtIndex:index];
|
||||||
if (info) {
|
if (info) {
|
||||||
cell.placeHolderPath = info.vipIcon;
|
|
||||||
cell.svgaPath = info.vipLogo;
|
cell.svgaPath = info.vipLogo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
- (NSInteger)daysBetween:(NSDate *)aDate;
|
- (NSInteger)daysBetween:(NSDate *)aDate;
|
||||||
|
|
||||||
- (NSDate *)dateByAddingDays:(NSInteger)days;
|
- (NSDate *)dateByAddingDays:(NSInteger)days;
|
||||||
|
- (NSDate *)dateByAddingSeconds:(NSInteger)seconds;
|
||||||
|
|
||||||
- (NSString *)stringForFormat:(NSString *)format;
|
- (NSString *)stringForFormat:(NSString *)format;
|
||||||
|
|
||||||
|
@@ -31,6 +31,13 @@ NSString * const kDateFormatYYMMDDTHHmmss = @"yyyy-MM-dd'T'HH:mm:ss";
|
|||||||
return [calendar dateByAddingComponents:components toDate:self options:0];
|
return [calendar dateByAddingComponents:components toDate:self options:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSDate *)dateByAddingSeconds:(NSInteger)seconds {
|
||||||
|
NSCalendar *calendar = [NSCalendar sharedCalendar];
|
||||||
|
NSDateComponents *components = [[NSDateComponents alloc] init];
|
||||||
|
[components setSecond:seconds];
|
||||||
|
return [calendar dateByAddingComponents:components toDate:self options:0];
|
||||||
|
}
|
||||||
|
|
||||||
- (NSInteger)daysBetween:(NSDate *)aDate {
|
- (NSInteger)daysBetween:(NSDate *)aDate {
|
||||||
NSUInteger unitFlags = NSCalendarUnitDay;
|
NSUInteger unitFlags = NSCalendarUnitDay;
|
||||||
NSDate *from = [NSDate at_dateFromString:[self stringForYearMonthDayDashed]];
|
NSDate *from = [NSDate at_dateFromString:[self stringForYearMonthDayDashed]];
|
||||||
|
Reference in New Issue
Block a user