123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- //
- // YOUPAIBBBaseBackpackVC.m
- // YOUQU
- //
- // Created by Elaine on 2021/12/10.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAIBBBaseBackpackVC.h"
- #import "JXCategoryView.h"
- #import "JXPagerView.h"
- #import "YOUPAILZBackpackVC.h"
- #import "YOUPAILZBackPackVipVC.h"
- #import "JXCategoryDotView.h"
- #define LZCategoryViewHeight 44.0f
- #define LZCategoryViewItemWidth 34.0f
- @interface YOUPAIBBBaseBackpackVC ()<JXCategoryViewDelegate,JXPagerViewDelegate,JXCategoryListContainerViewDelegate>
- @property (nonatomic, weak) JXCategoryListContainerView *youpaippagerView;
- //@property (nonatomic, strong) JXCategoryTitleView *categoryView;
- @property (strong, nonatomic) NSArray *youpaiptitlesArr;
- @property (nonatomic, strong) JXCategoryDotView *youpaipcategoryView;
- @property (nonatomic, strong) NSMutableArray *youpaipdotStates;
- @end
- @implementation YOUPAIBBBaseBackpackVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.title = @"我的背包";
- self.youpaiptitlesArr = @[@"贵族体验卡"];//优惠券
- [self youpaifsetupUI];
- [self youpaifrequestAvatarDressData];
- }
- -(void)youpaifsetupUI{
-
- JXCategoryDotView *categoryView = [[JXCategoryDotView alloc] init];
- [self.view addSubview:categoryView];
- [categoryView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(NavBarHeight);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.height.mas_equalTo(LZCategoryViewHeight);
- }];
- categoryView.backgroundColor = LCWhiteColor;
- categoryView.titles = self.youpaiptitlesArr;
- categoryView.delegate = self;
- categoryView.titleSelectedColor = LZ273145Color;
- categoryView.titleColor = LZ273145Color;
- categoryView.titleColorGradientEnabled = YES;
- categoryView.titleFont = LCBoldFont(14.0f);
- categoryView.titleSelectedFont = LCBoldFont(14.0f);
- categoryView.cellWidth = 100;
- categoryView.cellSpacing = 0.0f;
- categoryView.averageCellSpacingEnabled = YES;
- _youpaipdotStates = @[@YES, @YES].mutableCopy;
- categoryView.dotStates = _youpaipdotStates;
- self.youpaipcategoryView = categoryView;
- categoryView.dotSize = CGSizeMake(4, 4);
- categoryView.dotColor = LCRedColor;
- // self.myCategoryView.dotStates = self.dotStates;
- // [self.myCategoryView reloadDataWithoutListContainer];
- JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
- lineView.verticalMargin = 4.0f;
- lineView.indicatorHeight = 2.5f;
- lineView.indicatorWidth = 8;
- lineView.layer.cornerRadius = 1.25;
- lineView.layer.masksToBounds = YES;
- [lineView.layer addSublayer:[LCTools getGradientLayerWithSize:CGSizeMake(lineView.indicatorWidth, lineView.indicatorHeight) twoColors:@[HexColorFromRGB(0x7C69FE),HexColorFromRGB(0x7C69FE)] gradientType:GradientLeftToRight]];
- categoryView.indicators = @[lineView];
-
- JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self];
- pagerView.listCellBackgroundColor = LCWhiteColor;
-
- [self.view addSubview:pagerView];
- [pagerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(categoryView.mas_bottom).offset(30);
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.bottom.mas_equalTo(-SafeHeight);
- }];
- self.youpaippagerView = pagerView;
-
- self.youpaipcategoryView.listContainer = self.youpaippagerView;
-
- }
- // 返回列表的数量
- - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
- return self.youpaiptitlesArr.count;
- }
- // 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
- - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
- // noble_experience_card 贵族体验卡 video_coupon 视频优惠券
- YOUPAILZBackPackVipVC *vc = [YOUPAILZBackPackVipVC new];
- vc.youpaiptype = @"noble_experience_card";
- return vc;
- }
- #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:GetPackageDot 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"];
- NSDictionary *redDic = data[@"red_dot"];
- self.youpaipdotStates = @[@NO,redDic[@"noble_experience_card"]].mutableCopy;
- self.youpaipcategoryView.dotStates = self.youpaipdotStates;
- [self.youpaipcategoryView reloadDataWithoutListContainer];
-
- }
- } failure:^(NSError *error) {
-
- }];
- }
- @end
|