| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 | 
							- //
 
- //  ASVipCenterViewController.m
 
- //  Asteria
 
- //
 
- //  Created by iOS on 2023/6/26.
 
- //
 
- #import "ASVipCenterViewController.h"
 
- #import "ASUserBaseInfoView.h"
 
- #import "ASVipCenterLineItemView.h"
 
- #import "ASVipCenterCollectCell.h"
 
- #import "ASVipCouponsViewController.h"
 
- #import "ASBirthdayTreatViewController.h"
 
- #import "ASInfomationSetController.h"
 
- @interface ASVipCenterViewController () <UICollectionViewDelegate,UICollectionViewDataSource>
 
- @property (nonatomic, strong) UIScrollView *scrollV;
 
- @property (nonatomic, strong) UIView *contentV;
 
- @property (nonatomic, strong) ASUserBaseInfoView *userInfoV;
 
- @property (nonatomic, strong) UICollectionView *collectV;
 
- @property (nonatomic, strong) UIPageControl *control;
 
- @property (nonatomic, strong) NSMutableArray <ASVipCenterLineItemView *>*bottomVArr;
 
- //@property (nonatomic, strong) NSMutableArray *bottomTitleArr;
 
- @property (nonatomic, strong) NSArray *vipImgArr;
 
- @property (nonatomic, strong) UIStackView *bottomStv;
 
- @end
 
- @implementation ASVipCenterViewController
 
- - (void)viewDidLoad {
 
-     [super viewDidLoad];
 
-     
 
-     [UIView viewAddHorColorBg:self.view colorArr:@[
 
-         (id)_E0FFF5.CGColor,
 
-         (id)Col_FFF.CGColor
 
-         ] startP:CGPointMake(0.5, 0.25) endP:CGPointMake(0.5, 1)];
 
-     
 
- //    self.bottomTitleArr = [NSMutableArray arrayWithObjects:@"EXCLUSIVE $100 COUPON", @"BIRTHDAY TREAT", nil];
 
-     self.vipImgArr = @[@"vip_bg1",@"vip_bg2",@"vip_bg3",@"vip_bg4",@"vip_bg5"];
 
-     [self loadSubVs];
 
-     [self.view bringSubviewToFront:self.customNavBar];
 
-     [self configSubVs];
 
-     [self setData];
 
-     
 
- }
 
- - (void)setData {
 
-     [self.userInfoV setData];
 
-     ASVipModel *curVipM = ASUserInfoManager.shared.curVipInfo;
 
-     ASVipModel *nexVipM = ASUserInfoManager.shared.nextVipInfo;
 
-     self.userInfoV.usefualLb.text = [NSString stringWithFormat:@"Growth Value %ld/%ld", ASUserInfoManager.shared.pointAmount.integerValue, nexVipM.exppoints.integerValue];
 
-     NSArray *arr = ASUserInfoManager.shared.vipInfoArr;
 
-     self.control.numberOfPages = arr.count > 0 ? arr.count : 0;
 
-     NSInteger curPage = curVipM.level.integerValue-1;
 
-     self.control.currentPage = curPage >= 0 ? curPage : 0;
 
- }
 
- - (void)configSubVs {
 
-     self.titleStr = @"VIP Center";
 
-     [self setNavRightSearch:^{
 
-         
 
-     }];
 
-     self.statusBgV.backgroundColor = _E0FFF5;
 
-     self.customNavBar.backgroundColor = _F0FFFA;
 
-     
 
-     
 
-     
 
- }
 
- // MARK: - loadSubVs
 
- - (void)loadSubVs {
 
-     [self.view addSubview:self.scrollV];
 
-     [self.scrollV addSubview:self.contentV];
 
-     [self.contentV addSubview:self.userInfoV];
 
-     [self.contentV addSubview:self.collectV];
 
-     [self.contentV addSubview:self.control];
 
-     self.bottomStv = [self getBottomV:ASUserInfoManager.shared.curVipInfo];
 
-     [self.contentV addSubview:self.bottomStv];
 
-     
 
-     [self.scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.customNavBar.mas_bottom);
 
-         make.leading.trailing.bottom.equalTo(self.view);
 
-     }];
 
-     
 
-     [self.contentV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.edges.equalTo(self.scrollV);
 
-         make.width.equalTo(self.view);
 
-     }];
 
-     
 
-     [self.userInfoV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.contentV).offset(30);
 
-         make.leading.equalTo(self.contentV).offset(20);
 
-         make.trailing.equalTo(self.contentV).offset(-20);
 
