TrainDetailCell.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // TrainDetailCell.m
  3. // jiaPei
  4. //
  5. // Created by apple on 2017/3/10.
  6. // Copyright © 2017年 JCZ. All rights reserved.
  7. //
  8. #import "TrainDetailCell.h"
  9. @implementation TrainDetailCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. _titleLabel.font = [UIFont scaleSize:18];
  13. _contentLabel.font = [UIFont scaleSize:15];
  14. [_orbitBtn borderColor:defGreen width:1 cornorRadios:5];
  15. [_orbitBtn setTitle:@"查看轨迹" textColor:defGreen font:15 fotState:UIControlStateNormal];
  16. [_commentBtn borderColor:defGreen width:1 cornorRadios:5];
  17. [_commentBtn setTitle:@"评价" textColor:defGreen font:15 fotState:UIControlStateNormal];
  18. [_commentBtn setTitle:@"查看评价" textColor:defGreen font:15 fotState:UIControlStateSelected];
  19. }
  20. -(void)updateWith:(NSDictionary *)dic{
  21. if ([dic[@"CRI_STU_EVALUATE"] isEqualToString:@"1"]) {
  22. _commentBtn.selected = YES;
  23. }else{
  24. _commentBtn.selected = NO;
  25. }
  26. if ([dic[@"CRI_ENDTIME"] length] > 10) {
  27. _titleLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"CRI_STARTTIME"],[dic[@"CRI_ENDTIME"] substringFromIndex:10]];
  28. }else{
  29. _titleLabel.text = [NSString stringWithFormat:@"%@----%@",dic[@"CRI_STARTTIME"],dic[@"CRI_ENDTIME"]];
  30. }
  31. int time = [dic[@"CRI_VAILD_TIME"] intValue];
  32. int min = time%60;
  33. int hour = time/60;
  34. NSString *timeString = [NSString stringWithFormat:@"%d小时%d分钟",hour,min];
  35. if (hour == 0){
  36. timeString = [NSString stringWithFormat:@"%d分钟",min];
  37. }
  38. time = [dic[@"CRI_DURATION"] intValue];
  39. min = time%60;
  40. hour = time/60;
  41. NSString *valueTimeString = [NSString stringWithFormat:@"%d小时%d分钟",hour,min];
  42. if (hour == 0){
  43. valueTimeString = [NSString stringWithFormat:@"%d分钟",min];
  44. }
  45. _contentLabel.text = [NSString stringWithFormat:@"持续时间:%@ 有效时间:%@",valueTimeString,timeString];
  46. _checkMan.text = [NSString stringWithFormat:@"审核人 :%@",dic[@"CRI_AUDIT_USERNAME"]];
  47. _reasonLabel.text = [NSString stringWithFormat:@"审核原因:%@",dic[@"CRI_SECOND_AUDIT_REASON"]];
  48. _timeLab.text = [NSString stringWithFormat:@"审核时间:%@",dic[@"CRI_AUDIT_TIME"]];
  49. _statusLabel.text = [NSString stringWithFormat:@"%@",dic[@"CRI_SECOND_AUDIT_RESULT"]];
  50. if ([_statusLabel.text isEqualToString:@"0"]) {
  51. _statusLabel.text = @"审核通过";
  52. _statusLabel.textColor = [UIColor darkGrayColor];
  53. [self hiddenSecondCheck:YES];
  54. }else if ([_statusLabel.text isEqualToString:@"1"]) {
  55. _statusLabel.text = @"审核不通过";
  56. _statusLabel.textColor = [UIColor redColor];
  57. [self hiddenSecondCheck:NO];
  58. }else if ([_statusLabel.text isEqualToString:@"2"]) {
  59. _statusLabel.text = @"待审核";
  60. _statusLabel.textColor = [UIColor lightGrayColor];
  61. [self hiddenSecondCheck:YES];
  62. }
  63. NSString *reasonStr = dic[@"CRI_AUDIT_REASON"]? : @"";
  64. if (![_statusLabel.text isEqualToString:@"1"] && ![reasonStr isEqualToString:@""]) {
  65. _reasonLabel.text = [NSString stringWithFormat:@"审核原因:%@",reasonStr];
  66. _reasonLabel.textColor = [UIColor systemRedColor];
  67. _checkMan.hidden = YES;
  68. _reasonLabel.hidden = NO;
  69. _timeLab.hidden = YES;
  70. _statusLabel.hidden = YES;
  71. _reasonLabelTop.constant = -25;
  72. _orbitBtnTop.constant = -25;
  73. }else {
  74. _reasonLabelTop.constant = 0;
  75. _orbitBtnTop.constant = -70;
  76. }
  77. }
  78. -(void)hiddenSecondCheck:(BOOL)hidden{
  79. if (hidden) {
  80. _orbitBtnTop.constant = -70;
  81. }else{
  82. _orbitBtnTop.constant = 5;
  83. }
  84. _checkMan.hidden = hidden;
  85. _reasonLabel.hidden = hidden;
  86. _timeLab.hidden = hidden;
  87. _statusLabel.hidden = hidden;
  88. }
  89. + (CGFloat)heightForDic:(NSDictionary *)dic
  90. {
  91. // 而高度是动态返回
  92. CGRect bounds = [[NSString stringWithFormat:@"审核原因:%@",dic[@"CRI_SECOND_AUDIT_REASON"]] boundingRectWithSize:CGSizeMake(kSize.width-41, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15] forKey:NSFontAttributeName] context:nil];
  93. CGRect bounds0 = [[NSString stringWithFormat:@"审核原因:%@",dic[@"CRI_AUDIT_REASON"]] boundingRectWithSize:CGSizeMake(kSize.width-41, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:15] forKey:NSFontAttributeName] context:nil];
  94. BOOL showSecondCheck = [[NSString stringWithFormat:@"%@",dic[@"CRI_SECOND_AUDIT_RESULT"]] isEqualToString:@"1"];
  95. BOOL showCheck = [NSString stringWithFormat:@"%@",dic[@"CRI_AUDIT_REASON"]].length > 0;
  96. if (showSecondCheck) {
  97. return 140 + (bounds.size.height > 25 ? bounds.size.height : 25);
  98. }else if (showCheck){
  99. return 90 + (bounds0.size.height > 25 ? bounds0.size.height : 25);
  100. } return 90;
  101. }
  102. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  103. [super setSelected:selected animated:animated];
  104. // Configure the view for the selected state
  105. }
  106. @end