| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- //
- // HJFullTimeDetailViewController.m
- // HappyJob
- //
- // Created by Bob on 2019/3/21.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "HJFullTimeDetailViewController.h"
- #import "HJPositionDetailDataBox.h"
- #import "HJGetPositionDetailAPIManager.h"
- #import "HJJobDetailSelectiveBar.h"
- #import "HJJobDetailForwardView.h"
- #import "HJWorkplaceViewController.h"
- #import "HJTrafficViewController.h"
- #import "HJPositionDetailCompanyView.h"
- #import "HJPositionDetailCompanyInfoVC.h"//公司信息
- #import "HJFullTimeDetailHeaderView.h"
- @interface HJFullTimeDetailViewController ()
- <
- FBScrollLayoutViewDelegate,
- HJPositionDetailViewDelegate,
- HJJobDetailForwardViewDelegate,
- UIScrollViewDelegate
- >
- @property (nonatomic, strong, readwrite) HJPositionDetailView *detailView;
- @property (nonatomic, strong) HJGetPositionDetailAPIManager *detailAPIManager;
- @property (nonatomic, strong) HJPositionDetailDataBox *detailDataBox;
- @property (nonatomic, strong) HJFullTimeDetailHeaderView *headerView;
- @property (nonatomic, strong) HJJobDetailForwardView *addressView;//地址
- @property (nonatomic, strong) HJJobDetailForwardView *trafficView;//交通
- @property (nonatomic, strong) UIView *baseInfoView;//基本信息
- @property (nonatomic, strong) UIView *requireInfoView;//岗位希求
- @property (nonatomic, strong) UIView *otherInfoView;//其他福利
- @property (nonatomic, strong) HJPositionDetailCompanyView *companyInfoView;//公司详情
- @end
- @implementation HJFullTimeDetailViewController
- #pragma mark - life cycle
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self name:HJLoginRefreshNotification object:nil];
- }
- - (void)viewDidLoad {
-
- [super viewDidLoad];
- self.title = self.detailView.title;
-
- [self subViewsMakeConstraints];
-
- self.detailAPIManager.positionID = self.detailView.positionID;
- self.detailAPIManager.positionType = self.detailView.positionType;
- [self.detailAPIManager start];
-
- //添加登录刷新通知
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginRefresh:) name:HJLoginRefreshNotification object:nil];
- }
- - (void)subViewsMakeConstraints {
-
- if (self.selfPublish)
- {
- [self hj_setupGradientColorNavBar];
- self.detailView.customerServiceBtn.hidden = YES;
- }
- else
- {
- [self hj_setupNavBar];
- }
-
- [self.view addSubview:self.detailView];
- [self.detailView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.left.right.equalTo(self.view);
- if (self.selfPublish)
- {
- make.bottom.equalTo(self.view).offset(0);
- }
- else
- {
- make.bottom.equalTo(self.mas_bottomLayoutGuide).offset(0);
- }
- }];
- }
- #pragma mark - event response 通知
- - (void)loginRefresh:(NSNotification *)notification {
-
- [self.detailAPIManager start];
- }
- #pragma mark - FBScrollLayoutViewDelegate
- - (void)subviewsMakeConstraintsInScrollLayoutView:(FBScrollLayoutView *)scrollLayoutView contentView:(UIView *)contentView {
-
- [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(contentView).offset(10);
- make.left.right.equalTo(contentView);
- }];
-
- if ([contentView.subviews indexOfObject:self.addressView] != NSNotFound)
- {
- [self.addressView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.headerView.mas_bottom).offset(0);
- make.left.right.equalTo(contentView);
- make.height.mas_equalTo(75);
- }];
- [self.baseInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.addressView.mas_bottom).with.offset(10);
- make.left.right.equalTo(contentView);
- }];
- }
- else
- {
- [self.baseInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.headerView.mas_bottom).with.offset(10);
- make.left.right.equalTo(contentView);
- }];
- }
- [self.requireInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.baseInfoView.mas_bottom).with.offset(10);
- make.left.right.equalTo(contentView);
- }];
- [self.otherInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.requireInfoView.mas_bottom).with.offset(10);
- make.left.right.equalTo(contentView);
- }];
-
- if (self.selfPublish)
- {
- [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.otherInfoView.mas_bottom);
- }];
- }
- else
- {
- if ([contentView.subviews indexOfObject:self.trafficView] != NSNotFound)
- {
- [self.trafficView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.otherInfoView.mas_bottom).offset(1);
- make.left.right.equalTo(contentView);
- make.height.mas_equalTo(65);
- }];
-
- [self.companyInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.trafficView.mas_bottom).with.offset(10);
- make.left.right.equalTo(contentView);
- }];
- }
- else
- {
- [self.companyInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.otherInfoView.mas_bottom).with.offset(10);
- make.left.right.equalTo(contentView);
- }];
- }
-
- // 这个一定要加,这样就可以确定内容的整体高度,UIScrollView就可以根据这个设置contentSize
- [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.companyInfoView.mas_bottom);
- }];
- }
- }
- - (void)subviewsMakeConstraintsInScrollLayoutView:(FBScrollLayoutView *)scrollLayoutView footerView:(UIView *)footerView {
-
- if (self.selfPublish)
- {
- [footerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(0.1);
- }];
- }
- else
- {
- [self.detailView.favoriteButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(footerView).with.insets(UIEdgeInsetsMake(9, 15, 9, HJHorizontalScale(250)));
- make.height.mas_equalTo(44);
- }];
- [self.detailView.applyButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(footerView).with.insets(UIEdgeInsetsMake(9, HJHorizontalScale(135), 9, 15));
- }];
- }
- }
- #pragma mark - HJJobDetailForwardViewDelegate
- - (void)jobDetailForwardViewClicked:(HJJobDetailForwardView *)forwardView {
-
- if (forwardView == self.addressView)
- {//地址
- HJWorkplaceViewController *vc = [[HJWorkplaceViewController alloc] init];
- vc.dataBox = self.detailDataBox;
- [self.navigationController pushViewController:vc animated:YES];
- }
- if (forwardView == self.trafficView)
- {//交通
- HJTrafficViewController *vc = [[HJTrafficViewController alloc] init];
- vc.dataBox = self.detailDataBox;
- [self.navigationController pushViewController:vc animated:YES];
- }
- }
- #pragma mark - HJPositionDetailViewDelegate
- - (void)positionDetailView:(HJPositionDetailView *)detailView configData:(NSDictionary *)data {
-
- //发送积分任务通知(我的积分页面-->浏览岗位数量)
- [[NSNotificationCenter defaultCenter] postNotificationName:HJIntegralTaskNotification object:nil];
- if ([data[kHJDetailPositionIsShare] intValue] == 1)
- {
- //设置导航栏按钮
- if (!self.selfPublish)
- {//是否可以分享
- [self fb_setupNavBarRightButtonItems:@[self.detailView.shareButton]];
- }
- }
-
- [self.headerView configurationFullTimeDetailHeaderViewData:data];
- self.baseInfoView = data[kHJPositionKeyBaseInfo];
- self.requireInfoView = data[kHJPositionKeyRequireInfo];
- self.otherInfoView = data[kHJPositionKeyOtherInfo];
- self.companyInfoView = data[kHJPositionKeyCompanyNameInfo];
- NSDictionary *trafficDict = data[kHJPositionKeyTraffic];
- if (trafficDict)
- {
- self.trafficView.titleLabel.text = trafficDict[kHJPositionKeyInnerKey];
- [detailView.scrollLayoutView.contentView addSubview:self.trafficView];
- }
-
- if (data[kHJPositionKeyAddress])
- {
- [detailView.scrollLayoutView.contentView addSubview:self.addressView];
- NSArray *addressArray = data[kHJPositionKeyAddress][kHJPositionKeyInnerValue];
- self.addressView.titleLabel.text = [NSString stringWithFormat:@"%@",addressArray[0][@"kHJWorkplaceKeyAddress"]];
-
- if (addressArray.count <= 1)
- {//如果地址数量为1个的时候隐藏地址数量和分割线同时titleLabel的布局修改
- self.addressView.allLabel.hidden = YES;
- self.addressView.lineView.hidden = YES;
-
- [self.addressView.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.addressView.imageView.mas_right).offset(20);
- make.right.equalTo(self.addressView.mas_right).offset(-10);
- make.top.equalTo(self.addressView.mas_top).offset(15);
- }];
- }
- else
- {
- self.addressView.allLabel.hidden = NO;
- self.addressView.lineView.hidden = NO;
- self.addressView.allLabel.text = [NSString stringWithFormat:@"全部(%@)",@(addressArray.count)];
- }
- self.addressView.citylabel.text = [NSString stringWithFormat:@"%@",addressArray[0][@"kHJWorkplaceKeyArea"]];
- }
-
- [detailView.scrollLayoutView.contentView addSubview:self.headerView];
- [detailView.scrollLayoutView.contentView addSubview:self.baseInfoView];
- [detailView.scrollLayoutView.contentView addSubview:self.requireInfoView];
- [detailView.scrollLayoutView.contentView addSubview:self.otherInfoView];
-
- if (!self.selfPublish)
- {
- [detailView.scrollLayoutView.contentView addSubview:self.companyInfoView];
- [detailView.scrollLayoutView.footerView addSubview:self.detailView.applyButton];
- [detailView.scrollLayoutView.footerView addSubview:self.detailView.favoriteButton];
- }
- [detailView.scrollLayoutView makeConstraints];
-
- __weak typeof(self) weakSelf = self;
- self.companyInfoView.IntroductionButtonBlock = ^{
-
- HJPositionDetailCompanyInfoVC *vc = [[HJPositionDetailCompanyInfoVC alloc]init];
- vc.infoArray = data[kHJPositionKeyCompanyInfo];
- [weakSelf.navigationController pushViewController:vc animated:YES];
- };
-
- }
- #pragma mark - event response
- #pragma mark - private methods
- #pragma mark - getters and setters
- - (HJPositionDetailDataBox *)detailDataBox {
-
- if (_detailDataBox == nil)
- {
- _detailDataBox = [[HJPositionDetailDataBox alloc] init];
- }
- return _detailDataBox;
- }
- - (HJGetPositionDetailAPIManager *)detailAPIManager {
-
- if (_detailAPIManager == nil)
- {
- _detailAPIManager = [[HJGetPositionDetailAPIManager alloc] init];
- _detailAPIManager.APIManagerDelegate = self.detailView;
- _detailAPIManager.APIManagerInterceptor = self.detailView;
- }
- return _detailAPIManager;
- }
- - (HJPositionDetailView *)detailView {
-
- if (_detailView == nil)
- {
- _detailView = [[HJPositionDetailView alloc] init];
- _detailView.delegate = self;
- _detailView.scrollLayoutView.delegate = self;
- _detailView.APIManager = self.detailAPIManager;
- _detailView.dataBox = self.detailDataBox;
- _detailView.scrollLayoutView.scrollView.delegate = self;
- _detailView.scrollLayoutView.contentView.backgroundColor = COLOR_F5F5F5;
- }
- return _detailView;
- }
- - (HJFullTimeDetailHeaderView *)headerView {
-
- if (_headerView == nil)
- {
- _headerView = [[HJFullTimeDetailHeaderView alloc]init];
- }
- return _headerView;
- }
- - (HJJobDetailForwardView *)addressView {
-
- if (_addressView == nil)
- {
- _addressView = [[HJJobDetailForwardView alloc] initWithTitle:@"" andType:HJDetailForwardStyleStyleAddress];
- _addressView.backgroundColor = [UIColor whiteColor];
- _addressView.imageView.image = [UIImage imageNamed:@"positiondetail_address"];
- _addressView.delegate = self;
- }
- return _addressView;
- }
- - (HJJobDetailForwardView *)trafficView {
-
- if (_trafficView == nil)
- {
- _trafficView = [[HJJobDetailForwardView alloc] initWithTitle:@"查看厂车路线图 >>" andType:HJDetailForwardStyletraffic];
- _trafficView.imageView.image = [UIImage imageNamed:@"positiondetail_buss"];
- _trafficView.delegate = self;
- _trafficView.backgroundColor = [UIColor whiteColor];
- }
- return _trafficView;
- }
- @end
|