YOUPAIBBCallRecordCell.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. //
  2. // YOUPAIBBCallRecordCell.m
  3. // VQU
  4. //
  5. // Created by Elaine on 2021/10/22.
  6. // Copyright © 2021 MS. All rights reserved.
  7. //
  8. #import "YOUPAIBBCallRecordCell.h"
  9. #import "YOUPAILZLevelView.h"
  10. @interface YOUPAIBBCallRecordCell()
  11. @property(nonatomic,strong)UIImageView* youpaipavatarImgV;
  12. @property(nonatomic,strong)UILabel *youpaipnicknameL;
  13. @property (nonatomic,strong)UIImageView *youpaipsexImgV;
  14. //@property (nonatomic, weak) UIImageView *youpaipvipImgV;
  15. //@property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView;
  16. @property (nonatomic, strong) UILabel *youpaipdayL;
  17. @property (nonatomic, strong) UILabel *youpaiptimerL;
  18. @property (nonatomic, strong) UILabel *youpaipdescL;
  19. @end
  20. @implementation YOUPAIBBCallRecordCell
  21. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  22. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  23. self.selectionStyle = UITableViewCellSelectionStyleNone;
  24. //v1.5.6适配暗黑模式
  25. [self.contentView setBackgroundColor:LCBkgColor];
  26. [self youpaifinitUI];
  27. }
  28. return self;
  29. }
  30. - (void)youpaifinitUI{
  31. self.youpaipavatarImgV = [[UIImageView alloc]init];
  32. self.youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  33. self.youpaipavatarImgV.layer.cornerRadius = 22.0f;
  34. self.youpaipavatarImgV.layer.masksToBounds = YES;
  35. [self.contentView addSubview:self.youpaipavatarImgV];
  36. [self.youpaipavatarImgV makeConstraints:^(MASConstraintMaker *make) {
  37. make.left.offset(14.0f);
  38. make.centerY.equalTo(self.contentView.centerY);
  39. make.size.mas_equalTo(CGSizeMake(44.0f, 44.0f));
  40. }];
  41. self.youpaipnicknameL = [[UILabel alloc] init];
  42. self.youpaipnicknameL.font = LCFont(14);
  43. self.youpaipnicknameL.textColor = [UIColor whiteColor];
  44. [self.contentView addSubview:self.youpaipnicknameL];
  45. [self.youpaipnicknameL makeConstraints:^(MASConstraintMaker *make) {
  46. make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(10.0f);
  47. make.top.equalTo(self.youpaipavatarImgV.top).offset(5.5f);
  48. }];
  49. UIImageView *youpaipsexImgV = [[UIImageView alloc] init];
  50. [youpaipsexImgV setImage:[UIImage imageNamed:@"vqu_images_D_dynamic_woman"]];
  51. [self.contentView addSubview:youpaipsexImgV];
  52. self.youpaipsexImgV = youpaipsexImgV;
  53. [youpaipsexImgV makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.equalTo(self.youpaipnicknameL.right).offset(@3);
  55. make.centerY.equalTo(self.youpaipnicknameL);
  56. make.size.mas_equalTo(CGSizeMake(14, 14));
  57. }];
  58. // UIImageView *youpaipvipImgV = [[UIImageView alloc] init];
  59. // [self.contentView addSubview:youpaipvipImgV];
  60. // self.youpaipvipImgV = youpaipvipImgV;
  61. // [youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  62. // make.left.equalTo(youpaipsexImgV.mas_right).offset(3.0f);
  63. // make.centerY.equalTo(self.youpaipnicknameL);
  64. // }];
  65. //
  66. // YOUPAILZLevelView *youpaiplevelView = [[YOUPAILZLevelView alloc] init];
  67. // [self.contentView addSubview:youpaiplevelView];
  68. // self.youpaiplevelView = youpaiplevelView;
  69. // [youpaiplevelView mas_makeConstraints:^(MASConstraintMaker *make) {
  70. // make.left.equalTo(youpaipsexImgV.mas_right).offset(3.0f);
  71. // make.centerY.equalTo(self.youpaipnicknameL);
  72. // }];
  73. //
  74. UILabel *youpaipdayL = [[UILabel alloc] init];
  75. youpaipdayL.font = LCFont(11.0f);
  76. youpaipdayL.textColor = HexColorFromRGB(0x9F9DA5);
  77. youpaipdayL.textAlignment = NSTextAlignmentCenter;
  78. [self.contentView addSubview:youpaipdayL];
  79. self.youpaipdayL = youpaipdayL;
  80. [youpaipdayL mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.right.offset(-14.0f);
  82. make.top.equalTo(self.youpaipnicknameL.mas_top);
  83. }];
  84. UILabel *youpaiptimerL = [[UILabel alloc] init];
  85. youpaiptimerL.font = LCFont(11.0f);
  86. youpaiptimerL.textColor = HexColorFromRGB(0x9F9DA5);
  87. youpaiptimerL.textAlignment = NSTextAlignmentCenter;
  88. [self.contentView addSubview:youpaiptimerL];
  89. self.youpaiptimerL = youpaiptimerL;
  90. [youpaiptimerL mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.right.offset(-14.0f);
  92. make.top.equalTo(self.youpaipdayL.mas_bottom).offset(12.0f);
  93. }];
  94. UILabel *youpaipdescL = [[UILabel alloc] init];
  95. youpaipdescL.font = LCFont(12.0f);
  96. youpaipdescL.textColor = HexColorFromRGB(0x9F9DA5);
  97. youpaipdescL.textAlignment = NSTextAlignmentCenter;
  98. [self.contentView addSubview:youpaipdescL];
  99. self.youpaipdescL = youpaipdescL;
  100. [youpaipdescL mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(10.0f);
  102. make.top.equalTo(self.youpaipnicknameL.mas_bottom).offset(8.0f);
  103. }];
  104. [self.contentView addLineWithColor:HexColorFromRGB(0x28262D) lineRect:CGRectMake(14.0f, 77.5f, KScreenWidth - 28.0f, 0.5f)];
  105. }
  106. - (void)setYoupaiprecordModel:(YOUPAILCCallRecordModel *)youpaiprecordModel{
  107. _youpaiprecordModel = youpaiprecordModel;
  108. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:youpaiprecordModel.youpaipavatar]];
  109. self.youpaipnicknameL.text = youpaiprecordModel.youpaipnickname;
  110. if (youpaiprecordModel.youpaipstatus==1) {
  111. if (youpaiprecordModel.youpaiptype==1) {
  112. self.youpaipdescL.text = @"自己取消了呼叫";
  113. }else{
  114. self.youpaipdescL.text = @"对方取消了通话";
  115. }
  116. }else if (youpaiprecordModel.youpaipstatus==2){
  117. if (youpaiprecordModel.youpaiptype==1) {
  118. self.youpaipdescL.text = @"对方拒绝了通话";
  119. }else{
  120. self.youpaipdescL.text = @"自己拒绝接听";
  121. }
  122. }else if (youpaiprecordModel.youpaipstatus==3){
  123. self.youpaipdescL.text = @"超时未接听";
  124. }else if (youpaiprecordModel.youpaipstatus==4){
  125. if (youpaiprecordModel.youpaiptype==1) {
  126. self.youpaipdescL.text = [NSString stringWithFormat:@"本次支出%.0f钻石",youpaiprecordModel.youpaipcall_amount];
  127. }else{
  128. self.youpaipdescL.text = [NSString stringWithFormat:@"本次收入%.0f钻石",youpaiprecordModel.youpaipcall_income];
  129. }
  130. }
  131. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  132. //需要设置为和字符串相同的格式
  133. [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  134. NSDate *localDate = [dateFormatter dateFromString:youpaiprecordModel.youpaipcreate_time];
  135. NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
  136. NSInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitWeekday | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
  137. NSDate *now = [NSDate date];
  138. NSDateComponents *comps = [[NSDateComponents alloc] init];
  139. comps = [calendar components:unitFlags fromDate:now];
  140. NSDateComponents *create_comps = [[NSDateComponents alloc] init];
  141. create_comps = [calendar components:unitFlags fromDate:localDate];
  142. // NSLog(@"%ld年%ld月%ld日",(long)[comps year],(long)[comps month],(long)[comps day]);
  143. // NSLog(@"%ld",(long)[comps weekday]);
  144. NSString *day = @"";
  145. if ([comps year] == [create_comps year] && [comps month] == [create_comps month] && [comps day] == [create_comps day]) {
  146. day = @"今天";
  147. }else{
  148. day = [NSString stringWithFormat:@"%@月%@日",@([create_comps month]),@([create_comps day])];
  149. }
  150. self.youpaipdayL.text = day;
  151. self.youpaiptimerL.text = [NSString stringWithFormat:@"%02ld:%02ld",[create_comps hour],[create_comps minute]];
  152. if (youpaiprecordModel.youpaipgender == 1) {//0未知 1女 2男
  153. self.youpaipsexImgV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_woman"];
  154. }else{
  155. self.youpaipsexImgV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_man"];
  156. }
  157. }
  158. @end