StudentTableCell.m 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. //
  2. // StudentTableCell.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 16/3/7.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "StudentTableCell.h"
  9. @implementation StudentTableCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. _headImg.contentMode = UIViewContentModeScaleAspectFill;
  13. _headImg.clipsToBounds = YES;
  14. _headImg.layer.borderWidth = 1;
  15. _headImg.layer.borderColor = defGreen.CGColor;
  16. CGFloat x,y,w,h,bd;
  17. x = 9;
  18. y = 125;
  19. w = 20;
  20. h = 20;
  21. UIImageView *xxImg = [[UIImageView alloc] setxywh];
  22. xxImg.image = [UIImage imageNamed:@"xiuxue"];
  23. [self addSubview:xxImg];
  24. x = 25;
  25. y = 125;
  26. w = 70;
  27. _xxBtn = [[UIButton alloc] setxywh];
  28. [self addSubview:_xxBtn];
  29. bd = 15;
  30. x = 10;
  31. y = 140 + bd;
  32. h = 25;
  33. w = kSize.width - 20;
  34. _baoMingLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w * 15/32.0, h)];
  35. [self addSubview:_baoMingLabel];
  36. x += w * 15/32.0 + 5;
  37. _tongGuoLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w * 17/32.0 + 10, h)];
  38. [self addSubview:_tongGuoLabel];
  39. y += bd + h + 3;
  40. _learnTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w * 17/32.0 + 10, h)];
  41. [self addSubview:_learnTimeLabel];
  42. x = 10;
  43. _stateLabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, w * 15/32.0, h)];
  44. [self addSubview:_stateLabel];
  45. _baoMingLabel.textAlignment = NSTextAlignmentLeft;
  46. _tongGuoLabel.textAlignment = NSTextAlignmentLeft;
  47. _learnTimeLabel.textAlignment = NSTextAlignmentLeft;
  48. _stateLabel.textAlignment = NSTextAlignmentLeft;
  49. _baoMingLabel.textColor = contentTextColor;
  50. _tongGuoLabel.textColor = contentTextColor;
  51. _learnTimeLabel.textColor = contentTextColor;
  52. _stateLabel.textColor = contentTextColor;
  53. [_baoMingLabel setFont:[UIFont systemFontOfSize:Font14]];
  54. [_tongGuoLabel setFont:[UIFont systemFontOfSize:Font14]];
  55. [_stateLabel setFont:[UIFont systemFontOfSize:Font14]];
  56. [_learnTimeLabel setFont:[UIFont systemFontOfSize:Font14]];
  57. if (kSize.width > 350.0)
  58. {
  59. [_nameLabel setFont:[UIFont scaleSize:Font16]];
  60. [_sexLabel setFont:[UIFont scaleSize:Font16]];
  61. [_telLabel setFont:[UIFont scaleSize:Font16]];
  62. [_sfzhmLabel setFont:[UIFont scaleSize:Font16]];
  63. [_baoMingLabel setFont:[UIFont scaleSize:Font16]];
  64. [_tongGuoLabel setFont:[UIFont scaleSize:Font16]];
  65. [_stateLabel setFont:[UIFont scaleSize:Font16]];
  66. [_learnTimeLabel setFont:[UIFont scaleSize:Font16]];
  67. }
  68. }
  69. -(void)setModel:(NSDictionary *)model
  70. {
  71. //NSLog(@"---->%@",model);
  72. NSString *headString = model[@"TSO_PHOTO"];
  73. if (!headString || headString.length == 0) {
  74. headString = model[@"HEADIMG"];
  75. if (headString && ![headString hasPrefix:@"http"]){
  76. headString = [imgPreFix stringByAppendingString:headString];
  77. }
  78. }else{
  79. NSString *photoString = @"http://fj.jppt.com.cn";
  80. if (headString && ![headString hasPrefix:@"http"]){
  81. headString = [photoString stringByAppendingString:headString];
  82. }
  83. }
  84. if (!headString) {
  85. headString = @"";
  86. }
  87. [_headImg sd_setImageWithURL:[NSURL URLWithString:headString] placeholderImage:[UIImage imageNamed:@"noHeadImg.png"]];
  88. //学员信息在这里改动
  89. _nameLabel.text = [NSString stringWithFormat:@"学员姓名:%@",model[@"TSO_NAME"]];
  90. _sexLabel.text = [NSString stringWithFormat:@"性别:%@",[model[@"TSO_SEX"] isEqualToString: @"1"] ? @"男" : @"女"];
  91. [_telBtn setTitle:model[@"TSO_PHONE"] textColor:defGreen font:Font16 fotState:UIControlStateNormal];
  92. _sfzhmLabel.text = [NSString stringWithFormat:@"证件号码:%@",model[@"TSO_IDCARD"]];
  93. NSString *kString = model[@"CRDATE"];
  94. if ([kString containsString:@"-"]) {
  95. kString = [kString stringByReplacingOccurrencesOfString:@"-" withString:@"."];
  96. }
  97. _baoMingLabel.text = [NSString stringWithFormat:@"报名日期:%@",kString];
  98. int time = [model[@"FINISH_TRAIN"] intValue];
  99. if (_studeState == 1) {
  100. _tongGuoLabel.text = [NSString stringWithFormat:@"科一暂未通过%@",@""];
  101. _learnTimeLabel.text = [NSString stringWithFormat:@"科一完成学时:%d小时%d分",time/60,time%60];
  102. _stateLabel.text = [NSString stringWithFormat:@"学习阶段:科一"];
  103. }else if (_studeState == 2) {
  104. kString = model[@"KSRQ"];
  105. if ([kString containsString:@"-"]) {
  106. kString = [kString stringByReplacingOccurrencesOfString:@"-" withString:@"."];
  107. }
  108. if (kString.length > 10) {
  109. kString = [kString substringToIndex:10];
  110. }
  111. _tongGuoLabel.text = [NSString stringWithFormat:@"科一通过日期:%@",kString];
  112. _stateLabel.text = [NSString stringWithFormat:@"送审状态:科二%@",[model[@"TRAIN_STATE"] isEqualToString:@"0"] ? @"未通过" : @"已通过"];
  113. _learnTimeLabel.text = [NSString stringWithFormat:@"科二完成学时:%d小时%d分",time/60,time%60];
  114. }else if(_studeState == 3){
  115. kString = model[@"KSRQ"];
  116. if ([kString containsString:@"-"]) {
  117. kString = [kString stringByReplacingOccurrencesOfString:@"-" withString:@"."];
  118. }
  119. _tongGuoLabel.text = [NSString stringWithFormat:@"科二通过日期:%@",kString];
  120. _stateLabel.text = [NSString stringWithFormat:@"学习状态:科三%@",model[@"TRAIN_STATE"]];
  121. _learnTimeLabel.text = [NSString stringWithFormat:@"科三完成学时:%d小时%d分",time/60,time%60];
  122. }else if (_studeState == 4){
  123. _tongGuoLabel.text = [NSString stringWithFormat:@"科三通过日期:%@",kString];
  124. _learnTimeLabel.text = [NSString stringWithFormat:@"科四完成学时:%d小时%d分",time/60,time%60];
  125. _stateLabel.text = [NSString stringWithFormat:@"学习阶段:科四"];
  126. }
  127. }
  128. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  129. [super setSelected:selected animated:animated];
  130. // Configure the view for the selected state
  131. }
  132. - (IBAction)clickToTel:(id)sender {
  133. //拨打电话
  134. NSString* tel = _model[@"TSO_PHONE"];
  135. if (tel && ![tel isEqualToString:@""]) {
  136. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",tel]]];
  137. }
  138. }
  139. @end