123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- //
- // XYCertificationSkillsMainViewController.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/10/28.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYCertificationSkillsMainViewController.h"
- #import "XYVisitorsMenuView.h"
- #import "XYCertificationSkillsListCollectionViewController.h"
- #import "XYFamilyAPIManager.h"
- #import "XYFamilyDetailsViewController.h"
- #import "XYSkillCertificationApplyViewController.h"
- @interface XYCertificationSkillsMainViewController ()
- @property (nonatomic, readwrite, strong) XYVisitorsMenuView *menuView;
- @property (nonatomic, readwrite, strong) UIScrollView *scrollView;
- @end
- @implementation XYCertificationSkillsMainViewController
- /// 重写init方法,配置你想要的属性
- - (instancetype)init
- {
- self = [super init];
- if (self) {
- self.prefersNavigationBarBottomLineHidden = YES;
- self.interactivePopDisabled = YES;
- }
- return self;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- /// 设置
- [self _setup];
-
- /// 设置导航栏
- [self _setupNavigationItem];
-
- /// 设置子控件
- [self _setupSubViews];
-
- /// 布局子空间
- [self _makeSubViewsConstraints];
-
- [self removeControllerWithClass:XYSkillCertificationApplyViewController.class];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
-
- [self requestRemoteData];
- }
- #pragma mark — Override
- - (void)bindViewModel {
-
- }
- - (void)requestRemoteData {
- // 获取我的家族
- [[XYFamilyAPIManager new] getFamilySuccessHandler:^(ZYLResponseModel *responseModel) {
- NSString *familyId = responseModel.data[@"familyId"];
- // 申请签约状态 1:通过 0:待审核 2:拒绝 -1:未提交
- NSInteger lastAuditStatus = [responseModel.data[@"lastAuditStatus"] integerValue];
- if (responseModel.data[@"lastAuditStatus"] == nil) {
- lastAuditStatus = -1;
- }
- // 申请状态 0入会 1退会
- NSInteger lastApplyType = [responseModel.data[@"lastApplyType"] integerValue];
- if (lastApplyType == 1 && lastAuditStatus == 1) {
- self.navigationItem.rightBarButtonItem = nil;
- return;
- }
- // 有家族id且已通过审核才显示家族按钮
- if (StringIsNotEmpty(familyId)) {
- // 有家族时显示家族按钮
- self.navigationItem.rightBarButtonItem = [UIBarButtonItem systemItemWithTitle:@"家族" titleColor:Color_TextFont imageName:@"" target:self selector:@selector(rightBarButtonItemAction:) textType:YES];
- }else {
- self.navigationItem.rightBarButtonItem = nil;
- }
- } failureHandler:^(ZYLNetworkError *error) {
-
- }];
- }
- #pragma mark - 事件处理Or辅助方法
- - (void)rightBarButtonItemAction:(id)sender {
- [self.navigationController pushViewController:XYFamilyDetailsViewController.new animated:YES];
- }
- #pragma mark - 初始化
- - (void)_setup{
- self.title = kLocalizedString(@"大神认证");
- }
- #pragma mark - 设置导航栏
- - (void)_setupNavigationItem{
-
- }
- #pragma mark - 设置子控件
- - (void)_setupSubViews{
- [self.view addSubview:self.menuView];
- [self.view addSubview:self.scrollView];
-
- XYCertificationSkillsListCollectionViewController *authVc = [XYCertificationSkillsListCollectionViewController new];
- authVc.certificationSkillsType = CertificationSkillsTypeAuth;
- [self addChildViewController:authVc];
- [self.scrollView addSubview:authVc.view];
- authVc.view.frame = CGRectMake(0, 0, self.scrollView.f_width, self.scrollView.f_heigh);
-
- XYCertificationSkillsListCollectionViewController *submitVc = [XYCertificationSkillsListCollectionViewController new];
- submitVc.certificationSkillsType = CertificationSkillsTypeSubmit;
- [self addChildViewController:submitVc];
- [self.scrollView addSubview:submitVc.view];
- submitVc.view.frame = CGRectMake(self.scrollView.f_width, 0, self.scrollView.f_width, self.scrollView.f_heigh);
-
- WeakSelf
- // 选中回调
- [self.menuView setVisitorsMenuViewActionBlock:^(NSInteger index) {
- [weakSelf.scrollView setContentOffset:CGPointMake(index * SCREEN_WIDTH, 0) animated:YES];
- }];
- }
- #pragma mark - 布局子控件
- - (void)_makeSubViewsConstraints{
-
- }
- #pragma mark - Setter & Getter
- - (XYVisitorsMenuView *)menuView {
- if (!_menuView) {
- _menuView = [[XYVisitorsMenuView alloc] initWithFrame:CGRectMake(0, NAVGATION_HEIGHT, SCREEN_WIDTH, 40.0f)];
- _menuView.leftTitle = kLocalizedString(@"已认证");
- _menuView.rightTitle = kLocalizedString(@"认证中");
- }
- return _menuView;
- }
- - (UIScrollView *)scrollView {
- if (!_scrollView) {
- _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, self.menuView.f_top, SCREEN_WIDTH, SCREEN_HEIGHT - self.menuView.f_top)];
- _scrollView.backgroundColor = Color_Clear;
- _scrollView.contentSize = CGSizeMake(SCREEN_WIDTH * 2, 0);
- _scrollView.scrollEnabled = NO;
- _scrollView.bounces = NO;
- }
- return _scrollView;
- }
- @end
|