163 lines
6.0 KiB
Objective-C
Executable File
163 lines
6.0 KiB
Objective-C
Executable File
//
|
|
// SPMineDressVC.m
|
|
// SweetParty
|
|
//
|
|
// Created by bj_szd on 2022/6/6.
|
|
//
|
|
|
|
#import "SPMineDressVC.h"
|
|
#import "SPMineDressCell.h"
|
|
#import "JXCategoryTitleBackgroundView.h"
|
|
|
|
@interface SPMineDressVC () <UICollectionViewDelegateFlowLayout, UICollectionViewDataSource, JXCategoryViewDelegate>
|
|
|
|
@property (weak, nonatomic) IBOutlet UIImageView *kuangImgV;
|
|
@property (weak, nonatomic) IBOutlet UIImageView *avatarImgV;
|
|
@property (weak, nonatomic) IBOutlet UILabel *nicknameLab;
|
|
@property (weak, nonatomic) IBOutlet UIImageView *gxImgV;
|
|
@property (weak, nonatomic) IBOutlet UIImageView *mlImgV;
|
|
@property (weak, nonatomic) IBOutlet UIView *bottomBgView;
|
|
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
|
|
@property (weak, nonatomic) IBOutlet UILabel *IDLab;
|
|
|
|
@property (nonatomic, strong) NSArray *titles;
|
|
@property (nonatomic, strong) JXCategoryTitleBackgroundView *categoryView;
|
|
@property (nonatomic, strong) JXCategoryIndicatorImageView *lineView;
|
|
|
|
@property (nonatomic, strong) NSArray *dataArray;
|
|
@property (nonatomic, assign) NSInteger currentIndex;
|
|
|
|
@end
|
|
|
|
@implementation SPMineDressVC
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
|
|
[self showNaviBarWithTitle:@"我的装扮"];
|
|
|
|
self.titles = @[@"头像框", @"坐骑", @"资料展示" ,@"气泡", @"个人靓号", @"房间靓号"];
|
|
|
|
[self createUI];
|
|
|
|
[self fetchData];
|
|
}
|
|
|
|
-(void)fetchData {
|
|
NSDictionary *params = @{@"page":@(1), @"page_limit":@(1000), @"type":@(self.currentIndex+1)};
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/decorate/user_decorate_list" Loading:NO Hud:NO Success:^(id _Nonnull responseDic) {
|
|
NSArray *arr = [SPMineDressModel mj_objectArrayWithKeyValuesArray:responseDic[@"data"][@"list"]];
|
|
self.dataArray = arr;
|
|
[self.collectionView reloadData];
|
|
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}
|
|
|
|
- (void)createUI {
|
|
[self.bottomBgView addSubview:self.categoryView];
|
|
self.categoryView.frame = CGRectMake(10, 10, ScreenWidth-20, 40);
|
|
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
CGFloat itemW = (ScreenWidth-10*2-20*3)/4;
|
|
layout.itemSize = CGSizeMake(itemW, itemW+70);
|
|
layout.minimumInteritemSpacing = 20;
|
|
layout.minimumLineSpacing = 0;
|
|
layout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
|
|
|
|
_collectionView.collectionViewLayout = layout;
|
|
_collectionView.delegate = self;
|
|
_collectionView.dataSource = self;
|
|
[_collectionView registerNib:[UINib nibWithNibName:@"SPMineDressCell" bundle:nil] forCellWithReuseIdentifier:@"SPMineDressCell"];
|
|
|
|
[self.avatarImgV sd_setImageWithURL:[NSURL URLWithString:self.model.head_pic] placeholderImage:kDefaultUserIcon];
|
|
self.nicknameLab.text = self.model.nick_name;
|
|
self.IDLab.text = [NSString stringWithFormat:@"%@", self.model.uid];
|
|
[self.gxImgV sd_setImageWithURL:[NSURL URLWithString:self.model.contribution_level_image]];
|
|
[self.mlImgV sd_setImageWithURL:[NSURL URLWithString:self.model.charm_level_image]];
|
|
|
|
// [ControlCreator createButton:self.view rect:CGRectMake(ScreenWidth-60-12, yb_StatusBar_H+7, 60, 30) text:@"购买记录" font:YBMediumFont(12) color:HEXCOLOR(0x333333) backguoundColor:nil imageName:nil target:self action:@selector(onBuyRecord)];
|
|
}
|
|
|
|
- (void)onBuyRecord {
|
|
|
|
}
|
|
|
|
#pragma mark -------- collectionView代理方法 ------
|
|
|
|
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
|
|
return 1;
|
|
}
|
|
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
|
return self.dataArray.count;
|
|
}
|
|
|
|
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
SPMineDressCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"SPMineDressCell" forIndexPath:indexPath];
|
|
SPMineDressModel *model = self.dataArray[indexPath.row];
|
|
cell.model = model;
|
|
|
|
if (0 == self.currentIndex) {
|
|
if (model.is_using == 1) {
|
|
[self.kuangImgV sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
|
}
|
|
}
|
|
|
|
return cell;
|
|
}
|
|
|
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
SPMineDressModel *model = self.dataArray[indexPath.item];
|
|
|
|
NSDictionary *params = @{@"udid":model.udid};
|
|
NSString *urlStr = @"/api/decorate/user_use_decorate";
|
|
[[AFNetworkRequset shared] postRequestWithParams:params Path:urlStr Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
|
|
[self fetchData];
|
|
} Failure:^(id _Nonnull errorData) {
|
|
|
|
}];
|
|
}
|
|
|
|
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
|
self.currentIndex = index;
|
|
if (index < 3){
|
|
self.currentIndex = index;
|
|
}else{
|
|
self.currentIndex = index+1;
|
|
}
|
|
[self fetchData];
|
|
if (index == 2){
|
|
_lineView.horizontalMargin = 52;
|
|
}else if (index == 5 || index == 4){
|
|
_lineView.horizontalMargin = 40;
|
|
}else if (index == 0){
|
|
_lineView.horizontalMargin = 30;
|
|
}else{
|
|
_lineView.horizontalMargin = 22;
|
|
}
|
|
}
|
|
|
|
- (JXCategoryTitleBackgroundView *)categoryView {
|
|
if (!_categoryView) {
|
|
_categoryView = [[JXCategoryTitleBackgroundView alloc] init];
|
|
_categoryView.delegate = self;
|
|
_categoryView.titleFont = YBMediumFont(14);
|
|
_categoryView.titleSelectedFont = YBBoldFont(15);
|
|
_categoryView.titleColor = HEXCOLOR(0xFFFFFF);
|
|
_categoryView.titleSelectedColor = HEXCOLOR(0x333333);
|
|
_categoryView.selectedBackgroundColor = kClearColor;
|
|
_categoryView.cellWidth = 90;
|
|
_categoryView.cellSpacing = 10;
|
|
_categoryView.titles = self.titles;
|
|
_categoryView.contentEdgeInsetLeft = 0;
|
|
_categoryView.contentEdgeInsetRight = 0;
|
|
_categoryView.normalImageName = @"dress_title_nor";
|
|
_categoryView.selectedImageName = @"dress_title_sel";
|
|
}
|
|
return _categoryView;
|
|
}
|
|
|
|
@end
|