| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584 |
- //
- // BPositionViewController.m
- // HappyJob
- //
- // Created by 张晓光 on 2019/7/1.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "BPositionViewController.h"
- #import "BPositionCell.h"
- #import "BHomeNoCertificationView.h"//认证结果
- #import "BHomeCertificationFailVC.h"//认证失败
- #import "BHomeCertificationingEnterpriseVC.h"//认证中
- #import "BHomeCertificationEnterpriseVC.h"//企业认证
- #import "BCheckPeopleViewController.h"//查看人员
- #import "BHomeEnterpriseAuthAPI.h"//企业认证
- #import "BHomeChangeIdentityAPI.h"
- #import "BPositionListAPI.h"//列表API
- #import "BPositionChangeIsPauseAPI.h"//暂停开启API
- #import "BPositionChangeUpdateTimeAPI.h"//刷新API
- #import "BPositionChangeIsOnStatusAPI.h"//结束下架
- #import "BReleaseJobsViewController.h"//发布职位
- #import "BPositonModel.h"
- #import "BPositionDataBox.h"
- #import "HJFullTimeDetailViewController.h"//全职详情
- #import "HJPartTimeDetailViewController.h"//兼职详情
- @interface BPositionViewController ()
- <
- UITableViewDelegate,
- FBAPIManagerDelegate,
- FBAPIManagerInterceptor,
- BPositionDataBoxDelegate,
- UINavigationControllerDelegate,
- UIGestureRecognizerDelegate
- >
- @property (nonatomic, strong) UIButton *certificationBtn;
- @property (nonatomic, strong) BHomeNoCertificationView *certificationView;
- @property (nonatomic, strong) HeaderSelectView *headerView;
- @property (nonatomic, strong) HJPageListView *tableView;
- @property (nonatomic, strong) NSIndexPath *selectIndexPath;
- @property (nonatomic, strong) BHomeEnterpriseAuthAPI *authAPI;//查询企业是否认证结果
- @property (nonatomic, strong) BHomeChangeIdentityAPI *IDAPI;//查询企业认证结果
- @property (nonatomic, strong) BPositionListAPI *listAPI;//列表API
- @property (nonatomic, strong) BPositionChangeIsPauseAPI *pauseAPI;//暂停开启api
- @property (nonatomic, strong) BPositionChangeUpdateTimeAPI *updateTimeAPI;//刷新API
- @property (nonatomic, strong) BPositionChangeIsOnStatusAPI *isOnStatus;//结束下架
- @property (nonatomic, strong) BPositonModel *model;
- @property (nonatomic, strong) BPositionDataBox *dataBox;
- @end
- @implementation BPositionViewController
- - (void)dealloc {
-
- [[NSNotificationCenter defaultCenter] removeObserver:self name:HJEnterpriseAuthResultNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:HJReleaseSuccessfulRefreshNotification object:nil];
- }
- - (void)viewWillAppear:(BOOL)animated {
-
- [super viewWillAppear:animated];
- self.navigationController.delegate = self;
- self.navigationController.interactivePopGestureRecognizer.delegate = self;
-
- }
- - (void)viewDidLoad {
-
- [super viewDidLoad];
- self.navigationItem.title = @"职位";
- [self hj_setupNavBar];
- [self.authAPI start];
- // 错误页面刷新事件
- [self.view.errorView.refreshButton addTarget:self action:@selector(refreshButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
- //认证成功通知回调
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshEnterpriseAuthResult:) name:HJEnterpriseAuthResultNotification object:nil];
-
- //发布职位通知回调
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(releaseSuccessfulRefreshNotification:) name:HJReleaseSuccessfulRefreshNotification object:nil];
-
- }
- #pragma mark - 导航栏的代理
- - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
- // 判断要显示的控制器是否是自己
- // BOOL isPushSelfClass = [viewController isKindOfClass:[self class]];
- [self.navigationController setNavigationBarHidden:NO animated:animated];
-
- }
- #pragma mark - event response
- /* 发布职位成功回调 */
- - (void)releaseSuccessfulRefreshNotification:(NSNotificationCenter *)noti {
-
- [self.listAPI start];
- }
- /* 认证成功回调 */
- - (void)refreshEnterpriseAuthResult:(NSNotificationCenter *)noti {
-
- [self.authAPI start];
- }
- /* 错误页面刷新 */
- - (void)refreshButtonClicked:(UIButton *)btn {
-
- [self.authAPI start];
- }
- /* 认证 */
- - (void)positionCertificationButtonClick:(UIButton *)btn {
-
- if ([[HJCompanyInfoModel companyInfo].authenticationStatus integerValue] == 1)
- {//认证中
- BHomeCertificationingEnterpriseVC *vc = [[BHomeCertificationingEnterpriseVC alloc]init];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- if ([[HJCompanyInfoModel companyInfo].authenticationStatus integerValue] == 2)
- {//认证失败的
- BHomeCertificationFailVC *vc = [[BHomeCertificationFailVC alloc]init];
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- #pragma mark - BPositionDataBoxDelegate
- /* 查看简历 */
- - (void)positionResume:(BPositionDataBox *)dataBox positionModel:(BPositonModel *)model {
-
- BCheckPeopleViewController *checkPeople = [[BCheckPeopleViewController alloc]init];
- checkPeople.hidesBottomBarWhenPushed = YES;
- checkPeople.positionId = model.ID;
- checkPeople.positionCategory = model.positionCategory;
- [self.navigationController pushViewController:checkPeople animated:YES];
- }
- /* 刷新 */
- - (void)positionRefresh:(BPositionDataBox *)dataBox positionModel:(BPositonModel *)model cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- self.selectIndexPath = indexPath;
- self.updateTimeAPI.ID = model.ID;
- [self.updateTimeAPI start];
- }
- /* 是否暂停 1:暂停 */
- - (void)positionStop:(BPositionDataBox *)dataBox positionModel:(BPositonModel *)model cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- //是否暂停 1:暂停
- self.selectIndexPath = indexPath;
- self.pauseAPI.ID = model.ID;
- if ([model.isPause boolValue])
- {
- self.pauseAPI.isPause = @"0";
- }
- else
- {
- self.pauseAPI.isPause = @"1";
- }
- [self.pauseAPI start];
-
- }
- /* 是否下架 */
- - (void)positionEnd:(BPositionDataBox *)dataBox positionModel:(BPositonModel *)model cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- //是否下架 0下架
- self.selectIndexPath = indexPath;
- self.isOnStatus.ID = model.ID;
- self.isOnStatus.isOn = @"0";
- [self endRecruitment];
- }
- /* 编辑 */
- - (void)positionEdit:(BPositionDataBox *)dataBox positionModel:(BPositonModel *)model {
-
- self.model = model;
- [self editPosition];
- }
- #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 - FBAPIManagerDelegate
- - (void)managerCallAPIDidSuccess:(FBBaseAPIManager *)manager {
-
- [self.view dismissErrorView];
- NSDictionary *dict = [manager fetchDataWithBox:self.dataBox];
- if (manager == self.authAPI)
- {
- if ([[dict valueForKeyPath:@"data.isAuth"] boolValue] == NO)
- { //没有提交企业认证
- [self createCertificationView];
- }
- else if ([[dict valueForKeyPath:@"data.isAuth"] boolValue] == YES)
- {//有提交企业认证
- [self autoLayOutViews];
- [self.IDAPI start];
- [self.listAPI start];
- }
- }
- if (manager == self.IDAPI)
- {
- if ([[HJCompanyInfoModel companyInfo].authenticationStatus integerValue] == 1)
- {//认证中
- [self.certificationBtn setTitle:@"您已提交企业认证,正在审核中,点击查看 >>" forState:UIControlStateNormal];
- }
- else if ([[HJCompanyInfoModel companyInfo].authenticationStatus integerValue] == 2)
- {//认证失败
- [self.certificationBtn setTitle:@"您已提交企业认证,审核未通过,点击认证 >>" forState:UIControlStateNormal];
- }
- }
- if (manager == self.listAPI)
- {
- [self.tableView managerCallAPIDidSuccess:manager];
- }
- if (manager == self.updateTimeAPI)
- {//刷新
- NSMutableDictionary *listDict = [self.dataBox.dataSource[self.selectIndexPath.row] mutableCopy];
- listDict[@"updateDate"] = [HJAppService time_timestampToString:[NSString stringWithFormat:@"%@",dict[@"data"][@"date"]] withType:kTimeStampWithSecond];
- [self.dataBox.dataSource setObject:listDict atIndexedSubscript:self.selectIndexPath.row];
- [self refreshCellForRow];
- }
- if (manager == self.pauseAPI)
- {//暂停和开启
- NSMutableDictionary *listDict = [self.dataBox.dataSource[self.selectIndexPath.row] mutableCopy];
- [listDict setValue:@(![listDict[@"isPause"] boolValue]) forKey:@"isPause"];
- [self.dataBox.dataSource setObject:listDict atIndexedSubscript:self.selectIndexPath.row];
- [self refreshCellForRow];
- }
- if (manager == self.isOnStatus)
- {//结束
- NSMutableDictionary *listDict = [self.dataBox.dataSource[self.selectIndexPath.row] mutableCopy];
- listDict[@"isOn"] = @"0";
- [self.dataBox.dataSource setObject:listDict atIndexedSubscript:self.selectIndexPath.row];
- [self refreshCellForRow];
- }
- }
- - (void)managerCallAPIDidFailed:(FBBaseAPIManager *)manager {
-
- if ([manager isKindOfClass:[BHomeEnterpriseAuthAPI class]])
- {
- [self.view showErrorView];
- }
- id fetchData = [manager fetchDataWithBox:self.dataBox];
- if ([fetchData isKindOfClass:[NSString class]])
- {
- [self.view fb_showFailureWithStatus:fetchData];
- }
- }
- #pragma mark - UITableViewDelegate
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-
- NSDictionary *dict = [self.dataBox.dataSource objectAtIndex:indexPath.row];
- BPositonModel *model = [BPositonModel yy_modelWithJSON:dict];
- if ([model.positionCategory isEqualToString:@"8"])
- {
- HJFullTimeDetailViewController *vc = [[HJFullTimeDetailViewController alloc] init];
- vc.detailView.positionID = [model.ID integerValue];
- vc.detailView.positionType = [model.positionCategory integerValue];
- vc.hidesBottomBarWhenPushed = YES;
- vc.selfPublish = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- else
- {
- HJPartTimeDetailViewController *vc = [[HJPartTimeDetailViewController alloc] init];
- vc.detailView.positionID = [model.ID integerValue];
- vc.detailView.positionType = [model.positionCategory integerValue];
- vc.hidesBottomBarWhenPushed = YES;
- vc.selfPublish = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- /* 编辑 */
- - (void)editPosition{
-
- HJConfirmPanelViewController *vc = [[HJConfirmPanelViewController alloc] init];
- vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
- self.navigationController.definesPresentationContext = NO;
- vc.titleLabel.text = @"修改岗位信息需要重新审核,\n通过后求职者才能看到该岗位哦!";
- vc.titleIcon.image = nil;
- [vc.cancelButton setTitle:@"取消" forState:UIControlStateNormal];
- [vc.confirmButton setTitle:@"确定编辑" forState:UIControlStateNormal];
- [vc.confirmButton addTarget:self
- action:@selector(editButtonClicked:)
- forControlEvents:UIControlEventTouchUpInside];
- [self presentViewController:vc animated:YES completion:nil];
-
- }
- - (void)editButtonClicked:(UIButton *)sender {
-
- [self dismissViewControllerAnimated:NO completion:^{
-
- BReleaseJobsViewController *vc = [[BReleaseJobsViewController alloc]init];
- vc.model = self.model;
- vc.hidesBottomBarWhenPushed = YES;
- [self.navigationController pushViewController:vc animated:YES];
- }];
- }
- /* 下架 */
- - (void)endRecruitment {
-
- HJConfirmPanelViewController *vc = [[HJConfirmPanelViewController alloc] init];
- vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
- vc.modalPresentationStyle = UIModalPresentationOverCurrentContext;
- self.navigationController.definesPresentationContext = NO;
- vc.titleLabel.text = @"岗位下架后不能对其进行任何操作,\n也无法查看该岗位的报名和面试信息。";
- vc.titleIcon.image = nil;
- [vc.cancelButton setTitle:@"取消" forState:UIControlStateNormal];
- [vc.confirmButton setTitle:@"确定下架" forState:UIControlStateNormal];
- [vc.confirmButton addTarget:self
- action:@selector(recruitmentButtonClicked:)
- forControlEvents:UIControlEventTouchUpInside];
- [self presentViewController:vc animated:YES completion:nil];
-
- }
- - (void)recruitmentButtonClicked:(UIButton *)sender {
-
- [self dismissViewControllerAnimated:NO completion:^{
-
- [self.isOnStatus start];
-
- }];
- }
- #pragma mark - private method
- /* 刷新 */
- - (void)refreshCellForRow {
-
- NSIndexPath *indexPath=[NSIndexPath indexPathForRow:self.selectIndexPath.row inSection:0];
- [self.tableView.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
- }
- /* 没有认证*/
- - (void)createCertificationView {
-
- __weak typeof(self) weakSelf = self;
- [self.view addSubview:self.certificationView];
- [self.certificationView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(weakSelf.view);
- make.left.right.offset(0);
- }];
-
- _certificationView.certificationBlock = ^{
-
- BHomeCertificationEnterpriseVC *enterpriseVC = [[BHomeCertificationEnterpriseVC alloc]init];
- enterpriseVC.hidesBottomBarWhenPushed = YES;
- [weakSelf.navigationController pushViewController:enterpriseVC animated:YES];
- };
-
- }
- - (void)autoLayOutViews {
-
- __weak typeof(self) weakSelf = self;
- self.view.backgroundColor = COLOR_GRAYFA;
- [self.view addSubview:self.certificationBtn];
- [self.view addSubview:self.tableView];
- [self.view addSubview:self.headerView];
- [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.right.equalTo(weakSelf.view).offset(0);
- make.top.equalTo(weakSelf.view).offset(0);
- make.height.mas_equalTo(45);
- }];
- if ([[HJCompanyInfoModel companyInfo].authenticationStatus integerValue] == 1)
- {//认证中
- [self.certificationBtn setTitle:@"您已提交企业认证,正在审核中,点击查看 >>" forState:UIControlStateNormal];
- [self.certificationBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.right.offset(0);
- make.top.equalTo(weakSelf.headerView.mas_bottom).offset(0);
- make.height.mas_equalTo(40);
- }];
- }
- else if ([[HJCompanyInfoModel companyInfo].authenticationStatus integerValue] == 2)
- {//认证失败
- [self.certificationBtn setTitle:@"您已提交企业认证,审核未通过,点击认证 >>" forState:UIControlStateNormal];
- [self.certificationBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.right.offset(0);
- make.top.equalTo(weakSelf.headerView.mas_bottom).offset(0);
- make.height.mas_equalTo(40);
- }];
- }
- else
- {
- [self.certificationBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.right.offset(0);
- make.top.equalTo(weakSelf.headerView.mas_bottom).offset(-40);
- make.height.mas_equalTo(40);
- }];
- }
- [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.offset(0);
- make.top.equalTo(weakSelf.certificationBtn.mas_bottom).offset(0);
- }];
-
- //回调
- _headerView.changeBigScrollViewBlock = ^(NSInteger index) {
- //赋初始值
- weakSelf.listAPI.isOn = @"-1";
- weakSelf.listAPI.isPause = @"-1";
- weakSelf.listAPI.endDate = @"-1";
- weakSelf.listAPI.authenticationStatus = @"-1";
- if (index == 0)
- {//全部的
- }
- if (index == 1)
- {//正在
- weakSelf.listAPI.authenticationStatus = @"3";
- }
- if (index == 2)
- {//暂停
- weakSelf.listAPI.isPause = @"1";
- }
- if (index == 3)
- {//下架
- weakSelf.listAPI.isOn = @"0";
- }
- if (index == 4)
- { //结束
- weakSelf.listAPI.endDate = @"1";
- }
- if (index == 5)
- {//全部审核
- weakSelf.listAPI.authenticationStatus = @"0";
- }
- if (index == 6)
- {//审核通过
- weakSelf.listAPI.authenticationStatus = @"1";
- }
- if (index == 7)
- {//审核驳回
- weakSelf.listAPI.authenticationStatus = @"2";
- }
- [weakSelf.listAPI start];
- };
- }
- #pragma mark - setter and getter
- - (UIButton *)certificationBtn {
-
- if (_certificationBtn == nil)
- {
- _certificationBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _certificationBtn.titleLabel.font = [UIFont systemFontOfSize:12];
- _certificationBtn.backgroundColor = [UIColor colorFromHexString:@"FFEBE3"];
- [_certificationBtn setTitleColor:[UIColor colorFromHexString:@"FF6300"] forState:UIControlStateNormal];
- [_certificationBtn addTarget:self action:@selector(positionCertificationButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _certificationBtn;
- }
- - (BPositionDataBox *)dataBox {
-
- if (_dataBox == nil)
- {
- _dataBox = [[BPositionDataBox alloc]init];
- _dataBox.delegate = self;
- }
- return _dataBox;
- }
- - (BHomeNoCertificationView *)certificationView {
-
- if (_certificationView == nil)
- {
- _certificationView = [[BHomeNoCertificationView alloc]init];
- }
- return _certificationView;
- }
- - (HeaderSelectView *)headerView {
-
- if (_headerView == nil)
- {
- _headerView = [[HeaderSelectView alloc]init];
- [_headerView showHeaderSelectViewArray:@[@"全部",@"正在招聘",@"暂停招聘",@"已下架",@"已结束",@"全部审核",@"正在审核",@"审核驳回"] andIndex:0 andShowLineView:YES andNumber:4];
- }
- return _headerView;
- }
- - (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:@"msg_blank"];
- _tableView.blankView.label.text = @"暂无数据~空空如也";
- }
- return _tableView;
- }
- - (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;
- }
- - (BPositionListAPI *)listAPI {
-
- if (_listAPI == nil)
- {
- _listAPI = [[BPositionListAPI alloc]init];
- _listAPI.APIManagerDelegate = self;
- _listAPI.APIManagerInterceptor = self.tableView;
- }
- return _listAPI;
- }
- - (BPositionChangeIsPauseAPI *)pauseAPI {
-
- if (_pauseAPI == nil)
- {
- _pauseAPI = [[BPositionChangeIsPauseAPI alloc]init];
- _pauseAPI.APIManagerDelegate = self;
- _pauseAPI.APIManagerInterceptor = self;
- }
- return _pauseAPI;
- }
- - (BPositionChangeUpdateTimeAPI *)updateTimeAPI {
-
- if (_updateTimeAPI == nil)
- {
- _updateTimeAPI = [[BPositionChangeUpdateTimeAPI alloc]init];
- _updateTimeAPI.APIManagerDelegate = self;
- _updateTimeAPI.APIManagerInterceptor = self;
- }
- return _updateTimeAPI;
- }
- - (BPositionChangeIsOnStatusAPI *)isOnStatus {
-
- if (_isOnStatus == nil)
- {
- _isOnStatus = [[BPositionChangeIsOnStatusAPI alloc]init];
- _isOnStatus.APIManagerDelegate = self;
- _isOnStatus.APIManagerInterceptor = self;
- }
- return _isOnStatus;
- }
- /*
- #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
|