123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- //
- // YOUPAILZVipVC.m
- // VQU
- //
- // Created by CY on 2021/8/20.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZVipVC.h"
- #import "YOUPAILZVipCategoryModel.h"
- #import "JXCategoryView.h"
- #import "YOUPAILZVipDetailsVC.h"
- #import "YOUPAILZVipSetterVC.h"
- @interface YOUPAILZVipVC ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
- @property (nonatomic, weak) JXCategoryListContainerView *youpaippagerView;
- @property (nonatomic, weak) JXCategoryTitleView *youpaipcategoryView;
- @property (nonatomic,strong) NSArray <YOUPAILZVipCategoryModel *> *youpaipvips;
- @property(nonatomic,strong)UIView *youpaipredView;
- @end
- @implementation YOUPAILZVipVC
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- self.navigationController.navigationBarHidden = YES;
- [self youpaifrequestVipInfo];
- }
- - (void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
- self.navigationController.navigationBarHidden = NO;
-
- }
- - (UIStatusBarStyle)preferredStatusBarStyle{
- return UIStatusBarStyleLightContent;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifchangeRedDotStatus:) name:@"changeRedDotStatus" object:nil];
- [self youpaifloadNavView];
- [self youpaifrequestVipListData];
- }
- -(void)youpaifchangeRedDotStatus:(NSNotification*)notic{
- NSLog(@"%@",notic.userInfo);
- NSDictionary *dict = notic.userInfo;
- NSString *status = [NSString stringWithFormat:@"%@",dict[@"redDot"]];
- if ([status isEqualToString:@"1"]) {
- self.youpaipredView.hidden = NO;
- }else{
- self.youpaipredView.hidden = YES;
- }
- }
- -(void)dealloc{
- [[NSNotificationCenter defaultCenter]removeObserver:self];
- }
- -(void)youpaifloadNavView{
- UIView *navView = [UIView new];
- [self.view addSubview:navView];
- [navView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(0);
- make.right.mas_equalTo(0);
- make.top.mas_equalTo(0);
- make.height.mas_equalTo(NavBarHeight);
- }];
- navView.backgroundColor = LCBkgColor;
- //返回
- UIButton *cancelBtn = [UIButton new];
- [navView addSubview:cancelBtn ];
- [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(10);
- make.top.mas_equalTo(StatusBarHeight);
- make.size.mas_equalTo(CGSizeMake(40, 40));
- }];
- [cancelBtn setImage:[UIImage imageNamed:@"vqu_images_D_cancel"] forState:UIControlStateNormal];
-
- //title
- UILabel *titleLabel = [UILabel new];
- [navView addSubview:titleLabel];
- [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(cancelBtn);
- make.centerX.mas_equalTo(0);
- }];
- titleLabel.text = @"贵族中心";
- titleLabel.font = LCBoldFont(17);
- titleLabel.textColor = [UIColor whiteColor];
- //设置
- UIButton *setBtn = [UIButton new];
- [navView addSubview:setBtn ];
- [setBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.mas_equalTo(-14);
- make.centerY.mas_equalTo(titleLabel);
- make.size.mas_equalTo(CGSizeMake(40, 20));
- }];
- [setBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [setBtn setTitle:@"设置" forState:UIControlStateNormal];
- setBtn.titleLabel.font = [UIFont systemFontOfSize:14];
- //未读红点
- UIView *redView = [UIView new];
- [navView addSubview:redView];
- self.youpaipredView = redView;
- [redView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(setBtn.mas_right).offset(0);
- make.bottom.mas_equalTo(setBtn.mas_top).offset(-4);
- make.size.mas_equalTo(CGSizeMake(4, 4));
- }];
- redView.layer.cornerRadius = 2;
- redView.layer.masksToBounds = YES;
- redView.backgroundColor = LCRedColor;
- redView.hidden = YES;
- //事件
- [cancelBtn addTarget: self action:@selector(youpaifcancelButtonClick) forControlEvents:UIControlEventTouchUpInside];
- [setBtn addTarget: self action:@selector(youpaifvipSetterClick) forControlEvents:UIControlEventTouchUpInside];
- }
- -(void)youpaifcancelButtonClick{
- [self.navigationController popViewControllerAnimated:YES];
-
- }
- - (void)youpaifinitUI{
- // self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifvipSetterClick) title:@"设置" font:LCFont15 titleColor:[UIColor whiteColor] highlightedColor:[UIColor whiteColor] titleEdgeInsets:UIEdgeInsetsZero];
-
- JXCategoryTitleView *categoryView = [[JXCategoryTitleView alloc] init];
-
- NSMutableArray <NSString *>*titles = [NSMutableArray array];
- NSInteger index = 0;
- for (YOUPAILZVipCategoryModel *model in self.youpaipvips) {
- [titles addObject:model.youpaipname];
- if([model.youpaipid isEqual:[NSString stringWithFormat:@"%@",@([LCSaveModel getUserModel].youpaipuserinfo.youpaipvip)]]){
- index = [self.youpaipvips indexOfObject:model];
- }
- }
- categoryView.backgroundColor = LCBkgColor;
- categoryView.titles = titles.copy;
- categoryView.delegate = self;
- categoryView.titleSelectedColor = HexColorFromRGB(0xFDCC88);
- categoryView.titleColor = [[UIColor whiteColor] colorWithAlphaComponent:0.65f];
- categoryView.titleColorGradientEnabled = YES;
- categoryView.titleFont = LCFont(15.0f);
- categoryView.titleSelectedFont = LCBoldFont(15.0f);
- categoryView.defaultSelectedIndex = index;
- categoryView.cellWidth = JXCategoryViewAutomaticDimension;
- categoryView.cellSpacing = ScaleSize(20.0f);
- categoryView.averageCellSpacingEnabled = YES;
- [self.view addSubview:categoryView];
- self.youpaipcategoryView = categoryView;
- [categoryView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(0.0f);
- make.top.equalTo(NavBarHeight);
- make.right.offset(-0.0f);
- make.height.offset(40.0f);
- }];
-
- JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
- lineView.verticalMargin = 4.0f;
- lineView.indicatorHeight = 2.0f;
- lineView.indicatorWidth = 8;
- lineView.indicatorColor = HexColorFromRGB(0xFDCC88);
- lineView.indicatorCornerRadius = 1.0f;
- categoryView.indicators = @[lineView];
-
- JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self];
- [pagerView setDefaultSelectedIndex:index];
- pagerView.listCellBackgroundColor = LCBkgColor;
- [self.view addSubview:pagerView];
- self.youpaippagerView = pagerView;
- categoryView.listContainer = pagerView;
- [pagerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(0.0f);
- make.right.offset(0.0f);
- make.top.equalTo(categoryView.mas_bottom);
- make.bottom.offset(0.0f);
- }];
- }
- - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
- return self.youpaipvips.count;
- }
- - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
- YOUPAILZVipDetailsVC *vc = [[YOUPAILZVipDetailsVC alloc] init];
- vc.youpaipvipId = self.youpaipvips[index].youpaipid;
- return vc;
- }
- - (void)youpaifvipSetterClick{
- YOUPAILZVipSetterVC *setterVC = [[YOUPAILZVipSetterVC alloc] init];
- [self.navigationController pushViewController:setterVC animated:YES];
- }
- - (void)youpaifrequestVipListData{
- @weakify(self);
- [LCHttpHelper requestWithURLString:VipCategoryList parameters:@{} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- self.youpaipvips = [YOUPAILZVipCategoryModel mj_objectArrayWithKeyValuesArray:dict[@"data"]];
- [self youpaifinitUI];
- }
- } failure:^(NSError *error) {
- }];
- }
- - (void)youpaifrequestVipInfo{
-
- [LCHttpHelper requestWithURLString:VipDetails parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
-
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
-
- NSString *status = dict[@"data"][@"red_dot"][@"is_watch_setting"];
- [[NSNotificationCenter defaultCenter]postNotificationName:@"changeRedDotStatus" object:nil userInfo:@{@"redDot":status}];
-
- }
- } failure:^(NSError *error) {
- }];
- }
- @end
|