-     }];
 
-     
 
-     [self.collectV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.userInfoV.mas_bottom).offset(50);
 
-         make.leading.trailing.equalTo(self.contentV);
 
-         CGFloat collH = (KScreenWidth-40)/335*256;
 
-         make.height.equalTo(@(collH));
 
-     }];
 
-     
 
-     [self.control mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.height.equalTo(@10);
 
-         make.leading.equalTo(self.contentV).offset(20);
 
-         make.trailing.equalTo(self.contentV).offset(-20);
 
-         make.top.equalTo(self.collectV.mas_bottom).offset(20);
 
-     }];
 
-     
 
-     [self.bottomStv mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.control.mas_bottom).offset(20);
 
-         make.leading.trailing.equalTo(self.contentV);
 
-         make.bottom.equalTo(self.contentV.mas_bottom).offset(-80);
 
-     }];
 
-     
 
- }
 
- // MARK: - subvs
 
- - (ASUserBaseInfoView *)userInfoV {
 
-     if (!_userInfoV) {
 
-         ASUserBaseInfoView *v = [[ASUserBaseInfoView alloc] initWithFrame:CGRectZero];
 
-         v.backgroundColor = UIColor.clearColor;
 
-         v.usefualLb.font = [UIFont fontWithName:Rob_Regular size:14];
 
-         v.usefualLb.textColor = Col_666;
 
-         v.avaterV.layer.cornerRadius = 8;
 
-         v.avaterV.layer.masksToBounds = true;
 
-         _userInfoV = v;
 
-     }
 
-     return _userInfoV;
 
- }
 
- - (UIScrollView *)scrollV {
 
-     if (!_scrollV) {
 
-         UIScrollView *v = [[UIScrollView alloc] init];
 
-         v.backgroundColor = UIColor.clearColor;
 
-         v.showsVerticalScrollIndicator = false;
 
-         v.alwaysBounceVertical = true;
 
-         _scrollV = v;
 
-     }
 
-     return _scrollV;
 
- }
 
- - (UIView *)contentV {
 
-     if (!_contentV) {
 
-         UIView *v = [UIView baseV];
 
-         v.backgroundColor = UIColor.clearColor;
 
-         _contentV = v;
 
-     }
 
-     return _contentV;
 
- }
 
- - (UICollectionView *)collectV {
 
-     if (!_collectV) {
 
-         UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
 
-         layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
 
-         layout.minimumInteritemSpacing = 0;
 
-         layout.minimumLineSpacing = 0;
 
-         layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
 
-         CGFloat collH = (KScreenWidth-40)/335*256;
 
-         layout.itemSize = CGSizeMake(KScreenWidth, collH);
 
-         UICollectionView *collV = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, collH) collectionViewLayout:layout];
 
-         collV.backgroundColor = [UIColor clearColor];
 
-         collV.alwaysBounceHorizontal = true;
 
-         collV.scrollEnabled = true;
 
-         collV.pagingEnabled = true;
 
-         collV.delegate = self;
 
-         collV.dataSource = self;
 
-         collV.showsHorizontalScrollIndicator = false;
 
-         [collV registerClass:[ASVipCenterCollectCell class] forCellWithReuseIdentifier:@"ASVipCenterCollectCell"];
 
-         _collectV = collV;
 
-     }
 
-     return  _collectV;
 
- }
 
- -(UIPageControl *)control {
 
-     if (!_control) {
 
-         _control = [[UIPageControl alloc] init];
 
-         [_control setTintColor:[UIColor colorWithHexString:@"#000000"]];
 
-         [_control setPageIndicatorTintColor:[[UIColor colorWithHexString:@"#000000"] colorWithAlphaComponent:0.3] ];
 
-         [_control setCurrentPageIndicatorTintColor:[UIColor colorWithHexString:@"#000000"] ];
 
-         _control.transform = CGAffineTransformScale(_control.transform, 1.15, 1.15);
 
-         _control.userInteractionEnabled = false;
 
-     }
 
-     return  _control;
 
- }
 
