|
@@ -11,6 +11,8 @@
|
|
|
|
|
|
@interface SeatMemberView : UIView
|
|
|
|
|
|
+@property (nonatomic, strong) UIImageView *userAvatar;
|
|
|
+
|
|
|
@property (nonatomic, strong) NSString *userId;
|
|
|
|
|
|
@property (nonatomic, strong) NSString *userName;
|
|
@@ -36,12 +38,12 @@
|
|
|
self.backgroundColor = [UIColor clearColor];
|
|
|
|
|
|
if ([self.userId isEqualToString:UserDefault(UIDKey)]) { // 自己
|
|
|
- UIImageView *bgImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"seat_mine"]];
|
|
|
- [self addSubview:bgImage];
|
|
|
- [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ [self.userAvatar sd_setImageWithURL:[NSURL URLWithString:[UserDefault(AvatarUrlKey) getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
|
|
|
+ [self addSubview:self.userAvatar];
|
|
|
+ [self.userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.centerX.mas_equalTo(self.mas_centerX);
|
|
|
make.top.mas_equalTo(self.mas_top);
|
|
|
- make.width.height.mas_equalTo(54);
|
|
|
+ make.width.height.mas_equalTo(46);
|
|
|
}];
|
|
|
UIView *bgView = [[UIView alloc] initWithFrame:CGRectZero];
|
|
|
bgView.layer.cornerRadius = 7.0f;
|
|
@@ -52,15 +54,15 @@
|
|
|
make.centerX.mas_equalTo(self.mas_centerX);
|
|
|
make.left.mas_greaterThanOrEqualTo(self.mas_left).offset(5);
|
|
|
make.height.mas_equalTo(15);
|
|
|
- make.top.mas_equalTo(bgImage.mas_bottom).offset(-2);
|
|
|
+ make.top.mas_equalTo(self.userAvatar.mas_bottom).offset(2);
|
|
|
}];
|
|
|
|
|
|
[bgView addSubview:self.nameLabel];
|
|
|
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.centerX.mas_equalTo(bgView.mas_centerX);
|
|
|
make.centerY.mas_equalTo(bgView.mas_centerY);
|
|
|
- make.left.mas_equalTo(bgView.mas_left).offset(6);
|
|
|
- make.right.mas_equalTo(bgView.mas_right).offset(-6);
|
|
|
+ make.left.mas_equalTo(bgView.mas_left).offset(3);
|
|
|
+ make.right.mas_equalTo(bgView.mas_right).offset(-3);
|
|
|
}];
|
|
|
|
|
|
|
|
@@ -69,9 +71,10 @@
|
|
|
|
|
|
}
|
|
|
else { // 其他人
|
|
|
- UIImageView *bgImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"seat_other"]];
|
|
|
- [self addSubview:bgImage];
|
|
|
- [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ [self.userAvatar setImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
|
|
|
+
|
|
|
+ [self addSubview:self.userAvatar];
|
|
|
+ [self.userAvatar mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.centerX.mas_equalTo(self.mas_centerX);
|
|
|
make.top.mas_equalTo(self.mas_top).offset(4);
|
|
|
make.width.height.mas_equalTo(46);
|
|
@@ -80,7 +83,7 @@
|
|
|
[self addSubview:self.nameLabel];
|
|
|
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.left.right.mas_equalTo(self);
|
|
|
- make.top.mas_equalTo(bgImage.mas_bottom).offset(2);
|
|
|
+ make.top.mas_equalTo(self.userAvatar.mas_bottom).offset(2);
|
|
|
make.height.mas_equalTo(13);
|
|
|
}];
|
|
|
[self queryUserInfoWithUserId:self.userId];
|
|
@@ -97,12 +100,23 @@
|
|
|
return _nameLabel;
|
|
|
}
|
|
|
|
|
|
+- (UIImageView *)userAvatar {
|
|
|
+ if (!_userAvatar) {
|
|
|
+ _userAvatar = [[UIImageView alloc] init];
|
|
|
+ _userAvatar.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
+ _userAvatar.layer.cornerRadius = 23.0f;
|
|
|
+ [_userAvatar.layer setMasksToBounds:YES];
|
|
|
+ }
|
|
|
+ return _userAvatar;
|
|
|
+}
|
|
|
+
|
|
|
- (void)queryUserInfoWithUserId:(NSString *)userId {
|
|
|
[KSNetworkingManager imUserFriendQueryDetail:KS_POST userId:userId success:^(NSDictionary * _Nonnull dic) {
|
|
|
if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
NSDictionary *result = [dic dictionaryValueForKey:@"data"];
|
|
|
if (self) {
|
|
|
self.nameLabel.text = [result stringValueForKey:@"friendNickname"];
|
|
|
+ [self.userAvatar sd_setImageWithURL:[NSURL URLWithString:[[result stringValueForKey:@"friendAvatar"] getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
|
|
|
}
|
|
|
else {
|
|
|
NSLog(@"-delloc------");
|