Files
yuyin_ios/SweetParty/主类/音悦新增/房间设置/YYRoomCoverAlert.m
2025-08-08 11:05:33 +08:00

77 lines
2.0 KiB
Objective-C
Executable File

//
// YYRoomCoverAlert.m
// SweetParty
//
// Created by bj_szd on 2022/6/9.
//
#import "YYRoomCoverAlert.h"
#import "SelectPhotoManager.h"
@interface YYRoomCoverAlert ()
@property (nonatomic, copy) NSString *coverUrl;
@property (nonatomic, strong) SelectPhotoManager *photoManager;
@end
@implementation YYRoomCoverAlert
- (void)awakeFromNib {
[super awakeFromNib];
[self createUI];
}
- (void)createUI {
[self.confirmBtn setJianBianWithCGSize:CGSizeMake(ScreenWidth-32*2, 45)];
WEAK_SELF
[self.touchImgV dg_Tapped:^{
[weakSelf removeFromSuperview];
}];
self.coverImgV.touchViewBlock = ^{
[weakSelf doSelectPhoto];
};
}
- (void)doSelectPhoto {
__weak typeof(self) weakSelf = self;
if (!self.photoManager) {
self.photoManager = [[SelectPhotoManager alloc] init];
}
[self.photoManager startSelectPhotoWithImageName:nil];
self.photoManager.successHandle = ^(SelectPhotoManager *manager, UIImage *image) {
[image uploadToServiceWithBlock:^(NSString * _Nonnull upUrl, UIImage * _Nonnull upImage) {
weakSelf.coverUrl = upUrl;
weakSelf.coverImgV.image = upImage;
}];
};
}
- (void)setModel:(YYRoomSetModel *)model {
_model = model;
[self.coverImgV sd_setImageWithURL:[NSURL URLWithString:model.room_cover] placeholderImage:kDefaultUserIcon];
}
- (IBAction)onConfirm:(id)sender {
if (self.coverUrl.length <= 0) {
[HelpPageDefine showMessage:@"请选择房间封面"];
return;
}
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:self.model.mj_JSONObject];
[params setObject:self.coverUrl forKey:@"room_cover"];
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"/api/room/modify_room_info" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
if (self.onCompleteBlock) {
self.onCompleteBlock();
}
[self removeFromSuperview];
} Failure:^(id _Nonnull errorData) {
}];
}
@end