PlanCell.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // PlanCell.m
  3. // jiaPeiC
  4. //
  5. // Created by apple on 15/12/18.
  6. // Copyright © 2015年 JCZ. All rights reserved.
  7. //
  8. #import "PlanCell.h"
  9. #import "UIImageView+WebCache.h"
  10. @interface PlanCell()
  11. @end
  12. @implementation PlanCell
  13. - (void)awakeFromNib {
  14. [super awakeFromNib];
  15. }
  16. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  17. [super setSelected:selected animated:animated];
  18. }
  19. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  20. {
  21. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  22. if (self) {
  23. self.backgroundColor = backGroundColor;
  24. _headImg = [UIImageView new];
  25. [self.contentView addSubview:_headImg];
  26. UILabel *label = [UILabel new];
  27. [label setTextAlignment:NSTextAlignmentLeft];
  28. label.font = [UIFont scaleSize:Font18];
  29. [self.contentView addSubview:label];
  30. _nameLabel = label;
  31. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  32. btn.backgroundColor = defGreen;
  33. [btn setTitle:@"开始计时" forState:UIControlStateNormal];
  34. btn.titleLabel.textColor = [UIColor whiteColor];
  35. [self.contentView addSubview:btn];
  36. _on_offBtn = btn;
  37. btn = [UIButton buttonWithType:UIButtonTypeCustom];
  38. btn.backgroundColor = [UIColor clearColor];
  39. [btn addTarget:self action:@selector(clickToTel) forControlEvents:UIControlEventTouchUpInside];
  40. [self.contentView addSubview:btn];
  41. _telBtn = btn;
  42. }
  43. return self;
  44. }
  45. +(PlanCell*)cellForTabelView:(UITableView*)tableView
  46. {
  47. PlanCell* cell = [tableView dequeueReusableCellWithIdentifier:@"PlanCell"];
  48. if (!cell) {
  49. cell = [[PlanCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"PlanCell"];
  50. }
  51. return cell;
  52. }
  53. -(void)setModel:(NSDictionary *)model
  54. {
  55. /*
  56. RO_STATUS = ,
  57. RI_TIME = 14:00-17:00,
  58. RI_STATUS = 1,
  59. RO_ID = ,
  60. RI_ID = 103,
  61. CRDATE = 2017-02-16 11:02,
  62. RI_USER_TEL = 15188352230,
  63. PHOTO = http://fj.jppt.com.cn/http://image.jppt.com.cn/public/user/201701/1485147543320.jpg,
  64. RI_TASK_ID = 187,
  65. RI_REASON = Jiushibuxiang,
  66. RI_USER_NAME = 廖国荣,
  67. RI_USER = 1
  68. */
  69. _model = model;
  70. NSString *headString = model[@"PHOTO"];
  71. if (!headString || headString.length == 0) {
  72. headString = model[@"HEADIMG"];
  73. }
  74. if (!headString) {
  75. headString = @"";
  76. }
  77. [_headImg sd_setImageWithURL:[NSURL URLWithString:headString] placeholderImage:[UIImage imageNamed:@"noHeadImg.png"]];
  78. _nameLabel.text = model[@"RI_USER_NAME"];
  79. [_telBtn setTitle:model[@"RI_USER_TEL"] textColor:defGreen font:Font16 fotState:UIControlStateNormal];
  80. }
  81. -(void)clickToTel
  82. {
  83. //拨打电话
  84. NSString* tel = _model[@"RI_USER_TEL"];
  85. if (tel && ![tel isEqualToString:@""]) {
  86. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",tel]]];
  87. }
  88. }
  89. -(void)layoutSubviews
  90. {
  91. [super layoutSubviews];
  92. CGFloat wid = self.width;
  93. CGFloat x,y,w,h,bd;
  94. x = y = bd = 10;
  95. w = 70;
  96. h = 80;
  97. _headImg.frame = setDIYFrame;
  98. [_headImg borderColor:defGreen width:1 cornorRadios:5];
  99. x += w + bd;
  100. w = 80;
  101. h = 30;
  102. _nameLabel.frame = setDIYFrame;
  103. x += w;
  104. y += bd/2.0;
  105. w = wid - x - bd;
  106. h = 30;
  107. _telBtn.frame = setDIYFrame;
  108. x = _headImg.width + 2*bd;
  109. y += h + bd;
  110. w = wid - x - 2*bd;
  111. _on_offBtn.frame = setDIYFrame;
  112. [_on_offBtn borderColor:defGreen width:1 cornorRadios:5];
  113. }
  114. @end