From 37f94575321c6a9d56b0271ee6a4d2fcbfda9c93 Mon Sep 17 00:00:00 2001 From: eggmanQQQ <3671373519@qq.com> Date: Tue, 22 Oct 2024 15:26:41 +0800 Subject: [PATCH] =?UTF-8?q?1.0.18=20feat=EF=BC=9A=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=88=BF=E9=97=B4=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Setting/Model/XPRoomSettingItemModel.h | 2 + .../Presenter/XPRoomSettingPresenter.h | 4 +- .../Presenter/XPRoomSettingPresenter.m | 52 ++++++++++++- .../View/Cell/XPRoomSettingTableViewCell.m | 29 +++++++- .../Setting/View/MSRoomSetingBackdropVC.m | 15 +++- .../View/XPRoomSettingViewController.m | 73 ++++++++++++++----- 6 files changed, 151 insertions(+), 24 deletions(-) diff --git a/YuMi/Modules/YMRoom/View/Setting/Model/XPRoomSettingItemModel.h b/YuMi/Modules/YMRoom/View/Setting/Model/XPRoomSettingItemModel.h index ec027a5e..c54b5802 100644 --- a/YuMi/Modules/YMRoom/View/Setting/Model/XPRoomSettingItemModel.h +++ b/YuMi/Modules/YMRoom/View/Setting/Model/XPRoomSettingItemModel.h @@ -50,6 +50,8 @@ typedef NS_ENUM(NSInteger, RoomSettingItemType) { ///类型 @property (nonatomic,assign) RoomSettingItemType type; +@property (nonatomic, copy) NSString *avatar; + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/Setting/Presenter/XPRoomSettingPresenter.h b/YuMi/Modules/YMRoom/View/Setting/Presenter/XPRoomSettingPresenter.h index 9b356228..6c6727b4 100644 --- a/YuMi/Modules/YMRoom/View/Setting/Presenter/XPRoomSettingPresenter.h +++ b/YuMi/Modules/YMRoom/View/Setting/Presenter/XPRoomSettingPresenter.h @@ -57,7 +57,9 @@ NS_ASSUME_NONNULL_BEGIN roomId:(NSString *)roomId type:(RoomType)type itemType:(RoomSettingItemType)itemType - mgId:(NSString *)mgId backPic:(NSString *)backPic; + mgId:(NSString *)mgId + backPic:(NSString *)backPic + avatar:(NSString *)avatar; /// 获取房间在线用户 /// @param roomUid roomUid -(void)getRoomOnlineUserListWithRoomUid:(NSString *)roomUid; diff --git a/YuMi/Modules/YMRoom/View/Setting/Presenter/XPRoomSettingPresenter.m b/YuMi/Modules/YMRoom/View/Setting/Presenter/XPRoomSettingPresenter.m index f8a8dafd..8094058a 100644 --- a/YuMi/Modules/YMRoom/View/Setting/Presenter/XPRoomSettingPresenter.m +++ b/YuMi/Modules/YMRoom/View/Setting/Presenter/XPRoomSettingPresenter.m @@ -51,6 +51,7 @@ XPRoomSettingItemModel *avatarItem = [[XPRoomSettingItemModel alloc] init]; avatarItem.title = YMLocalizedString(@"RoomSetting_1.0.17_0"); avatarItem.subTitle = roomInfo.roomTag; + avatarItem.avatar = roomInfo.avatar; avatarItem.type = RoomSettingItemType_Avatar; XPRoomSettingItemModel *tagItem = [[XPRoomSettingItemModel alloc] init]; @@ -97,7 +98,9 @@ NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = roomId; request.userIds = @[uid]; + @kWeakify(self); [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { + @kStrongify(self); NSArray * array; if (error == nil) { NIMChatroomMember * member = members.firstObject; @@ -106,7 +109,7 @@ BOOL isCreatorOrSuperAdmin = (member.type == NIMChatroomMemberTypeCreator || isSuperAdmin); // 是否是许可房间 - BOOL isPermitRoom = (roomInfo.isPermitRoom == PermitRoomType_License); +// BOOL isPermitRoom = (roomInfo.isPermitRoom == PermitRoomType_License); // 是否设置了房间密码 BOOL hasRoomPwd = (roomInfo.roomPwd.length > 0); @@ -169,7 +172,6 @@ [themeList addObject:themeItem]; } list[1] = themeList; - } [[self getView] getRoomSettingListSuccess:list]; @@ -181,7 +183,9 @@ /// @param roomUid 房主的uid - (void)getRoomInfo:(NSString *)roomUid { NSString * uid = [AccountInfoStorage instance].getUid; + @kWeakify(self); [Api getRoomInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:data.data]; [[self getView] getRoomInfoSuccess:roomInfo]; } showLoading:YES] uid:roomUid intoUid:uid]; @@ -190,7 +194,9 @@ /// @param roomUid 房主的uid - (void)openRoomArrangeMic:(NSString *)roomUid { NSString * uid = [AccountInfoStorage instance].getUid; + @kWeakify(self); [Api openRoomArrangeMic:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); [[self getView] openRoomArrangeMicSuccess]; } showLoading:YES] roomUid:roomUid operUid:uid]; } @@ -199,7 +205,9 @@ /// @param roomUid 房主的uid - (void)closeRoomArrangeMic:(NSString *)roomUid { NSString * uid = [AccountInfoStorage instance].getUid; + @kWeakify(self); [Api closeRoomArrangeMic:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); [[self getView] closeRoomArrangeMicSuccess]; } showLoading:YES] roomUid:roomUid operUid:uid]; } @@ -208,7 +216,9 @@ /// @param roomUid 房主的uid - (void)openRoomLeaveMode:(NSString *)roomUid { NSString * uid = [AccountInfoStorage instance].getUid; + @kWeakify(self); [Api openRoomLeaveMode:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); [[self getView] openRoomArrangeMicSuccess]; } showLoading:YES] roomUid:roomUid uid:uid]; } @@ -217,7 +227,9 @@ /// @param roomUid 房主的uid - (void)closeRoomLeaveMode:(NSString *)roomUid { NSString * uid = [AccountInfoStorage instance].getUid; + @kWeakify(self); [Api closeRoomLeaveMode:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); [[self getView] closeRoomArrangeMicSuccess]; } showLoading:YES] roomUid:roomUid uid:uid]; } @@ -229,7 +241,9 @@ NSString * uid = [AccountInfoStorage instance].getUid; NSString * ticket = [AccountInfoStorage instance].getTicket; NSString * isCleScreenStr = isCloseScreen ? @"1" : @"0"; + @kWeakify(self); [Api updateRoomInfoMessageState:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:data.data]; [[self getView] updateRoomMessageScreenStateSuccess:roomInfo]; } showLoading:YES] roomId:roomId isCloseScreen:isCleScreenStr ticket:ticket uid:uid]; @@ -244,7 +258,18 @@ /// @param roomUid 房间uid /// @param roomId 群聊的id /// @param mgId 小游戏的id -- (void)updateRoomInfo:(NSString *)title roomPwd:(NSString *)roomPwd tagId:(NSString *)tagId classifyId:(NSString *)classifyId hasAnimationEffect:(BOOL)hasAnimationEffect roomUid:(NSString *)roomUid roomId:(NSString *)roomId type:(RoomType)type itemType:(RoomSettingItemType)itemType mgId:(NSString *)mgId backPic:(NSString *)backPic{ +- (void)updateRoomInfo:(NSString *)title + roomPwd:(NSString *)roomPwd + tagId:(NSString *)tagId + classifyId:(NSString *)classifyId + hasAnimationEffect:(BOOL)hasAnimationEffect + roomUid:(NSString *)roomUid + roomId:(NSString *)roomId + type:(RoomType)type + itemType:(RoomSettingItemType)itemType + mgId:(NSString *)mgId + backPic:(NSString *)backPic + avatar:(nonnull NSString *)avatar { NSString * uid = [AccountInfoStorage instance].getUid; NSString * ticket = [AccountInfoStorage instance].getTicket; NSMutableDictionary * params = [NSMutableDictionary dictionary]; @@ -276,25 +301,38 @@ if (mgId.length > 0) { [params setObject:mgId forKey:@"mgId"]; } + + if (avatar.length > 0) { + [params setObject:avatar forKey:@"avatar"]; + } + ///获取房间角色 NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = roomId; request.userIds = @[uid]; + @kWeakify(self); [[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray * _Nullable members) { + @kStrongify(self); if (error == nil) { NIMChatroomMember * member = members.firstObject; if (member.type == NIMTeamMemberTypeOwner) { + @kWeakify(self); [Api ownerUpdateRoomInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data]; [[self getView] updateRoomInfoSuccess:roomInfo itemType:itemType]; }fail:^(NSInteger code, NSString * _Nullable msg) { + @kStrongify(self); [[self getView] updateRoomInfoFail:msg]; } showLoading:YES] params:params]; } else if(member.type == NIMTeamMemberTypeManager) { + @kWeakify(self); [Api managerUpdateRoomInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); RoomInfoModel * roomInfo = [RoomInfoModel modelWithJSON:data.data]; [[self getView] updateRoomInfoSuccess:roomInfo itemType:itemType]; }fail:^(NSInteger code, NSString * _Nullable msg) { + @kStrongify(self); [[self getView] updateRoomInfoFail:msg]; } showLoading:YES] params:params]; } @@ -307,7 +345,9 @@ /// 获取房间在线用户 /// @param roomUid roomUid -(void)getRoomOnlineUserListWithRoomUid:(NSString *)roomUid{ + @kWeakify(self); [Api requestRoomOnlineUserList:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); NSArray *list = [XPMessageRemoteExtModel modelsWithArray:data.data]; [[self getView]getRoomOnlineUserListSuccess:list]; } fail:^(NSInteger code, NSString * _Nullable msg) { @@ -317,20 +357,26 @@ /// 关闭房间礼物值 /// @param roomUid 房间的uid - (void)closeRoomGiftValue:(NSString *)roomUid itemModel:(XPRoomSettingItemModel *)itemModel{ + @kWeakify(self); NSString * uid = [AccountInfoStorage instance].getUid; [Api closeRoomGiftValue:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); [[self getView] closeRoomGiftValueSuccessWithItemModel:itemModel]; }fail:^(NSInteger code, NSString * _Nullable msg) { + @kStrongify(self); [[self getView] closeRoomGiftValueFailWithItemModel:itemModel]; }] uid:uid roomUid:roomUid]; } /// 开启房间礼物值 /// @param roomUid 房间的uid - (void)openRoomGiftValue:(NSString *)roomUid itemModel:(XPRoomSettingItemModel *)itemModel{ + @kWeakify(self); NSString * uid = [AccountInfoStorage instance].getUid; [Api openRoomGiftValue:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); [[self getView] openRoomGiftValueSuccessWithItemModel:itemModel]; }fail:^(NSInteger code, NSString * _Nullable msg) { + @kStrongify(self); [[self getView] openRoomGiftValueFailWithItemModel:itemModel]; }] uid:uid roomUid:roomUid]; } diff --git a/YuMi/Modules/YMRoom/View/Setting/View/Cell/XPRoomSettingTableViewCell.m b/YuMi/Modules/YMRoom/View/Setting/View/Cell/XPRoomSettingTableViewCell.m index f5895227..4b340b22 100644 --- a/YuMi/Modules/YMRoom/View/Setting/View/Cell/XPRoomSettingTableViewCell.m +++ b/YuMi/Modules/YMRoom/View/Setting/View/Cell/XPRoomSettingTableViewCell.m @@ -30,6 +30,8 @@ @property (nonatomic,strong) UIImageView *arrowImageView; ///分割线 @property (nonatomic,strong) UIView * lineView; +///右侧头像 +@property (nonatomic,strong) NetImageView * avatarImageView; @end @implementation XPRoomSettingTableViewCell @@ -53,6 +55,7 @@ [self.stackView addArrangedSubview:self.subTitleLabel]; [self.stackView addArrangedSubview:self.switchView]; + [self.stackView addArrangedSubview:self.avatarImageView]; [self.stackView addArrangedSubview:self.arrowImageView]; } @@ -72,6 +75,10 @@ make.bottom.mas_equalTo(0); make.height.mas_equalTo(0.5); }]; + + [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.height.mas_equalTo(40); + }]; } #pragma mark - Event Response - (void)switchDidChange:(UISwitch *)swtich { @@ -84,6 +91,13 @@ - (void)setItemModel:(XPRoomSettingItemModel *)itemModel { _itemModel = itemModel; self.titleLabel.text = _itemModel.title; + self.avatarImageView.hidden = (itemModel.type != RoomSettingItemType_Avatar); + + if (itemModel.type == RoomSettingItemType_Avatar) { + self.avatarImageView.hidden = NO; + self.avatarImageView.imageUrl = itemModel.avatar; + } + if (_itemModel.type == RoomSettingItemType_Title || _itemModel.type == RoomSettingItemType_Class || _itemModel.type == RoomSettingItemType_Tag || @@ -102,7 +116,7 @@ self.subTitleLabel.hidden = YES; self.switchView.on = _itemModel.switchState; } - + if (_itemModel.type == RoomSettingItemType_Leave_Model && _itemModel.switchState) { self.leaveLabel.hidden = NO; } else { @@ -162,6 +176,19 @@ return _arrowImageView; } +- (NetImageView *)avatarImageView { + if (_avatarImageView == nil) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeUserIcon; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _avatarImageView = [[NetImageView alloc] initWithConfig:config]; + _avatarImageView.layer.cornerRadius = 6; + _avatarImageView.layer.masksToBounds = YES; + _avatarImageView.hidden = YES; + } + return _avatarImageView; +} + - (UIView *)lineView { if (!_lineView) { _lineView = [[UIView alloc] init]; diff --git a/YuMi/Modules/YMRoom/View/Setting/View/MSRoomSetingBackdropVC.m b/YuMi/Modules/YMRoom/View/Setting/View/MSRoomSetingBackdropVC.m index 9f6ec621..7a0e390a 100644 --- a/YuMi/Modules/YMRoom/View/Setting/View/MSRoomSetingBackdropVC.m +++ b/YuMi/Modules/YMRoom/View/Setting/View/MSRoomSetingBackdropVC.m @@ -86,8 +86,19 @@ NSString * mgId = [NSString stringWithFormat:@"%lld", self.roomInfo.mgId]; NSString * roomClassifyId = self.roomInfo.singleRoomSortId; NSString *backPic = self.imageList[indexPath.row]; - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:roomTag classifyId:roomClassifyId hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:RoomSettingItemType_Title mgId:mgId backPic:backPic]; - + [self.presenter updateRoomInfo:self.roomInfo.title + roomPwd:self.roomInfo.roomPwd + tagId:roomTag + classifyId:roomClassifyId + hasAnimationEffect:self.roomInfo.hasAnimationEffect + roomUid:roomUid + roomId:roomId + type:self.roomInfo.type + itemType:RoomSettingItemType_Title + mgId:mgId + backPic:backPic + avatar:self.roomInfo.avatar]; + } cancelHandler:^{ [self.navigationController popViewControllerAnimated:YES]; }]; diff --git a/YuMi/Modules/YMRoom/View/Setting/View/XPRoomSettingViewController.m b/YuMi/Modules/YMRoom/View/Setting/View/XPRoomSettingViewController.m index 7dd9828e..175b0a71 100644 --- a/YuMi/Modules/YMRoom/View/Setting/View/XPRoomSettingViewController.m +++ b/YuMi/Modules/YMRoom/View/Setting/View/XPRoomSettingViewController.m @@ -36,6 +36,8 @@ #import "XPRoomRoleViewController.h" #import "MSRoomSetingBackdropVC.h" +#import "UploadFile.h" + @interface XPRoomSettingViewController () ///房间信息 @property (nonatomic,strong) RoomInfoModel *roomInfo; @@ -47,6 +49,8 @@ @property (nonatomic,weak) id hostDelegate; ///是否是公会超管 @property (nonatomic,assign) BOOL meIsSuperAdmin; + +@property (nonatomic, assign) BOOL isUpdateAvatar; @end @implementation XPRoomSettingViewController @@ -214,7 +218,7 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index view.tagId = self.roomInfo.singleRoomSortId; view.completion = ^(NSString * _Nonnull tag) { NSString * mgId = [NSString stringWithFormat:@"%lld", self.roomInfo.mgId]; - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:roomTag classifyId:tag hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:itemModel.type mgId:mgId backPic:self.roomInfo.backPic]; + [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:roomTag classifyId:tag hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:itemModel.type mgId:mgId backPic:self.roomInfo.backPic avatar:self.roomInfo.avatar]; }; [TTPopup popupView:view style:TTPopupStyleAlert]; } @@ -226,7 +230,7 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index view.tagId = [NSString stringWithFormat:@"%ld", self.roomInfo.tagId]; view.completion = ^(NSString * _Nonnull tag) { NSString * mgId = [NSString stringWithFormat:@"%lld", self.roomInfo.mgId]; - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:tag classifyId:roomClassifyId hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:itemModel.type mgId:mgId backPic:self.roomInfo.backPic]; + [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:tag classifyId:roomClassifyId hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:itemModel.type mgId:mgId backPic:self.roomInfo.backPic avatar:self.roomInfo.avatar]; }; [TTPopup popupView:view style:TTPopupStyleAlert]; } @@ -240,10 +244,9 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; imagePicker.allowsEditing = YES; - - // [self presentViewController:[self photoPickerWillDisplayGIF: NO] - // animated:YES - // completion:nil]; + [self presentViewController:imagePicker + animated:YES + completion:nil]; } denied:^{ @kStrongify(self); [self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController7") content:YMLocalizedString(@"XPMineUserInfoEditViewController8")]; @@ -329,9 +332,9 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index NSString * roomClassifyId = self.roomInfo.singleRoomSortId; if (type == RoomSettingInputType_Pwd) { NSString *pwdDes = [DESEncrypt encryptUseDES:text key:KeyWithType(KeyType_PasswordEncode)]; - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:pwdDes tagId:roomTag classifyId:roomClassifyId hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:RoomSettingItemType_Pwd mgId:mgId backPic:self.roomInfo.backPic]; + [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:pwdDes tagId:roomTag classifyId:roomClassifyId hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:RoomSettingItemType_Pwd mgId:mgId backPic:self.roomInfo.backPic avatar:self.roomInfo.avatar]; } else if(type == RoomSettingInputType_Title) { - [self.presenter updateRoomInfo:text roomPwd:self.roomInfo.roomPwd tagId:roomTag classifyId:roomClassifyId hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:RoomSettingItemType_Title mgId:mgId backPic:self.roomInfo.backPic]; + [self.presenter updateRoomInfo:text roomPwd:self.roomInfo.roomPwd tagId:roomTag classifyId:roomClassifyId hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:RoomSettingItemType_Title mgId:mgId backPic:self.roomInfo.backPic avatar:self.roomInfo.avatar]; } } @@ -396,7 +399,18 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index [TTPopup popupView:titleView style:TTPopupStyleAlert]; } else { NSString * mgId = [NSString stringWithFormat:@"%lld", self.roomInfo.mgId]; - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:@"" tagId:roomTag classifyId:roomClassifyId hasAnimationEffect:self.roomInfo.hasAnimationEffect roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:itemModel.type mgId:mgId backPic:self.roomInfo.backPic]; + [self.presenter updateRoomInfo:self.roomInfo.title + roomPwd:@"" + tagId:roomTag + classifyId:roomClassifyId + hasAnimationEffect:self.roomInfo.hasAnimationEffect + roomUid:roomUid + roomId:roomId + type:self.roomInfo.type + itemType:itemModel.type + mgId:mgId + backPic:self.roomInfo.backPic + avatar:self.roomInfo.avatar]; } } break; @@ -404,7 +418,7 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index { if (isOn) { NSString * mgId = [NSString stringWithFormat:@"%lld", self.roomInfo.mgId]; - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:roomTag classifyId:roomClassifyId hasAnimationEffect:YES roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:itemModel.type mgId:mgId backPic:self.roomInfo.backPic]; + [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:roomTag classifyId:roomClassifyId hasAnimationEffect:YES roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:itemModel.type mgId:mgId backPic:self.roomInfo.backPic avatar:self.roomInfo.avatar]; return; } TTAlertConfig *config = [[TTAlertConfig alloc] init]; @@ -414,7 +428,7 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index [TTPopup alertWithConfig:config confirmHandler:^{ NSString * mgId = [NSString stringWithFormat:@"%lld", self.roomInfo.mgId]; - [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:roomTag classifyId:roomClassifyId hasAnimationEffect:NO roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:itemModel.type mgId:mgId backPic:self.roomInfo.backPic]; + [self.presenter updateRoomInfo:self.roomInfo.title roomPwd:self.roomInfo.roomPwd tagId:roomTag classifyId:roomClassifyId hasAnimationEffect:NO roomUid:roomUid roomId:roomId type:self.roomInfo.type itemType:itemModel.type mgId:mgId backPic:self.roomInfo.backPic avatar:self.roomInfo.avatar]; } cancelHandler:^{ [switchView setOn:!switchView.isOn]; }]; @@ -468,14 +482,35 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index #pragma mark - UIImagePickerControllerDelegate - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { + self.isUpdateAvatar = YES; UIImage *selectedPhoto = [info objectForKey:UIImagePickerControllerEditedImage]; if (selectedPhoto) { - if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { - UIImageWriteToSavedPhotosAlbum(selectedPhoto, nil, nil, nil); - } - // TODO: 更新房间头像 API // [self showLoading]; -// [self.presenter uploadAvatar:selectedPhoto]; + NSData *data = UIImageJPEGRepresentation(selectedPhoto, 0.5); + NSString *format = [UIImage getImageTypeWithImageData:data]; + NSString *name = [NSString stringWithFormat:@"image/%@.%@",[NSString createUUID],format]; + @kWeakify(self); + [[UploadFile share] QCloudUploadImage:data named:name success:^(NSString * _Nonnull key, NSDictionary * _Nonnull resp) { + @kStrongify(self); + NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; + NSString * roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId]; + NSString * roomTag = [NSString stringWithFormat:@"%ld", self.roomInfo.tagId]; + NSString * mgId = [NSString stringWithFormat:@"%lld", self.roomInfo.mgId]; + NSString * roomClassifyId = self.roomInfo.singleRoomSortId; + [self.presenter updateRoomInfo:self.roomInfo.title + roomPwd:self.roomInfo.roomPwd + tagId:roomTag + classifyId:roomClassifyId + hasAnimationEffect:self.roomInfo.hasAnimationEffect + roomUid:roomUid roomId:roomId + type:self.roomInfo.type + itemType:RoomSettingItemType_Avatar + mgId:mgId + backPic:self.roomInfo.backPic + avatar:key]; + } failure:^(NSNumber * _Nonnull resCode, NSString * _Nonnull message) { + + }]; } [picker dismissViewControllerAnimated:YES completion:^{}]; } @@ -505,7 +540,6 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index [self.tableView reloadData]; } - - (void)getRoomSettingListSuccess:(NSArray *)list { self.datasource = list; [self.tableView reloadData]; @@ -545,6 +579,10 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index } - (void)updateRoomInfoSuccess:(RoomInfoModel *)roomInfo itemType:(RoomSettingItemType)itemType { + if (self.isUpdateAvatar) { + self.isUpdateAvatar = NO; + [self showSuccessToast:YMLocalizedString(@"XPMineUserInfoEditViewController13")]; + } NSString * roomUid = [NSString stringWithFormat:@"%ld", self.roomInfo.uid]; [self.presenter getRoomInfo:roomUid]; if (itemType == RoomSettingItemType_Gift_Effect) { @@ -564,6 +602,7 @@ XPRoomSettingItemModel * itemModel = [[self.datasource xpSafeObjectAtIndex:index } - (void)updateRoomInfoFail:(NSString *)message { + self.isUpdateAvatar = NO; [self showErrorToast:message]; }