| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- //
- // BHomeViewController.m
- // HappyJob
- //
- // Created by 张晓光 on 2019/7/1.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "BHomeViewController.h"
- #import "BHomeListCell.h"
- #import "BHomeSearchView.h"
- #import "BHomeNoCertificationView.h"//认证结果
- #import "BHomeResumeDetailViewController.h"//简历详情
- #import "BHomeCertificationEnterpriseVC.h"//企业认证
- #import "BHomeEnterpriseAuthAPI.h"//查询企业认证结果
- #import "BHomeChangeIdentityAPI.h"//自发布切换身份
- #import "BHomeListAPI.h"//简历列表
- #import "BHomeDataBox.h"
- @interface BHomeViewController ()
- <
- UITableViewDelegate,
- UITextFieldDelegate,
- FBAPIManagerDelegate,
- FBAPIManagerInterceptor,
- UINavigationControllerDelegate,
- UIGestureRecognizerDelegate
- >
- @property (nonatomic, strong) BHomeNoCertificationView *certificationView;
- @property (nonatomic, strong) HJPageListView *tableView;
- @property (nonatomic, strong) BHomeSearchView *searchView;
- @property (nonatomic, strong) BHomeDataBox *dataBox;
- @property (nonatomic, strong) BHomeEnterpriseAuthAPI *authAPI;//查询企业认证结果
- @property (nonatomic, strong) BHomeChangeIdentityAPI *IDAPI;//自发布切换身份
- @property (nonatomic, strong) BHomeListAPI *listAPI;//简历列表
- @end
- @implementation BHomeViewController
- - (void)dealloc {
-
- [[NSNotificationCenter defaultCenter] removeObserver:self name:HJEnterpriseAuthResultNotification object:nil];
- }
- - (void)viewWillAppear:(BOOL)animated {
-
- [super viewWillAppear:animated];
-
- // [self.navigationController setNavigationBarHidden:YES animated:YES];
- self.navigationController.delegate = self;
- self.navigationController.interactivePopGestureRecognizer.delegate = self;
- }
- - (void)viewDidLoad {
-
- [super viewDidLoad];
-
- //认证成功通知回调
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshEnterpriseAuthResult:) name:HJEnterpriseAuthResultNotification object:nil];
- // 错误页面刷新事件
- [self.view.errorView.refreshButton addTarget:self action:@selector(refreshButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
- self.edgesForExtendedLayout = UIRectEdgeNone;
-
- [self.authAPI start];
- }
- #pragma mark - 导航栏的代理
- - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
- // 判断要显示的控制器是否是自己
- // BOOL isPushSelfClass = [viewController isKindOfClass:[self class]];
- [self.navigationController setNavigationBarHidden:YES animated:animated];
-
- }
- #pragma mark - event response
- /* 认证成功回调(只有提交里信息) */
- - (void)refreshEnterpriseAuthResult:(NSNotificationCenter *)noti {
-
- [self.authAPI start];
-
- }
- /* 错误页面刷新事件 */
- - (void)refreshButtonClicked:(UIButton *)btn {
-
- [self.authAPI start];
-
- }
- #pragma mark - UITextFieldDelegate
- /* 当点击键盘上的return键*/
- - (BOOL)textFieldShouldReturn:(UITextField *)textField
- {
- [self.searchView.searchTextField resignFirstResponder];
- self.listAPI.searchStr = textField.text;
- [self.listAPI start];
- return YES ;
- }
- #pragma mark - FBAPIManagerInterceptor
- - (BOOL)manager:(FBBaseAPIManager *)manager shouldStartCallAPIWithParams:(NSDictionary *)params {
-
- [self.view fb_showLoading];
- return YES;
- }
- - (void)managerShouldFinishCallAPI:(FBBaseAPIManager *)manager {
-
- [self.view fb_dismiss];
- }
- #pragma mark - FBPageableAPIManager
- - (void)managerCallAPIDidSuccess:(FBBaseAPIManager *)manager {
-
- [self.view dismissErrorView];
- if (manager == self.authAPI)
- {
- id fetchData = [manager fetchDataWithBox:self.dataBox];
- if ([[fetchData valueForKeyPath:@"data.isAuth"] boolValue] == NO)
- { //没有提交企业认证
- [self createCertificationView];
- }
- else if ([[fetchData valueForKeyPath:@"data.isAuth"] boolValue] == YES)
- { //有提交企业认证
- [self.IDAPI start];
- }
- }
- if (manager == self.IDAPI)
- {
- [manager fetchDataWithBox:self.dataBox];
- [self createTableView];
- [self.listAPI start];
- }
- if (manager == self.listAPI)
- {
- [self.tableView managerCallAPIDidSuccess:manager];
- }
- }
- - (void)managerCallAPIDidFailed:(FBBaseAPIManager *)manager {
-
- [self.view showErrorView];
- id fetchData = [manager fetchDataWithBox:self.dataBox];
- if ([fetchData isKindOfClass:[NSString class]])
- {
- [self.view fb_showFailureWithStatus:fetchData];
- }
- if (manager == self.listAPI)
- {
- [self.tableView managerCallAPIDidFailed:manager];
- }
- }
- #pragma mark - UItableView代理
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
- UIViewController *vc = [self.dataBox positionDetailViewControllerAtIndexPath:indexPath];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark - private methods
- /* 创建TableView */
- - (void)createTableView {
-
- [self.view addSubview:self.searchView];
- [self.view addSubview:self.tableView];
- __weak typeof(self) weakSelf = self;
- [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.offset(0);
- make.top.offset(0);
- make.height.mas_equalTo(STATUS_H + NAVIGATION_H);
- }];
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(weakSelf.searchView.mas_bottom).offset(0);
- make.left.bottom.right.offset(0);
- }];
-
- }
- /* 没有认证页面 */
- - (void)createCertificationView {
-
- __weak typeof(self) weakSelf = self;
- [self.view addSubview:self.certificationView];
-
- [self.certificationView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.right.offset(0);
- make.centerY.equalTo(weakSelf.view);
-
- }];
-
- _certificationView.certificationBlock = ^{
-
- BHomeCertificationEnterpriseVC *enterpriseVC = [[BHomeCertificationEnterpriseVC alloc]init];
- enterpriseVC.hidesBottomBarWhenPushed = YES;
- [weakSelf.navigationController pushViewController:enterpriseVC animated:YES];
- };
- }
- #pragma mark - event response
- - (void)searchButtonClick {
-
- [self.searchView.searchTextField resignFirstResponder];
- self.listAPI.searchStr = self.searchView.searchTextField.text;
- [self.listAPI start];
- }
- #pragma mark - setter and getter
- - (BHomeDataBox *)dataBox {
-
- if (_dataBox == nil)
- {
- _dataBox = [[BHomeDataBox alloc] init];
- }
- return _dataBox;
- }
- - (BHomeNoCertificationView *)certificationView {
-
- if (_certificationView == nil)
- {
- _certificationView = [[BHomeNoCertificationView alloc]init];
- }
- return _certificationView;
- }
- - (BHomeEnterpriseAuthAPI *)authAPI {
-
- if (_authAPI == nil)
- {
- _authAPI = [[BHomeEnterpriseAuthAPI alloc]init];
- _authAPI.APIManagerDelegate = self;
- _authAPI.APIManagerInterceptor = self;
- }
- return _authAPI;
- }
- - (BHomeChangeIdentityAPI *)IDAPI {
-
- if (_IDAPI == nil)
- {
- _IDAPI = [[BHomeChangeIdentityAPI alloc]init];
- _IDAPI.APIManagerDelegate = self;
- }
- return _IDAPI;
- }
- - (BHomeListAPI *)listAPI {
-
- if (_listAPI == nil)
- {
- _listAPI = [[BHomeListAPI alloc]init];
- _listAPI.APIManagerDelegate = self;
- _listAPI.APIManagerInterceptor = self.tableView;
- }
- return _listAPI;
- }
- - (BHomeSearchView *)searchView {
-
- if (_searchView == nil)
- {
- _searchView = [[BHomeSearchView alloc]init];
- _searchView.searchTextField.delegate = self;
- _searchView.searchTextField.placeholder = @"输入姓名或岗位等信息查找简历";
- [_searchView.cancelButton addTarget:self action:@selector(searchButtonClick) forControlEvents:UIControlEventTouchUpInside];
- }
- return _searchView;
- }
- - (HJPageListView *)tableView {
-
- if (_tableView == nil)
- {
- _tableView = [[HJPageListView alloc] init];
- _tableView.tableView.delegate = self;
- _tableView.tableView.dataSource = self.dataBox;
- _tableView.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- _tableView.APIManager = self.listAPI;
- _tableView.dataBox = self.dataBox;
- //自定义空白页
- _tableView.blankView.imageView.image = [UIImage imageNamed:@"b_home_empty"];
- NSMutableAttributedString *countAtt1 = [[NSMutableAttributedString alloc]initWithString:@"暂时还没有简历投递进来\n\n岗位信息内容填写越丰富\n越容易收到高质量的简历"];
- [countAtt1 addAttribute:NSForegroundColorAttributeName value:COLOR_BACK3 range:NSMakeRange(0, 11)];
- [countAtt1 addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0, 11)];
- _tableView.blankView.label.font = [UIFont systemFontOfSize:12];
- _tableView.blankView.label.attributedText = countAtt1;
- }
- return _tableView;
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|