| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- //
- // HJPartTimeDetailViewController.m
- // HappyJob
- //
- // Created by Bob on 2019/4/3.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "HJPartTimeDetailViewController.h"
- #import "HJJobDetailForwardView.h"
- #import "HJJobDetailSelectiveBar.h"
- #import "HJWorkplaceViewController.h"
- #import "HJPositionDetailDataBox.h"
- #import "HJGetPositionDetailAPIManager.h"
- #import "HJLeftRightLabelView.h"
- #import "FBFlowLayoutView.h"
- #import "HJPositionDetailModel.h"
- #import "UIButton+HJTagButton.h"
- #import "HJPositionDetailCompanyView.h"
- #import "HJPositionDetailCompanyInfoVC.h"//公司信息
- #import "HJPartTimeDetailHeaderView.h"
- @interface HJPartTimeDetailViewController ()
- <
- HJJobDetailForwardViewDelegate,
- FBScrollLayoutViewDelegate,
- HJPositionDetailViewDelegate,
- FBFlowLayoutDelegate,
- FBFlowLayoutDataSource,
- UIScrollViewDelegate
- >
- @property (nonatomic, strong, readwrite) HJPositionDetailView *detailView;
- @property (nonatomic, strong) HJGetPositionDetailAPIManager *detailAPIManager;
- @property (nonatomic, strong) HJPositionDetailDataBox *detailDataBox;
- @property (nonatomic, strong) HJPartTimeDetailHeaderView *headerView;
- @property (nonatomic, strong) UIView *addressBgView;
- @property (nonatomic, strong) UIView *welfareBgView;
- @property (nonatomic, strong) UIView *workTimeBgView;
- @property (nonatomic, strong) HJJobDetailForwardView *addressView;
- @property (nonatomic, strong) UILabel *welfareLabel;
- @property (nonatomic, strong) FBFlowLayoutView *welfareView;
- @property (nonatomic, strong) HJLeftRightLabelView *workTimeLabel;
- @property (nonatomic, strong) UIView *baseInfoView;
- @property (nonatomic, strong) UIView *requireInfoView;
- @property (nonatomic, strong) HJPositionDetailCompanyView *companyInfoView;
- @property (nonatomic, copy) NSArray *welfareTagArray;
- @end
- @implementation HJPartTimeDetailViewController
- #pragma mark - life cycle
- - (void)dealloc {
-
- [[NSNotificationCenter defaultCenter] removeObserver:self name:HJLoginRefreshNotification object:nil];
- }
- - (void)viewWillAppear:(BOOL)animated {
-
- [super viewWillAppear:animated];
- [self hj_setupNavBar];
- }
- - (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.detailView.customerServiceBtn.hidden = YES;
- }
- [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(5);
- make.left.right.equalTo(contentView);
- }];
-
- [self.addressBgView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.headerView.mas_bottom).with.offset(0);
- make.left.right.equalTo(contentView);
- }];
- if ([self.addressBgView.subviews indexOfObject:self.addressView] != NSNotFound)
- {
- [self.addressView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.addressBgView.mas_top).offset(0);
- make.bottom.equalTo(self.addressBgView.mas_bottom).offset(0);
- make.left.right.equalTo(self.addressBgView);
- make.height.mas_equalTo(75);
- }];
- }
-
- [self.welfareBgView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.addressBgView.mas_bottom).offset(1);
- make.left.right.equalTo(contentView);
- }];
- if ([self.welfareBgView.subviews indexOfObject:self.welfareView] != NSNotFound)
- {
- [self.welfareLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.welfareBgView.mas_top).with.offset(10);
- make.left.equalTo(self.welfareBgView).with.offset(15);
- make.width.mas_equalTo(80);
- }];
- [self.welfareView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.welfareLabel);
- make.left.equalTo(self.welfareLabel.mas_right).with.offset(12);
- make.right.equalTo(self.welfareBgView).with.offset(-15);
- make.bottom.equalTo(self.welfareBgView.mas_bottom).offset(-10);
- }];
- }
-
- [self.workTimeBgView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.welfareBgView.mas_bottom).with.offset(0);
- make.left.right.equalTo(contentView);
- }];
- if ([self.workTimeBgView.subviews indexOfObject:self.workTimeLabel] != NSNotFound)
- {
- [self.workTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.top.equalTo(self.workTimeBgView.mas_top).offset(0);
- make.bottom.equalTo(self.workTimeBgView.mas_bottom).offset(0);
- make.left.right.equalTo(self.workTimeBgView);
- }];
- }
- [self.baseInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.workTimeBgView.mas_bottom).with.offset(5);
- make.left.right.equalTo(contentView);
- }];
- [self.requireInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.baseInfoView.mas_bottom).with.offset(5);
- make.left.right.equalTo(contentView);
- }];
-
- if (self.selfPublish)
- {
- // 这个一定要加,这样就可以确定内容的整体高度,UIScrollView就可以根据这个设置contentSize
- [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.requireInfoView.mas_bottom).with.offset(0);
- }];
- }
- else
- {
- [self.companyInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.requireInfoView.mas_bottom).with.offset(5);
- make.left.right.equalTo(contentView);
- }];
- [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.companyInfoView.mas_bottom).with.offset(0);
- }];
- }
- }
- - (void)subviewsMakeConstraintsInScrollLayoutView:(FBScrollLayoutView *)scrollLayoutView footerView:(UIView *)footerView {
-
- if (self.selfPublish)
- {
- [footerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.mas_equalTo(0.01);
- }];
- }
- else
- {
- [self.detailView.callButton 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 - FBFlowLayoutDelegate
- - (CGFloat)estimateWidthInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
-
- return (SCREEN_WIDTH - HJHorizontalScale(125));
- }
- - (CGFloat)subviewHorizontalSpacingInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
-
- return 6;
- }
- - (CGFloat)subviewVerticalSpacingInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
-
- return 6;
- }
- - (NSUInteger)numberInFlowLayoutView:(FBFlowLayoutView *)flowLayoutView {
- return self.welfareTagArray.count;
- }
- - (UIView *)flowLayoutView:(FBFlowLayoutView *)flowLayoutView subviewAtIndex:(NSUInteger)index {
- NSString *title = self.welfareTagArray[index];
- UIButton *tagButton = [UIButton hj_createWelfareTagButtonWithTitle:title maxSize:CGSizeMake(flowLayoutView.contentWidth, MAXFLOAT)];
- return tagButton;
- }
- #pragma mark - HJJobDetailForwardViewDelegate
- - (void)jobDetailForwardViewClicked:(HJJobDetailForwardView *)forwardView {
-
- HJWorkplaceViewController *vc = [[HJWorkplaceViewController alloc] init];
- vc.dataBox = self.detailDataBox;
- [self.navigationController pushViewController:vc animated:YES];
- }
- #pragma mark - HJPositionDetailViewDelegate
- - (void)positionDetailView:(HJPositionDetailView *)detailView configData:(NSDictionary *)data {
-
- if ([data[kHJDetailPositionIsShare] intValue] == 1)
- {
- //设置导航栏按钮
- if (!self.selfPublish)
- {
- [self fb_setupNavBarRightButtonItems:@[self.detailView.shareButton]];
- }
- }
-
- [self.headerView configurationPartTimeDetailHeaderViewData:data andCollectionButton:self.detailView.favoriteButton];
- self.baseInfoView = data[kHJPositionKeyBaseInfo];
- self.requireInfoView = data[kHJPositionKeyRequireInfo];
- self.companyInfoView = data[kHJPositionKeyCompanyNameInfo];
-
- //地址
- if (data[kHJPositionKeyAddress])
- {
- 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"]];
- [self.addressBgView addSubview:self.addressView];
-
- }
- //福利
- HJPositionDetailModel *model = data[kHJPositionKeyDetailModel];
- NSArray *welfareTagArray = [model.position getWelfareArray];
- if (welfareTagArray.count > 0)
- {
- self.welfareTagArray = welfareTagArray;
- [self.welfareBgView addSubview:self.welfareLabel];
- [self.welfareBgView addSubview:self.welfareView];
- }
-
- //工作时间
- if (model.position.workDay.length > 0)
- {
- NSDictionary *workTimeDict = @{kHJLeftLabelText: @"工作时间:", kHJRightLabelText: [NSString stringWithFormat:@"%@\n%@", model.position.workDay, model.position.workTime ? model.position.workTime:@""]};
- self.workTimeLabel = [[HJLeftRightLabelView alloc] initWithTextArray:@[workTimeDict]];
- [self.workTimeBgView addSubview:self.workTimeLabel];
- }
-
- [detailView.scrollLayoutView.contentView addSubview:self.headerView];
- [detailView.scrollLayoutView.contentView addSubview:self.addressBgView];
- [detailView.scrollLayoutView.contentView addSubview:self.welfareBgView];
- [detailView.scrollLayoutView.contentView addSubview:self.workTimeBgView];
- [detailView.scrollLayoutView.contentView addSubview:self.baseInfoView];
- [detailView.scrollLayoutView.contentView addSubview:self.requireInfoView];
-
- if (!self.selfPublish)
- {
- [detailView.scrollLayoutView.contentView addSubview:self.companyInfoView];
- [detailView.scrollLayoutView.footerView addSubview:self.detailView.applyButton];
- [detailView.scrollLayoutView.footerView addSubview:self.detailView.callButton];
- }
- [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
- - (HJPartTimeDetailHeaderView *)headerView {
-
- if (_headerView == nil)
- {
- _headerView = [[HJPartTimeDetailHeaderView alloc]init];
- }
- return _headerView;
- }
- - (UIView *)addressBgView {
-
- if (_addressBgView == nil)
- {
- _addressBgView = [[UIView alloc]init];
- _addressBgView.backgroundColor = [UIColor whiteColor];
- }
- return _addressBgView;
- }
- - (UIView *)welfareBgView {
-
- if (_welfareBgView == nil)
- {
- _welfareBgView = [[UIView alloc]init];
- _welfareBgView.backgroundColor = [UIColor whiteColor];
- }
- return _welfareBgView;
- }
- - (UIView *)workTimeBgView {
-
- if (_workTimeBgView == nil)
- {
- _workTimeBgView = [[UIView alloc]init];
- _workTimeBgView.backgroundColor = [UIColor whiteColor];
- }
- return _workTimeBgView;
- }
- - (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;
- }
- - (UILabel *)welfareLabel {
-
- if (_welfareLabel == nil)
- {
- _welfareLabel = [[UILabel alloc] init];
- _welfareLabel.text = @"岗位福利:";
- _welfareLabel.textColor = COLOR_000000;
- _welfareLabel.font = [UIFont systemFontOfSize:14];
- _welfareLabel.textAlignment = NSTextAlignmentLeft;
- }
- return _welfareLabel;
- }
- - (FBFlowLayoutView *)welfareView {
-
- if (_welfareView == nil)
- {
- _welfareView = [[FBFlowLayoutView alloc] init];
- _welfareView.delegate = self;
- _welfareView.dataSource = self;
- _welfareView.numberOfLines = 0;
- }
- return _welfareView;
- }
- - (HJJobDetailForwardView *)addressView {
-
- if (_addressView == nil)
- {
- _addressView = [[HJJobDetailForwardView alloc] init];
- _addressView.imageView.image = [UIImage imageNamed:@"positiondetail_address"];
- _addressView.delegate = self;
- _addressView.backgroundColor = [UIColor whiteColor];
- }
- return _addressView;
- }
- @end
|