JXFriendCell.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // JXFriendCell.m
  3. // share
  4. //
  5. // Created by 1 on 2019/3/21.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXFriendCell.h"
  9. #import "JXShareUser.h"
  10. @interface JXFriendCell ()
  11. @property (nonatomic, strong) UIImageView *imgV;
  12. @property (nonatomic, strong) UILabel *name;
  13. @end
  14. @implementation JXFriendCell
  15. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  16. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  17. _imgV = [[UIImageView alloc] initWithFrame:CGRectMake(14,5,52,52)];
  18. _imgV.layer.cornerRadius = 25;
  19. _imgV.layer.masksToBounds = YES;
  20. _imgV.layer.borderColor = [UIColor darkGrayColor].CGColor;
  21. [self.contentView addSubview:_imgV];
  22. _name = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_imgV.frame)+14, 25, JX_SCREEN_WIDTH - 115 -CGRectGetMaxX(_imgV.frame)-14, 14)];
  23. _name.textColor = HEXCOLOR(0x323232);
  24. _name.font = SYSFONT(16);
  25. [self.contentView addSubview:_name];
  26. }
  27. return self;
  28. }
  29. - (void)setDataWithUser:(JXShareUser *)user {
  30. _name.text = user.userNickname;
  31. if (user.roomId.length > 0) {
  32. _imgV.image = [UIImage imageNamed:@"groupImage"];
  33. }else {
  34. [self getHeadImageSmall:user.userId imageView:_imgV];
  35. }
  36. }
  37. -(void)getHeadImageSmall:(NSString*)userId imageView:(UIImageView*)iv{
  38. // 客服头像
  39. if([userId intValue]<10100 && [userId intValue]>=10000){ // im_10000
  40. iv.image = [UIImage imageNamed:[NSString stringWithFormat:@"ALOGO_120"]];
  41. return;
  42. }
  43. // 支付
  44. if ([userId intValue] == [SHIKU_TRANSFER intValue]) {
  45. iv.image = [UIImage imageNamed:[NSString stringWithFormat:@"shiku_transfer"]];
  46. return;
  47. }
  48. NSString* s;
  49. if([userId isKindOfClass:[NSNumber class]])
  50. s = [(NSNumber*)userId stringValue];
  51. else
  52. s = userId;
  53. if([s length]<=0)
  54. return;
  55. // // 我的其他手机设备头像
  56. // if ([s isEqualToString:ANDROID_USERID] || [s isEqualToString:IOS_USERID]) {
  57. // iv.image = [UIImage imageNamed:@"fdy"];
  58. // return;
  59. // }
  60. // // 我的电脑端头像
  61. // if ([s isEqualToString:PC_USERID] || [s isEqualToString:MAC_USERID] || [s isEqualToString:WEB_USERID]) {
  62. // iv.image = [UIImage imageNamed:@"feb"];
  63. // return;
  64. // }
  65. NSString* dir = [NSString stringWithFormat:@"%d",[s intValue] % 10000];
  66. NSString* url = [NSString stringWithFormat:@"%@avatar/t/%@/%@.jpg",[share_defaults objectForKey:kDownloadAvatarUrl],dir,s];
  67. UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];
  68. if (!image) {
  69. image = [UIImage imageNamed:@"avatar_normal"];
  70. }
  71. iv.image = image;
  72. // [iv sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"avatar_normal"] options:SDWebImageRetryFailed];
  73. }
  74. @end