TerminalListCell.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // TerminalListCell.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/8/3.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "TerminalListCell.h"
  9. @implementation TerminalListCell
  10. +(instancetype)cellForTableView:(UITableView *)tableView{
  11. TerminalListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"];
  12. if (!cell) {
  13. cell = [[[NSBundle mainBundle]loadNibNamed:@"TerminalListCell" owner:nil options:nil]lastObject];
  14. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  15. }
  16. return cell;
  17. }
  18. -(void)setDic:(NSDictionary *)dic{
  19. self.carNum.text = dic[@"TCO_LICNUM"];
  20. CGFloat x = [self.carNum.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}].width+10;
  21. self.carNum.width = x>150?150:x;
  22. self.carNum.width = x<80?80:x;
  23. BOOL isOnline = [dic[@"TDI_IS_CONNECT"] integerValue] == 1;
  24. self.status.textColor = isOnline ? [UIColor darkGrayColor] : [UIColor lightGrayColor];
  25. self.status.text = isOnline ? @"在线":@"不在线";
  26. self.type.textColor = KContentTextColor;
  27. NSString *subTitle = @"";
  28. switch ([dic[@"TDI_TERMTYPE"] integerValue]) {
  29. case 1:
  30. subTitle = @"车载计程计时终端";
  31. break;
  32. case 2:
  33. subTitle = @"课堂教学计时终端";
  34. break;
  35. case 3:
  36. subTitle = @"模拟训练计时终端";
  37. break;
  38. case 0:
  39. subTitle = @"教练APP设备";
  40. break;
  41. case 10:
  42. subTitle = @"学员APP设备";
  43. break;
  44. default:
  45. break;
  46. }
  47. self.type.text = [NSString stringWithFormat:@"终端类型:%@",subTitle];
  48. BOOL isRegister = [dic[@"TDI_REG_STATUS"] integerValue] == 1;
  49. self.registerLab.textColor = isRegister ? KContentTextColor : [UIColor redColor];
  50. self.registerLab.text = isRegister ? @"已注册" : @"未注册";
  51. }
  52. - (IBAction)orbitClick:(id)sender {
  53. //轨迹
  54. if (self.clickBlock) {
  55. self.clickBlock(@1);
  56. }
  57. }
  58. - (IBAction)sendMsgClick:(id)sender {
  59. //发送消息
  60. if (self.clickBlock) {
  61. self.clickBlock(@2);
  62. }
  63. }
  64. - (IBAction)cancleAlarmClick:(id)sender {
  65. //解除警报
  66. if (self.clickBlock) {
  67. self.clickBlock(@3);
  68. }
  69. }
  70. - (IBAction)videoClick:(id)sender {
  71. //录像
  72. if (self.clickBlock) {
  73. self.clickBlock(@4);
  74. }
  75. }
  76. - (IBAction)goMapClick:(id)sender {
  77. //点击车牌号
  78. if (self.clickBlock) {
  79. self.clickBlock(@5);
  80. }
  81. }
  82. - (void)awakeFromNib {
  83. [super awakeFromNib];
  84. self.carNum.textColor = KTitleColor;
  85. self.carNum.backgroundColor = RGB_COLOR(247, 196, 5);
  86. self.carNum.layer.cornerRadius = 3;
  87. self.carNum.layer.masksToBounds = YES;
  88. }
  89. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  90. [super setSelected:selected animated:animated];
  91. // Configure the view for the selected state
  92. }
  93. @end