提交
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#import "QXNiceGiftPopView.h"
|
||||
#import "GKPageControl.h"
|
||||
#import "QXGiftCell.h"
|
||||
#import "QXHomePageNetwork.h"
|
||||
|
||||
@interface QXNiceGiftPopView()<UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
@property (nonatomic,strong)UIImageView *lightBgImageView;
|
||||
@@ -15,12 +16,13 @@
|
||||
@property (nonatomic,strong)UIImageView *timeDownbgView;
|
||||
@property (nonatomic,strong)UILabel *timeDownLabel;
|
||||
@property (nonatomic,strong)UIView *giftBgView;
|
||||
@property (nonatomic,strong)UIButton *ruleBtn;
|
||||
//@property (nonatomic,strong)UIButton *ruleBtn;
|
||||
@property (nonatomic,strong)UICollectionView *collectionView;
|
||||
@property (nonatomic,strong)GKPageControl *pageControl;
|
||||
@property (nonatomic,strong)UILabel *messageLabel;
|
||||
@property (nonatomic,strong)UIButton *getBtn;
|
||||
@property (nonatomic,strong)UIButton *closeBtn;
|
||||
@property (nonatomic,strong)QXNiceGiftRechargeModel *model;
|
||||
@end
|
||||
@implementation QXNiceGiftPopView
|
||||
|
||||
@@ -57,7 +59,7 @@
|
||||
|
||||
self.timeDownLabel = [[UILabel alloc] init];
|
||||
self.timeDownLabel.textColor = RGB16(0x666666);
|
||||
self.timeDownLabel.text = QXText(@"剩余时间");
|
||||
self.timeDownLabel.text = QXText(@"截止时间");
|
||||
self.timeDownLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self addSubview:self.timeDownLabel];
|
||||
[self.timeDownLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -66,19 +68,19 @@
|
||||
make.right.equalTo(self.timeDownbgView).offset(-19);
|
||||
}];
|
||||
|
||||
self.ruleBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 54, 20)];
|
||||
self.ruleBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.ruleBtn addTarget:self action:@selector(ruleAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.ruleBtn setTitle:QXText(@"规则") forState:(UIControlStateNormal)];
|
||||
self.ruleBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.ruleBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
[self.ruleBtn addRoundedCornersWithRadius:10 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerBottomLeft)];
|
||||
[self addSubview:self.ruleBtn];
|
||||
[self.ruleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.bgImageView);
|
||||
make.centerY.equalTo(self.timeDownbgView);
|
||||
make.size.mas_equalTo(CGSizeMake(ScaleWidth(54), ScaleWidth(20)));
|
||||
}];
|
||||
// self.ruleBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 54, 20)];
|
||||
// self.ruleBtn.backgroundColor = QXConfig.themeColor;
|
||||
// [self.ruleBtn addTarget:self action:@selector(ruleAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
// [self.ruleBtn setTitle:QXText(@"规则") forState:(UIControlStateNormal)];
|
||||
// self.ruleBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
// [self.ruleBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
// [self.ruleBtn addRoundedCornersWithRadius:10 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerBottomLeft)];
|
||||
// [self addSubview:self.ruleBtn];
|
||||
// [self.ruleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.right.equalTo(self.bgImageView);
|
||||
// make.centerY.equalTo(self.timeDownbgView);
|
||||
// make.size.mas_equalTo(CGSizeMake(ScaleWidth(54), ScaleWidth(20)));
|
||||
// }];
|
||||
|
||||
self.giftBgView = [[UIView alloc] init];
|
||||
// self.giftBgView.backgroundColor = [UIColor whiteColor];
|
||||
@@ -142,7 +144,7 @@
|
||||
self.getBtn = [[UIButton alloc] init];
|
||||
[self.getBtn addRoundedCornersWithRadius:21];
|
||||
self.getBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.getBtn setTitle:QXText(@"立即领取") forState:(UIControlStateNormal)];
|
||||
[self.getBtn setTitle:QXText(@"立即充值") forState:(UIControlStateNormal)];
|
||||
[self.getBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
self.getBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.getBtn addTarget:self action:@selector(getAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
@@ -163,46 +165,37 @@
|
||||
make.top.equalTo(self.bgImageView.mas_bottom).offset(8);
|
||||
make.height.width.mas_equalTo(30);
|
||||
}];
|
||||
[self getGiftList];
|
||||
}
|
||||
|
||||
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
|
||||
if ([scrollView isKindOfClass:[UICollectionView class]]) {
|
||||
long offsetX = (long)scrollView.contentOffset.x;
|
||||
int width = ScaleWidth(275-15*2-12*2-3*8);
|
||||
int remainder = offsetX % width;
|
||||
NSInteger index;
|
||||
if (remainder>(width)/2) {
|
||||
index = offsetX/width+1;
|
||||
}else{
|
||||
index = offsetX/width;
|
||||
-(void)getGiftList{
|
||||
MJWeakSelf
|
||||
[QXHomePageNetwork getSkyDropGiftListSuccessBlock:^(QXNiceGiftRechargeModel * _Nonnull model) {
|
||||
weakSelf.model = model;
|
||||
weakSelf.timeDownLabel.text = model.effective_time;
|
||||
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:model.counter];
|
||||
[attr yy_setColor:QXConfig.themeColor range:[model.counter rangeOfString:model.money]];
|
||||
[attr yy_setColor:QXConfig.themeColor range:[model.counter rangeOfString:model.diamond]];
|
||||
weakSelf.messageLabel.attributedText = attr;
|
||||
[weakSelf.collectionView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
if (weakSelf.refreshBlcock) {
|
||||
weakSelf.refreshBlcock();
|
||||
}
|
||||
self.pageControl.currentPage = index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(void)setGiftArray:(NSArray *)giftArray{
|
||||
_giftArray = giftArray;
|
||||
self.pageControl.numberOfPages = giftArray.count/4+1;
|
||||
self.pageControl.currentPage = 0;
|
||||
[self.collectionView reloadData];
|
||||
}];
|
||||
}
|
||||
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.giftArray.count;
|
||||
return self.model.gift_list.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXGiftCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXGiftCell" forIndexPath:indexPath];
|
||||
cell.cellType = QXGiftCellTypeNiceGift;
|
||||
cell.roomGiftModel = self.model.gift_list[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
|
||||
// 规则
|
||||
-(void)ruleAction{
|
||||
if (self.ruleActionBlock) {
|
||||
self.ruleActionBlock();
|
||||
}
|
||||
}
|
||||
|
||||
// 立即领取
|
||||
-(void)getAction{
|
||||
if (self.getActionBlock) {
|
||||
|
||||
Reference in New Issue
Block a user