HJFullTimeDetailViewController.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. //
  2. // HJFullTimeDetailViewController.m
  3. // HappyJob
  4. //
  5. // Created by Bob on 2019/3/21.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJFullTimeDetailViewController.h"
  9. #import "HJPositionDetailDataBox.h"
  10. #import "HJGetPositionDetailAPIManager.h"
  11. #import "HJJobDetailSelectiveBar.h"
  12. #import "HJJobDetailForwardView.h"
  13. #import "HJWorkplaceViewController.h"
  14. #import "HJTrafficViewController.h"
  15. #import "HJPositionDetailCompanyView.h"
  16. #import "HJPositionDetailCompanyInfoVC.h"//公司信息
  17. #import "HJFullTimeDetailHeaderView.h"
  18. @interface HJFullTimeDetailViewController ()
  19. <
  20. FBScrollLayoutViewDelegate,
  21. HJPositionDetailViewDelegate,
  22. HJJobDetailForwardViewDelegate,
  23. UIScrollViewDelegate
  24. >
  25. @property (nonatomic, strong, readwrite) HJPositionDetailView *detailView;
  26. @property (nonatomic, strong) HJGetPositionDetailAPIManager *detailAPIManager;
  27. @property (nonatomic, strong) HJPositionDetailDataBox *detailDataBox;
  28. @property (nonatomic, strong) HJFullTimeDetailHeaderView *headerView;
  29. @property (nonatomic, strong) HJJobDetailForwardView *addressView;//地址
  30. @property (nonatomic, strong) HJJobDetailForwardView *trafficView;//交通
  31. @property (nonatomic, strong) UIView *baseInfoView;//基本信息
  32. @property (nonatomic, strong) UIView *requireInfoView;//岗位希求
  33. @property (nonatomic, strong) UIView *otherInfoView;//其他福利
  34. @property (nonatomic, strong) HJPositionDetailCompanyView *companyInfoView;//公司详情
  35. @end
  36. @implementation HJFullTimeDetailViewController
  37. #pragma mark - life cycle
  38. - (void)dealloc {
  39. [[NSNotificationCenter defaultCenter] removeObserver:self name:HJLoginRefreshNotification object:nil];
  40. }
  41. - (void)viewDidLoad {
  42. [super viewDidLoad];
  43. self.title = self.detailView.title;
  44. [self subViewsMakeConstraints];
  45. self.detailAPIManager.positionID = self.detailView.positionID;
  46. self.detailAPIManager.positionType = self.detailView.positionType;
  47. [self.detailAPIManager start];
  48. //添加登录刷新通知
  49. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginRefresh:) name:HJLoginRefreshNotification object:nil];
  50. }
  51. - (void)subViewsMakeConstraints {
  52. if (self.selfPublish)
  53. {
  54. [self hj_setupGradientColorNavBar];
  55. self.detailView.customerServiceBtn.hidden = YES;
  56. }
  57. else
  58. {
  59. [self hj_setupNavBar];
  60. }
  61. [self.view addSubview:self.detailView];
  62. [self.detailView mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.top.left.right.equalTo(self.view);
  64. if (self.selfPublish)
  65. {
  66. make.bottom.equalTo(self.view).offset(0);
  67. }
  68. else
  69. {
  70. make.bottom.equalTo(self.mas_bottomLayoutGuide).offset(0);
  71. }
  72. }];
  73. }
  74. #pragma mark - event response 通知
  75. - (void)loginRefresh:(NSNotification *)notification {
  76. [self.detailAPIManager start];
  77. }
  78. #pragma mark - FBScrollLayoutViewDelegate
  79. - (void)subviewsMakeConstraintsInScrollLayoutView:(FBScrollLayoutView *)scrollLayoutView contentView:(UIView *)contentView {
  80. [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.top.equalTo(contentView).offset(10);
  82. make.left.right.equalTo(contentView);
  83. }];
  84. if ([contentView.subviews indexOfObject:self.addressView] != NSNotFound)
  85. {
  86. [self.addressView mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.top.equalTo(self.headerView.mas_bottom).offset(0);
  88. make.left.right.equalTo(contentView);
  89. make.height.mas_equalTo(75);
  90. }];
  91. [self.baseInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  92. make.top.equalTo(self.addressView.mas_bottom).with.offset(10);
  93. make.left.right.equalTo(contentView);
  94. }];
  95. }
  96. else
  97. {
  98. [self.baseInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  99. make.top.equalTo(self.headerView.mas_bottom).with.offset(10);
  100. make.left.right.equalTo(contentView);
  101. }];
  102. }
  103. [self.requireInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  104. make.top.equalTo(self.baseInfoView.mas_bottom).with.offset(10);
  105. make.left.right.equalTo(contentView);
  106. }];
  107. [self.otherInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.top.equalTo(self.requireInfoView.mas_bottom).with.offset(10);
  109. make.left.right.equalTo(contentView);
  110. }];
  111. if (self.selfPublish)
  112. {
  113. [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  114. make.bottom.equalTo(self.otherInfoView.mas_bottom);
  115. }];
  116. }
  117. else
  118. {
  119. if ([contentView.subviews indexOfObject:self.trafficView] != NSNotFound)
  120. {
  121. [self.trafficView mas_makeConstraints:^(MASConstraintMaker *make) {
  122. make.top.equalTo(self.otherInfoView.mas_bottom).offset(1);
  123. make.left.right.equalTo(contentView);
  124. make.height.mas_equalTo(65);
  125. }];
  126. [self.companyInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  127. make.top.equalTo(self.trafficView.mas_bottom).with.offset(10);
  128. make.left.right.equalTo(contentView);
  129. }];
  130. }
  131. else
  132. {
  133. [self.companyInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  134. make.top.equalTo(self.otherInfoView.mas_bottom).with.offset(10);
  135. make.left.right.equalTo(contentView);
  136. }];
  137. }
  138. // 这个一定要加,这样就可以确定内容的整体高度,UIScrollView就可以根据这个设置contentSize
  139. [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  140. make.bottom.equalTo(self.companyInfoView.mas_bottom);
  141. }];
  142. }
  143. }
  144. - (void)subviewsMakeConstraintsInScrollLayoutView:(FBScrollLayoutView *)scrollLayoutView footerView:(UIView *)footerView {
  145. if (self.selfPublish)
  146. {
  147. [footerView mas_makeConstraints:^(MASConstraintMaker *make) {
  148. make.height.mas_equalTo(0.1);
  149. }];
  150. }
  151. else
  152. {
  153. [self.detailView.favoriteButton mas_makeConstraints:^(MASConstraintMaker *make) {
  154. make.edges.equalTo(footerView).with.insets(UIEdgeInsetsMake(9, 15, 9, HJHorizontalScale(250)));
  155. make.height.mas_equalTo(44);
  156. }];
  157. [self.detailView.applyButton mas_makeConstraints:^(MASConstraintMaker *make) {
  158. make.edges.equalTo(footerView).with.insets(UIEdgeInsetsMake(9, HJHorizontalScale(135), 9, 15));
  159. }];
  160. }
  161. }
  162. #pragma mark - HJJobDetailForwardViewDelegate
  163. - (void)jobDetailForwardViewClicked:(HJJobDetailForwardView *)forwardView {
  164. if (forwardView == self.addressView)
  165. {//地址
  166. HJWorkplaceViewController *vc = [[HJWorkplaceViewController alloc] init];
  167. vc.dataBox = self.detailDataBox;
  168. [self.navigationController pushViewController:vc animated:YES];
  169. }
  170. if (forwardView == self.trafficView)
  171. {//交通
  172. HJTrafficViewController *vc = [[HJTrafficViewController alloc] init];
  173. vc.dataBox = self.detailDataBox;
  174. [self.navigationController pushViewController:vc animated:YES];
  175. }
  176. }
  177. #pragma mark - HJPositionDetailViewDelegate
  178. - (void)positionDetailView:(HJPositionDetailView *)detailView configData:(NSDictionary *)data {
  179. //发送积分任务通知(我的积分页面-->浏览岗位数量)
  180. [[NSNotificationCenter defaultCenter] postNotificationName:HJIntegralTaskNotification object:nil];
  181. if ([data[kHJDetailPositionIsShare] intValue] == 1)
  182. {
  183. //设置导航栏按钮
  184. if (!self.selfPublish)
  185. {//是否可以分享
  186. [self fb_setupNavBarRightButtonItems:@[self.detailView.shareButton]];
  187. }
  188. }
  189. [self.headerView configurationFullTimeDetailHeaderViewData:data];
  190. self.baseInfoView = data[kHJPositionKeyBaseInfo];
  191. self.requireInfoView = data[kHJPositionKeyRequireInfo];
  192. self.otherInfoView = data[kHJPositionKeyOtherInfo];
  193. self.companyInfoView = data[kHJPositionKeyCompanyNameInfo];
  194. NSDictionary *trafficDict = data[kHJPositionKeyTraffic];
  195. if (trafficDict)
  196. {
  197. self.trafficView.titleLabel.text = trafficDict[kHJPositionKeyInnerKey];
  198. [detailView.scrollLayoutView.contentView addSubview:self.trafficView];
  199. }
  200. if (data[kHJPositionKeyAddress])
  201. {
  202. [detailView.scrollLayoutView.contentView addSubview:self.addressView];
  203. NSArray *addressArray = data[kHJPositionKeyAddress][kHJPositionKeyInnerValue];
  204. self.addressView.titleLabel.text = [NSString stringWithFormat:@"%@",addressArray[0][@"kHJWorkplaceKeyAddress"]];
  205. if (addressArray.count <= 1)
  206. {//如果地址数量为1个的时候隐藏地址数量和分割线同时titleLabel的布局修改
  207. self.addressView.allLabel.hidden = YES;
  208. self.addressView.lineView.hidden = YES;
  209. [self.addressView.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
  210. make.left.equalTo(self.addressView.imageView.mas_right).offset(20);
  211. make.right.equalTo(self.addressView.mas_right).offset(-10);
  212. make.top.equalTo(self.addressView.mas_top).offset(15);
  213. }];
  214. }
  215. else
  216. {
  217. self.addressView.allLabel.hidden = NO;
  218. self.addressView.lineView.hidden = NO;
  219. self.addressView.allLabel.text = [NSString stringWithFormat:@"全部(%@)",@(addressArray.count)];
  220. }
  221. self.addressView.citylabel.text = [NSString stringWithFormat:@"%@",addressArray[0][@"kHJWorkplaceKeyArea"]];
  222. }
  223. [detailView.scrollLayoutView.contentView addSubview:self.headerView];
  224. [detailView.scrollLayoutView.contentView addSubview:self.baseInfoView];
  225. [detailView.scrollLayoutView.contentView addSubview:self.requireInfoView];
  226. [detailView.scrollLayoutView.contentView addSubview:self.otherInfoView];
  227. if (!self.selfPublish)
  228. {
  229. [detailView.scrollLayoutView.contentView addSubview:self.companyInfoView];
  230. [detailView.scrollLayoutView.footerView addSubview:self.detailView.applyButton];
  231. [detailView.scrollLayoutView.footerView addSubview:self.detailView.favoriteButton];
  232. }
  233. [detailView.scrollLayoutView makeConstraints];
  234. __weak typeof(self) weakSelf = self;
  235. self.companyInfoView.IntroductionButtonBlock = ^{
  236. HJPositionDetailCompanyInfoVC *vc = [[HJPositionDetailCompanyInfoVC alloc]init];
  237. vc.infoArray = data[kHJPositionKeyCompanyInfo];
  238. [weakSelf.navigationController pushViewController:vc animated:YES];
  239. };
  240. }
  241. #pragma mark - event response
  242. #pragma mark - private methods
  243. #pragma mark - getters and setters
  244. - (HJPositionDetailDataBox *)detailDataBox {
  245. if (_detailDataBox == nil)
  246. {
  247. _detailDataBox = [[HJPositionDetailDataBox alloc] init];
  248. }
  249. return _detailDataBox;
  250. }
  251. - (HJGetPositionDetailAPIManager *)detailAPIManager {
  252. if (_detailAPIManager == nil)
  253. {
  254. _detailAPIManager = [[HJGetPositionDetailAPIManager alloc] init];
  255. _detailAPIManager.APIManagerDelegate = self.detailView;
  256. _detailAPIManager.APIManagerInterceptor = self.detailView;
  257. }
  258. return _detailAPIManager;
  259. }
  260. - (HJPositionDetailView *)detailView {
  261. if (_detailView == nil)
  262. {
  263. _detailView = [[HJPositionDetailView alloc] init];
  264. _detailView.delegate = self;
  265. _detailView.scrollLayoutView.delegate = self;
  266. _detailView.APIManager = self.detailAPIManager;
  267. _detailView.dataBox = self.detailDataBox;
  268. _detailView.scrollLayoutView.scrollView.delegate = self;
  269. _detailView.scrollLayoutView.contentView.backgroundColor = COLOR_F5F5F5;
  270. }
  271. return _detailView;
  272. }
  273. - (HJFullTimeDetailHeaderView *)headerView {
  274. if (_headerView == nil)
  275. {
  276. _headerView = [[HJFullTimeDetailHeaderView alloc]init];
  277. }
  278. return _headerView;
  279. }
  280. - (HJJobDetailForwardView *)addressView {
  281. if (_addressView == nil)
  282. {
  283. _addressView = [[HJJobDetailForwardView alloc] initWithTitle:@"" andType:HJDetailForwardStyleStyleAddress];
  284. _addressView.backgroundColor = [UIColor whiteColor];
  285. _addressView.imageView.image = [UIImage imageNamed:@"positiondetail_address"];
  286. _addressView.delegate = self;
  287. }
  288. return _addressView;
  289. }
  290. - (HJJobDetailForwardView *)trafficView {
  291. if (_trafficView == nil)
  292. {
  293. _trafficView = [[HJJobDetailForwardView alloc] initWithTitle:@"查看厂车路线图 >>" andType:HJDetailForwardStyletraffic];
  294. _trafficView.imageView.image = [UIImage imageNamed:@"positiondetail_buss"];
  295. _trafficView.delegate = self;
  296. _trafficView.backgroundColor = [UIColor whiteColor];
  297. }
  298. return _trafficView;
  299. }
  300. @end