PlanCell.m 4.0 KB

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