HJJoinApplySuccessContentView.m 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. //
  2. // HJJoinApplySuccessContentView.m
  3. // HappyJob
  4. //
  5. // Created by Bob on 2019/4/9.
  6. // Copyright © 2019 Bob. All rights reserved.
  7. //
  8. #import "HJJoinApplySuccessContentView.h"
  9. //#import "HJCornerRadiusView.h"
  10. #import "HJPortraitGroupView.h"
  11. #import "HJResumeModel.h"
  12. #import "HJJoinApplyContentListView.h"
  13. @interface HJJoinApplySuccessContentView ()
  14. @property (nonatomic, strong) UIView *bgView;
  15. @property (nonatomic, strong) UIImageView *titleIcon;
  16. @property (nonatomic, strong) UILabel *titleLabel;
  17. @property (nonatomic, strong) UILabel *moneyTopLabel;
  18. @property (nonatomic, assign) HJJoinApplyContentViewType type;
  19. @property (nonatomic, strong) HJJoinApplyContentListView *lastView;
  20. @end
  21. @implementation HJJoinApplySuccessContentView
  22. - (instancetype)initWithType:(HJJoinApplyContentViewType)type {
  23. if (self = [super init])
  24. {
  25. self.backgroundColor = COLOR_GRAYFA5;
  26. [self addSubview:self.bgView];
  27. [self.bgView addSubview:self.titleIcon];
  28. [self.bgView addSubview:self.titleLabel];
  29. [self.bgView addSubview:self.moneyTopLabel];
  30. [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.left.right.equalTo(self).offset(0);
  32. make.top.equalTo(self.mas_top).offset(10);
  33. }];
  34. [_titleIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.centerY.equalTo(self.bgView);
  36. make.left.equalTo(self.bgView).offset(40);
  37. make.size.mas_offset(CGSizeMake(36, 36));
  38. }];
  39. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.top.equalTo(self.bgView).with.offset(20);
  41. make.left.equalTo(self.titleIcon.mas_right).with.offset(20);
  42. }];
  43. [_moneyTopLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.equalTo(self.titleIcon.mas_right).with.offset(20);
  45. make.right.equalTo(self.bgView.mas_right).offset(-15);
  46. make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
  47. make.bottom.equalTo(self.bgView.mas_bottom).with.offset(-20);
  48. }];
  49. if (type == HJJoinApplyContentViewTypeSuccess)
  50. {
  51. self.titleLabel.text = @"恭喜您!拼工已成功!";
  52. self.titleLabel.textColor = [UIColor colorFromHexString:@"FF6630"];
  53. self.titleIcon.image = [UIImage imageNamed:@"job_spellwork_successful"];
  54. }
  55. else
  56. {
  57. self.titleLabel.text = @"很遗憾,拼工失败。";
  58. self.titleLabel.textColor = COLOR_BACK3;
  59. self.titleIcon.image = [UIImage imageNamed:@"job_spellwork_fail"];
  60. }
  61. _type = type;
  62. }
  63. return self;
  64. }
  65. - (void)configData:(NSDictionary *)data {
  66. NSLog(@"data:::::::%@",data);
  67. id num = [data valueForKey:@"groupNumber"];
  68. id names = [data valueForKeyPath:@"myGroupList.hpResumeAPI.realName"];
  69. if ([names isKindOfClass:[NSArray class]] && [num isKindOfClass:[NSNumber class]])
  70. {
  71. NSString *name = [[NSString alloc] initWithString:[names firstObject]];
  72. NSString *string;
  73. if (self.type == HJJoinApplyContentViewTypeSuccess)
  74. {
  75. string = [NSString stringWithFormat:@"共有%@人加入了%@的拼工,获得拼工奖励金为",num,name];
  76. }
  77. else
  78. {
  79. string = [NSString stringWithFormat:@"共有%@人加入了%@的拼工,获得基础奖励:",num,name];
  80. }
  81. NSMutableString *cash = [[NSMutableString alloc] initWithString:@"0元"];
  82. //基础返现根据性别判断,1是男,2是女
  83. HJResumeModel *resume = [HJResumeModel resume];
  84. if (resume.gender == 1)
  85. {
  86. //男maleReward
  87. id maleReward = [data valueForKeyPath:@"position.maleReward"];
  88. if (![maleReward isEqual:[NSNull null]])
  89. {
  90. cash = [[NSMutableString alloc] initWithString:[NSString stringWithFormat:@"%@元", maleReward]];
  91. }
  92. }
  93. else if (resume.gender == 2)
  94. {
  95. //女femaleReward
  96. id femaleReward = [data valueForKeyPath:@"position.femaleReward"];
  97. if (![femaleReward isEqual:[NSNull null]])
  98. {
  99. cash = [[NSMutableString alloc] initWithString:[NSString stringWithFormat:@"%@元", femaleReward]];
  100. }
  101. }
  102. if (self.type == HJJoinApplyContentViewTypeSuccess)
  103. {
  104. if ([num integerValue] > 4)
  105. {
  106. //五人团返现
  107. id fiveGroupCashback = [data valueForKeyPath:@"position.fiveGroupCashback"];
  108. if (![fiveGroupCashback isEqual:[NSNull null]])
  109. {
  110. [cash appendString:[NSString stringWithFormat:@"+%@元", fiveGroupCashback]];
  111. }
  112. }
  113. else if ([num integerValue] > 2)
  114. {
  115. //三人团返现
  116. id threeGroupCashback = [data valueForKeyPath:@"position.threeGroupCashback"];
  117. if (![threeGroupCashback isEqual:[NSNull null]])
  118. {
  119. [cash appendString:[NSString stringWithFormat:@"+%@元", threeGroupCashback]];
  120. }
  121. }
  122. }
  123. self.moneyTopLabel.text = [NSString stringWithFormat:@"%@%@",string,cash];
  124. }
  125. NSMutableArray *listArray = [NSMutableArray array];
  126. if (![data[@"myGroupList"] isKindOfClass:[NSNull class]])
  127. {
  128. listArray = [NSMutableArray arrayWithArray:data[@"myGroupList"]];
  129. }
  130. if (listArray.count > 0)
  131. {
  132. for (int i = 0; i < listArray.count; i ++ )
  133. {
  134. NSDictionary *dict = listArray[i][@"hpResumeAPI"];
  135. HJJoinApplyContentListView *listView = [[HJJoinApplyContentListView alloc]init];
  136. [self addSubview:listView];
  137. if (![dict[@"headImg"] isKindOfClass:[NSNull class]])
  138. {
  139. [listView.headerImageV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",dict[@"headImg"]]] placeholderImage:[UIImage imageNamed:@"portrait_default"]];
  140. }
  141. if (![dict[@"realName"] isKindOfClass:[NSNull class]])
  142. {
  143. listView.nameLabel.text = dict[@"realName"];
  144. }
  145. [listView mas_makeConstraints:^(MASConstraintMaker *make) {
  146. make.left.right.equalTo(self).offset(0);
  147. if (i == 0)
  148. {
  149. make.top.equalTo(self.bgView.mas_bottom).offset(10);
  150. }
  151. else
  152. {
  153. make.top.equalTo(self.lastView.mas_bottom).offset(1);
  154. }
  155. if (i == listArray.count - 1)
  156. {
  157. make.bottom.equalTo(self.mas_bottom).offset(-10);
  158. }
  159. }];
  160. self.lastView = listView;
  161. }
  162. }
  163. else
  164. {
  165. [self.bgView mas_remakeConstraints:^(MASConstraintMaker *make) {
  166. make.top.offset(10);
  167. make.left.right.offset(0);
  168. make.bottom.offset(-10);
  169. }];
  170. }
  171. }
  172. #pragma mark - getters and setters
  173. - (UIView *)bgView {
  174. if (_bgView == nil)
  175. {
  176. _bgView = [[UIView alloc] init];
  177. _bgView.backgroundColor = [UIColor whiteColor];
  178. }
  179. return _bgView;
  180. }
  181. - (UIImageView *)titleIcon {
  182. if (_titleIcon == nil)
  183. {
  184. _titleIcon = [[UIImageView alloc] init];
  185. }
  186. return _titleIcon;
  187. }
  188. - (UILabel *)titleLabel {
  189. if (_titleLabel == nil)
  190. {
  191. _titleLabel = [[UILabel alloc] init];
  192. _titleLabel.font = [UIFont systemFontOfSize:17];
  193. }
  194. return _titleLabel;
  195. }
  196. - (UILabel *)moneyTopLabel {
  197. if (_moneyTopLabel == nil)
  198. {
  199. _moneyTopLabel = [[UILabel alloc] init];
  200. _moneyTopLabel.font = [UIFont systemFontOfSize:13];
  201. _moneyTopLabel.textColor = [UIColor colorWithRed:102/255.0 green:102/255.0 blue:102/255.0 alpha:1.0];
  202. _moneyTopLabel.numberOfLines = 0;
  203. }
  204. return _moneyTopLabel;
  205. }
  206. @end