packageRoolCell.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // packageRoolCell.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/4/30.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "packageRoolCell.h"
  9. #import "UIView+LK.h"
  10. @interface packageRoolCell()
  11. @property (nonatomic,strong) UILabel *nameL;
  12. @property (nonatomic,weak) UILabel *priceL;
  13. @property (nonatomic, weak)UILabel *contentL;
  14. @end
  15. @implementation packageRoolCell
  16. -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  17. if(self= [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
  18. self.nameL = [[UILabel alloc] init];
  19. self.nameL.font=[UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
  20. self.nameL.textColor=[UIColor whiteColor];
  21. [self addSubview:self.nameL];
  22. [self.nameL mas_makeConstraints:^(MASConstraintMaker *make) {
  23. make.centerY.mas_equalTo(self.centerY).mas_offset(0);
  24. make.left.mas_equalTo(10);
  25. }];
  26. UILabel *priceL = [[UILabel alloc]init];
  27. priceL.font=[UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
  28. priceL.textColor=[UIColor yellowColor];
  29. priceL.textAlignment=NSTextAlignmentLeft;
  30. priceL.numberOfLines=3;
  31. [self addSubview:priceL];
  32. self.priceL=priceL;
  33. [priceL mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.mas_equalTo(self.nameL.mas_right).mas_offset(8);
  35. make.centerY.mas_equalTo(self.nameL.centerY).mas_offset(0);
  36. }];
  37. UILabel *contentL = [[UILabel alloc]init];
  38. contentL.font=[UIFont systemFontOfSize:16 weight:UIFontWeightRegular];
  39. contentL.textColor=[UIColor whiteColor];
  40. contentL.textAlignment=NSTextAlignmentLeft;
  41. contentL.numberOfLines=3;
  42. [self addSubview:contentL];
  43. self.contentL=contentL;
  44. [contentL mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.right.mas_equalTo(-15);
  46. make.centerY.mas_equalTo(self.nameL.centerY).mas_offset(0);
  47. }];
  48. }
  49. return self;
  50. }
  51. +(instancetype)cellWithTableView:(UITableView *)tableView{
  52. static NSString *ID = @"packageRoolCell";
  53. packageRoolCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  54. if (cell == nil) {
  55. cell = [[packageRoolCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
  56. }
  57. cell.backgroundColor = [UIColor clearColor];
  58. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  59. return cell;
  60. }
  61. -(void)setModel:(packageRoolModel *)model{
  62. _model=model;
  63. self.nameL.text=[NSString stringWithFormat:@"恭喜%@",model.userName];
  64. self.priceL.text=[NSString stringWithFormat:@"获得%@",model.money];
  65. NSString *timeStr=[self timeFormate:model.gmtCreate];
  66. self.contentL.text=[NSString stringWithFormat:@"%@",timeStr];
  67. }
  68. - (NSString *)timeFormate:(NSString *)timeS{
  69. NSTimeInterval time=[timeS doubleValue]+28800;//因为时差问题要加8小时 == 28800 sec
  70. NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time/1000];
  71. NSLog(@"date:%@",[detaildate description]);
  72. //实例化一个NSDateFormatter对象
  73. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  74. //设定时间格式,这里可以设置成自己需要的格式
  75. [dateFormatter setDateFormat:@"yyyy-MM-dd"];
  76. NSString *currentDateStr = [dateFormatter stringFromDate: detaildate];
  77. return currentDateStr;
  78. }
  79. @end