YOUPAIHROperationRecordCell.m 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //
  2. // YOUPAIHROperationRecordCell.m
  3. // VQU
  4. //
  5. // Created by xiaohaoran on 2021/11/8.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIHROperationRecordCell.h"
  9. @interface YOUPAIHROperationRecordCell ()
  10. @property(nonatomic,strong)UILabel *youpaiptypeLabel;
  11. @property(nonatomic,strong)UILabel *youpaipnickLabel;
  12. @property(nonatomic,strong)UILabel *youpaipnearLabel;
  13. @property(nonatomic,strong)UILabel *youpaiptimeLabel;
  14. @property(nonatomic,strong)UILabel *youpaipmessageLabel;
  15. @end
  16. @implementation YOUPAIHROperationRecordCell
  17. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  18. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  19. [self youpaifsetSubView];
  20. }
  21. return self;
  22. }
  23. -(void)youpaifsetSubView{
  24. //type
  25. UILabel *youpaiptypeLabel = [UILabel new];
  26. self.youpaiptypeLabel = youpaiptypeLabel;
  27. [self.contentView addSubview:youpaiptypeLabel];
  28. [youpaiptypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.left.mas_equalTo(14);
  30. make.top.mas_equalTo(14);
  31. make.size.mas_equalTo(CGSizeMake(32, 15));
  32. }];
  33. youpaiptypeLabel.textAlignment = NSTextAlignmentCenter;
  34. youpaiptypeLabel.textColor = [UIColor whiteColor];
  35. youpaiptypeLabel.font = [UIFont systemFontOfSize:10];
  36. youpaiptypeLabel.layer.cornerRadius = 7.5;
  37. youpaiptypeLabel.clipsToBounds = YES;
  38. //昵称
  39. UILabel *youpaipnickLabel = [UILabel new];
  40. self.youpaipnickLabel = youpaipnickLabel;
  41. [self.contentView addSubview:youpaipnickLabel];
  42. [youpaipnickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  43. make.left.mas_equalTo(youpaiptypeLabel.mas_right).offset(4);
  44. make.centerY.mas_equalTo(youpaiptypeLabel);
  45. }];
  46. youpaipnickLabel.text = @"David Myers";
  47. youpaipnickLabel.font = LCBoldFont(14);
  48. youpaipnickLabel.textColor = [UIColor whiteColor];
  49. //年
  50. UILabel *youpaipnearLabel = [UILabel new];
  51. self.youpaipnearLabel = youpaipnearLabel;
  52. [self.contentView addSubview:youpaipnearLabel];
  53. [youpaipnearLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.right.mas_equalTo(-14);
  55. make.centerY.mas_equalTo(youpaipnickLabel);
  56. }];
  57. // youpaipnearLabel.text = @"2021-11-22";
  58. youpaipnearLabel.textColor = HexColorFromRGB(0x9F9DA5);
  59. youpaipnearLabel.font =[UIFont systemFontOfSize:11];
  60. //分
  61. UILabel *youpaiptimeLabel = [UILabel new];
  62. self.youpaiptimeLabel = youpaiptimeLabel;
  63. [self.contentView addSubview:youpaiptimeLabel];
  64. [youpaiptimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.right.mas_equalTo(-14);
  66. make.top.mas_equalTo(youpaipnearLabel.mas_bottom).offset(12);
  67. }];
  68. // youpaiptimeLabel.text = @"08:56";
  69. youpaiptimeLabel.textColor = HexColorFromRGB(0x9F9DA5);
  70. youpaiptimeLabel.font =[UIFont systemFontOfSize:11];
  71. //image
  72. UIImageView *im = [UIImageView new];
  73. [self.contentView addSubview:im];
  74. [im mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.left.mas_equalTo(14);
  76. make.top.mas_equalTo(youpaiptypeLabel.mas_bottom).offset(8);
  77. make.size.mas_equalTo(CGSizeMake(16, 16));
  78. }];
  79. im.image = [UIImage imageNamed:@"vqu_images_chatroom_record"];
  80. //message
  81. UILabel *messageLabel = [UILabel new];
  82. self.youpaipmessageLabel = messageLabel;
  83. [self.contentView addSubview:messageLabel];
  84. [messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.left.mas_equalTo(im.mas_right).offset(4);
  86. make.centerY.mas_equalTo(im);
  87. }];
  88. // messageLabel.text= @"设置房间密码为:1234";
  89. messageLabel.textColor = HexColorFromRGB(0x9F9DA5);
  90. messageLabel.font = [UIFont systemFontOfSize:12];
  91. //分割线
  92. UIView *lineView = [UIView new];
  93. [self.contentView addSubview:lineView];
  94. [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
  95. make.left.mas_equalTo(14);
  96. make.right.mas_equalTo(-14);
  97. make.bottom.mas_equalTo(0);
  98. make.height.mas_equalTo(0.5);
  99. }];
  100. lineView.backgroundColor = HexColorFromRGB(0x28262D);
  101. }
  102. -(void)setYoupaipmodel:(YOUPAIHROperationRecordModel *)youpaipmodel
  103. {
  104. _youpaipmodel = youpaipmodel;
  105. //homeowner == 房主 host= 主持 manager = 管理
  106. if ([youpaipmodel.youpaipmanager_identity isEqualToString:@"homeowner"]) {
  107. self.youpaiptypeLabel.text = @"房主";
  108. self.youpaiptypeLabel.backgroundColor = HexColorFromRGB(0xDD5C7E);
  109. }else if ([youpaipmodel.youpaipmanager_identity isEqualToString:@"host"]){
  110. self.youpaiptypeLabel.text = @"主持";
  111. self.youpaiptypeLabel.backgroundColor = HexColorFromRGB(0xEA7B49);
  112. }else if ([youpaipmodel.youpaipmanager_identity isEqualToString:@"manager"]){
  113. self.youpaiptypeLabel.text = @"管理";
  114. self.youpaiptypeLabel.backgroundColor = HexColorFromRGB(0x3A80DB);
  115. }else if ([youpaipmodel.youpaipmanager_identity isEqualToString:@"super_manager"]){
  116. self.youpaiptypeLabel.text = @"超管";
  117. self.youpaiptypeLabel.backgroundColor = HexColorFromRGB(0xff3a3a);
  118. }
  119. self.youpaipnearLabel.text = youpaipmodel.youpaipcreate_time;
  120. self.youpaiptimeLabel.text = youpaipmodel.youpaipSF_time;
  121. self.youpaipnickLabel.text= youpaipmodel.youpaipnickname;
  122. NSString *str = youpaipmodel.youpaipdes;
  123. NSString *changeStr = youpaipmodel.youpaipop_user_name;
  124. NSRange rangeRmb=[str rangeOfString:[NSString stringWithFormat:@"%@", changeStr]];
  125. NSMutableAttributedString *rmbStr=[[NSMutableAttributedString alloc] initWithString:str attributes:nil];
  126. if ([[[UIDevice currentDevice] systemVersion] floatValue]>=6.0) {
  127. NSDictionary *fontDic=[NSDictionary dictionaryWithObjectsAndKeys:HexColorFromRGB(0xFFDB80),NSForegroundColorAttributeName,[UIFont systemFontOfSize:12],NSFontAttributeName, nil];
  128. [rmbStr addAttributes:fontDic range:rangeRmb];
  129. self.youpaipmessageLabel.attributedText = rmbStr;
  130. }else{
  131. self.youpaipmessageLabel.text=rmbStr.string;
  132. }
  133. }
  134. @end