- - (UIStackView *)getBottomV:(ASVipModel *)vipM {
 
-     UIStackView *stv = [UIStackView baseStackV:true];
 
-     stv.spacing = 0;
 
-     stv.distribution = UIStackViewDistributionFillEqually;
 
-     
 
-     self.bottomVArr = [NSMutableArray array];
 
-     for (int i=0; i<vipM.privilege.count; i++) {
 
-         ASVipPriSubModel *tempM = vipM.privilege[i];
 
-         NSString *title = [NSString stringWithFormat:@"%@ %@", tempM.title, tempM.desc];
 
-         ASVipCenterLineItemView *v = [[ASVipCenterLineItemView alloc] initWithFrame:CGRectZero];
 
-         [v setData:title canGoNext:true];
 
-         v.tag = 90000+i;
 
-         __weak typeof(self) weakSelf = self;
 
-         v.selectCallBack = ^{
 
-             if (vipM.level.integerValue != ASUserInfoManager.shared.curVipInfo.level.integerValue) {
 
-                 return;
 
-             }
 
-             if (tempM.type.integerValue == 1) { // 优惠券
 
-                 ASVipCouponsViewController *vc = [ASVipCouponsViewController new];
 
-                 vc.level = vipM.level;
 
-                 [self.navigationController pushViewController:vc animated:true];
 
-             } else if (tempM.type.integerValue == 2) { // 生日
 
-                 if (ASUserInfoManager.shared.birthStatus.integerValue == -1) {
 
-                     ASInfomationSetController *vc = [ASInfomationSetController new];
 
-                     [self.navigationController pushViewController:vc animated:true];
 
-                     return;
 
-                 }
 
-                 ASBirthdayTreatViewController *vc = [ASBirthdayTreatViewController new];
 
-                 vc.isBirthday = ASUserInfoManager.shared.birthStatus.integerValue == 2;
 
-                 [self.navigationController pushViewController:vc animated:true];
 
-             }
 
-         };
 
-         [self.bottomVArr addObject:v];
 
-         [stv addArrangedSubview:v];
 
-     }
 
-     return stv;
 
- }
 
- // MARK: - collectV delegate datesource
 
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
 
-     return ASUserInfoManager.shared.vipInfoArr.count;
 
- }
 
- - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
 
-     ASVipCenterCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ASVipCenterCollectCell" forIndexPath:indexPath];
 
-     NSArray *arr = ASUserInfoManager.shared.vipInfoArr;
 
-     if (arr.count <= indexPath.row) {
 
-         return cell;
 
-     }
 
-     ASVipModel *model = arr[indexPath.row];
 
-     if (model.nextExppoints != nil && model.nextExppoints.integerValue > 0) {
 
-         [cell setData:self.vipImgArr[indexPath.row%self.vipImgArr.count] desStr:[NSString stringWithFormat:@"INTEGRAL TO %@-%@", model.exppoints, model.nextExppoints]];
 
-     } else {
 
-         [cell setData:self.vipImgArr[indexPath.row%self.vipImgArr.count] desStr:[NSString stringWithFormat:@"INTEGRAL TO %ld", model.exppoints.integerValue + 1]];
 
-     }
 
-     cell.desLb.textColor = Col_000;
 
-     if (indexPath.row == arr.count-1) {
 
-         cell.desLb.textColor = _FFE797;
 
-     }
 
-     return cell;
 
- }
 
- - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
 
-     NSInteger page = (NSInteger)scrollView.contentOffset.x/SCREEN_WIDTH;
 
-     self.control.currentPage = page;
 
-     [self reSetCurrentBottom];
 
- }
 
- - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
 
-     NSInteger page = (NSInteger)scrollView.contentOffset.x/SCREEN_WIDTH;
 
-     self.control.currentPage = page;
 
-     [self reSetCurrentBottom];
 
- }
 
- - (void)reSetCurrentBottom {
 
-     NSArray *arr = ASUserInfoManager.shared.vipInfoArr;
 
-     if (arr.count <= self.control.currentPage) {
 
-         return;
 
-     }
 
-     ASVipModel *model = arr[self.control.currentPage];
 
-     if (self.bottomStv && self.bottomStv.superview != nil) {
 
-         for (UIView *item in self.bottomStv.arrangedSubviews) {
 
-             [self.bottomStv removeArrangedSubview:item];
 
-         }
 
-         [self.bottomStv removeFromSuperview];
 
-     }
 
-     self.bottomStv = [self getBottomV:model];
 
-     [self.contentV addSubview:self.bottomStv];
 
-     [self.bottomStv mas_remakeConstraints:^(MASConstraintMaker *make) {
 
-         make.top.equalTo(self.control.mas_bottom).offset(20);
 
-         make.leading.trailing.equalTo(self.contentV);
 
-         make.bottom.equalTo(self.contentV.mas_bottom).offset(-80);
 
-     }];
 
- }
 
- @end
 
 
  |