// // YOUPAILZPersonalizedDressVC.m // VQU // // Created by CY on 2021/8/17. // Copyright © 2021 leo. All rights reserved. // #import "YOUPAILZPersonalizedDressVC.h" #import "JXCategoryView.h" #import "JXCategoryDotView.h" #import "YOUPAIHRDressRedModel.h" @interface YOUPAILZPersonalizedDressVC () @property (nonatomic, weak) JXCategoryListContainerView *youpaippagerView; //@property (nonatomic, strong) JXCategoryTitleView *categoryView; @property (nonatomic, strong) JXCategoryDotView *youpaipcategoryView; @property (nonatomic, strong) NSMutableArray *youpaipdotStates; @end @implementation YOUPAILZPersonalizedDressVC - (void)viewDidLoad { [super viewDidLoad]; self.title = @"个性装扮"; [self youpaifinitUI]; [self youpaifrequestAvatarDressData]; } - (void)youpaifinitUI{ JXCategoryDotView *categoryView = [[JXCategoryDotView alloc] initWithFrame:CGRectMake((KScreenWidth - 284.0f)/ 2.0f, NavBarHeight, 284.0f, 44.0f)]; categoryView.backgroundColor = LCBkgColor; categoryView.titles = self.titles; categoryView.delegate = self; categoryView.titleSelectedColor = [UIColor whiteColor]; categoryView.titleColor = HexColorFromRGB(0x9F9DA5); categoryView.titleColorGradientEnabled = YES; categoryView.titleFont = LCFont(14.0f); categoryView.titleSelectedFont = LCBoldFont(14.0f); categoryView.cellSpacing = 28.0f; // categoryView.cellWidth = 64.0f; categoryView.averageCellSpacingEnabled = YES; // categoryView.averageCellSpacingEnabled = NO; [self.view addSubview:categoryView]; self.youpaipcategoryView = categoryView; // _dotStates = @[@NO, @YES,@YES,@YES].mutableCopy; // categoryView.dotStates = _dotStates; categoryView.dotSize = CGSizeMake(4, 4); categoryView.dotColor = LCRedColor; JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init]; lineView.verticalMargin = 4.0f; lineView.indicatorHeight = 2.0f; lineView.indicatorWidth = 12.0f; lineView.indicatorColor = HexColorFromRGB(0xF4003F); lineView.indicatorCornerRadius = 1.0f; categoryView.indicators = @[lineView]; JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self]; pagerView.frame = CGRectMake(0.0f, NavBarHeight + 44.0f, KScreenWidth, KScreenHeight - (NavBarHeight + 44.0f)); pagerView.listCellBackgroundColor = LCBkgColor; [self.view addSubview:pagerView]; self.youpaippagerView = pagerView; categoryView.listContainer = pagerView; } - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{ return self.titles.count; } - (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{ UIViewController *vc = [[NSClassFromString(self.vcNames[index]) alloc] init]; return vc; } - (NSArray *)titles{ return @[@"头像框",@"座驾",@"气泡",@"名片卡"]; } - (NSArray *)vcNames{ return @[@"YOUPAILZAvatarDressVC",@"YOUPAILZCarDressVC",@"YOUPAILZBubbleDressVC",@"YOUPAILZCardDressVC"]; } #pragma mark - JXCategoryViewDelegate - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index { if ([self.youpaipdotStates[index] boolValue] == YES) { self.youpaipdotStates[index] = @(NO); self.youpaipcategoryView.dotStates = self.youpaipdotStates; [categoryView reloadCellAtIndex:index]; } } - (void)youpaifrequestAvatarDressData{ @weakify(self); [LCHttpHelper requestWithURLString:GetDressList parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) { @strongify(self); NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) {//成功 NSDictionary *data = [dict objectForKey:@"data"]; YOUPAIHRDressRedModel *model = [YOUPAIHRDressRedModel mj_objectWithKeyValues:data[@"red_dot"]]; self.youpaipdotStates = @[@NO,@(model.youpaipcar),@(model.youpaipbubble),@(model.youpaipcard)].mutableCopy; self.youpaipcategoryView.dotStates = self.youpaipdotStates; [self.youpaipcategoryView reloadDataWithoutListContainer]; } } failure:^(NSError *error) { }]; } @end