1
This commit is contained in:
@@ -74,6 +74,7 @@
|
||||
|
||||
/// 上传头像
|
||||
- (void)upLoadAvatarWithData:(NSData *)avatarData completion:(KBUpLoadAvatarCompletion)completion{
|
||||
KBWeakSelf;
|
||||
[KBHUD show];
|
||||
[[KBNetworkManager shared] uploadFile:KB_API_FILE_UPLOAD
|
||||
fileData:avatarData
|
||||
@@ -90,8 +91,12 @@
|
||||
}
|
||||
NSString *avImageString = json[@"data"];
|
||||
// [weakSelf.avatarView kb_setImageURL:[NSURL URLWithString:avImageString] placeholder:KBPlaceholderImage];
|
||||
|
||||
NSLog(@"上传成功: %@", json);
|
||||
KBUser *localUser = [KBUserSessionManager shared].currentUser;
|
||||
localUser.avatarUrl = avImageString;
|
||||
[weakSelf updateUserInfo:localUser completion:^(BOOL success, NSError * _Nullable error) {
|
||||
if (error) { if (completion) completion(NO, error); return; }
|
||||
completion(true,nil);
|
||||
}];
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -99,12 +104,18 @@
|
||||
/// 更新用户信息
|
||||
- (void)updateUserInfo:(KBUser *)user completion:(KBUpdateUserInfoCompletion)completion{
|
||||
/// 获取用户信息
|
||||
KBUser *localUser = [KBUserSessionManager shared].currentUser;
|
||||
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
if (localUser.userId.length) params[@"uid"] = localUser.userId;
|
||||
if (localUser.nickName.length) params[@"nickName"] = localUser.nickName;
|
||||
params[@"gender"] = (NSInteger)localUser.gender;
|
||||
if (localUser.avatarUrl.length) params[@"avatarUrl"] = localUser.avatarUrl;
|
||||
if (user.userId.length) params[@"uid"] = user.userId;
|
||||
if (user.nickName.length) params[@"nickName"] = user.nickName;
|
||||
params[@"gender"] = @(user.gender);
|
||||
if (user.avatarUrl.length) params[@"avatarUrl"] = user.avatarUrl;
|
||||
[KBHUD show];
|
||||
[[KBNetworkManager shared] POST:API_UPDATA_INFO jsonBody:params headers:nil autoShowBusinessError:true completion:^(NSDictionary * _Nullable json, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
[KBHUD dismiss];
|
||||
if (error) { if (completion) completion(NO, error); return; }
|
||||
completion(true,nil);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user