| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532 |
- //
- // BPositionCell.m
- // HappyJob
- //
- // Created by 张晓光 on 2019/7/1.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "BPositionCell.h"
- #import "BPositonModel.h"
- @interface BPositionCell ()
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, strong) UILabel *updateTimelabel;
- @property (nonatomic, strong) UILabel *nameLabel;
- @property (nonatomic, strong) UIButton *stateBtn;
- @property (nonatomic, strong) UILabel *countlabel;
- @property (nonatomic, strong) UILabel *addressLabel;
- @property (nonatomic, strong) UILabel *timeLabel;
- @property (nonatomic, strong) UIButton *refreshBtn;
- @property (nonatomic, strong) UIButton *stopBtn;
- @property (nonatomic, strong) UIButton *endBtn;
- @property (nonatomic, strong) UIButton *editBtn;
- @property (nonatomic, strong) UIButton *resumeBtn;//简历
- @property (nonatomic, strong) UIView *lineView;
- @end
- @implementation BPositionCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
-
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
- {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- self.backgroundColor = COLOR_GRAYFA;
- [self initViews];
- [self autoLayOutViews];
- }
- return self;
-
- }
- - (void)initViews {
-
- [self.contentView addSubview:self.bgView];
- [self.bgView addSubview:self.updateTimelabel];
- [self.bgView addSubview:self.nameLabel];
- [self.bgView addSubview:self.stateBtn];
- [self.bgView addSubview:self.resumeBtn];
- [self.resumeBtn addSubview:self.countlabel];
- [self.bgView addSubview:self.addressLabel];
- [self.bgView addSubview:self.timeLabel];
- [self.bgView addSubview:self.refreshBtn];
- [self.bgView addSubview:self.stopBtn];
- [self.bgView addSubview:self.endBtn];
- [self.bgView addSubview:self.editBtn];
- [self.bgView addSubview:self.lineView];
- }
- - (void)BPositionCellArray:(NSArray *)array andIndexPath:(NSIndexPath *)indexPath {
-
- NSDictionary *dict = [array objectAtIndex:indexPath.row];
- BPositonModel *model = [BPositonModel yy_modelWithJSON:dict];
- //更新时间
- NSString *updateDate = [HJAppService compareCurrentTimeDayAndMonth:[NSString stringWithFormat:@"%ld",(long)[HJAppService timeSwitchTimestamp:model.updateDate]]];
- self.updateTimelabel.text = [NSString stringWithFormat:@"最后更新于:%@",updateDate];
-
- //职位名称
- self.nameLabel.text = model.positionName;
- _nameLabel.preferredMaxLayoutWidth = SCREEN_WIDTH - 150;
-
- //地址
- if (model.hpPositionAddressList.count == 0)
- {
- self.addressLabel.text = [NSString stringWithFormat:@"工作地点:%@",@"全国"];
- }
- else
- {
- self.addressLabel.text = [NSString stringWithFormat:@"工作地点:%@ %@",model.hpPositionAddressList[0].adname ? [[model.hpPositionAddressList[0].adname componentsSeparatedByString:@"-"] componentsJoinedByString:@" "] :@"",model.hpPositionAddressList[0].address ? model.hpPositionAddressList[0].address:@""];
- }
-
- if ([model.positionCategory isEqualToString:@"8"])
- { //8全职
- if ([model.recruitNumber integerValue] > 0 )
- {
- self.timeLabel.text = [NSString stringWithFormat:@"招聘人数:%@",[NSString stringWithFormat:@"%@人 (全职工作)",model.recruitNumber]];
- }
- else
- {
- self.timeLabel.text = [NSString stringWithFormat:@"招聘人数:%@",@"若干人 (全职工作)"];
- }
- }
- else
- { //9兼职
-
- if (model.workDate == nil || [model.workDate isEqualToString:@""])
- {
- self.timeLabel.text = [NSString stringWithFormat:@"工作时间:%@",@"(兼职工作)"];
- }
- else
- {
- NSArray *timeArray = [model.workDate componentsSeparatedByString:@","];
-
- NSString *startTime = [HJAppService compareCurrentTimeDayAndMonth:[NSString stringWithFormat:@"%ld",(long)[HJAppService timeSwitchTimestamp:[NSString stringWithFormat:@"%@ 00:00:00",timeArray[0]]]]];
- NSString *endTime = [HJAppService compareCurrentTimeDayAndMonth:[NSString stringWithFormat:@"%ld",(long)[HJAppService timeSwitchTimestamp:[NSString stringWithFormat:@"%@ 00:00:00",[timeArray lastObject]]]]];
-
- self.timeLabel.text = [NSString stringWithFormat:@"工作时间:%@",[NSString stringWithFormat:@"%@-%@(兼职工作)",startTime,endTime]];
- }
- }
-
- //职位审核状态
- if ([model.authenticationStatus integerValue] == 1)
- {//审核中
- _stateBtn.hidden = NO;
- self.updateTimelabel.hidden = YES;
- [_stateBtn setTitle:@"审核中" forState:UIControlStateNormal];
- [_stateBtn setImage:[UIImage imageNamed:@"b_position_ing"] forState:UIControlStateNormal];
- [_stateBtn setTitleColor:COLOR_GRAY9 forState:UIControlStateNormal];
- }
- else if ([model.authenticationStatus integerValue] == 2)
- {//审核驳回
- _stateBtn.hidden = NO;
- self.updateTimelabel.hidden = YES;
- [_stateBtn setTitle:@"审核驳回" forState:UIControlStateNormal];
- [_stateBtn setImage:[UIImage imageNamed:@"position_audit_rejected"] forState:UIControlStateNormal];
- [_stateBtn setTitleColor:COLOR_READFF forState:UIControlStateNormal];
- }
- else
- {
- _stateBtn.hidden = YES;
- self.updateTimelabel.hidden = NO;
- }
-
- //简历数量
- if ([model.count integerValue] > 0)
- {
- self.countlabel.hidden = NO;
- }
- else
- {
- self.countlabel.hidden = YES;
- }
-
- //是否结束 0下架 1未下架
- if ([model.isOn boolValue])
- {//未下架
- self.editBtn.selected = YES;
- if ([self isTimeEnd:model.endDate])
- {//时间结束
- if ([model.isPause boolValue])
- {
- [self.stopBtn setTitle:@"开始" forState:UIControlStateNormal];
- }
- else
- {
- [self.stopBtn setTitle:@"暂停" forState:UIControlStateNormal];
- }
- self.refreshBtn.selected = NO;
- self.stopBtn.selected = NO;
- self.resumeBtn.selected = NO;
- }
- else
- {//时间未结束
- self.refreshBtn.selected = YES;
- self.stopBtn.selected = YES;
- self.resumeBtn.selected = YES;
-
- //是否暂停 1:暂停
- if ([model.isPause boolValue])
- {
- [self.stopBtn setTitle:@"开始" forState:UIControlStateNormal];
- }
- else
- {
- [self.stopBtn setTitle:@"暂停" forState:UIControlStateNormal];
- }
- }
- }
- else
- {//下架
- //是否暂停 1:暂停
- if ([model.isPause boolValue])
- {
- [self.stopBtn setTitle:@"开始" forState:UIControlStateNormal];
- }
- else
- {
- [self.stopBtn setTitle:@"暂停" forState:UIControlStateNormal];
- }
-
- self.stopBtn.selected = NO;
- self.refreshBtn.selected = NO;
- self.endBtn.selected = NO;
- self.editBtn.selected = NO;
- self.resumeBtn.selected = NO;
- self.stateBtn.hidden = YES;
- }
- }
- /* 判断时间是否结束 */
- - (BOOL)isTimeEnd:(NSString *)endTimeStr {
-
- if (endTimeStr)
- {
- //yes结束
- NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
- [formatter setDateFormat:@"yyyy-MM-dd"];
- NSString *todayDate=[formatter stringFromDate:[NSDate date]];
- NSDate *today = [formatter dateFromString:todayDate];
- NSDate *endTime = [formatter dateFromString:endTimeStr];
- NSComparisonResult result = [endTime compare:today];
- if (result == NSOrderedDescending)
- {
- return NO;
- }
- else if (result == NSOrderedSame)
- {
- return NO;
- }
- else
- {
- return YES;
- }
- }
- else
- {
- return NO;
- }
- }
- #pragma mark - 布局
- - (void)autoLayOutViews {
-
- __weak typeof(self) weakSelf = self;
- [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.leading.equalTo(weakSelf.contentView.mas_leading).offset(0);
- make.trailing.equalTo(weakSelf.contentView.mas_trailing).offset(0);
- make.top.equalTo(weakSelf.contentView.mas_top).offset(0);
- make.bottom.equalTo(weakSelf.contentView.mas_bottom).offset(-10);
- }];
- [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(weakSelf.bgView.mas_leading).offset(15);
- make.top.equalTo(weakSelf.bgView.mas_top).offset(20);
- }];
- [_updateTimelabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.right.equalTo(weakSelf.bgView).offset(-15);
- make.centerY.equalTo(weakSelf.nameLabel);
- }];
-
- [_stateBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.right.equalTo(weakSelf.bgView).offset(-15);
- make.centerY.equalTo(weakSelf.nameLabel);
- }];
-
- [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(weakSelf.bgView.mas_leading).offset(15);
- make.trailing.equalTo(weakSelf.bgView.mas_trailing).offset(-15);
- make.top.equalTo(weakSelf.nameLabel.mas_bottom).offset(20);
- }];
-
- [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(weakSelf.bgView.mas_leading).offset(15);
- make.trailing.equalTo(weakSelf.bgView.mas_trailing).offset(-15);
- make.top.equalTo(weakSelf.addressLabel.mas_bottom).offset(5);
- }];
- [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.right.offset(0);
- make.top.equalTo(self.timeLabel.mas_bottom).offset(10);
- make.height.mas_equalTo(1);
- }];
-
- [_refreshBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.leading.equalTo(weakSelf.bgView.mas_leading).offset(15);
- make.top.equalTo(weakSelf.timeLabel.mas_bottom).offset(20);
- make.bottom.equalTo(weakSelf.bgView.mas_bottom).offset(-20);
- make.size.mas_offset(CGSizeMake(HJHorizontalScale(53), HJHorizontalScale(26)));
- }];
- [_stopBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(weakSelf.refreshBtn.mas_trailing).offset(15);
- make.centerY.equalTo(weakSelf.refreshBtn);
- make.size.mas_offset(CGSizeMake(HJHorizontalScale(53), HJHorizontalScale(26)));
- }];
- [_endBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(weakSelf.stopBtn.mas_trailing).offset(15);
- make.centerY.equalTo(weakSelf.refreshBtn);
- make.size.mas_offset(CGSizeMake(HJHorizontalScale(53), HJHorizontalScale(26)));
- }];
- [_editBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(weakSelf.endBtn.mas_trailing).offset(15);
- make.centerY.equalTo(weakSelf.refreshBtn);
- make.size.mas_offset(CGSizeMake(HJHorizontalScale(53), HJHorizontalScale(26)));
- }];
- [_resumeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.trailing.equalTo(weakSelf.bgView.mas_trailing).offset(-15);
- make.centerY.equalTo(weakSelf.refreshBtn);
- make.size.mas_offset(CGSizeMake(HJHorizontalScale(69), HJHorizontalScale(27)));
- }];
- [_countlabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.right.top.offset(0);
- make.size.mas_offset(CGSizeMake(10, 10));
- }];
-
- }
- #pragma mark - event response
- /* 简历 */
- - (void)resumeButtonClick:(UIButton *)btn {
-
- self.resumeBlock(btn.selected);
- }
- /* 刷新 */
- - (void)refreshButtonClick:(UIButton *)btn {
-
- self.refreshButtonBlock(btn.selected);
- }
- /* 暂停 */
- - (void)stopButtonClick:(UIButton *)btn {
-
- self.stopButtonBlock(btn.selected);
- }
- /* 结束 */
- - (void)endButtonClick:(UIButton *)btn {
-
- self.endButtonBlock(btn.selected);
- }
- /* 编辑 */
- - (void)editButtonClick:(UIButton *)btn {
-
- self.editButtonBlock(btn.selected);
- }
- #pragma mark - getter and setter
- - (UIView *)bgView {
-
- if (_bgView == nil)
- {
- _bgView = [[UIView alloc]init];
- _bgView.backgroundColor = [UIColor whiteColor];
- }
- return _bgView;
- }
- - (UILabel *)updateTimelabel {
-
- if (_updateTimelabel == nil)
- {
- _updateTimelabel = [[UILabel alloc]init];
- _updateTimelabel.textColor = COLOR_GRAY9;
- _updateTimelabel.font = [UIFont systemFontOfSize:12];
- }
- return _updateTimelabel;
- }
- - (UILabel *)nameLabel {
-
- if (_nameLabel == nil)
- {
- _nameLabel = [[UILabel alloc]init];
- _nameLabel.textColor = COLOR_BACK3;
- _nameLabel.font = [UIFont systemFontOfSize:17];
- }
- return _nameLabel;
- }
- - (UIButton *)stateBtn {
-
- if (_stateBtn == nil)
- {
- _stateBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _stateBtn.titleLabel.font = [UIFont systemFontOfSize:12];
- [_stateBtn setTitleColor:COLOR_GRAY9 forState:UIControlStateNormal];
- [_stateBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:3];
- }
- return _stateBtn;
- }
- - (UILabel *)addressLabel {
-
- if (_addressLabel == nil)
- {
- _addressLabel = [[UILabel alloc]init];
- _addressLabel.textColor = COLOR_BACK6;
- _addressLabel.font = [UIFont systemFontOfSize:12];
- }
- return _addressLabel;
- }
- - (UILabel *)timeLabel {
-
- if (_timeLabel == nil)
- {
- _timeLabel = [[UILabel alloc]init];
- _timeLabel.textColor = COLOR_BACK6;
- _timeLabel.font = [UIFont systemFontOfSize:12];
- }
- return _timeLabel;
- }
- - (UIButton *)refreshBtn {
-
- if (_refreshBtn == nil)
- {
- _refreshBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_refreshBtn setTitle:@"刷新" forState:UIControlStateNormal];
- _refreshBtn.selected = YES;
- [_refreshBtn setTitleColor:COLOR_BACK3 forState:UIControlStateSelected];
- [_refreshBtn setTitleColor:COLOR_GRAY9 forState:UIControlStateNormal];
- _refreshBtn.titleLabel.font = [UIFont systemFontOfSize:12];
- _refreshBtn.layer.borderWidth = 1;
- _refreshBtn.layer.borderColor = COLOR_GRAY9.CGColor;
- _refreshBtn.layer.cornerRadius = 5;
- _refreshBtn.layer.masksToBounds = YES;
- [_refreshBtn addTarget:self action:@selector(refreshButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _refreshBtn;
- }
- - (UIButton *)stopBtn {
-
- if (_stopBtn == nil)
- {
- _stopBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_stopBtn setTitle:@"暂停" forState:UIControlStateNormal];
- _stopBtn.titleLabel.font = [UIFont systemFontOfSize:12];
- _stopBtn.selected = YES;
- [_stopBtn setTitleColor:COLOR_BACK3 forState:UIControlStateSelected];
- [_stopBtn setTitleColor:COLOR_GRAY9 forState:UIControlStateNormal];
- _stopBtn.layer.borderWidth = 1;
- _stopBtn.layer.borderColor = COLOR_GRAY9.CGColor;
- _stopBtn.layer.cornerRadius = 5;
- _stopBtn.layer.masksToBounds = YES;
- [_stopBtn addTarget:self action:@selector(stopButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _stopBtn;
- }
- - (UIButton *)endBtn {
-
- if (_endBtn == nil)
- {
- _endBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_endBtn setTitle:@"下架" forState:UIControlStateNormal];
- _endBtn.selected = YES;
- [_endBtn setTitleColor:COLOR_BACK3 forState:UIControlStateSelected];
- [_endBtn setTitleColor:COLOR_GRAY9 forState:UIControlStateNormal];
- _endBtn.titleLabel.font = [UIFont systemFontOfSize:12];
- _endBtn.layer.borderWidth = 1;
- _endBtn.layer.borderColor = COLOR_GRAY9.CGColor;
- _endBtn.layer.cornerRadius = 5;
- _endBtn.layer.masksToBounds = YES;
- [_endBtn addTarget:self action:@selector(endButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _endBtn;
- }
- - (UIButton *)editBtn {
-
- if (_editBtn == nil)
- {
- _editBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [_editBtn setTitle:@"编辑" forState:UIControlStateNormal];
- _endBtn.selected = YES;
- [_editBtn setTitleColor:COLOR_BACK3 forState:UIControlStateSelected];
- [_editBtn setTitleColor:COLOR_GRAY9 forState:UIControlStateNormal];
- _editBtn.titleLabel.font = [UIFont systemFontOfSize:12];
- _editBtn.layer.borderWidth = 1;
- _editBtn.layer.borderColor = COLOR_GRAY9.CGColor;
- _editBtn.layer.cornerRadius = 5;
- _editBtn.layer.masksToBounds = YES;
- [_editBtn addTarget:self action:@selector(editButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _editBtn;
- }
- - (UIButton *)resumeBtn {
-
- if (_resumeBtn == nil)
- {
- _resumeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _resumeBtn.selected = YES;
- [_resumeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- [_resumeBtn setTitleColor:COLOR_BACK3 forState:UIControlStateSelected];
- [_resumeBtn setTitle:@"简历管理" forState:UIControlStateNormal];
- _resumeBtn.titleLabel.font = [UIFont systemFontOfSize:12];
- _resumeBtn.layer.borderColor = COLOR_GRAY9.CGColor;
- _resumeBtn.layer.cornerRadius = 5;
- _resumeBtn.backgroundColor = COLOR_BACKE;
- [_resumeBtn addTarget:self action:@selector(resumeButtonClick:) forControlEvents:UIControlEventTouchUpInside];
- }
- return _resumeBtn;
- }
- - (UILabel *)countlabel {
-
- if (_countlabel == nil)
- {
- _countlabel = [[UILabel alloc]init];
- _countlabel.backgroundColor = COLOR_READFF;
- _countlabel.layer.cornerRadius = 5;
- _countlabel.layer.masksToBounds = YES;
- }
- return _countlabel;
- }
- - (UIView *)lineView {
-
- if (_lineView == nil)
- {
- _lineView = [[UIView alloc]init];
- _lineView.backgroundColor = COLOR_BACKE;
- }
- return _lineView;
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|