211 lines
7.9 KiB
Mathematica
211 lines
7.9 KiB
Mathematica
|
|
//
|
|||
|
|
// KBPayMainVC.m
|
|||
|
|
// keyBoard
|
|||
|
|
//
|
|||
|
|
// Created by Mac on 2026/2/3.
|
|||
|
|
//
|
|||
|
|
|
|||
|
|
#import "KBPayMainVC.h"
|
|||
|
|
#import "JXPagerView.h"
|
|||
|
|
#import "KBShopHeadView.h"
|
|||
|
|
#import <JXCategoryView/JXCategoryView.h>
|
|||
|
|
#import "KBCategoryTitleView.h"
|
|||
|
|
#import <JXPagingView/JXPagerView.h>
|
|||
|
|
#import <MJRefresh/MJRefresh.h>
|
|||
|
|
//#import "KBShopItemVC.h"
|
|||
|
|
#import "KBVipPay.h"
|
|||
|
|
#import "KBPaySvipVC.h"
|
|||
|
|
|
|||
|
|
|
|||
|
|
#import "KBSearchVC.h"
|
|||
|
|
#import "MySkinVC.h"
|
|||
|
|
|
|||
|
|
#import "JXPagerView.h"
|
|||
|
|
#import "PagingViewTableHeaderView.h"
|
|||
|
|
#import "JXCategoryTitleView.h"
|
|||
|
|
|
|||
|
|
static const CGFloat JXTableHeaderViewHeight = 224;
|
|||
|
|
static const CGFloat JXheightForHeaderInSection = 50;
|
|||
|
|
|
|||
|
|
@interface KBPayMainVC ()<JXCategoryViewDelegate,JXPagerViewDelegate, JXPagerMainTableViewGestureDelegate>
|
|||
|
|
@property (nonatomic, strong) JXPagerView *pagerView;
|
|||
|
|
@property (nonatomic, strong) PagingViewTableHeaderView *userHeaderView;
|
|||
|
|
@property (nonatomic, strong, readonly) JXCategoryTitleView *categoryView;
|
|||
|
|
@property (nonatomic, assign) BOOL isNeedFooter;
|
|||
|
|
@property (nonatomic, assign) BOOL isNeedHeader;
|
|||
|
|
- (JXPagerView *)preferredPagingView;
|
|||
|
|
@property (nonatomic, strong) NSArray <NSString *> *titles;
|
|||
|
|
@property (nonatomic, strong) UIView *naviBGView;
|
|||
|
|
@property (nonatomic, strong) UIButton *closeButton; // 当前选中的方案索引
|
|||
|
|
|
|||
|
|
@end
|
|||
|
|
|
|||
|
|
@implementation KBPayMainVC
|
|||
|
|
|
|||
|
|
- (void)viewDidLoad {
|
|||
|
|
[super viewDidLoad];
|
|||
|
|
|
|||
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|||
|
|
self.navigationController.navigationBar.translucent = false;
|
|||
|
|
self.edgesForExtendedLayout = UIRectEdgeNone;
|
|||
|
|
// self.kb_navView.hidden = true;
|
|||
|
|
_titles = @[@"VIP", @"SVIP"];
|
|||
|
|
|
|||
|
|
_userHeaderView = [[PagingViewTableHeaderView alloc] init];
|
|||
|
|
|
|||
|
|
_categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, JXheightForHeaderInSection)];
|
|||
|
|
self.categoryView.titles = self.titles;
|
|||
|
|
self.categoryView.backgroundColor = [UIColor whiteColor];
|
|||
|
|
self.categoryView.delegate = self;
|
|||
|
|
self.categoryView.titleSelectedColor = [UIColor colorWithRed:105/255.0 green:144/255.0 blue:239/255.0 alpha:1];
|
|||
|
|
self.categoryView.titleColor = [UIColor blackColor];
|
|||
|
|
self.categoryView.titleColorGradientEnabled = YES;
|
|||
|
|
self.categoryView.titleLabelZoomEnabled = YES;
|
|||
|
|
self.categoryView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
|||
|
|
|
|||
|
|
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
|
|||
|
|
lineView.indicatorColor = [UIColor colorWithRed:105/255.0 green:144/255.0 blue:239/255.0 alpha:1];
|
|||
|
|
lineView.indicatorWidth = 30;
|
|||
|
|
self.categoryView.indicators = @[lineView];
|
|||
|
|
|
|||
|
|
_pagerView = [self preferredPagingView];
|
|||
|
|
self.pagerView.mainTableView.gestureDelegate = self;
|
|||
|
|
[self.view addSubview:self.pagerView];
|
|||
|
|
|
|||
|
|
self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
|
|||
|
|
|
|||
|
|
//导航栏隐藏的情况,处理扣边返回,下面的代码要加上
|
|||
|
|
// [self.pagerView.listContainerView.scrollView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
|
|||
|
|
// [self.pagerView.mainTableView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
|
|||
|
|
|
|||
|
|
self.automaticallyAdjustsScrollViewInsets = NO;
|
|||
|
|
CGFloat naviHeight = KB_NAV_TOTAL_HEIGHT;
|
|||
|
|
self.pagerView.pinSectionHeaderVerticalOffset = naviHeight;
|
|||
|
|
|
|||
|
|
self.naviBGView = [[UIView alloc] init];
|
|||
|
|
self.naviBGView.alpha = 0;
|
|||
|
|
self.naviBGView.backgroundColor = [UIColor whiteColor];
|
|||
|
|
self.naviBGView.frame = CGRectMake(0, 0, self.view.bounds.size.width, naviHeight);
|
|||
|
|
[self.view addSubview:self.naviBGView];
|
|||
|
|
|
|||
|
|
UILabel *naviTitleLabel = [[UILabel alloc] init];
|
|||
|
|
naviTitleLabel.text = @"导航栏隐藏";
|
|||
|
|
naviTitleLabel.textAlignment = NSTextAlignmentCenter;
|
|||
|
|
naviTitleLabel.frame = CGRectMake(0, KB_STATUSBAR_HEIGHT, self.view.bounds.size.width, 44);
|
|||
|
|
[self.naviBGView addSubview:naviTitleLabel];
|
|||
|
|
|
|||
|
|
// UIButton *back = [UIButton buttonWithType:UIButtonTypeSystem];
|
|||
|
|
// [back setTitle:@"返回" forState:UIControlStateNormal];
|
|||
|
|
// back.frame = CGRectMake(12, KB_STATUSBAR_HEIGHT, 44, 44);
|
|||
|
|
// [back addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|||
|
|
// [self.naviBGView addSubview:back];
|
|||
|
|
|
|||
|
|
[self.view addSubview:self.closeButton];
|
|||
|
|
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|||
|
|
make.top.equalTo(self.view).offset(KB_NAV_TOTAL_HEIGHT - 30);
|
|||
|
|
make.left.equalTo(self.view).offset(15);
|
|||
|
|
make.width.height.mas_equalTo(36);
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|||
|
|
[super viewDidAppear:animated];
|
|||
|
|
|
|||
|
|
self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|||
|
|
[super viewWillDisappear:animated];
|
|||
|
|
|
|||
|
|
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (JXPagerView *)preferredPagingView {
|
|||
|
|
return [[JXPagerView alloc] initWithDelegate:self];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)viewDidLayoutSubviews {
|
|||
|
|
[super viewDidLayoutSubviews];
|
|||
|
|
|
|||
|
|
self.pagerView.frame = self.view.bounds;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#pragma mark - JXPagerViewDelegate
|
|||
|
|
|
|||
|
|
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
|||
|
|
return self.userHeaderView;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
|||
|
|
return JXTableHeaderViewHeight;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|||
|
|
return JXheightForHeaderInSection;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|||
|
|
return self.categoryView;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
|
|||
|
|
//和categoryView的item数量一致
|
|||
|
|
return self.categoryView.titles.count;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
|||
|
|
if (index == 0) {
|
|||
|
|
KBVipPay *list = [[KBVipPay alloc] init];
|
|||
|
|
return list;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
KBPaySvipVC *list = [[KBPaySvipVC alloc] init];
|
|||
|
|
|
|||
|
|
return list;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#pragma mark - JXCategoryViewDelegate
|
|||
|
|
|
|||
|
|
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
|||
|
|
self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#pragma mark - JXPagerMainTableViewGestureDelegate
|
|||
|
|
|
|||
|
|
- (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
|
|||
|
|
//禁止categoryView左右滑动的时候,上下和左右都可以滚动
|
|||
|
|
if (otherGestureRecognizer == self.categoryView.collectionView.panGestureRecognizer) {
|
|||
|
|
return NO;
|
|||
|
|
}
|
|||
|
|
return [gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]] && [otherGestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView {
|
|||
|
|
CGFloat thresholdDistance = 100;
|
|||
|
|
CGFloat percent = scrollView.contentOffset.y/thresholdDistance;
|
|||
|
|
percent = MAX(0, MIN(1, percent));
|
|||
|
|
self.naviBGView.alpha = percent;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#pragma mark - Action
|
|||
|
|
- (void)onTapClose{
|
|||
|
|
[[KBMaiPointReporter sharedReporter] reportClickWithEventName:@"click_vip_close_btn"
|
|||
|
|
pageId:@"vip_pay"
|
|||
|
|
elementId:@"close_btn"
|
|||
|
|
extra:nil
|
|||
|
|
completion:nil];
|
|||
|
|
[self.navigationController popViewControllerAnimated:true];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#pragma mark - lazy
|
|||
|
|
- (UIButton *)closeButton {
|
|||
|
|
if (!_closeButton) {
|
|||
|
|
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|||
|
|
[_closeButton setImage:[UIImage imageNamed:@"close_white2_icon"] forState:UIControlStateNormal];
|
|||
|
|
[_closeButton addTarget:self action:@selector(onTapClose) forControlEvents:UIControlEventTouchUpInside];
|
|||
|
|
}
|
|||
|
|
return _closeButton;
|
|||
|
|
}
|
|||
|
|
@end
|