YOUPAILCCallRecordCell.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. //
  2. // YOUPAILCCallRecordCell.m
  3. // LiveChat
  4. //
  5. // Created by 张灿 on 2018/10/13.
  6. // Copyright © 2018年 caicai. All rights reserved.
  7. //
  8. #import "YOUPAILCCallRecordCell.h"
  9. #import "YOUPAILZLevelView.h"
  10. #import "ZCUtils.h"
  11. @interface YOUPAILCCallRecordCell()
  12. @property(nonatomic,strong)UIImageView* youpaipavatarImgV;
  13. @property(nonatomic,strong)UILabel *youpaipnicknameL;
  14. //@property (nonatomic,strong)UIImageView *sexImgV;
  15. @property (nonatomic, weak) UIImageView *youpaipvipImgV;
  16. @property (nonatomic, weak) YOUPAILZLevelView *youpaiplevelView;
  17. @property (nonatomic, strong) UILabel *youpaipdayL;
  18. @property (nonatomic, strong) UILabel *youpaiptimerL;
  19. @property (nonatomic, strong) UILabel *youpaipdescL;
  20. //@property(nonatomic,strong)UILabel* moneyLabel;
  21. //@property(nonatomic,strong)UILabel* otherLabel;
  22. ////@property(nonatomic,strong)UILabel* skillLabel;
  23. //@property(nonatomic,strong)UILabel* timeLabel;
  24. ////@property(nonatomic,strong)UILabel* createTLabel;
  25. @end
  26. @implementation YOUPAILCCallRecordCell
  27. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  28. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  29. self.selectionStyle = UITableViewCellSelectionStyleNone;
  30. [self youpaifinitUI];
  31. }
  32. return self;
  33. }
  34. - (void)youpaifinitUI{
  35. self.youpaipavatarImgV = [[UIImageView alloc]init];
  36. self.youpaipavatarImgV.contentMode = UIViewContentModeScaleAspectFill;
  37. self.youpaipavatarImgV.layer.cornerRadius = 22.0f;
  38. self.youpaipavatarImgV.layer.masksToBounds = YES;
  39. [self.contentView addSubview:self.youpaipavatarImgV];
  40. [self.youpaipavatarImgV makeConstraints:^(MASConstraintMaker *make) {
  41. make.left.offset(14.0f);
  42. make.centerY.equalTo(self.contentView.centerY);
  43. make.size.mas_equalTo(CGSizeMake(44.0f, 44.0f));
  44. }];
  45. self.youpaipnicknameL = [[UILabel alloc] init];
  46. self.youpaipnicknameL.font = LCFont(14);
  47. self.youpaipnicknameL.textColor = LZ273145Color;
  48. [self.contentView addSubview:self.youpaipnicknameL];
  49. [self.youpaipnicknameL makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(10.0f);
  51. make.top.equalTo(self.youpaipavatarImgV.top).offset(5.5f);
  52. }];
  53. // UIImageView *sexImgV = [[UIImageView alloc] init];
  54. // [sexImgV setImage:[UIImage imageNamed:@"vqu_images_D_dynamic_woman"]];
  55. // [self.contentView addSubview:sexImgV];
  56. // self.sexImgV = sexImgV;
  57. // [sexImgV makeConstraints:^(MASConstraintMaker *make) {
  58. // make.left.equalTo(self.nicknameL.right).offset(@3);
  59. // make.centerY.equalTo(self.nicknameL);
  60. // make.size.mas_equalTo(CGSizeMake(14, 14));
  61. // }];
  62. UIImageView *vipImgV = [[UIImageView alloc] init];
  63. [self.contentView addSubview:vipImgV];
  64. self.youpaipvipImgV = vipImgV;
  65. [vipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
  67. make.centerY.equalTo(self.youpaipnicknameL);
  68. }];
  69. YOUPAILZLevelView *levelView = [[YOUPAILZLevelView alloc] init];
  70. [self.contentView addSubview:levelView];
  71. self.youpaiplevelView = levelView;
  72. [levelView mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
  74. make.centerY.equalTo(self.youpaipnicknameL);
  75. }];
  76. UILabel *dayL = [[UILabel alloc] init];
  77. dayL.font = LCFont(11.0f);
  78. dayL.textColor = HexColorFromRGB(0x9F9DA5);
  79. dayL.textAlignment = NSTextAlignmentCenter;
  80. [self.contentView addSubview:dayL];
  81. self.youpaipdayL = dayL;
  82. [dayL mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.right.offset(-14.0f);
  84. make.top.equalTo(self.youpaipnicknameL.mas_top);
  85. }];
  86. UILabel *timerL = [[UILabel alloc] init];
  87. timerL.font = LCFont(11.0f);
  88. timerL.textColor = HexColorFromRGB(0x9F9DA5);
  89. timerL.textAlignment = NSTextAlignmentCenter;
  90. [self.contentView addSubview:timerL];
  91. self.youpaiptimerL = timerL;
  92. [timerL mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.right.offset(-14.0f);
  94. make.top.equalTo(self.youpaipdayL.mas_bottom).offset(12.0f);
  95. }];
  96. UILabel *descL = [[UILabel alloc] init];
  97. descL.font = LCFont(12.0f);
  98. descL.textColor = LZA3AABEColor;
  99. descL.textAlignment = NSTextAlignmentCenter;
  100. [self.contentView addSubview:descL];
  101. self.youpaipdescL = descL;
  102. [descL mas_makeConstraints:^(MASConstraintMaker *make) {
  103. make.left.equalTo(self.youpaipavatarImgV.mas_right).offset(10.0f);
  104. make.top.equalTo(self.youpaipnicknameL.mas_bottom).offset(8.0f);
  105. }];
  106. [self.contentView addLineWithColor:LZF5F4F7Color lineRect:CGRectMake(14.0f, 77.5f, KScreenWidth - 28.0f, 0.5f)];
  107. }
  108. - (void)setYoupaiprecordModel:(YOUPAILCCallRecordModel *)recordModel{
  109. _youpaiprecordModel = recordModel;
  110. [self.youpaipavatarImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:recordModel.youpaipavatar]];
  111. self.youpaipnicknameL.text = recordModel.youpaipnickname;
  112. if (recordModel.youpaipstatus==1) {
  113. if (recordModel.youpaiptype==1) {
  114. self.youpaipdescL.text = @"自己取消了呼叫";
  115. }else{
  116. self.youpaipdescL.text = @"对方取消了通话";
  117. }
  118. }else if (recordModel.youpaipstatus==2){
  119. if (recordModel.youpaiptype==1) {
  120. self.youpaipdescL.text = @"对方拒绝了通话";
  121. }else{
  122. self.youpaipdescL.text = @"自己拒绝接听";
  123. }
  124. }else if (recordModel.youpaipstatus==3){
  125. self.youpaipdescL.text = @"超时未接听";
  126. }else if (recordModel.youpaipstatus==4){
  127. if (recordModel.youpaiptype==1) {
  128. self.youpaipdescL.text = [NSString stringWithFormat:@"通话时长%@(支出%@钻石)",[self getMMSSFromSS:[NSString stringWithFormat:@"%ld",recordModel.youpaipcall_time]],recordModel.youpaipcall_amount];
  129. }else{
  130. self.youpaipdescL.text = [NSString stringWithFormat:@"通话时长%@(收入%@钻石)",[self getMMSSFromSS:[NSString stringWithFormat:@"%ld",recordModel.youpaipcall_time]],recordModel.youpaipcall_income];
  131. }
  132. }
  133. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  134. //需要设置为和字符串相同的格式
  135. [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  136. NSDate *localDate = [dateFormatter dateFromString:recordModel.youpaipcreate_time];
  137. NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
  138. NSInteger unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitWeekday | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond;
  139. NSDate *now = [NSDate date];
  140. NSDateComponents *comps = [[NSDateComponents alloc] init];
  141. comps = [calendar components:unitFlags fromDate:now];
  142. NSDateComponents *create_comps = [[NSDateComponents alloc] init];
  143. create_comps = [calendar components:unitFlags fromDate:localDate];
  144. // NSLog(@"%ld年%ld月%ld日",(long)[comps year],(long)[comps month],(long)[comps day]);
  145. // NSLog(@"%ld",(long)[comps weekday]);
  146. NSString *day = @"";
  147. if ([comps year] == [create_comps year] && [comps month] == [create_comps month] && [comps day] == [create_comps day]) {
  148. day = @"今天";
  149. }else{
  150. day = [NSString stringWithFormat:@"%@月%@日",@([create_comps month]),@([create_comps day])];
  151. }
  152. self.youpaipdayL.text = day;
  153. self.youpaiptimerL.text = [NSString stringWithFormat:@"%02ld:%02ld",[create_comps hour],[create_comps minute]];
  154. // if (recordModel.gender == 1) {//0未知 1女 2男
  155. // self.sexImgV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_woman"];
  156. // }else{
  157. // self.sexImgV.image = [UIImage imageNamed:@"vqu_images_D_dynamic_man"];
  158. // }
  159. self.youpaipvipImgV.hidden = YES;
  160. self.youpaiplevelView.hidden = YES;
  161. UIView *frontV;
  162. if (recordModel.youpaipvip_icon.length != 0) {
  163. self.youpaipvipImgV.hidden = NO;
  164. [self.youpaipvipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:recordModel.youpaipvip_icon]];
  165. [self.youpaipvipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
  166. if (frontV == nil) {
  167. make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
  168. }else{
  169. make.left.equalTo(frontV.mas_right).offset(3.0f);
  170. }
  171. make.centerY.equalTo(self.youpaipnicknameL);
  172. make.size.mas_offset(CGSizeMake(30.0f, 19.0f));
  173. }];
  174. frontV = self.youpaipvipImgV;
  175. }
  176. self.youpaiplevelView.hidden = NO;
  177. [self.youpaiplevelView youpaifreloadWithIcon:recordModel.youpaipgrade.youpaipimg1 iconWidth:recordModel.youpaipgrade.youpaipicon_width bgImg:recordModel.youpaipgrade.youpaipimg2 bgImgWidth:recordModel.youpaipgrade.youpaipicon1_width levelName:recordModel.youpaipgrade.youpaipgrade_name level:recordModel.youpaipgrade.youpaipgrade];
  178. [self.youpaiplevelView mas_remakeConstraints:^(MASConstraintMaker *make) {
  179. if (frontV == nil) {
  180. make.left.equalTo(self.youpaipnicknameL.mas_right).offset(3.0f);
  181. }else{
  182. make.left.equalTo(frontV.mas_right).offset(3.0f);
  183. }
  184. make.centerY.equalTo(self.youpaipnicknameL);
  185. make.size.mas_offset(self.youpaiplevelView.mj_size);
  186. }];
  187. // [self.levelView youpaifreloadWithIcon:recordModel.grade.img1 iconWidth:recordModel.grade.icon_width bgImg:recordModel.grade.img2 bgImgWidth:recordModel.grade.icon1_width levelName:recordModel.grade.grade_name level:recordModel.grade.grade];
  188. // [self.levelView mas_updateConstraints:^(MASConstraintMaker *make) {
  189. // make.size.mas_offset(self.levelView.mj_size);
  190. // }];
  191. }
  192. -(NSString *)getMMSSFromSS:(NSString *)totalTime{
  193. NSInteger seconds = [totalTime integerValue];
  194.     //format of hour
  195.     NSString *str_hour = [NSString stringWithFormat:@"%02ld",seconds/3600];
  196.     //format of minute
  197.     NSString *str_minute = [NSString stringWithFormat:@"%02ld",(seconds%3600)/60];
  198.     //format of second
  199.     NSString *str_second = [NSString stringWithFormat:@"%02ld",seconds%60];
  200.     //format of time
  201.     NSString *format_time = [NSString stringWithFormat:@"%@:%@:%@",str_hour,str_minute,str_second];
  202.     return format_time;
  203. }
  204. @end