| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- //
- // HJJoinApplySuccessContentView.m
- // HappyJob
- //
- // Created by Bob on 2019/4/9.
- // Copyright © 2019 Bob. All rights reserved.
- //
- #import "HJJoinApplySuccessContentView.h"
- //#import "HJCornerRadiusView.h"
- #import "HJPortraitGroupView.h"
- #import "HJResumeModel.h"
- #import "HJJoinApplyContentListView.h"
- @interface HJJoinApplySuccessContentView ()
- @property (nonatomic, strong) UIView *bgView;
- @property (nonatomic, strong) UIImageView *titleIcon;
- @property (nonatomic, strong) UILabel *titleLabel;
- @property (nonatomic, strong) UILabel *moneyTopLabel;
- @property (nonatomic, assign) HJJoinApplyContentViewType type;
- @property (nonatomic, strong) HJJoinApplyContentListView *lastView;
- @end
- @implementation HJJoinApplySuccessContentView
- - (instancetype)initWithType:(HJJoinApplyContentViewType)type {
-
- if (self = [super init])
- {
- self.backgroundColor = COLOR_GRAYFA5;
-
- [self addSubview:self.bgView];
- [self.bgView addSubview:self.titleIcon];
- [self.bgView addSubview:self.titleLabel];
- [self.bgView addSubview:self.moneyTopLabel];
-
- [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.right.equalTo(self).offset(0);
- make.top.equalTo(self.mas_top).offset(10);
- }];
- [_titleIcon mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.centerY.equalTo(self.bgView);
- make.left.equalTo(self.bgView).offset(40);
- make.size.mas_offset(CGSizeMake(36, 36));
- }];
- [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgView).with.offset(20);
- make.left.equalTo(self.titleIcon.mas_right).with.offset(20);
- }];
- [_moneyTopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.equalTo(self.titleIcon.mas_right).with.offset(20);
- make.right.equalTo(self.bgView.mas_right).offset(-15);
- make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
- make.bottom.equalTo(self.bgView.mas_bottom).with.offset(-20);
- }];
-
-
- if (type == HJJoinApplyContentViewTypeSuccess)
- {
- self.titleLabel.text = @"恭喜您!拼工已成功!";
- self.titleLabel.textColor = [UIColor colorFromHexString:@"FF6630"];
- self.titleIcon.image = [UIImage imageNamed:@"job_spellwork_successful"];
- }
- else
- {
- self.titleLabel.text = @"很遗憾,拼工失败。";
- self.titleLabel.textColor = COLOR_BACK3;
- self.titleIcon.image = [UIImage imageNamed:@"job_spellwork_fail"];
- }
-
- _type = type;
- }
- return self;
- }
- - (void)configData:(NSDictionary *)data {
-
- NSLog(@"data:::::::%@",data);
-
- id num = [data valueForKey:@"groupNumber"];
- id names = [data valueForKeyPath:@"myGroupList.hpResumeAPI.realName"];
- if ([names isKindOfClass:[NSArray class]] && [num isKindOfClass:[NSNumber class]])
- {
-
- NSString *name = [[NSString alloc] initWithString:[names firstObject]];
-
- NSString *string;
-
- if (self.type == HJJoinApplyContentViewTypeSuccess)
- {
- string = [NSString stringWithFormat:@"共有%@人加入了%@的拼工,获得拼工奖励金为",num,name];
- }
- else
- {
- string = [NSString stringWithFormat:@"共有%@人加入了%@的拼工,获得基础奖励:",num,name];
- }
-
- NSMutableString *cash = [[NSMutableString alloc] initWithString:@"0元"];
- //基础返现根据性别判断,1是男,2是女
- HJResumeModel *resume = [HJResumeModel resume];
- if (resume.gender == 1)
- {
- //男maleReward
- id maleReward = [data valueForKeyPath:@"position.maleReward"];
- if (![maleReward isEqual:[NSNull null]])
- {
- cash = [[NSMutableString alloc] initWithString:[NSString stringWithFormat:@"%@元", maleReward]];
- }
- }
- else if (resume.gender == 2)
- {
- //女femaleReward
- id femaleReward = [data valueForKeyPath:@"position.femaleReward"];
- if (![femaleReward isEqual:[NSNull null]])
- {
- cash = [[NSMutableString alloc] initWithString:[NSString stringWithFormat:@"%@元", femaleReward]];
- }
- }
- if (self.type == HJJoinApplyContentViewTypeSuccess)
- {
- if ([num integerValue] > 4)
- {
- //五人团返现
- id fiveGroupCashback = [data valueForKeyPath:@"position.fiveGroupCashback"];
- if (![fiveGroupCashback isEqual:[NSNull null]])
- {
- [cash appendString:[NSString stringWithFormat:@"+%@元", fiveGroupCashback]];
- }
- }
- else if ([num integerValue] > 2)
- {
- //三人团返现
- id threeGroupCashback = [data valueForKeyPath:@"position.threeGroupCashback"];
- if (![threeGroupCashback isEqual:[NSNull null]])
- {
- [cash appendString:[NSString stringWithFormat:@"+%@元", threeGroupCashback]];
- }
- }
- }
-
- self.moneyTopLabel.text = [NSString stringWithFormat:@"%@%@",string,cash];
- }
-
- NSMutableArray *listArray = [NSMutableArray array];
- if (![data[@"myGroupList"] isKindOfClass:[NSNull class]])
- {
- listArray = [NSMutableArray arrayWithArray:data[@"myGroupList"]];
- }
- if (listArray.count > 0)
- {
- for (int i = 0; i < listArray.count; i ++ )
- {
- NSDictionary *dict = listArray[i][@"hpResumeAPI"];
- HJJoinApplyContentListView *listView = [[HJJoinApplyContentListView alloc]init];
- [self addSubview:listView];
- if (![dict[@"headImg"] isKindOfClass:[NSNull class]])
- {
- [listView.headerImageV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",dict[@"headImg"]]] placeholderImage:[UIImage imageNamed:@"portrait_default"]];
- }
- if (![dict[@"realName"] isKindOfClass:[NSNull class]])
- {
- listView.nameLabel.text = dict[@"realName"];
- }
-
- [listView mas_makeConstraints:^(MASConstraintMaker *make) {
-
- make.left.right.equalTo(self).offset(0);
- if (i == 0)
- {
- make.top.equalTo(self.bgView.mas_bottom).offset(10);
- }
- else
- {
- make.top.equalTo(self.lastView.mas_bottom).offset(1);
- }
- if (i == listArray.count - 1)
- {
- make.bottom.equalTo(self.mas_bottom).offset(-10);
- }
- }];
- self.lastView = listView;
- }
- }
- else
- {
- [self.bgView mas_remakeConstraints:^(MASConstraintMaker *make) {
-
- make.top.offset(10);
- make.left.right.offset(0);
- make.bottom.offset(-10);
- }];
- }
- }
- #pragma mark - getters and setters
- - (UIView *)bgView {
-
- if (_bgView == nil)
- {
- _bgView = [[UIView alloc] init];
- _bgView.backgroundColor = [UIColor whiteColor];
- }
- return _bgView;
- }
- - (UIImageView *)titleIcon {
-
- if (_titleIcon == nil)
- {
- _titleIcon = [[UIImageView alloc] init];
- }
- return _titleIcon;
- }
- - (UILabel *)titleLabel {
-
- if (_titleLabel == nil)
- {
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.font = [UIFont systemFontOfSize:17];
- }
- return _titleLabel;
- }
- - (UILabel *)moneyTopLabel {
-
- if (_moneyTopLabel == nil)
- {
- _moneyTopLabel = [[UILabel alloc] init];
- _moneyTopLabel.font = [UIFont systemFontOfSize:13];
- _moneyTopLabel.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
- _moneyTopLabel.numberOfLines = 0;
- }
- return _moneyTopLabel;
- }
- @end
|