XYCertificationSkillsMainViewController.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // XYCertificationSkillsMainViewController.m
  3. // Starbuds
  4. //
  5. // Created by 翟玉磊 on 2020/10/28.
  6. // Copyright © 2020 翟玉磊. All rights reserved.
  7. //
  8. #import "XYCertificationSkillsMainViewController.h"
  9. #import "XYVisitorsMenuView.h"
  10. #import "XYCertificationSkillsListCollectionViewController.h"
  11. #import "XYFamilyAPIManager.h"
  12. #import "XYFamilyDetailsViewController.h"
  13. #import "XYSkillCertificationApplyViewController.h"
  14. @interface XYCertificationSkillsMainViewController ()
  15. @property (nonatomic, readwrite, strong) XYVisitorsMenuView *menuView;
  16. @property (nonatomic, readwrite, strong) UIScrollView *scrollView;
  17. @end
  18. @implementation XYCertificationSkillsMainViewController
  19. /// 重写init方法,配置你想要的属性
  20. - (instancetype)init
  21. {
  22. self = [super init];
  23. if (self) {
  24. self.prefersNavigationBarBottomLineHidden = YES;
  25. self.interactivePopDisabled = YES;
  26. }
  27. return self;
  28. }
  29. - (void)viewDidLoad {
  30. [super viewDidLoad];
  31. /// 设置
  32. [self _setup];
  33. /// 设置导航栏
  34. [self _setupNavigationItem];
  35. /// 设置子控件
  36. [self _setupSubViews];
  37. /// 布局子空间
  38. [self _makeSubViewsConstraints];
  39. [self removeControllerWithClass:XYSkillCertificationApplyViewController.class];
  40. }
  41. - (void)viewWillAppear:(BOOL)animated {
  42. [super viewWillAppear:animated];
  43. [self requestRemoteData];
  44. }
  45. #pragma mark — Override
  46. - (void)bindViewModel {
  47. }
  48. - (void)requestRemoteData {
  49. // 获取我的家族
  50. [[XYFamilyAPIManager new] getFamilySuccessHandler:^(ZYLResponseModel *responseModel) {
  51. NSString *familyId = responseModel.data[@"familyId"];
  52. // 申请签约状态 1:通过 0:待审核 2:拒绝 -1:未提交
  53. NSInteger lastAuditStatus = [responseModel.data[@"lastAuditStatus"] integerValue];
  54. if (responseModel.data[@"lastAuditStatus"] == nil) {
  55. lastAuditStatus = -1;
  56. }
  57. // 申请状态 0入会 1退会
  58. NSInteger lastApplyType = [responseModel.data[@"lastApplyType"] integerValue];
  59. if (lastApplyType == 1 && lastAuditStatus == 1) {
  60. self.navigationItem.rightBarButtonItem = nil;
  61. return;
  62. }
  63. // 有家族id且已通过审核才显示家族按钮
  64. if (StringIsNotEmpty(familyId)) {
  65. // 有家族时显示家族按钮
  66. self.navigationItem.rightBarButtonItem = [UIBarButtonItem systemItemWithTitle:@"家族" titleColor:Color_TextFont imageName:@"" target:self selector:@selector(rightBarButtonItemAction:) textType:YES];
  67. }else {
  68. self.navigationItem.rightBarButtonItem = nil;
  69. }
  70. } failureHandler:^(ZYLNetworkError *error) {
  71. }];
  72. }
  73. #pragma mark - 事件处理Or辅助方法
  74. - (void)rightBarButtonItemAction:(id)sender {
  75. [self.navigationController pushViewController:XYFamilyDetailsViewController.new animated:YES];
  76. }
  77. #pragma mark - 初始化
  78. - (void)_setup{
  79. self.title = kLocalizedString(@"大神认证");
  80. }
  81. #pragma mark - 设置导航栏
  82. - (void)_setupNavigationItem{
  83. }
  84. #pragma mark - 设置子控件
  85. - (void)_setupSubViews{
  86. [self.view addSubview:self.menuView];
  87. [self.view addSubview:self.scrollView];
  88. XYCertificationSkillsListCollectionViewController *authVc = [XYCertificationSkillsListCollectionViewController new];
  89. authVc.certificationSkillsType = CertificationSkillsTypeAuth;
  90. [self addChildViewController:authVc];
  91. [self.scrollView addSubview:authVc.view];
  92. authVc.view.frame = CGRectMake(0, 0, self.scrollView.f_width, self.scrollView.f_heigh);
  93. XYCertificationSkillsListCollectionViewController *submitVc = [XYCertificationSkillsListCollectionViewController new];
  94. submitVc.certificationSkillsType = CertificationSkillsTypeSubmit;
  95. [self addChildViewController:submitVc];
  96. [self.scrollView addSubview:submitVc.view];
  97. submitVc.view.frame = CGRectMake(self.scrollView.f_width, 0, self.scrollView.f_width, self.scrollView.f_heigh);
  98. WeakSelf
  99. // 选中回调
  100. [self.menuView setVisitorsMenuViewActionBlock:^(NSInteger index) {
  101. [weakSelf.scrollView setContentOffset:CGPointMake(index * SCREEN_WIDTH, 0) animated:YES];
  102. }];
  103. }
  104. #pragma mark - 布局子控件
  105. - (void)_makeSubViewsConstraints{
  106. }
  107. #pragma mark - Setter & Getter
  108. - (XYVisitorsMenuView *)menuView {
  109. if (!_menuView) {
  110. _menuView = [[XYVisitorsMenuView alloc] initWithFrame:CGRectMake(0, NAVGATION_HEIGHT, SCREEN_WIDTH, 40.0f)];
  111. _menuView.leftTitle = kLocalizedString(@"已认证");
  112. _menuView.rightTitle = kLocalizedString(@"认证中");
  113. }
  114. return _menuView;
  115. }
  116. - (UIScrollView *)scrollView {
  117. if (!_scrollView) {
  118. _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, self.menuView.f_top, SCREEN_WIDTH, SCREEN_HEIGHT - self.menuView.f_top)];
  119. _scrollView.backgroundColor = Color_Clear;
  120. _scrollView.contentSize = CGSizeMake(SCREEN_WIDTH * 2, 0);
  121. _scrollView.scrollEnabled = NO;
  122. _scrollView.bounces = NO;
  123. }
  124. return _scrollView;
  125. }
  126. @end