YOUPAILZPersonalizedDressVC.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // YOUPAILZPersonalizedDressVC.m
  3. // VQU
  4. //
  5. // Created by CY on 2021/8/17.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAILZPersonalizedDressVC.h"
  9. #import "JXCategoryView.h"
  10. #import "JXCategoryDotView.h"
  11. #import "YOUPAIHRDressRedModel.h"
  12. @interface YOUPAILZPersonalizedDressVC ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
  13. @property (nonatomic, weak) JXCategoryListContainerView *youpaippagerView;
  14. //@property (nonatomic, strong) JXCategoryTitleView *categoryView;
  15. @property (nonatomic, strong) JXCategoryDotView *youpaipcategoryView;
  16. @property (nonatomic, strong) NSMutableArray *youpaipdotStates;
  17. @end
  18. @implementation YOUPAILZPersonalizedDressVC
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. self.title = @"个性装扮";
  22. [self youpaifinitUI];
  23. [self youpaifrequestAvatarDressData];
  24. }
  25. - (void)youpaifinitUI{
  26. JXCategoryDotView *categoryView = [[JXCategoryDotView alloc] initWithFrame:CGRectMake((KScreenWidth - 284.0f)/ 2.0f, NavBarHeight, 284.0f, 44.0f)];
  27. categoryView.backgroundColor = LCBkgColor;
  28. categoryView.titles = self.titles;
  29. categoryView.delegate = self;
  30. categoryView.titleSelectedColor = [UIColor whiteColor];
  31. categoryView.titleColor = HexColorFromRGB(0x9F9DA5);
  32. categoryView.titleColorGradientEnabled = YES;
  33. categoryView.titleFont = LCFont(14.0f);
  34. categoryView.titleSelectedFont = LCBoldFont(14.0f);
  35. categoryView.cellSpacing = 28.0f;
  36. // categoryView.cellWidth = 64.0f;
  37. categoryView.averageCellSpacingEnabled = YES;
  38. // categoryView.averageCellSpacingEnabled = NO;
  39. [self.view addSubview:categoryView];
  40. self.youpaipcategoryView = categoryView;
  41. // _dotStates = @[@NO, @YES,@YES,@YES].mutableCopy;
  42. // categoryView.dotStates = _dotStates;
  43. categoryView.dotSize = CGSizeMake(4, 4);
  44. categoryView.dotColor = LCRedColor;
  45. JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
  46. lineView.verticalMargin = 4.0f;
  47. lineView.indicatorHeight = 2.0f;
  48. lineView.indicatorWidth = 12.0f;
  49. lineView.indicatorColor = HexColorFromRGB(0xF4003F);
  50. lineView.indicatorCornerRadius = 1.0f;
  51. categoryView.indicators = @[lineView];
  52. JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self];
  53. pagerView.frame = CGRectMake(0.0f, NavBarHeight + 44.0f, KScreenWidth, KScreenHeight - (NavBarHeight + 44.0f));
  54. pagerView.listCellBackgroundColor = LCBkgColor;
  55. [self.view addSubview:pagerView];
  56. self.youpaippagerView = pagerView;
  57. categoryView.listContainer = pagerView;
  58. }
  59. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
  60. return self.titles.count;
  61. }
  62. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
  63. UIViewController *vc = [[NSClassFromString(self.vcNames[index]) alloc] init];
  64. return vc;
  65. }
  66. - (NSArray <NSString *> *)titles{
  67. return @[@"头像框",@"座驾",@"气泡",@"名片卡"];
  68. }
  69. - (NSArray <NSString *> *)vcNames{
  70. return @[@"YOUPAILZAvatarDressVC",@"YOUPAILZCarDressVC",@"YOUPAILZBubbleDressVC",@"YOUPAILZCardDressVC"];
  71. }
  72. #pragma mark - JXCategoryViewDelegate
  73. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
  74. if ([self.youpaipdotStates[index] boolValue] == YES) {
  75. self.youpaipdotStates[index] = @(NO);
  76. self.youpaipcategoryView.dotStates = self.youpaipdotStates;
  77. [categoryView reloadCellAtIndex:index];
  78. }
  79. }
  80. - (void)youpaifrequestAvatarDressData{
  81. @weakify(self);
  82. [LCHttpHelper requestWithURLString:GetDressList parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  83. @strongify(self);
  84. NSDictionary* dict = (NSDictionary*)responseObject;
  85. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  86. if (code == 0) {//成功
  87. NSDictionary *data = [dict objectForKey:@"data"];
  88. YOUPAIHRDressRedModel *model = [YOUPAIHRDressRedModel mj_objectWithKeyValues:data[@"red_dot"]];
  89. self.youpaipdotStates = @[@NO,@(model.youpaipcar),@(model.youpaipbubble),@(model.youpaipcard)].mutableCopy;
  90. self.youpaipcategoryView.dotStates = self.youpaipdotStates;
  91. [self.youpaipcategoryView reloadDataWithoutListContainer];
  92. }
  93. } failure:^(NSError *error) {
  94. }];
  95. }
  96. @end