我的
This commit is contained in:
@@ -6,13 +6,15 @@
|
||||
//
|
||||
|
||||
#import "QXMineServiceCell.h"
|
||||
|
||||
@class QXMineServiceSubCell;
|
||||
@interface QXMineServiceCell()<UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@property (nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)UICollectionView *collectionView;
|
||||
@property (nonatomic,strong)NSMutableArray *serviceArray;
|
||||
@property (nonatomic,strong)NSMutableArray *serviceImageArray;
|
||||
@property (nonatomic,strong)NSMutableArray *moreArray;
|
||||
@property (nonatomic,strong)QXServiceModel *inviteModel;
|
||||
@end
|
||||
|
||||
@implementation QXMineServiceCell
|
||||
@@ -34,24 +36,25 @@
|
||||
}
|
||||
-(void)createViews{
|
||||
self.bgView = [[UIView alloc] init];
|
||||
self.bgView.backgroundColor = [UIColor whiteColor];
|
||||
self.bgView.backgroundColor = RGB16(0x231F2C);
|
||||
[self.bgView addRoundedCornersWithRadius:10];
|
||||
[self.contentView addSubview:self.bgView];
|
||||
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.right.mas_equalTo(-16);
|
||||
make.top.bottom.equalTo(self);
|
||||
make.top.mas_equalTo(6);
|
||||
make.bottom.mas_equalTo(-6);
|
||||
}];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
self.titleLabel.textColor = QXConfig.textColor;
|
||||
self.titleLabel.font = [UIFont boldSystemFontOfSize:14];
|
||||
self.titleLabel.textColor = RGB16(0x929196);
|
||||
self.titleLabel.text = QXText(@"更多服务");
|
||||
[self.bgView addSubview:self.titleLabel];;
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.mas_equalTo(12);
|
||||
make.right.mas_equalTo(-12);
|
||||
make.height.mas_equalTo(24);
|
||||
make.height.mas_equalTo(16);
|
||||
}];
|
||||
|
||||
|
||||
@@ -69,14 +72,13 @@
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
self.collectionView.showsHorizontalScrollIndicator = NO;
|
||||
self.collectionView.bounces = NO;
|
||||
self.collectionView.scrollEnabled = NO;
|
||||
self.collectionView.backgroundColor = UIColor.clearColor;
|
||||
[self.bgView addSubview:self.collectionView];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.equalTo(self.bgView);
|
||||
make.top.equalTo(self.titleLabel.mas_bottom).offset(22);
|
||||
make.height.mas_equalTo(btnHeight*2+10);
|
||||
// make.right.mas_equalTo(-12);
|
||||
make.top.equalTo(self.titleLabel.mas_bottom).offset(12);
|
||||
make.bottom.mas_equalTo(-12);
|
||||
}];
|
||||
|
||||
|
||||
@@ -101,23 +103,32 @@
|
||||
//
|
||||
// }
|
||||
}
|
||||
-(void)serviceClick:(UIButton*)sender{
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickServiceWithBtn:title:)]) {
|
||||
[self.delegate didClickServiceWithBtn:sender title:sender.titleLabel.text];
|
||||
|
||||
-(void)setIsMore:(BOOL)isMore{
|
||||
_isMore = isMore;
|
||||
self.titleLabel.text = isMore?@"更多":@"常用服务";
|
||||
if (isMore) {
|
||||
if ([self.moreArray containsObject:self.inviteModel]) {
|
||||
return;
|
||||
}
|
||||
if (QXGlobal.shareGlobal.isOpenRecharge) {
|
||||
[self.moreArray insertObject:self.inviteModel atIndex:1];
|
||||
}
|
||||
}
|
||||
}
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.serviceArray.count;
|
||||
return self.isMore?self.moreArray.count:self.serviceArray.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXMineServiceSubCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXMineServiceSubCell" forIndexPath:indexPath];
|
||||
cell.imageView.image = [UIImage imageNamed:self.serviceImageArray[indexPath.row]];
|
||||
cell.titleLabel.text = self.serviceArray[indexPath.row];
|
||||
QXServiceModel *model = self.isMore?self.moreArray[indexPath.row]:self.serviceArray[indexPath.row];
|
||||
cell.model = model;
|
||||
return cell;
|
||||
}
|
||||
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickServiceWithBtn:title:)]) {
|
||||
[self.delegate didClickServiceWithBtn:nil title:self.serviceArray[indexPath.row]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickServiceWithType:)]) {
|
||||
QXServiceModel *model = self.isMore?self.moreArray[indexPath.row]:self.serviceArray[indexPath.row];
|
||||
[self.delegate didClickServiceWithType:model.type];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,32 +144,76 @@
|
||||
}
|
||||
-(NSMutableArray *)serviceArray{
|
||||
if (!_serviceArray) {
|
||||
QXServiceModel *md1 = [[QXServiceModel alloc] init];
|
||||
md1.title = @"等级";
|
||||
md1.icon = @"service_level";
|
||||
md1.type = QXMineServiceTypeLevel;
|
||||
|
||||
QXServiceModel *md2 = [[QXServiceModel alloc] init];
|
||||
md2.title = @"个性装扮";
|
||||
md2.icon = @"service_dress";
|
||||
md2.type = QXMineServiceTypeDress;
|
||||
|
||||
QXServiceModel *md3 = [[QXServiceModel alloc] init];
|
||||
md3.title = @"我的背包";
|
||||
md3.icon = @"service_bag";
|
||||
md3.type = QXMineServiceTypeBackpack;
|
||||
|
||||
QXServiceModel *md4 = [[QXServiceModel alloc] init];
|
||||
md4.title = @"设置";
|
||||
md4.icon = @"service_setting";
|
||||
md4.type = QXMineServiceTypeSetting;
|
||||
|
||||
|
||||
_serviceArray = [NSMutableArray arrayWithArray:@[
|
||||
QXText(@"钱包"),
|
||||
QXText(@"段位"),
|
||||
QXText(@"公会中心"),
|
||||
QXText(@"个性装扮"),
|
||||
QXText(@"道具商城"),
|
||||
QXText(@"我的背包"),
|
||||
QXText(@"每日任务")
|
||||
md1,
|
||||
md2,
|
||||
md3,
|
||||
md4,
|
||||
]];
|
||||
}
|
||||
return _serviceArray;
|
||||
}
|
||||
-(NSMutableArray *)serviceImageArray{
|
||||
if (!_serviceImageArray) {
|
||||
_serviceImageArray = [NSMutableArray arrayWithArray:@[
|
||||
@"service_wallet",
|
||||
@"service_level",
|
||||
@"service_guild",
|
||||
@"service_dress",
|
||||
@"service_shop",
|
||||
@"service_bag",
|
||||
@"service_task"
|
||||
-(NSMutableArray *)moreArray{
|
||||
if (!_moreArray) {
|
||||
QXServiceModel *md1 = [[QXServiceModel alloc] init];
|
||||
md1.title = @"帮助中心";
|
||||
md1.icon = @"service_help";
|
||||
md1.type = QXMineServiceTypeHelp;
|
||||
|
||||
QXServiceModel *md2 = [[QXServiceModel alloc] init];
|
||||
md2.title = @"每日任务";
|
||||
md2.icon = @"service_task";
|
||||
md2.type = QXMineServiceTypeDayTask;
|
||||
|
||||
QXServiceModel *md3 = [[QXServiceModel alloc] init];
|
||||
md3.title = @"意见反馈";
|
||||
md3.icon = @"service_bag";
|
||||
md3.type = QXMineServiceTypeReport;
|
||||
|
||||
QXServiceModel *md4 = [[QXServiceModel alloc] init];
|
||||
md4.title = @"个税客服";
|
||||
md4.icon = @"service_customer_service";
|
||||
md4.type = QXMineServiceTypeCustomerService;
|
||||
|
||||
_moreArray = [NSMutableArray arrayWithArray:@[
|
||||
md1,
|
||||
md2,
|
||||
md3,
|
||||
md4,
|
||||
]];
|
||||
}
|
||||
|
||||
return _serviceImageArray;
|
||||
return _moreArray;
|
||||
}
|
||||
-(QXServiceModel *)inviteModel{
|
||||
if (!_inviteModel) {
|
||||
_inviteModel = [[QXServiceModel alloc] init];
|
||||
_inviteModel.title = @"邀请";
|
||||
_inviteModel.icon = @"service_invite";
|
||||
_inviteModel.type = QXMineServiceTypeInvite;
|
||||
}
|
||||
return _inviteModel;
|
||||
}
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
@@ -184,17 +239,22 @@
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)setModel:(QXServiceModel *)model{
|
||||
_model = model;
|
||||
self.imageView.image = [UIImage imageNamed:model.icon];
|
||||
self.titleLabel.text = model.title;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
UIImageView *imageView = [[UIImageView alloc] init];
|
||||
[self.contentView addSubview:imageView];
|
||||
self.imageView = imageView;
|
||||
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.centerX.equalTo(self.contentView);
|
||||
make.height.width.mas_equalTo(18);
|
||||
make.height.width.mas_equalTo(ScaleWidth(24));
|
||||
}];
|
||||
|
||||
UILabel *titleLabel = [[UILabel alloc] init];
|
||||
titleLabel.textColor = QXConfig.textColor;
|
||||
titleLabel.textColor = RGB16(0x929196);
|
||||
titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.contentView addSubview:titleLabel];
|
||||
self.titleLabel = titleLabel;
|
||||
|
||||
Reference in New Issue
Block a user