更换腾讯cos上传
@@ -79,12 +79,12 @@
|
||||
}else{
|
||||
[self updateBgImage:@"app_home_bg"];
|
||||
}
|
||||
UIImageView *logoImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mi_di"]];
|
||||
UIImageView *logoImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yusheng"]];
|
||||
[self.view addSubview:logoImageView];
|
||||
[logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.top.mas_equalTo(kSafeAreaTop +8);
|
||||
make.width.mas_equalTo(66);
|
||||
make.width.mas_equalTo(110);
|
||||
make.height.mas_equalTo(32);
|
||||
}];
|
||||
|
||||
|
||||
@@ -171,23 +171,38 @@
|
||||
}
|
||||
NSMutableArray *files = [[NSMutableArray alloc] initWithObjects:fileData, nil];
|
||||
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
// NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
// NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// showLoadingInView(self.view);
|
||||
// [[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// hideLoadingInView(weakSelf.view);
|
||||
// });
|
||||
// if (state == UploadImageSuccess) {
|
||||
// NSString *fileName = [names lastObject];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// weakSelf.avartar = fileUrl;
|
||||
// [weakSelf.headerBtn sd_setImageWithURL:[NSURL URLWithString:fileUrl] forState:(UIControlStateNormal)];
|
||||
// weakSelf.isPhoto = YES;
|
||||
// }else{
|
||||
// showToastInView(QXText(@"文件上传失败,请重新尝试"), self.view);
|
||||
// }
|
||||
// }];
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.view);
|
||||
[[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],contentType];
|
||||
[[QXCOSUploadManager shareManager] uploadFile:files withObjectKey:@[fileName] isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
QXLOG(@"uploadstate --- %ld ---url---%@",state,names);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
hideLoadingInView(weakSelf.view);
|
||||
});
|
||||
if (state == UploadImageSuccess) {
|
||||
NSString *fileName = [names lastObject];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
weakSelf.avartar = fileUrl;
|
||||
[weakSelf.headerBtn sd_setImageWithURL:[NSURL URLWithString:fileUrl] forState:(UIControlStateNormal)];
|
||||
weakSelf.isPhoto = YES;
|
||||
if (state == QXCOSUploadImageSuccess) {
|
||||
weakSelf.avartar = names.firstObject;
|
||||
[weakSelf.headerBtn sd_setImageWithURL:[NSURL URLWithString:weakSelf.avartar] forState:(UIControlStateNormal)];
|
||||
}else{
|
||||
showToastInView(QXText(@"文件上传失败,请重新尝试"), self.view);
|
||||
showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.view);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -34,6 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic,assign)NSInteger auth;
|
||||
/// 装扮
|
||||
@property (nonatomic,strong)NSString *dress;
|
||||
/// 聊天气泡
|
||||
@property (nonatomic,strong)NSString *chat_bubble;
|
||||
/// 各种卡片
|
||||
@property (nonatomic,strong)NSArray *icon;
|
||||
/// 1 能聊天 0不能聊天
|
||||
|
||||
@@ -22,6 +22,8 @@ typedef NS_ENUM(NSInteger) {
|
||||
QXRoomMessageTypeMuteLocalAudio = 126,
|
||||
/// 基础文本消息类型
|
||||
QXRoomMessageTypeText = 1,
|
||||
/// 基础表情类型
|
||||
QXRoomMessageTypeEmoji = 2,
|
||||
/// 系统消息
|
||||
QXRoomMessageTypeSystem = 1000,
|
||||
/// 用户进入房间
|
||||
@@ -278,6 +280,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
-(void)quitGroupWithRoomId:(NSString*)roomId;
|
||||
|
||||
-(void)sendChatMessage:(NSString *)message messageType:(QXRoomMessageType)messageType needInsertMessage:(BOOL)needInsertMessage;
|
||||
/// 发送表情
|
||||
-(void)sendChatEmoji:(QXEmojiModel *)emoji;
|
||||
|
||||
-(void)sendC2CMessage:(NSString *)message messageType:(QXRoomMessageType)messageType userId:(NSString*)userId;
|
||||
@end
|
||||
|
||||
@@ -718,6 +718,12 @@
|
||||
userInfo.uid = userModel.user_id.longLongValue;
|
||||
userInfo.volume = 0;
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:noticeUserSpeak object:userInfo];
|
||||
}else if (meesageType == QXRoomMessageTypeEmoji) {
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
model.messageType = QXRoomChatMessageTypeEmoji;
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -733,6 +739,7 @@
|
||||
@"nickname":[QXGlobal shareGlobal].loginModel.nickname?[QXGlobal shareGlobal].loginModel.nickname:@"",
|
||||
@"avatar":[QXGlobal shareGlobal].loginModel.avatar?[QXGlobal shareGlobal].loginModel.avatar:@"",
|
||||
@"icon":[QXGlobal shareGlobal].loginModel.icon?[QXGlobal shareGlobal].loginModel.icon:@"",
|
||||
@"chat_bubble":[QXGlobal shareGlobal].loginModel.chat_bubble?:@"",
|
||||
},
|
||||
@"text":message
|
||||
}
|
||||
@@ -745,6 +752,7 @@
|
||||
userInfo.nickname = [QXGlobal shareGlobal].loginModel.nickname;
|
||||
userInfo.user_id = [QXGlobal shareGlobal].loginModel.user_id;
|
||||
userInfo.icon = [QXGlobal shareGlobal].loginModel.icon;
|
||||
userInfo.chat_bubble = [QXGlobal shareGlobal].loginModel.chat_bubble;
|
||||
model.FromUserInfo = userInfo;
|
||||
model.messageType = QXRoomChatMessageTypeChat;
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
@@ -761,7 +769,47 @@
|
||||
|
||||
|
||||
}
|
||||
|
||||
-(void)sendChatEmoji:(QXEmojiModel *)emoji{
|
||||
NSDictionary *dict = @{
|
||||
@"RoomId":self.roomId?self.roomId:@"",
|
||||
@"MsgType":[NSNumber numberWithInteger:QXRoomMessageTypeEmoji],
|
||||
@"Text":@{
|
||||
@"FromUserInfo":@{
|
||||
@"user_id":[QXGlobal shareGlobal].loginModel.user_id?[QXGlobal shareGlobal].loginModel.user_id:@"",
|
||||
@"nickname":[QXGlobal shareGlobal].loginModel.nickname?[QXGlobal shareGlobal].loginModel.nickname:@"",
|
||||
@"avatar":[QXGlobal shareGlobal].loginModel.avatar?[QXGlobal shareGlobal].loginModel.avatar:@"",
|
||||
@"icon":[QXGlobal shareGlobal].loginModel.icon?[QXGlobal shareGlobal].loginModel.icon:@"",
|
||||
@"chat_bubble":[QXGlobal shareGlobal].loginModel.chat_bubble?:@"",
|
||||
},
|
||||
@"emoji":@{
|
||||
@"image":emoji.image?:@"",
|
||||
@"animate_image":emoji.animate_image?:@""
|
||||
},
|
||||
@"text":@""
|
||||
}
|
||||
};
|
||||
QXRoomChatListModel *model = [[QXRoomChatListModel alloc] init];
|
||||
model.text = @"";
|
||||
QXUserHomeModel *userInfo = [[QXUserHomeModel alloc] init];
|
||||
userInfo.avatar = [QXGlobal shareGlobal].loginModel.avatar;
|
||||
userInfo.nickname = [QXGlobal shareGlobal].loginModel.nickname;
|
||||
userInfo.user_id = [QXGlobal shareGlobal].loginModel.user_id;
|
||||
userInfo.icon = [QXGlobal shareGlobal].loginModel.icon;
|
||||
userInfo.chat_bubble = [QXGlobal shareGlobal].loginModel.chat_bubble;
|
||||
model.FromUserInfo = userInfo;
|
||||
model.messageType = QXRoomChatMessageTypeEmoji;
|
||||
model.emoji = emoji;
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
NSString *jsonStr = [dict jsonStringEncoded];
|
||||
NSData *data =[jsonStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[[V2TIMManager sharedInstance] sendGroupCustomMessage:data to:self.groupId priority:V2TIM_PRIORITY_NORMAL succ:^{
|
||||
QXLOG(@"发送自定义消息成功");
|
||||
} fail:^(int code, NSString * _Nullable desc) {
|
||||
QXLOG(@"发送自定义消息失败");
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)sendC2CMessage:(NSString *)message messageType:(QXRoomMessageType)messageType userId:(NSString *)userId{
|
||||
NSDictionary *dict = @{
|
||||
@@ -769,10 +817,11 @@
|
||||
@"MsgType":[NSNumber numberWithInteger:messageType],
|
||||
@"Text":@{
|
||||
@"FromUserInfo":@{
|
||||
@"user_id":[QXGlobal shareGlobal].loginModel.user_id?[QXGlobal shareGlobal].loginModel.user_id:@"",
|
||||
@"nickname":[QXGlobal shareGlobal].loginModel.nickname?[QXGlobal shareGlobal].loginModel.nickname:@"",
|
||||
@"avatar":[QXGlobal shareGlobal].loginModel.avatar?[QXGlobal shareGlobal].loginModel.avatar:@"",
|
||||
@"icon":[QXGlobal shareGlobal].loginModel.icon?[QXGlobal shareGlobal].loginModel.icon:@"",
|
||||
@"user_id":[QXGlobal shareGlobal].loginModel.user_id?:@"",
|
||||
@"nickname":[QXGlobal shareGlobal].loginModel.nickname?:@"",
|
||||
@"avatar":[QXGlobal shareGlobal].loginModel.avatar?:@"",
|
||||
@"icon":[QXGlobal shareGlobal].loginModel.icon?:@"",
|
||||
@"chat_bubble":[QXGlobal shareGlobal].loginModel.chat_bubble?:@"",
|
||||
},
|
||||
@"text":message
|
||||
}
|
||||
|
||||
@@ -214,20 +214,35 @@
|
||||
}
|
||||
NSMutableArray *files = [[NSMutableArray alloc] initWithObjects:fileData, nil];
|
||||
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
// NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
// NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// showLoadingInView(self.view);
|
||||
// [[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// hideLoadingInView(weakSelf.view);
|
||||
// });
|
||||
// if (state == UploadImageSuccess) {
|
||||
// NSString *fileName = [names lastObject];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// weakSelf.avartar = fileUrl;
|
||||
// [weakSelf.selectedBtn sd_setImageWithURL:[NSURL URLWithString:fileUrl] forState:(UIControlStateNormal)];
|
||||
// }else{
|
||||
// showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.view);
|
||||
// }
|
||||
// }];
|
||||
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.view);
|
||||
[[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],contentType];
|
||||
[[QXCOSUploadManager shareManager] uploadFile:files withObjectKey:@[fileName] isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
hideLoadingInView(weakSelf.view);
|
||||
});
|
||||
if (state == UploadImageSuccess) {
|
||||
NSString *fileName = [names lastObject];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
weakSelf.avartar = fileUrl;
|
||||
[weakSelf.selectedBtn sd_setImageWithURL:[NSURL URLWithString:fileUrl] forState:(UIControlStateNormal)];
|
||||
if (state == QXCOSUploadImageSuccess) {
|
||||
weakSelf.avartar = names.firstObject;
|
||||
[weakSelf.selectedBtn sd_setImageWithURL:[NSURL URLWithString:weakSelf.avartar] forState:(UIControlStateNormal)];
|
||||
}else{
|
||||
showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.view);
|
||||
}
|
||||
|
||||
@@ -386,19 +386,38 @@
|
||||
[self presentViewController:imagePickerVc animated:YES completion:nil];
|
||||
}
|
||||
- (void)OSSUploadPhoto{
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// showLoadingInView(self.view);
|
||||
// [[QXOSSManager sharedInstance] activityUploadFile:self.uploadArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async_and_wait(dispatch_get_main_queue(), ^{
|
||||
// [weakSelf.urlArray removeAllObjects];
|
||||
// hideLoadingInView(weakSelf.view);
|
||||
// if (state == UploadImageSuccess) {
|
||||
// showToast(QXText(@"上传成功"));
|
||||
// for (int i = 0; i < names.count; i++) {
|
||||
// NSString *name = names[i];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
// [weakSelf.urlArray addObject:fileUrl];
|
||||
// }
|
||||
// [weakSelf uploadImages];
|
||||
// }else{
|
||||
// showToast(QXText(@"上传失败"));
|
||||
// }
|
||||
// });
|
||||
// }];
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.view);
|
||||
[[QXOSSManager sharedInstance] activityUploadFile:self.uploadArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
dispatch_async_and_wait(dispatch_get_main_queue(), ^{
|
||||
[weakSelf.urlArray removeAllObjects];
|
||||
[[QXCOSUploadManager shareManager] activityUploadFile:self.uploadArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
hideLoadingInView(weakSelf.view);
|
||||
if (state == UploadImageSuccess) {
|
||||
showToast(QXText(@"上传成功"));
|
||||
[weakSelf.urlArray removeAllObjects];
|
||||
if (state == QXCOSUploadImageSuccess) {
|
||||
for (int i = 0; i < names.count; i++) {
|
||||
NSString *name = names[i];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
[weakSelf.urlArray addObject:fileUrl];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
[weakSelf.urlArray addObject:name];
|
||||
}
|
||||
showToast(QXText(@"上传成功"));
|
||||
[weakSelf uploadImages];
|
||||
}else{
|
||||
showToast(QXText(@"上传失败"));
|
||||
@@ -423,8 +442,10 @@
|
||||
}];
|
||||
}
|
||||
- (NSString *)imagePathWithKey:(NSString *)keyPath {
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;
|
||||
return [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,keyPath];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;
|
||||
// return [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,keyPath];
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],keyPath];
|
||||
return fileName;
|
||||
}
|
||||
|
||||
-(NSMutableArray *)valueArray{
|
||||
|
||||
@@ -107,8 +107,11 @@
|
||||
[QXMineNetwork setUserDressIsCancel:isCancel udid:model.udid type:self.model.id successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
if (weakSelf.model.id.intValue == 1) {
|
||||
[QXGlobal shareGlobal].loginModel.dress = model.play_image;
|
||||
[[QXGlobal shareGlobal] updateUserInfoWithMolde:[QXGlobal shareGlobal].loginModel];
|
||||
}
|
||||
if (weakSelf.model.id.intValue == 9) {
|
||||
[QXGlobal shareGlobal].loginModel.chat_bubble = model.base_image;
|
||||
}
|
||||
[[QXGlobal shareGlobal] updateUserInfoWithMolde:[QXGlobal shareGlobal].loginModel];
|
||||
showToast(@"设置成功");
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#import "UIImage+QX.h"
|
||||
#import "QXTimer.h"
|
||||
#import "QXMineNetwork.h"
|
||||
#import "QXCOSUploadManager.h"
|
||||
|
||||
@interface QXCreateRoomViewController ()<UITextFieldDelegate>
|
||||
@property (nonatomic,strong) UILabel *roomCoverLabel;
|
||||
@@ -260,26 +261,33 @@
|
||||
QXLOG(@"资源加载错误");
|
||||
return;
|
||||
}
|
||||
if (fileData.length > 1024*1024 && [contentType isEqualToString:IMG_FILE_BASE_PATH]) {
|
||||
QXLOG(@"请不要上传超过1M的头像");
|
||||
return;
|
||||
}
|
||||
NSMutableArray *files = [[NSMutableArray alloc] initWithObjects:fileData, nil];
|
||||
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
// NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
// NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// [QXProjectTools showLoadingInView:self.view];
|
||||
// [[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// [QXProjectTools hideLoadingInView:self.view];
|
||||
// });
|
||||
// if (state == UploadImageSuccess) {
|
||||
// NSString *fileName = [names lastObject];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// weakSelf.roomCoverUrl = fileUrl;
|
||||
// [weakSelf.roomImageView sd_setImageWithURL:[NSURL URLWithString:fileUrl] placeholderImage:[UIImage imageNamed:@"mine_room_cover_add"]];
|
||||
// }else{
|
||||
// QXLOG(@"文件上传失败,请重新尝试");
|
||||
// }
|
||||
// }];
|
||||
__weak typeof(self)weakSelf = self;
|
||||
[QXProjectTools showLoadingInView:self.view];
|
||||
[[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[QXProjectTools hideLoadingInView:self.view];
|
||||
});
|
||||
if (state == UploadImageSuccess) {
|
||||
NSString *fileName = [names lastObject];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
weakSelf.roomCoverUrl = fileUrl;
|
||||
[weakSelf.roomImageView sd_setImageWithURL:[NSURL URLWithString:fileUrl] placeholderImage:[UIImage imageNamed:@"mine_room_cover_add"]];
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],contentType];
|
||||
[[QXCOSUploadManager shareManager] uploadFile:files withObjectKey:@[fileName] isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
QXLOG(@"uploadstate --- %ld ---url---%@",state,names);
|
||||
if (state == QXCOSUploadImageSuccess) {
|
||||
weakSelf.roomCoverUrl = names.firstObject;
|
||||
[weakSelf.roomImageView sd_setImageWithURL:[NSURL URLWithString:weakSelf.roomCoverUrl] placeholderImage:[UIImage imageNamed:@"mine_room_cover_add"]];
|
||||
}else{
|
||||
QXLOG(@"文件上传失败,请重新尝试");
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic,strong)NSString *charm_level;
|
||||
/// 装扮
|
||||
@property (nonatomic,strong)NSString *dress;
|
||||
/// 聊天气泡
|
||||
@property (nonatomic,strong)NSString *chat_bubble;
|
||||
/// 是否已实名 1 已实名 0 未实名
|
||||
@property (nonatomic,strong)NSString *auth;
|
||||
/// 是否使用靓号 0未使用 1 已使用
|
||||
@@ -64,6 +66,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic,strong)NSString *sex;
|
||||
/// 装扮
|
||||
@property (nonatomic,strong)NSString *dress;
|
||||
/// 聊天气泡
|
||||
@property (nonatomic,strong)NSString *chat_bubble;
|
||||
/// ip
|
||||
@property (nonatomic,strong)NSString *loginip;
|
||||
/// 昵称
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#import "QXRoomUserCharmModel.h"
|
||||
#import "QXRoomHourRankModel.h"
|
||||
#import "QXRedPacketModel.h"
|
||||
#import "QXEmojiTypeModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@@ -1135,6 +1136,25 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
room_id:(NSString*)room_id
|
||||
successBlock:(void (^)(NSDictionary* dict))successBlock
|
||||
failBlock:(void (^)(NSError * error, NSString * msg))failBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
表情类型列表
|
||||
*/
|
||||
+(void)roomEmojiTypeListSuccessBlock:(void (^)(NSArray <QXEmojiTypeModel*>* list))successBlock
|
||||
failBlock:(void (^)(NSError * error, NSString * msg))failBlock;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
表情列表
|
||||
*/
|
||||
+(void)roomEmojiListWithTypeId:(NSString*)type_id
|
||||
pid:(NSString*)pid
|
||||
successBlock:(void (^)(NSArray <QXEmojiModel*>* list))successBlock
|
||||
failBlock:(void (^)(NSError * error, NSString * msg))failBlock;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
[QXGlobal shareGlobal].loginModel.icon = userModel.icon;
|
||||
[QXGlobal shareGlobal].loginModel.dress = userModel.dress;
|
||||
[QXGlobal shareGlobal].loginModel.auth = userModel.auth.intValue;
|
||||
[QXGlobal shareGlobal].loginModel.chat_bubble = userModel.chat_bubble;
|
||||
[[QXGlobal shareGlobal] updateUserInfoWithMolde:[QXGlobal shareGlobal].loginModel];
|
||||
[[NSUserDefaults standardUserDefaults] setInteger:userModel.is_can_chat forKey:kIsCanChat];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:userModel.can_chat_money forKey:kIsCanChatMoney];
|
||||
@@ -2209,4 +2210,42 @@
|
||||
failBlock(error,msg);
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
表情类型列表
|
||||
*/
|
||||
+(void)roomEmojiTypeListSuccessBlock:(void (^)(NSArray <QXEmojiTypeModel*>* list))successBlock
|
||||
failBlock:(void (^)(NSError * error, NSString * msg))failBlock{
|
||||
[[QXRequset shareInstance] getWithUrl:QXRoomEmoji parameters:@{} needCache:NO success:^(id responseObject) {
|
||||
if (successBlock) {
|
||||
NSArray*list = [NSArray yy_modelArrayWithClass:[QXEmojiTypeModel class] json:responseObject[@"data"]];
|
||||
successBlock(list);
|
||||
}
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
failBlock(error,msg);
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
表情列表
|
||||
*/
|
||||
+(void)roomEmojiListWithTypeId:(NSString*)type_id
|
||||
pid:(NSString*)pid
|
||||
successBlock:(void (^)(NSArray <QXEmojiModel*>* list))successBlock
|
||||
failBlock:(void (^)(NSError * error, NSString * msg))failBlock{
|
||||
NSDictionary *parameters =@{
|
||||
@"type_id":type_id?type_id:@"",
|
||||
// @"pid":pid?pid:@""
|
||||
};
|
||||
[[QXRequset shareInstance] getWithUrl:QXRoomEmojiList parameters:parameters needCache:NO success:^(id responseObject) {
|
||||
if (successBlock) {
|
||||
NSArray*list = [NSArray yy_modelArrayWithClass:[QXEmojiModel class] json:responseObject[@"data"]];
|
||||
successBlock(list);
|
||||
}
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
failBlock(error,msg);
|
||||
}];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -206,9 +206,53 @@
|
||||
[self.viewController presentViewController:imagePickerVc animated:YES completion:nil];
|
||||
}
|
||||
- (void)OSSUploadPhoto{
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// showLoadingInView(self.viewController.view);
|
||||
// [[QXOSSManager sharedInstance] activityUploadFile:self.dataArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async_and_wait(dispatch_get_main_queue(), ^{
|
||||
// hideLoadingInView(weakSelf.viewController.view);
|
||||
// if (state == UploadImageSuccess) {
|
||||
// showToast(QXText(@"上传成功"));
|
||||
// if (self.imgs == nil) {
|
||||
// [weakSelf.urlArray removeAllObjects];
|
||||
// if (names.count < self.maxCount) {
|
||||
// for (NSString*fileName in names) {
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// [weakSelf.urlArray addObject:fileUrl];
|
||||
// }
|
||||
// [weakSelf.urlArray addObject:@"mine_room_cover_add"];
|
||||
// }else if (names.count == self.maxCount){
|
||||
// for (NSString*fileName in names) {
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// [weakSelf.urlArray addObject:fileUrl];
|
||||
// }
|
||||
// }else{
|
||||
// for (int i = 0; i < self.maxCount; i++) {
|
||||
// NSString *name = names[i];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
// [weakSelf.urlArray addObject:fileUrl];
|
||||
// }
|
||||
// }
|
||||
// [weakSelf uploadImgs];
|
||||
// }else{
|
||||
// NSMutableArray *arr = [NSMutableArray array];
|
||||
// for (NSString*fileName in names) {
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// [weakSelf.urlArray insertObject:fileUrl atIndex:0];
|
||||
// [arr addObject:fileUrl];
|
||||
// }
|
||||
// [weakSelf uploadImgs:arr];
|
||||
// }
|
||||
//
|
||||
// }else{
|
||||
// showToast(QXText(@"上传失败"));
|
||||
// }
|
||||
// });
|
||||
// }];
|
||||
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.viewController.view);
|
||||
[[QXOSSManager sharedInstance] activityUploadFile:self.dataArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
[[QXCOSUploadManager shareManager] activityUploadFile:self.dataArray withObjectKey:self.keyArray isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
dispatch_async_and_wait(dispatch_get_main_queue(), ^{
|
||||
hideLoadingInView(weakSelf.viewController.view);
|
||||
if (state == UploadImageSuccess) {
|
||||
@@ -217,29 +261,29 @@
|
||||
[weakSelf.urlArray removeAllObjects];
|
||||
if (names.count < self.maxCount) {
|
||||
for (NSString*fileName in names) {
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray addObject:fileUrl];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray addObject:fileName];
|
||||
}
|
||||
[weakSelf.urlArray addObject:@"mine_room_cover_add"];
|
||||
}else if (names.count == self.maxCount){
|
||||
for (NSString*fileName in names) {
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray addObject:fileUrl];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray addObject:fileName];
|
||||
}
|
||||
}else{
|
||||
for (int i = 0; i < self.maxCount; i++) {
|
||||
NSString *name = names[i];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
[weakSelf.urlArray addObject:fileUrl];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,name];
|
||||
[weakSelf.urlArray addObject:name];
|
||||
}
|
||||
}
|
||||
[weakSelf uploadImgs];
|
||||
}else{
|
||||
NSMutableArray *arr = [NSMutableArray array];
|
||||
for (NSString*fileName in names) {
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray insertObject:fileUrl atIndex:0];
|
||||
[arr addObject:fileUrl];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
[weakSelf.urlArray insertObject:fileName atIndex:0];
|
||||
[arr addObject:fileName];
|
||||
}
|
||||
[weakSelf uploadImgs:arr];
|
||||
}
|
||||
@@ -251,8 +295,10 @@
|
||||
}];
|
||||
}
|
||||
- (NSString *)imagePathWithKey:(NSString *)keyPath {
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;
|
||||
return [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,keyPath];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;
|
||||
// return [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,keyPath];
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],keyPath];
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -122,22 +122,33 @@
|
||||
}
|
||||
NSMutableArray *files = [[NSMutableArray alloc] initWithObjects:fileData, nil];
|
||||
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
// NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
// NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// showLoadingInView(self.viewController.view);
|
||||
// [[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// hideLoadingInView(weakSelf.viewController.view);
|
||||
// });
|
||||
// if (state == UploadImageSuccess) {
|
||||
// NSString *fileName = [names lastObject];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// weakSelf.avartar = fileUrl;
|
||||
// [weakSelf chamgeAvatar];
|
||||
// }else{
|
||||
// showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.viewController.view);
|
||||
// }
|
||||
// }];
|
||||
__weak typeof(self)weakSelf = self;
|
||||
showLoadingInView(self.viewController.view);
|
||||
[[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
hideLoadingInView(weakSelf.viewController.view);
|
||||
});
|
||||
if (state == UploadImageSuccess) {
|
||||
NSString *fileName = [names lastObject];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
weakSelf.avartar = fileUrl;
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],contentType];
|
||||
[[QXCOSUploadManager shareManager] uploadFile:files withObjectKey:@[fileName] isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
QXLOG(@"uploadstate --- %ld ---url---%@",state,names);
|
||||
if (state == QXCOSUploadImageSuccess) {
|
||||
weakSelf.avartar = names.firstObject;
|
||||
[weakSelf chamgeAvatar];
|
||||
}else{
|
||||
showToastInView(QXText(@"文件上传失败,请重新尝试"), weakSelf.viewController.view);
|
||||
QXLOG(@"文件上传失败,请重新尝试");
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1010 B |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 736 KiB After Width: | Height: | Size: 354 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1010 B |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 7.6 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 4.7 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 9.0 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 678 KiB After Width: | Height: | Size: 354 KiB |
6
QXLive/Other/Assets.xcassets/chat_buble/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,12 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "Chat, Messages@2x.png",
|
||||
"filename" : "chat_buble1@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "Chat, Messages@3x.png",
|
||||
"filename" : "chat_buble1@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
BIN
QXLive/Other/Assets.xcassets/chat_buble/chat_bubble1.imageset/chat_buble1@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
QXLive/Other/Assets.xcassets/chat_buble/chat_bubble1.imageset/chat_buble1@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 234 KiB |
22
QXLive/Other/Assets.xcassets/chat_buble/chat_bubble2.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "chat_bubble2@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "chat_bubble2@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
QXLive/Other/Assets.xcassets/chat_buble/chat_bubble2.imageset/chat_bubble2@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 69 KiB |
BIN
QXLive/Other/Assets.xcassets/chat_buble/chat_bubble2.imageset/chat_bubble2@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 165 KiB |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 14 KiB |
@@ -5,12 +5,12 @@
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "mi_di@2x.png",
|
||||
"filename" : "yusheng@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "mi_di@3x.png",
|
||||
"filename" : "yusheng@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
BIN
QXLive/Other/Assets.xcassets/login/yusheng.imageset/yusheng@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
QXLive/Other/Assets.xcassets/login/yusheng.imageset/yusheng@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 32 KiB |
22
QXLive/Other/Assets.xcassets/room/room_emoji_btn.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "room_emoji_btn@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "room_emoji_btn@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
QXLive/Other/Assets.xcassets/room/room_emoji_btn.imageset/room_emoji_btn@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
QXLive/Other/Assets.xcassets/room/room_emoji_btn.imageset/room_emoji_btn@3x.png
vendored
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 904 B |
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -87,7 +87,8 @@ static NSString *const OSSEndPoint = @"oss-cn-beijing.aliyuncs.com";
|
||||
|
||||
|
||||
//文件路径
|
||||
static NSString *const IMG_FILE_BASE_PATH = @"ios_images/";
|
||||
//static NSString *const IMG_FILE_BASE_PATH = @"ios_images/";
|
||||
static NSString *const IMG_FILE_BASE_PATH = @"images/ios_images/";
|
||||
static NSString *const VIDEO_FILE_BASE_PATH = @"ios/videos/";
|
||||
static NSString *const AUDIO_FILE_BASE_PATH = @"ios_audio/";
|
||||
static NSString *const CHAT_IMG_FILE_BASE_PATH = @"emchat/image/ios/";
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#import "UIControl+QX.h"
|
||||
#import "QXBaseWebViewController.h"
|
||||
#import "QXBaseNavigationController.h"
|
||||
#import "QXCOSUploadManager.h"
|
||||
|
||||
#import "QXLive-Bridging-Header.h"
|
||||
#endif /* PrefixHeader_pch */
|
||||
|
||||
@@ -466,4 +466,11 @@ static NSString * QXRoomDrawRedpacket = @"api/Redpacket/grab";
|
||||
static NSString * QXRoomRedpacketList = @"api/Redpacket/roomRedPackets";
|
||||
/// 红包详情
|
||||
static NSString * QXRoomRedpacketDetail = @"api/Redpacket/detail";
|
||||
/// 表情类型列表
|
||||
static NSString * QXRoomEmoji = @"api/RoomEmoji/type_list";
|
||||
/// 表情类型列表
|
||||
static NSString * QXRoomEmojiList = @"api/RoomEmoji/emoji_list";
|
||||
|
||||
/// 获取上传临时密钥
|
||||
static NSString * QXGetCosTempKeys = @"api/Upload/getTempKeys";
|
||||
#endif /* Api_h */
|
||||
|
||||
|
Before Width: | Height: | Size: 312 KiB |
BIN
QXLive/Other/chat_buble.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
@@ -35,6 +35,7 @@
|
||||
#import "QXRoomViewController+Activity.h"
|
||||
#import "QXRoomViewController+QXGiftDrift.h"
|
||||
#import "QXRedBagRecordViewController.h"
|
||||
#import "QXRoomEmojiView.h"
|
||||
|
||||
@interface QXRoomViewController ()<
|
||||
QXRoomBottomViewDelegate,
|
||||
@@ -82,7 +83,7 @@ QXRoomUserInfoViewDelegate
|
||||
@property (nonatomic,strong)QXAllRoomHourRankView *hourRankView;
|
||||
@property (nonatomic,strong)QXAllRoomHourRankTagView *hourRankIconView;
|
||||
|
||||
|
||||
@property (nonatomic,strong)QXRoomEmojiView *emojiView;
|
||||
@end
|
||||
|
||||
@implementation QXRoomViewController
|
||||
@@ -1370,6 +1371,10 @@ QXRoomUserInfoViewDelegate
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QXRoomBottomViewEventTypeEmoji:{
|
||||
[self.emojiView showInView:self.view];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1989,5 +1994,12 @@ QXRoomUserInfoViewDelegate
|
||||
}
|
||||
return _redbagListView;
|
||||
}
|
||||
|
||||
-(QXRoomEmojiView *)emojiView{
|
||||
if (!_emojiView) {
|
||||
_emojiView = [[QXRoomEmojiView alloc] init];
|
||||
}
|
||||
return _emojiView;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
41
QXLive/Room(房间)/Model/QXEmojiTypeModel.h
Normal file
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// QXEmojiTypeModel.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/22.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class QXEmojiChirldModel;
|
||||
@interface QXEmojiTypeModel : NSObject
|
||||
@property (nonatomic,strong)NSString *id;
|
||||
@property (nonatomic,strong)NSString *type_name;
|
||||
@end
|
||||
|
||||
|
||||
@interface QXEmojiModel : NSObject
|
||||
@property (nonatomic,strong)NSString *id;
|
||||
@property (nonatomic,strong)NSString *pid;
|
||||
@property (nonatomic,strong)NSString *type_id;
|
||||
///
|
||||
@property (nonatomic,strong)NSString *name;
|
||||
/// 表情图片
|
||||
@property (nonatomic,strong)NSString *image;
|
||||
/// 动图表情动画
|
||||
@property (nonatomic,strong)NSString *animate_image;
|
||||
@property (nonatomic,strong)NSArray<QXEmojiChirldModel*> *children;
|
||||
/// 是否已经动画过了
|
||||
@property (nonatomic,assign)BOOL isAnimated;
|
||||
@end
|
||||
|
||||
|
||||
@interface QXEmojiChirldModel : NSObject
|
||||
@property (nonatomic,strong)NSString *id;
|
||||
@property (nonatomic,strong)NSString *pid;
|
||||
@property (nonatomic,strong)NSString *type_id;
|
||||
@property (nonatomic,strong)NSString *name;
|
||||
@property (nonatomic,strong)NSString *image;
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
30
QXLive/Room(房间)/Model/QXEmojiTypeModel.m
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// QXEmojiTypeModel.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/22.
|
||||
//
|
||||
|
||||
#import "QXEmojiTypeModel.h"
|
||||
|
||||
@implementation QXEmojiTypeModel
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXEmojiModel
|
||||
|
||||
+(NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
|
||||
return @{
|
||||
@"children" : @"QXEmojiChirldModel",
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXEmojiChirldModel
|
||||
|
||||
|
||||
|
||||
@end
|
||||
@@ -25,6 +25,8 @@ typedef NS_ENUM(NSInteger) {
|
||||
QXRoomBottomViewEventTypeGift,
|
||||
/// 设置
|
||||
QXRoomBottomViewEventTypeSetting,
|
||||
/// 表情
|
||||
QXRoomBottomViewEventTypeEmoji = 50,
|
||||
}QXRoomBottomViewEventType;
|
||||
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
@interface QXRoomBottomView()<QXDynamicCommentInputViewDelegate>
|
||||
@property (nonatomic,strong)UIView *sayBg;
|
||||
@property (nonatomic,strong)UIImageView *sayImageView;
|
||||
@property (nonatomic,strong)UILabel *sayLabel;
|
||||
@property (nonatomic,strong)UIButton *emojiBtn;
|
||||
@property (nonatomic,strong)UIButton *chatBtn;
|
||||
|
||||
/// voice
|
||||
@property (nonatomic,strong)QXBadgeButton *playAudioBtn;
|
||||
@@ -52,14 +52,6 @@
|
||||
self.sayBg = [[UIView alloc] init];
|
||||
self.sayBg.backgroundColor = RGB16A(0xffffff, 0.2);
|
||||
[self.sayBg addRoundedCornersWithRadius:18];
|
||||
[self.sayBg addTapBlock:^(id _Nonnull obj) {
|
||||
if (weakSelf.roomModel.user_info.is_mute.intValue == 1) {
|
||||
showToast(@"您已被禁言");
|
||||
return;
|
||||
}
|
||||
[weakSelf.vc.view addSubview:weakSelf.commentView];
|
||||
[weakSelf.commentView.textField becomeFirstResponder];
|
||||
}];
|
||||
[self addSubview:self.sayBg];
|
||||
[self.sayBg mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
@@ -68,22 +60,25 @@
|
||||
make.width.mas_equalTo(106);
|
||||
}];
|
||||
|
||||
self.sayImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"room_say_icon"]];
|
||||
[self.sayBg addSubview:self.sayImageView];
|
||||
[self.sayImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(10);
|
||||
make.centerY.equalTo(self.sayBg);
|
||||
make.width.height.mas_equalTo(24);
|
||||
self.emojiBtn = [[UIButton alloc] init];
|
||||
self.emojiBtn.tag = QXRoomBottomViewEventTypeEmoji;
|
||||
[self.emojiBtn addTarget:self action:@selector(eventAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.emojiBtn setImage:[UIImage imageNamed:@"room_emoji_btn"] forState:(UIControlStateNormal)];
|
||||
[self.sayBg addSubview:self.emojiBtn];
|
||||
[self.emojiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.bottom.equalTo(self.sayBg);
|
||||
make.width.equalTo(self.emojiBtn.mas_height);
|
||||
}];
|
||||
|
||||
self.sayLabel = [[UILabel alloc] init];
|
||||
self.sayLabel.textColor = [UIColor whiteColor];
|
||||
self.sayLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.sayLabel.text = QXText(@"说点什么");
|
||||
self.sayLabel.textAlignment = NSTextAlignmentCenter;
|
||||
[self.sayBg addSubview:self.sayLabel];
|
||||
[self.sayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.sayImageView.mas_right);
|
||||
self.chatBtn = [[UIButton alloc] init];
|
||||
[self.chatBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
|
||||
[self.chatBtn addTarget:self action:@selector(chatAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
self.chatBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.chatBtn setTitle:QXText(@"说点什么") forState:(UIControlStateNormal)];
|
||||
[self.sayBg addSubview:self.chatBtn];
|
||||
[self.chatBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.emojiBtn.mas_right);
|
||||
make.centerY.equalTo(self.sayBg);
|
||||
make.right.equalTo(self.sayBg);
|
||||
}];
|
||||
@@ -323,6 +318,15 @@
|
||||
-(void)setPlayAudioStatus:(BOOL)status{
|
||||
self.playAudioBtn.selected = status;
|
||||
}
|
||||
|
||||
-(void)chatAction{
|
||||
if (self.roomModel.user_info.is_mute.intValue == 1) {
|
||||
showToast(@"您已被禁言");
|
||||
return;
|
||||
}
|
||||
[self.vc.view addSubview:self.commentView];
|
||||
[self.commentView.textField becomeFirstResponder];
|
||||
}
|
||||
-(void)eventAction:(UIButton*)sender{
|
||||
|
||||
if (sender == self.audioBtn) {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#import "QXSongListModel.h"
|
||||
#import "QXRoomSeatDelegate.h"
|
||||
#import "QXRoomFriendRelationModel.h"
|
||||
#import "QXEmojiTypeModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
typedef NS_ENUM(NSInteger) {
|
||||
@@ -20,6 +21,8 @@ typedef NS_ENUM(NSInteger) {
|
||||
QXRoomChatMessageTypeChat = 1,
|
||||
/// 礼物消息
|
||||
QXRoomChatMessageTypeGift = 2,
|
||||
/// 表情
|
||||
QXRoomChatMessageTypeEmoji = 3,
|
||||
}QXRoomChatMessageType;
|
||||
@class QXRoomChatListModel;
|
||||
@interface QXRoomChatListView : UIView
|
||||
@@ -31,6 +34,7 @@ typedef NS_ENUM(NSInteger) {
|
||||
@end
|
||||
|
||||
@interface QXRoomChatListCell : UITableViewCell
|
||||
@property(nonatomic,strong)UIView *bgView;
|
||||
@property(nonatomic,strong)UIImageView *headerImageView;
|
||||
@property(nonatomic,strong)UIView *iconBgView;
|
||||
@property(nonatomic,strong)NSMutableArray *iconViewArray;
|
||||
@@ -44,6 +48,7 @@ typedef NS_ENUM(NSInteger) {
|
||||
@end
|
||||
|
||||
@interface QXRoomGiftListCell : UITableViewCell
|
||||
@property(nonatomic,strong)UIView *bgView;
|
||||
@property(nonatomic,strong)UIImageView *headerImageView;
|
||||
@property(nonatomic,strong)UIView *iconBgView;
|
||||
/// 礼物图片
|
||||
@@ -60,9 +65,27 @@ typedef NS_ENUM(NSInteger) {
|
||||
+(instancetype)cellWithTableView:(UITableView *)tableView;
|
||||
@end
|
||||
|
||||
@interface QXRoomEmojiListCell : UITableViewCell
|
||||
@property(nonatomic,strong)UIView *bgView;
|
||||
@property(nonatomic,strong)UIImageView *headerImageView;
|
||||
@property(nonatomic,strong)UIView *iconBgView;
|
||||
/// 礼物图片
|
||||
@property(nonatomic,strong)UIImageView *giftImageView;
|
||||
/// 礼物数量
|
||||
@property(nonatomic,strong)UILabel *giftCountLabel;
|
||||
@property(nonatomic,strong)NSMutableArray *iconViewArray;
|
||||
@property(nonatomic,strong)UILabel *nameLabel;
|
||||
@property(nonatomic,strong)SDAnimatedImageView *animatedImageView;
|
||||
@property(nonatomic,strong)UIImageView *bubbleImageView;
|
||||
@property (nonatomic,strong)QXRoomChatListModel *message;
|
||||
@property (nonatomic,weak)id<QXRoomSeatDelegate>delegate;
|
||||
-(void)loadBubble;
|
||||
+(instancetype)cellWithTableView:(UITableView *)tableView;
|
||||
@end
|
||||
|
||||
|
||||
@interface QXRoomChatListSystemCell : UITableViewCell
|
||||
@property(nonatomic,strong)UIView *bgView;
|
||||
@property(nonatomic,strong)UIImageView *bubbleImageView;
|
||||
@property(nonatomic,strong)UILabel *titleLabel;
|
||||
@property (nonatomic,strong)QXRoomChatListModel *message;
|
||||
+(instancetype)cellWithTableView:(UITableView *)tableView;
|
||||
@@ -82,7 +105,6 @@ typedef NS_ENUM(NSInteger) {
|
||||
@property (nonatomic,strong)QXSongListModel* songInfo;
|
||||
/// 下一首音乐
|
||||
@property (nonatomic,strong)QXSongListModel* nextInfo;
|
||||
@property (nonatomic,assign)BOOL havBubble;
|
||||
|
||||
@property (nonatomic,strong)NSString* total;
|
||||
|
||||
@@ -93,6 +115,9 @@ typedef NS_ENUM(NSInteger) {
|
||||
|
||||
@property (nonatomic,strong)QXRoomFriendRelationModel* friend_user;
|
||||
|
||||
/// 发送表情
|
||||
@property (nonatomic,strong)QXEmojiModel* emoji;
|
||||
|
||||
/// 礼物数量 巡乐会
|
||||
@property (nonatomic,strong)NSString *gift_num;
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#import "UIImage+WebP.h"
|
||||
#define messageNameColor RGB16(0x00C8FF)
|
||||
#define messageGiftColor RGB16(0xFFE309)
|
||||
#define messageBubbleColor RGB16A(0x000000, 0.3)
|
||||
#define messageBubbleMargin 4
|
||||
NSArray<NSValue *> *findAllOccurrencesOfString(NSString *fullString, NSString *substring) {
|
||||
NSMutableArray<NSValue *> *occurrences = [NSMutableArray array];
|
||||
NSRange searchRange = NSMakeRange(0, fullString.length);
|
||||
@@ -247,6 +249,11 @@ NSInteger maxMessageCount = 20;
|
||||
cell.delegate = self;
|
||||
cell.message = model;
|
||||
return cell;
|
||||
}else if(model.messageType == QXRoomChatMessageTypeEmoji){
|
||||
QXRoomEmojiListCell *cell = [QXRoomEmojiListCell cellWithTableView:tableView];
|
||||
cell.delegate = self;
|
||||
cell.message = model;
|
||||
return cell;
|
||||
}else{
|
||||
QXRoomChatListSystemCell *cell = [QXRoomChatListSystemCell cellWithTableView:tableView];
|
||||
cell.message = model;
|
||||
@@ -257,6 +264,17 @@ NSInteger maxMessageCount = 20;
|
||||
if ([cell isKindOfClass:[QXRoomChatListCell class]]) {
|
||||
QXRoomChatListCell *Listcell = (QXRoomChatListCell *)cell;
|
||||
[Listcell loadBubble];
|
||||
return;
|
||||
}
|
||||
if ([cell isKindOfClass:[QXRoomGiftListCell class]]) {
|
||||
QXRoomGiftListCell *Listcell = (QXRoomGiftListCell *)cell;
|
||||
[Listcell loadBubble];
|
||||
return;
|
||||
}
|
||||
if ([cell isKindOfClass:[QXRoomEmojiListCell class]]) {
|
||||
QXRoomEmojiListCell *Listcell = (QXRoomEmojiListCell *)cell;
|
||||
[Listcell loadBubble];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,6 +283,18 @@ NSInteger maxMessageCount = 20;
|
||||
QXRoomChatListCell *Listcell = (QXRoomChatListCell *)cell;
|
||||
[Listcell.bubbleImageView sd_cancelLatestImageLoad];
|
||||
}
|
||||
|
||||
if ([cell isKindOfClass:[QXRoomGiftListCell class]]) {
|
||||
QXRoomGiftListCell *Listcell = (QXRoomGiftListCell *)cell;
|
||||
[Listcell.bubbleImageView sd_cancelLatestImageLoad];
|
||||
return;
|
||||
}
|
||||
if ([cell isKindOfClass:[QXRoomEmojiListCell class]]) {
|
||||
QXRoomEmojiListCell *Listcell = (QXRoomEmojiListCell *)cell;
|
||||
[Listcell.bubbleImageView sd_cancelLatestImageLoad];
|
||||
[Listcell.animatedImageView sd_cancelLatestImageLoad];
|
||||
return;
|
||||
}
|
||||
}
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXRoomChatListModel *model;
|
||||
@@ -277,19 +307,27 @@ NSInteger maxMessageCount = 20;
|
||||
// }
|
||||
CGFloat height = 0;
|
||||
if (model.messageType == QXRoomChatMessageTypeChat) {
|
||||
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16-28-6-8-8];
|
||||
|
||||
if (model.havBubble) {
|
||||
/// 有气泡
|
||||
height = 30+14+6+30 + height;
|
||||
if ([model.FromUserInfo.chat_bubble isExist]) {
|
||||
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-60-18];
|
||||
height = 28+19+13+16 + height;
|
||||
}else{
|
||||
// 无气泡
|
||||
height = 30+14+6+12 + height;
|
||||
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-60-18-16];
|
||||
height = 28+19+13+8 + height;
|
||||
}
|
||||
|
||||
}else if (model.messageType == QXRoomChatMessageTypeGift) {
|
||||
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16-28-6-8-8];
|
||||
height = 30+14+6+12 + height;
|
||||
if ([model.FromUserInfo.chat_bubble isExist]) {
|
||||
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-60-18];
|
||||
height = 28+19+13+16 + height;
|
||||
}else{
|
||||
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-60-18-16];
|
||||
height = 28+19+13+8 + height;
|
||||
}
|
||||
}else if(model.messageType == QXRoomChatMessageTypeEmoji){
|
||||
if ([model.FromUserInfo.chat_bubble isExist]) {
|
||||
height = 28+19+13+16 + 40;
|
||||
}else{
|
||||
height = 28+19+13+8 + 40;
|
||||
}
|
||||
}else{
|
||||
height = [model.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16-8-8*2] + 12+16+1;
|
||||
}
|
||||
@@ -319,6 +357,10 @@ NSInteger maxMessageCount = 20;
|
||||
if (distanceFromBottom < height) {
|
||||
self.isDragging = NO;
|
||||
}
|
||||
CGFloat bottomEdge = scrollView.contentOffset.y + scrollView.frame.size.height;
|
||||
if (scrollView.contentSize.height-bottomEdge) {
|
||||
self.messageCountBtn.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
|
||||
@@ -442,35 +484,53 @@ NSInteger maxMessageCount = 20;
|
||||
}
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.bgView = [[UIView alloc] init];
|
||||
[self.contentView addSubview:self.bgView];
|
||||
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.right.mas_equalTo(0);
|
||||
make.top.mas_equalTo(messageBubbleMargin);
|
||||
make.bottom.mas_equalTo(-messageBubbleMargin);
|
||||
}];
|
||||
|
||||
self.bubbleImageView = [[UIImageView alloc] init];
|
||||
self.bubbleImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
[self.bubbleImageView addRoundedCornersWithRadius:6];
|
||||
|
||||
self.bubbleImageView.backgroundColor = messageBubbleColor;
|
||||
[self.bgView addSubview:self.bubbleImageView];
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.bgView);
|
||||
}];
|
||||
|
||||
self.headerImageView = [[UIImageView alloc] init];
|
||||
self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
self.headerImageView.backgroundColor = [UIColor whiteColor];
|
||||
[self.headerImageView addRoundedCornersWithRadius:14];
|
||||
[self.contentView addSubview:self.headerImageView];
|
||||
[self.bgView addSubview:self.headerImageView];
|
||||
|
||||
[self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.top.mas_equalTo(2);
|
||||
make.top.mas_equalTo(19);
|
||||
make.size.mas_equalTo(CGSizeMake(28, 28));
|
||||
}];
|
||||
|
||||
UIButton *headerBtn = [[UIButton alloc] init];
|
||||
[headerBtn addTarget:self action:@selector(headerAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.contentView addSubview:headerBtn];
|
||||
[self.bgView addSubview:headerBtn];
|
||||
[headerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.equalTo(self.headerImageView).offset(-2);
|
||||
make.bottom.right.equalTo(self.headerImageView).offset(2);
|
||||
}];
|
||||
|
||||
self.nameLabel = [[UILabel alloc] init];
|
||||
self.nameLabel.textColor = RGB16(0xCCA882);
|
||||
self.nameLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.contentView addSubview:self.nameLabel];
|
||||
self.nameLabel.textColor = RGB16(0xDED6ED);
|
||||
self.nameLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.bgView addSubview:self.nameLabel];
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.contentView);
|
||||
make.top.equalTo(self.headerImageView).offset(-3);
|
||||
make.left.equalTo(self.headerImageView.mas_right).offset(6);
|
||||
make.right.equalTo(self.contentView).offset(-6);
|
||||
make.height.mas_equalTo(14);
|
||||
make.height.mas_equalTo(18);
|
||||
}];
|
||||
|
||||
|
||||
@@ -479,49 +539,25 @@ NSInteger maxMessageCount = 20;
|
||||
self.titleLabel.textColor = [UIColor whiteColor];
|
||||
self.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.titleLabel.numberOfLines = 0;
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
[self.bgView addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.nameLabel).offset(8);
|
||||
make.top.equalTo(self.headerImageView.mas_bottom).offset(14);
|
||||
make.right.mas_lessThanOrEqualTo(-8);
|
||||
make.left.equalTo(self.nameLabel).offset(0);
|
||||
make.top.equalTo(self.headerImageView.mas_bottom).offset(13);
|
||||
make.right.mas_lessThanOrEqualTo(-18);
|
||||
}];
|
||||
|
||||
|
||||
self.nameLabel.text = @"张三站撒旦撒大萨达撒";
|
||||
|
||||
self.bubbleImageView = [[UIImageView alloc] init];
|
||||
// UIImage * image = [UIImage imageWithColor:RGB16A(0x000000, 0.4)];
|
||||
[self.bubbleImageView addRoundedCornersWithRadius:6];
|
||||
|
||||
// UIImage *image = [UIImage imageWithContentsOfFile:path];
|
||||
// image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(20, 40, 20 , 40) resizingMode:(UIImageResizingModeStretch)];
|
||||
// self.bubbleImageView.image = image;
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0xFFFFFF, 0.2);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[self.contentView addSubview:self.bubbleImageView];
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-8);
|
||||
make.top.equalTo(self.titleLabel).offset(-6);
|
||||
make.bottom.equalTo(self.titleLabel).offset(6);
|
||||
make.right.equalTo(self.titleLabel).offset(8);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
}];
|
||||
|
||||
[self.contentView bringSubviewToFront:self.titleLabel];
|
||||
|
||||
self.iconBgView = [[UIView alloc] init];
|
||||
[self.contentView addSubview:self.iconBgView];
|
||||
[self.bgView addSubview:self.iconBgView];
|
||||
[self.iconBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.nameLabel);
|
||||
make.right.equalTo(self.contentView);
|
||||
make.width.mas_equalTo(UserIconWidth*2+6);
|
||||
make.height.mas_equalTo(16);
|
||||
make.top.equalTo(self.nameLabel.mas_bottom).offset(2);
|
||||
}];
|
||||
@@ -532,6 +568,7 @@ NSInteger maxMessageCount = 20;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
UIImageView *iconImageView = [[UIImageView alloc] init];
|
||||
iconImageView.hidden = YES;
|
||||
iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.iconBgView addSubview:iconImageView];
|
||||
[iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(i*(iconWidth+margin));
|
||||
@@ -541,41 +578,42 @@ NSInteger maxMessageCount = 20;
|
||||
}];
|
||||
[self.iconViewArray addObject:iconImageView];
|
||||
}
|
||||
|
||||
}
|
||||
-(void)loadBubble{
|
||||
if (!self.message.havBubble) {
|
||||
[self.bubbleImageView sd_cancelLatestImageLoad];
|
||||
self.bubbleImageView.image = nil;
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0xFFFFFF, 0.2);
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-8);
|
||||
make.top.equalTo(self.titleLabel).offset(-6);
|
||||
make.bottom.equalTo(self.titleLabel).offset(6);
|
||||
make.right.equalTo(self.titleLabel).offset(8);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
if ([self.message.FromUserInfo.chat_bubble isExist]) {
|
||||
self.bubbleImageView.backgroundColor = UIColor.clearColor;
|
||||
self.bgView.backgroundColor = UIColor.clearColor;
|
||||
// self.bubbleImageView.image = [[UIImage imageNamed:@"chat_bubble2"] resizableImageWithCapInsets:UIEdgeInsetsMake(30, 40, 40, 40) resizingMode:(UIImageResizingModeStretch)];;
|
||||
[self.bubbleImageView sd_setImageWithURL:[NSURL URLWithString:self.message.FromUserInfo.chat_bubble] placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(40, 40, 40, 40) resizingMode:(UIImageResizingModeStretch)];
|
||||
self.bubbleImageView.image = image;
|
||||
}];
|
||||
[self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(8);
|
||||
make.right.mas_equalTo(0);
|
||||
make.top.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(0);
|
||||
}];
|
||||
[self.headerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.top.mas_equalTo(19);
|
||||
}];
|
||||
}else{
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"气泡" ofType:@"webp"];
|
||||
[self.bubbleImageView sd_setImageWithURL:[NSURL fileURLWithPath:path] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(20, 30, 20 , 30) resizingMode:(UIImageResizingModeStretch)];
|
||||
self.bubbleImageView.image = image;
|
||||
|
||||
self.bgView.backgroundColor = UIColor.clearColor;
|
||||
[self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.right.mas_equalTo(-8);
|
||||
make.top.mas_equalTo(messageBubbleMargin);
|
||||
make.bottom.mas_equalTo(-messageBubbleMargin);
|
||||
}];
|
||||
CGFloat height = [self.message.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16-28-6-8-8];
|
||||
self.bubbleImageView.backgroundColor = [UIColor clearColor];
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-48);
|
||||
// make.height.mas_equalTo(height+12);
|
||||
make.height.mas_equalTo(height+60);
|
||||
// make.width.mas_equalTo(ScaleWidth(280)-16-28-6-8-8);
|
||||
make.centerY.equalTo(self.titleLabel);
|
||||
make.right.equalTo(self.titleLabel).offset(48);
|
||||
[self.headerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(9);
|
||||
make.top.mas_equalTo(11);
|
||||
}];
|
||||
self.bubbleImageView.image = nil;
|
||||
self.bubbleImageView.backgroundColor = messageBubbleColor;
|
||||
}
|
||||
|
||||
}
|
||||
-(NSMutableArray *)iconViewArray{
|
||||
if (!_iconViewArray) {
|
||||
@@ -666,34 +704,53 @@ NSInteger maxMessageCount = 20;
|
||||
}
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.bgView = [[UIView alloc] init];
|
||||
[self.contentView addSubview:self.bgView];
|
||||
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.right.mas_equalTo(0);
|
||||
make.top.mas_equalTo(messageBubbleMargin);
|
||||
make.bottom.mas_equalTo(-messageBubbleMargin);
|
||||
}];
|
||||
|
||||
self.bubbleImageView = [[UIImageView alloc] init];
|
||||
self.bubbleImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
[self.bubbleImageView addRoundedCornersWithRadius:6];
|
||||
|
||||
self.bubbleImageView.backgroundColor = messageBubbleColor;
|
||||
[self.bgView addSubview:self.bubbleImageView];
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.bgView);
|
||||
}];
|
||||
|
||||
self.headerImageView = [[UIImageView alloc] init];
|
||||
self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
self.headerImageView.backgroundColor = [UIColor whiteColor];
|
||||
[self.headerImageView addRoundedCornersWithRadius:14];
|
||||
[self.contentView addSubview:self.headerImageView];
|
||||
[self.bgView addSubview:self.headerImageView];
|
||||
|
||||
[self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.top.mas_equalTo(2);
|
||||
make.top.mas_equalTo(19);
|
||||
make.size.mas_equalTo(CGSizeMake(28, 28));
|
||||
}];
|
||||
|
||||
UIButton *headerBtn = [[UIButton alloc] init];
|
||||
[headerBtn addTarget:self action:@selector(headerAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.contentView addSubview:headerBtn];
|
||||
[self.bgView addSubview:headerBtn];
|
||||
[headerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.equalTo(self.headerImageView).offset(-2);
|
||||
make.bottom.right.equalTo(self.headerImageView).offset(2);
|
||||
}];
|
||||
|
||||
self.nameLabel = [[UILabel alloc] init];
|
||||
self.nameLabel.textColor = RGB16(0xCCA882);
|
||||
self.nameLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.contentView addSubview:self.nameLabel];
|
||||
self.nameLabel.textColor = RGB16(0xDED6ED);
|
||||
self.nameLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.bgView addSubview:self.nameLabel];
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.contentView);
|
||||
make.left.equalTo(self.headerImageView.mas_right).offset(6);
|
||||
make.right.equalTo(self.contentView).offset(-6);
|
||||
make.height.mas_equalTo(14);
|
||||
make.top.equalTo(self.headerImageView).offset(-3);
|
||||
make.left.equalTo(self.headerImageView.mas_right).offset(8);
|
||||
make.height.mas_equalTo(18);
|
||||
}];
|
||||
|
||||
|
||||
@@ -702,49 +759,25 @@ NSInteger maxMessageCount = 20;
|
||||
self.titleLabel.textColor = [UIColor whiteColor];
|
||||
self.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
self.titleLabel.numberOfLines = 0;
|
||||
[self.contentView addSubview:self.titleLabel];
|
||||
[self.bgView addSubview:self.titleLabel];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.nameLabel).offset(8);
|
||||
make.top.equalTo(self.headerImageView.mas_bottom).offset(14);
|
||||
make.right.mas_lessThanOrEqualTo(-8);
|
||||
make.left.equalTo(self.nameLabel).offset(0);
|
||||
make.top.equalTo(self.headerImageView.mas_bottom).offset(13);
|
||||
make.right.mas_lessThanOrEqualTo(-18);
|
||||
}];
|
||||
|
||||
|
||||
self.nameLabel.text = @"张三站撒旦撒大萨达撒";
|
||||
|
||||
self.bubbleImageView = [[UIImageView alloc] init];
|
||||
// UIImage * image = [UIImage imageWithColor:RGB16A(0x000000, 0.4)];
|
||||
[self.bubbleImageView addRoundedCornersWithRadius:6];
|
||||
|
||||
// UIImage *image = [UIImage imageWithContentsOfFile:path];
|
||||
// image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(20, 40, 20 , 40) resizingMode:(UIImageResizingModeStretch)];
|
||||
// self.bubbleImageView.image = image;
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0xFFFFFF, 0.2);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[self.contentView addSubview:self.bubbleImageView];
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-8);
|
||||
make.top.equalTo(self.titleLabel).offset(-6);
|
||||
make.bottom.equalTo(self.titleLabel).offset(6);
|
||||
make.right.equalTo(self.titleLabel).offset(8);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
}];
|
||||
|
||||
[self.contentView bringSubviewToFront:self.titleLabel];
|
||||
|
||||
self.iconBgView = [[UIView alloc] init];
|
||||
[self.contentView addSubview:self.iconBgView];
|
||||
[self.bgView addSubview:self.iconBgView];
|
||||
[self.iconBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.nameLabel);
|
||||
make.right.equalTo(self.contentView);
|
||||
make.width.mas_equalTo(UserIconWidth*2+6);
|
||||
make.height.mas_equalTo(16);
|
||||
make.top.equalTo(self.nameLabel.mas_bottom).offset(2);
|
||||
}];
|
||||
@@ -755,6 +788,7 @@ NSInteger maxMessageCount = 20;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
UIImageView *iconImageView = [[UIImageView alloc] init];
|
||||
iconImageView.hidden = YES;
|
||||
iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.iconBgView addSubview:iconImageView];
|
||||
[iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(i*(iconWidth+margin));
|
||||
@@ -764,41 +798,40 @@ NSInteger maxMessageCount = 20;
|
||||
}];
|
||||
[self.iconViewArray addObject:iconImageView];
|
||||
}
|
||||
|
||||
}
|
||||
-(void)loadBubble{
|
||||
if (!self.message.havBubble) {
|
||||
[self.bubbleImageView sd_cancelLatestImageLoad];
|
||||
self.bubbleImageView.image = nil;
|
||||
self.bubbleImageView.backgroundColor = RGB16A(0xFFFFFF, 0.2);
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-8);
|
||||
make.top.equalTo(self.titleLabel).offset(-6);
|
||||
make.bottom.equalTo(self.titleLabel).offset(6);
|
||||
make.right.equalTo(self.titleLabel).offset(8);
|
||||
// make.left.equalTo(self.titleLabel).offset(-55);
|
||||
// make.top.equalTo(self.titleLabel).offset(0);
|
||||
// make.bottom.equalTo(self.titleLabel).offset(0);
|
||||
// make.right.equalTo(self.titleLabel).offset(55);
|
||||
if ([self.message.FromUserInfo.chat_bubble isExist]) {
|
||||
self.bubbleImageView.backgroundColor = UIColor.clearColor;
|
||||
// self.bubbleImageView.image = [[UIImage imageNamed:@"chat_bubble2"] resizableImageWithCapInsets:UIEdgeInsetsMake(30, 40, 40, 40) resizingMode:(UIImageResizingModeStretch)];;
|
||||
[self.bubbleImageView sd_setImageWithURL:[NSURL URLWithString:self.message.FromUserInfo.chat_bubble] placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(40, 40, 40, 40) resizingMode:(UIImageResizingModeStretch)];
|
||||
self.bubbleImageView.image = image;
|
||||
}];
|
||||
[self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(8);
|
||||
make.right.mas_equalTo(0);
|
||||
make.top.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(0);
|
||||
}];
|
||||
[self.headerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.top.mas_equalTo(19);
|
||||
}];
|
||||
}else{
|
||||
NSString *path = [[NSBundle mainBundle] pathForResource:@"气泡" ofType:@"webp"];
|
||||
[self.bubbleImageView sd_setImageWithURL:[NSURL fileURLWithPath:path] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(20, 30, 20 , 30) resizingMode:(UIImageResizingModeStretch)];
|
||||
self.bubbleImageView.image = image;
|
||||
|
||||
[self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.right.mas_equalTo(-8);
|
||||
make.top.mas_equalTo(messageBubbleMargin);
|
||||
make.bottom.mas_equalTo(-messageBubbleMargin);
|
||||
}];
|
||||
CGFloat height = [self.message.text heightForFont:[UIFont systemFontOfSize:14] width:ScaleWidth(280)-16-28-6-8-8];
|
||||
self.bubbleImageView.backgroundColor = [UIColor clearColor];
|
||||
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.titleLabel).offset(-48);
|
||||
// make.height.mas_equalTo(height+12);
|
||||
make.height.mas_equalTo(height+60);
|
||||
// make.width.mas_equalTo(ScaleWidth(280)-16-28-6-8-8);
|
||||
make.centerY.equalTo(self.titleLabel);
|
||||
make.right.equalTo(self.titleLabel).offset(48);
|
||||
[self.headerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(9);
|
||||
make.top.mas_equalTo(11);
|
||||
}];
|
||||
self.bubbleImageView.image = nil;
|
||||
self.bubbleImageView.backgroundColor = messageBubbleColor;
|
||||
}
|
||||
|
||||
}
|
||||
-(NSMutableArray *)iconViewArray{
|
||||
if (!_iconViewArray) {
|
||||
@@ -809,6 +842,209 @@ NSInteger maxMessageCount = 20;
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXRoomEmojiListCell
|
||||
|
||||
|
||||
+(instancetype)cellWithTableView:(UITableView *)tableView{
|
||||
static NSString* cellId = @"QXRoomEmojiListCell";
|
||||
QXRoomEmojiListCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
|
||||
if (!cell) {
|
||||
cell = [[QXRoomEmojiListCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId];
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
||||
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
||||
self.contentView.backgroundColor = [UIColor clearColor];
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)setMessage:(QXRoomChatListModel *)message{
|
||||
_message = message;
|
||||
self.nameLabel.text = message.FromUserInfo.nickname;
|
||||
[self.headerImageView sd_setImageWithURL:[NSURL URLWithString:message.FromUserInfo.avatar]];
|
||||
self.iconBgView.hidden = YES;
|
||||
for (int i = 0;i < message.FromUserInfo.icon.count;i++) {
|
||||
if (i < 3) {
|
||||
self.iconBgView.hidden = NO;
|
||||
UIImageView *iconImageView = self.iconViewArray[i];
|
||||
iconImageView.hidden = NO;
|
||||
[iconImageView sd_setImageWithURL:[NSURL URLWithString:message.FromUserInfo.icon[i]]];
|
||||
}else{
|
||||
self.iconBgView.hidden = YES;
|
||||
}
|
||||
}
|
||||
if (![message.emoji.animate_image isExist]) {
|
||||
[self.animatedImageView sd_cancelCurrentImageLoad];
|
||||
[self.animatedImageView sd_setImageWithURL:[NSURL URLWithString:message.emoji.image]];
|
||||
return;
|
||||
}
|
||||
if (message.emoji.isAnimated) {
|
||||
[self.animatedImageView sd_cancelCurrentImageLoad];
|
||||
[self.animatedImageView sd_setImageWithURL:[NSURL URLWithString:message.emoji.image]];
|
||||
}else{
|
||||
message.emoji.isAnimated = YES;
|
||||
NSURL *animiteUrl = [NSURL URLWithString:message.emoji.animate_image];
|
||||
[self.animatedImageView sd_setImageWithURL:animiteUrl
|
||||
placeholderImage:nil
|
||||
options:SDWebImageHighPriority
|
||||
completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
// 监听动画结束
|
||||
if (image) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (double)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// 动画结束后显示最后一帧
|
||||
[self.animatedImageView.player stopPlaying];
|
||||
[self.animatedImageView.player clearFrameBuffer];
|
||||
[self.animatedImageView sd_cancelCurrentImageLoad];
|
||||
[self.animatedImageView sd_setImageWithURL:[NSURL URLWithString:message.emoji.image]];
|
||||
});
|
||||
}else{
|
||||
[self.animatedImageView sd_cancelCurrentImageLoad];
|
||||
[self.animatedImageView sd_setImageWithURL:[NSURL URLWithString:message.emoji.image]];
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
-(void)initSubviews{
|
||||
self.bgView = [[UIView alloc] init];
|
||||
[self.contentView addSubview:self.bgView];
|
||||
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.right.mas_equalTo(0);
|
||||
make.top.mas_equalTo(messageBubbleMargin);
|
||||
make.bottom.mas_equalTo(-messageBubbleMargin);
|
||||
}];
|
||||
|
||||
self.bubbleImageView = [[UIImageView alloc] init];
|
||||
self.bubbleImageView.contentMode = UIViewContentModeScaleToFill;
|
||||
[self.bubbleImageView addRoundedCornersWithRadius:6];
|
||||
|
||||
self.bubbleImageView.backgroundColor = messageBubbleColor;
|
||||
[self.bgView addSubview:self.bubbleImageView];
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.equalTo(self.bgView);
|
||||
}];
|
||||
|
||||
self.headerImageView = [[UIImageView alloc] init];
|
||||
self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
self.headerImageView.backgroundColor = [UIColor whiteColor];
|
||||
[self.headerImageView addRoundedCornersWithRadius:14];
|
||||
[self.bgView addSubview:self.headerImageView];
|
||||
|
||||
[self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.top.mas_equalTo(19);
|
||||
make.size.mas_equalTo(CGSizeMake(28, 28));
|
||||
}];
|
||||
|
||||
UIButton *headerBtn = [[UIButton alloc] init];
|
||||
[headerBtn addTarget:self action:@selector(headerAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.bgView addSubview:headerBtn];
|
||||
[headerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.top.equalTo(self.headerImageView).offset(-2);
|
||||
make.bottom.right.equalTo(self.headerImageView).offset(2);
|
||||
}];
|
||||
|
||||
self.nameLabel = [[UILabel alloc] init];
|
||||
self.nameLabel.textColor = RGB16(0xDED6ED);
|
||||
self.nameLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.bgView addSubview:self.nameLabel];
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.headerImageView).offset(-3);
|
||||
make.left.equalTo(self.headerImageView.mas_right).offset(6);
|
||||
make.height.mas_equalTo(18);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
self.animatedImageView = [[SDAnimatedImageView alloc] init];
|
||||
self.animatedImageView.shouldCustomLoopCount = YES;
|
||||
self.animatedImageView.animationRepeatCount = 5;
|
||||
self.animatedImageView.clearBufferWhenStopped = YES;
|
||||
self.animatedImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.bgView addSubview:self.animatedImageView];
|
||||
[self.animatedImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.nameLabel).offset(0);
|
||||
make.top.equalTo(self.headerImageView.mas_bottom).offset(13);
|
||||
make.height.width.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
|
||||
self.nameLabel.text = @"张三站撒旦撒大萨达撒";
|
||||
|
||||
self.iconBgView = [[UIView alloc] init];
|
||||
[self.bgView addSubview:self.iconBgView];
|
||||
[self.iconBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.nameLabel);
|
||||
make.width.mas_equalTo(UserIconWidth*2+6);
|
||||
make.height.mas_equalTo(16);
|
||||
make.top.equalTo(self.nameLabel.mas_bottom).offset(2);
|
||||
}];
|
||||
|
||||
CGFloat iconWidth = UserIconWidth;
|
||||
CGFloat iconHeight = UserIconHeight;
|
||||
CGFloat margin = 6;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
UIImageView *iconImageView = [[UIImageView alloc] init];
|
||||
iconImageView.hidden = YES;
|
||||
iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.iconBgView addSubview:iconImageView];
|
||||
[iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(i*(iconWidth+margin));
|
||||
make.width.mas_equalTo(iconWidth);
|
||||
make.height.mas_equalTo(iconHeight);
|
||||
make.centerY.equalTo(self.iconBgView);
|
||||
}];
|
||||
[self.iconViewArray addObject:iconImageView];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void)loadBubble{
|
||||
if ([self.message.FromUserInfo.chat_bubble isExist]) {
|
||||
self.bubbleImageView.backgroundColor = UIColor.clearColor;
|
||||
// self.bubbleImageView.image = [[UIImage imageNamed:@"chat_bubble2"] resizableImageWithCapInsets:UIEdgeInsetsMake(30, 40, 40, 40) resizingMode:(UIImageResizingModeStretch)];;
|
||||
[self.bubbleImageView sd_setImageWithURL:[NSURL URLWithString:self.message.FromUserInfo.chat_bubble] placeholderImage:nil options:SDWebImageRetryFailed completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
image = [image resizableImageWithCapInsets:UIEdgeInsetsMake(40, 40, 40, 40) resizingMode:(UIImageResizingModeStretch)];
|
||||
self.bubbleImageView.image = image;
|
||||
}];
|
||||
[self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(8);
|
||||
make.right.mas_equalTo(0);
|
||||
make.top.mas_equalTo(0);
|
||||
make.bottom.mas_equalTo(0);
|
||||
}];
|
||||
[self.headerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.top.mas_equalTo(19);
|
||||
}];
|
||||
}else{
|
||||
[self.bgView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.right.mas_equalTo(-8);
|
||||
make.top.mas_equalTo(messageBubbleMargin);
|
||||
make.bottom.mas_equalTo(-messageBubbleMargin);
|
||||
}];
|
||||
[self.headerImageView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(9);
|
||||
make.top.mas_equalTo(11);
|
||||
}];
|
||||
self.bubbleImageView.image = nil;
|
||||
self.bubbleImageView.backgroundColor = messageBubbleColor;
|
||||
}
|
||||
}
|
||||
-(NSMutableArray *)iconViewArray{
|
||||
if (!_iconViewArray) {
|
||||
_iconViewArray = [NSMutableArray array];
|
||||
}
|
||||
return _iconViewArray;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXRoomChatListSystemCell
|
||||
|
||||
@@ -872,21 +1108,16 @@ NSInteger maxMessageCount = 20;
|
||||
|
||||
-(void)initSubviews{
|
||||
self.bgView = [[UIView alloc] init];
|
||||
self.bgView.backgroundColor = RGB16A(0xFFFFFF, 0.2);
|
||||
self.bgView.backgroundColor = messageBubbleColor;
|
||||
[self.bgView addRoundedCornersWithRadius:6];
|
||||
[self.contentView addSubview:self.bgView];
|
||||
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.right.mas_lessThanOrEqualTo(-8);
|
||||
make.top.mas_equalTo(6);
|
||||
make.bottom.mas_equalTo(-6);
|
||||
make.top.mas_equalTo(messageBubbleMargin);
|
||||
make.bottom.mas_equalTo(-messageBubbleMargin);
|
||||
}];
|
||||
|
||||
self.bubbleImageView = [[UIImageView alloc] init];
|
||||
[self.bgView addSubview:self.bubbleImageView];
|
||||
[self.bubbleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.bottom.equalTo(self.bgView);
|
||||
}];
|
||||
|
||||
self.titleLabel = [[UILabel alloc] init];
|
||||
// self.titleLabel.textColor = RGB16(0XD1A9FE);
|
||||
|
||||
18
QXLive/Room(房间)/View/表情/QXEmojiCell.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// QXEmojiCell.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/22.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "QXEmojiTypeModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXEmojiCell : UICollectionViewCell
|
||||
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
|
||||
@property (nonatomic,strong)QXEmojiModel *model;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
21
QXLive/Room(房间)/View/表情/QXEmojiCell.m
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// QXEmojiCell.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/22.
|
||||
//
|
||||
|
||||
#import "QXEmojiCell.h"
|
||||
|
||||
@implementation QXEmojiCell
|
||||
|
||||
- (void)awakeFromNib {
|
||||
[super awakeFromNib];
|
||||
// Initialization code
|
||||
}
|
||||
-(void)setModel:(QXEmojiModel *)model{
|
||||
_model = model;
|
||||
self.titleLabel.text = model.name;
|
||||
[self.imageView sd_setImageWithURL:[NSURL URLWithString:model.image]];
|
||||
}
|
||||
@end
|
||||
52
QXLive/Room(房间)/View/表情/QXEmojiCell.xib
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
||||
<device id="retina6_12" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
|
||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="QXEmojiCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="265" height="273"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="265" height="273"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Het-BN-kc9">
|
||||
<rect key="frame" x="0.0" y="255" width="265" height="18"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="18" id="2fI-ft-DLa"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
||||
<color key="textColor" red="0.73333333333333328" green="0.72549019607843135" blue="0.77647058823529413" alpha="0.84999999999999998" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="LlC-Kp-7ty">
|
||||
<rect key="frame" x="0.0" y="0.0" width="265" height="255"/>
|
||||
</imageView>
|
||||
</subviews>
|
||||
</view>
|
||||
<viewLayoutGuide key="safeArea" id="SEy-5g-ep8"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="Het-BN-kc9" secondAttribute="bottom" id="2BG-mC-FaO"/>
|
||||
<constraint firstItem="LlC-Kp-7ty" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="2qv-XJ-xHU"/>
|
||||
<constraint firstAttribute="trailing" secondItem="LlC-Kp-7ty" secondAttribute="trailing" id="D6X-gv-ZCy"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Het-BN-kc9" secondAttribute="trailing" id="NMN-es-X8p"/>
|
||||
<constraint firstItem="LlC-Kp-7ty" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="eud-aw-Nov"/>
|
||||
<constraint firstItem="Het-BN-kc9" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="gQo-iX-ukL"/>
|
||||
<constraint firstItem="Het-BN-kc9" firstAttribute="top" secondItem="LlC-Kp-7ty" secondAttribute="bottom" id="swe-Hs-WHd"/>
|
||||
</constraints>
|
||||
<size key="customSize" width="265" height="273"/>
|
||||
<connections>
|
||||
<outlet property="imageView" destination="LlC-Kp-7ty" id="ZPe-C3-RBQ"/>
|
||||
<outlet property="titleLabel" destination="Het-BN-kc9" id="lDC-MQ-3fj"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="303.05343511450383" y="98.239436619718319"/>
|
||||
</collectionViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
23
QXLive/Room(房间)/View/表情/QXRoomEmojiContentView.h
Normal file
@@ -0,0 +1,23 @@
|
||||
//
|
||||
// QXRoomEmojiContentView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/22.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "JXCategoryListContainerView.h"
|
||||
#import "QXEmojiTypeModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@protocol QXRoomEmojiContentViewDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
-(void)didSelectedEmoji:(QXEmojiModel*)model;
|
||||
|
||||
@end
|
||||
@interface QXRoomEmojiContentView : UIView<JXCategoryListContentViewDelegate>
|
||||
@property (nonatomic,strong)QXEmojiTypeModel *model;
|
||||
@property (nonatomic,weak)id<QXRoomEmojiContentViewDelegate>delegate;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
104
QXLive/Room(房间)/View/表情/QXRoomEmojiContentView.m
Normal file
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// QXRoomEmojiContentView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/22.
|
||||
//
|
||||
|
||||
#import "QXRoomEmojiContentView.h"
|
||||
#import "QXEmojiCell.h"
|
||||
#import "QXMineNetwork.h"
|
||||
@interface QXRoomEmojiContentView()<UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
@property (nonatomic,strong)UICollectionView *collectionView;
|
||||
@property (nonatomic,strong)NSMutableArray *dataArray;
|
||||
@end
|
||||
|
||||
@implementation QXRoomEmojiContentView
|
||||
|
||||
-(UIView *)listView{
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)initSubviews{
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.itemSize = CGSizeMake((int)(SCREEN_WIDTH-16*2-12*3)/4, ScaleWidth(75));
|
||||
layout.minimumLineSpacing = 12;
|
||||
layout.minimumInteritemSpacing = 12;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16);
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
|
||||
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
||||
[self.collectionView registerNib:[UINib nibWithNibName:@"QXEmojiCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXEmojiCell"];
|
||||
self.collectionView.delegate = self;
|
||||
self.collectionView.dataSource = self;
|
||||
self.collectionView.showsHorizontalScrollIndicator = NO;
|
||||
self.collectionView.bounces = NO;
|
||||
self.collectionView.pagingEnabled = NO;
|
||||
self.collectionView.backgroundColor = [UIColor clearColor];
|
||||
[self addSubview:self.collectionView];
|
||||
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(12);
|
||||
make.bottom.equalTo(self);
|
||||
make.right.mas_equalTo(0);
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)setModel:(QXEmojiTypeModel *)model{
|
||||
_model = model;
|
||||
@weakify(self)
|
||||
[QXMineNetwork roomEmojiListWithTypeId:model.id pid:@"" successBlock:^(NSArray<QXEmojiModel *> * _Nonnull list) {
|
||||
@strongify(self);
|
||||
[self.dataArray removeAllObjects];
|
||||
[self.dataArray addObjectsFromArray:list];
|
||||
[self.collectionView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.dataArray.count;
|
||||
}
|
||||
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXEmojiCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXEmojiCell" forIndexPath:indexPath];
|
||||
cell.model = self.dataArray[indexPath.row];
|
||||
return cell;
|
||||
}
|
||||
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXEmojiModel *md = self.dataArray[indexPath.row];
|
||||
QXEmojiModel *result = [self randomResultWithEmoji:md];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectedEmoji:)]) {
|
||||
[self.delegate didSelectedEmoji:result];
|
||||
}
|
||||
}
|
||||
-(QXEmojiModel*)randomResultWithEmoji:(QXEmojiModel*)emoji{
|
||||
QXEmojiModel *result;
|
||||
if (emoji.children.count>0) {
|
||||
NSUInteger randomIndex = arc4random() % emoji.children.count;
|
||||
QXEmojiChirldModel *md = emoji.children[randomIndex];
|
||||
result = [[QXEmojiModel alloc] init];
|
||||
result.image = md.image;
|
||||
result.animate_image = emoji.animate_image;
|
||||
}else{
|
||||
result = emoji;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
-(NSMutableArray *)dataArray{
|
||||
if (!_dataArray) {
|
||||
_dataArray = [NSMutableArray array];
|
||||
}
|
||||
return _dataArray;
|
||||
}
|
||||
@end
|
||||
16
QXLive/Room(房间)/View/表情/QXRoomEmojiView.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// QXRoomEmojiView.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/22.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXRoomEmojiView : UIView
|
||||
-(void)showInView:(UIView *)view;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
128
QXLive/Room(房间)/View/表情/QXRoomEmojiView.m
Normal file
@@ -0,0 +1,128 @@
|
||||
//
|
||||
// QXRoomEmojiView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/22.
|
||||
//
|
||||
|
||||
#import "QXRoomEmojiView.h"
|
||||
#import "JXCategoryView.h"
|
||||
#import "QXMineNetwork.h"
|
||||
#import "QXRoomEmojiContentView.h"
|
||||
|
||||
@interface QXRoomEmojiView()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate,UIGestureRecognizerDelegate,QXRoomEmojiContentViewDelegate>
|
||||
@property (nonatomic,strong)JXCategoryTitleView *categoryView;
|
||||
@property (nonatomic,strong)JXCategoryListContainerView *containerView;
|
||||
@property (nonatomic,strong)QXRoomEmojiContentView *contentView;
|
||||
@property (nonatomic,strong)NSMutableArray *dataArray;
|
||||
@property (nonatomic,strong)NSMutableArray *titleArray;
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@end
|
||||
@implementation QXRoomEmojiView
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
|
||||
tap.delegate = self;
|
||||
[self addGestureRecognizer:tap];
|
||||
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
|
||||
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(330))];
|
||||
self.bgView.backgroundColor = RGB16(0x1B1926);
|
||||
[self.bgView addRoundedCornersWithRadius:14 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
||||
[self addSubview:self.bgView];
|
||||
|
||||
|
||||
self.categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(14, 0, SCREEN_WIDTH, 50)];
|
||||
self.categoryView.delegate = self;
|
||||
self.categoryView.titleSelectedColor = [UIColor colorWithHexString:@"#FFFFFF"];
|
||||
self.categoryView.titleColor = [UIColor colorWithHexString:@"#BDBBC8"];
|
||||
self.categoryView.cellWidth = JXCategoryViewAutomaticDimension;
|
||||
self.categoryView.contentEdgeInsetLeft = 5;
|
||||
self.categoryView.cellSpacing = 24;
|
||||
// self.categoryView.titleLabelZoomScale = 1.1;
|
||||
self.categoryView.titleLabelZoomEnabled = YES;
|
||||
self.categoryView.titleFont = [UIFont boldSystemFontOfSize:16];
|
||||
self.categoryView.titleSelectedFont = [UIFont boldSystemFontOfSize:18];
|
||||
self.categoryView.averageCellSpacingEnabled = NO;
|
||||
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
|
||||
lineView.indicatorColor = RGB16(0xffffff);
|
||||
lineView.indicatorWidth = JXCategoryViewAutomaticDimension;
|
||||
self.categoryView.indicators = @[lineView];
|
||||
self.containerView = [[JXCategoryListContainerView alloc] initWithType:(JXCategoryListContainerType_ScrollView) delegate:self];
|
||||
self.containerView.frame = CGRectMake(0, self.categoryView.bottom, SCREEN_WIDTH, self.bgView.height-self.categoryView.bottom);
|
||||
[self.bgView addSubview:self.categoryView];
|
||||
[self.bgView addSubview:self.containerView];
|
||||
self.categoryView.listContainer = self.containerView;
|
||||
[self getEmojiTypeList];
|
||||
}
|
||||
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||||
return touch.view == self;
|
||||
}
|
||||
-(void)getEmojiTypeList{
|
||||
@weakify(self)
|
||||
[QXMineNetwork roomEmojiTypeListSuccessBlock:^(NSArray<QXEmojiTypeModel *> * _Nonnull list) {
|
||||
@strongify(self);
|
||||
[self.dataArray removeAllObjects];
|
||||
[self.dataArray addObjectsFromArray:list];
|
||||
[self.titleArray removeAllObjects];
|
||||
for (QXEmojiTypeModel *md in list) {
|
||||
[self.titleArray addObject:md.type_name];
|
||||
}
|
||||
self.categoryView.titles = self.titleArray;
|
||||
[self.categoryView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)didSelectedEmoji:(QXEmojiModel *)model{
|
||||
[self hide];
|
||||
[[QXRoomMessageManager shared] sendChatEmoji:model];
|
||||
}
|
||||
-(NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
|
||||
return self.dataArray.count;
|
||||
}
|
||||
-(id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
|
||||
QXRoomEmojiContentView *emojiView = [[QXRoomEmojiContentView alloc] initWithFrame:self.containerView.bounds];
|
||||
emojiView.model = self.dataArray[index];
|
||||
emojiView.delegate = self;
|
||||
return emojiView;
|
||||
}
|
||||
|
||||
-(void)showInView:(UIView *)view{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
[view addSubview:self];
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(330);
|
||||
}];
|
||||
}
|
||||
-(void)hide{
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.bgView.y = SCREEN_HEIGHT;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
-(NSMutableArray *)dataArray{
|
||||
if (!_dataArray) {
|
||||
_dataArray = [NSMutableArray array];
|
||||
}
|
||||
return _dataArray;
|
||||
}
|
||||
-(NSMutableArray *)titleArray{
|
||||
if (!_titleArray) {
|
||||
_titleArray = [NSMutableArray array];
|
||||
}
|
||||
return _titleArray;
|
||||
}
|
||||
@end
|
||||
@@ -207,19 +207,30 @@
|
||||
}
|
||||
NSMutableArray *files = [[NSMutableArray alloc] initWithObjects:fileData, nil];
|
||||
|
||||
NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// NSString *fileBasePath = IMG_FILE_BASE_PATH;// 默认图片上传
|
||||
// NSString *fileName = [NSString stringWithFormat:@"%@%@/%@.%@",fileBasePath,[[QXOSSManager sharedInstance] currentDate],[NSUUID UUID].UUIDString,contentType];
|
||||
// NSMutableArray *fileNames = [[NSMutableArray alloc] initWithObjects:fileName, nil];
|
||||
// __weak typeof(self)weakSelf = self;
|
||||
// [QXProjectTools showLoadingInView:self.viewController.view];
|
||||
// [[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
// dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// [QXProjectTools hideLoadingInView:self.viewController.view];
|
||||
// });
|
||||
// if (state == UploadImageSuccess) {
|
||||
// NSString *fileName = [names lastObject];
|
||||
// NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
// weakSelf.roomCoverUrl = fileUrl;
|
||||
// [weakSelf uploadImage];
|
||||
// }else{
|
||||
// QXLOG(@"文件上传失败,请重新尝试");
|
||||
// }
|
||||
// }];
|
||||
__weak typeof(self)weakSelf = self;
|
||||
[QXProjectTools showLoadingInView:self.viewController.view];
|
||||
[[QXOSSManager sharedInstance] uploadFile:files withObjectKey:fileNames isAsync:YES complete:^(NSArray<NSString *> *names, UploadImageState state) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[QXProjectTools hideLoadingInView:self.viewController.view];
|
||||
});
|
||||
if (state == UploadImageSuccess) {
|
||||
NSString *fileName = [names lastObject];
|
||||
NSString *fileUrl =[NSString stringWithFormat:@"https://%@.%@/%@",OSS_BUCKET_NAME,OSSEndPoint,fileName];
|
||||
weakSelf.roomCoverUrl = fileUrl;
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.%@",[[QXCOSUploadManager shareManager] currentDate],contentType];
|
||||
[[QXCOSUploadManager shareManager] uploadFile:files withObjectKey:@[fileName] isAsync:YES complete:^(NSArray<NSString *> * _Nonnull names, QXCOSUploadImageState state) {
|
||||
QXLOG(@"uploadstate --- %ld ---url---%@",state,names);
|
||||
if (state == QXCOSUploadImageSuccess) {
|
||||
weakSelf.roomCoverUrl = names.firstObject;
|
||||
[weakSelf uploadImage];
|
||||
}else{
|
||||
QXLOG(@"文件上传失败,请重新尝试");
|
||||
|
||||
36
QXLive/Tools/COS/QXCOSUploadManager.h
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// QXCOSUploadManager.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/23.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
typedef NS_ENUM(NSInteger, QXCOSUploadImageState) {
|
||||
QXCOSUploadImageFailed = 0,
|
||||
QXCOSUploadImageSuccess = 1
|
||||
};
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class QXCOSUploadCredentialsModel;
|
||||
@interface QXCOSUploadManager : NSObject
|
||||
+(instancetype)shareManager;
|
||||
- (void)uploadFile:(NSArray *_Nonnull)files withObjectKey:(NSArray *)objectKeys isAsync:(BOOL)isAsync complete:(void(^)(NSArray<NSString *> * names, QXCOSUploadImageState state))complete;
|
||||
- (void)activityUploadFile:(NSArray *)files withObjectKey:(NSArray *)objectKeys isAsync:(BOOL)isAsync complete:(void(^)(NSArray<NSString *> *names, QXCOSUploadImageState state))complete;
|
||||
- (NSString *)currentDate;
|
||||
@end
|
||||
|
||||
@interface QXCOSUploadModel : NSObject
|
||||
@property (nonatomic,strong)NSString *bucket;
|
||||
@property (nonatomic,strong)NSString *expiredTime;
|
||||
@property (nonatomic,strong)NSString *startTime;
|
||||
@property (nonatomic,strong)NSString *region;
|
||||
@property (nonatomic,strong)QXCOSUploadCredentialsModel *credentials;
|
||||
@end
|
||||
|
||||
@interface QXCOSUploadCredentialsModel : NSObject
|
||||
@property (nonatomic,strong)NSString *sessionToken;
|
||||
@property (nonatomic,strong)NSString *tmpSecretId;
|
||||
@property (nonatomic,strong)NSString *tmpSecretKey;
|
||||
@end
|
||||
NS_ASSUME_NONNULL_END
|
||||
226
QXLive/Tools/COS/QXCOSUploadManager.m
Normal file
@@ -0,0 +1,226 @@
|
||||
//
|
||||
// QXCOSUploadManager.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/10/23.
|
||||
//
|
||||
|
||||
#import "QXCOSUploadManager.h"
|
||||
#import <QCloudCOSXML/QCloudCOSXMLTransfer.h>
|
||||
@implementation QXCOSUploadManager
|
||||
+(instancetype)shareManager{
|
||||
static QXCOSUploadManager *manager = nil;
|
||||
static dispatch_once_t predicate;
|
||||
dispatch_once(&predicate, ^{
|
||||
manager = [[QXCOSUploadManager alloc] init];
|
||||
});
|
||||
return manager;
|
||||
}
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
// 设置并发数4
|
||||
[QCloudHTTPSessionManager shareClient].customConcurrentCount = 4;
|
||||
// 设置自动上限8
|
||||
[QCloudHTTPSessionManager shareClient].maxConcurrencyTask = 9;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)uploadFile:(NSArray *)files withObjectKey:(NSArray *)objectKeys isAsync:(BOOL)isAsync complete:(void (^)(NSArray<NSString *> * _Nullable, QXCOSUploadImageState))complete{
|
||||
[[QXRequset shareInstance] getWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,QXGetCosTempKeys] parameters:@{} needCache:NO success:^(id responseObject) {
|
||||
QXCOSUploadModel *model = [QXCOSUploadModel yy_modelWithJSON:responseObject[@"data"]];
|
||||
if (![model.region isExist] || ![model.bucket isExist] || ![model.credentials.sessionToken isExist] || ![model.credentials.tmpSecretId isExist] || ![model.credentials.tmpSecretKey isExist]) {
|
||||
QXLOG(@"服务端配置错误");
|
||||
complete(@[],QXCOSUploadImageFailed);
|
||||
return;
|
||||
}
|
||||
NSString *region = model.region;
|
||||
QCloudServiceConfiguration* configuration = [QCloudServiceConfiguration new];
|
||||
QCloudCOSXMLEndPoint* endpoint = [[QCloudCOSXMLEndPoint alloc] init];
|
||||
endpoint.regionName = region;
|
||||
// 使用 HTTPS
|
||||
endpoint.useHTTPS = true;
|
||||
configuration.endpoint = endpoint;
|
||||
// 初始化 COS 服务示例
|
||||
[QCloudCOSXMLService registerDefaultCOSXMLWithConfiguration:configuration];
|
||||
[QCloudCOSTransferMangerService registerDefaultCOSTransferMangerWithConfiguration:configuration];
|
||||
|
||||
NSString *bucket = model.bucket;
|
||||
|
||||
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
|
||||
queue.maxConcurrentOperationCount = files.count;
|
||||
NSMutableArray *callBackNames = [NSMutableArray array];
|
||||
for (int i = 0 ; i < files.count ;i++) {
|
||||
id file = files[i];
|
||||
if (file) {
|
||||
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
|
||||
QCloudCOSXMLUploadObjectRequest* put = [QCloudCOSXMLUploadObjectRequest new];
|
||||
QCloudCredential * credential = [QCloudCredential new];
|
||||
credential.secretID = model.credentials.tmpSecretId;
|
||||
credential.secretKey = model.credentials.tmpSecretKey;
|
||||
credential.token = model.credentials.sessionToken;
|
||||
// 设置临时密钥
|
||||
put.credential = credential;
|
||||
put.bucket = bucket;
|
||||
put.object = [NSString stringWithFormat:@"%@%@",IMG_FILE_BASE_PATH,objectKeys[i]];
|
||||
if ([file isKindOfClass:[UIImage class]]) {
|
||||
NSData *data = UIImageJPEGRepresentation(file, 0.3);
|
||||
put.body = data;
|
||||
}else if ([file isKindOfClass:[NSData class]]){
|
||||
put.body = file;
|
||||
}else if ([file isKindOfClass:[NSURL class]]){
|
||||
put.body = (NSURL *)file;
|
||||
}
|
||||
// 监听上传进度
|
||||
[put setSendProcessBlock:^(int64_t bytesSent,
|
||||
int64_t totalBytesSent,
|
||||
int64_t totalBytesExpectedToSend) {
|
||||
// bytesSent 本次要发送的字节数(一个大文件可能要分多次发送)
|
||||
// totalBytesSent 已发送的字节数
|
||||
// totalBytesExpectedToSend 本次上传要发送的总字节数(即一个文件大小)
|
||||
}];
|
||||
|
||||
// 监听上传结果
|
||||
[put setFinishBlock:^(QCloudUploadObjectResult *result, NSError *error) {
|
||||
if (!error) {
|
||||
NSLog(@"upload object success!");
|
||||
} else {
|
||||
NSLog(@"upload object failed, error: %@" , error);
|
||||
}
|
||||
NSString * fileUrl = result.location;
|
||||
[callBackNames addObject:fileUrl];
|
||||
if (isAsync) {
|
||||
if (file == files.lastObject) {
|
||||
NSLog(@"upload object finished!");
|
||||
if (complete) {
|
||||
complete([NSArray arrayWithArray:callBackNames] ,QXCOSUploadImageSuccess);
|
||||
}
|
||||
}
|
||||
}
|
||||
}];
|
||||
[[QCloudCOSTransferMangerService defaultCOSTransferManager] UploadObject:put];
|
||||
}];
|
||||
if (queue.operations.count != 0) {
|
||||
[operation addDependency:queue.operations.lastObject];
|
||||
}
|
||||
[queue addOperation:operation];
|
||||
}
|
||||
if (!isAsync) {
|
||||
[queue waitUntilAllOperationsAreFinished];
|
||||
NSLog(@"haha");
|
||||
if (complete) {
|
||||
if (complete) {
|
||||
complete([NSArray arrayWithArray:callBackNames], QXCOSUploadImageSuccess);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)activityUploadFile:(NSArray *)files withObjectKey:(NSArray *)objectKeys isAsync:(BOOL)isAsync complete:(void (^)(NSArray<NSString *> * _Nonnull, QXCOSUploadImageState))complete{
|
||||
[[QXRequset shareInstance] getWithUrl:[NSString stringWithFormat:@"%@%@",ServerUrl,QXGetCosTempKeys] parameters:@{} needCache:NO success:^(id responseObject) {
|
||||
QXCOSUploadModel *model = [QXCOSUploadModel yy_modelWithJSON:responseObject[@"data"]];
|
||||
if (![model.region isExist] || ![model.bucket isExist] || ![model.credentials.sessionToken isExist] || ![model.credentials.tmpSecretId isExist] || ![model.credentials.tmpSecretKey isExist]) {
|
||||
QXLOG(@"服务端配置错误");
|
||||
complete(@[],QXCOSUploadImageFailed);
|
||||
return;
|
||||
}
|
||||
NSString *region = model.region;
|
||||
QCloudServiceConfiguration* configuration = [QCloudServiceConfiguration new];
|
||||
QCloudCOSXMLEndPoint* endpoint = [[QCloudCOSXMLEndPoint alloc] init];
|
||||
endpoint.regionName = region;
|
||||
// 使用 HTTPS
|
||||
endpoint.useHTTPS = true;
|
||||
configuration.endpoint = endpoint;
|
||||
// 初始化 COS 服务示例
|
||||
[QCloudCOSXMLService registerDefaultCOSXMLWithConfiguration:configuration];
|
||||
[QCloudCOSTransferMangerService registerDefaultCOSTransferMangerWithConfiguration:configuration];
|
||||
|
||||
NSString *bucket = model.bucket;
|
||||
|
||||
NSMutableArray *callBackNames = [NSMutableArray array];
|
||||
for (int i = 0 ; i < files.count ;i++) {
|
||||
id file = files[i];
|
||||
if (file) {
|
||||
QCloudCOSXMLUploadObjectRequest* put = [QCloudCOSXMLUploadObjectRequest new];
|
||||
QCloudCredential * credential = [QCloudCredential new];
|
||||
credential.secretID = model.credentials.tmpSecretId;
|
||||
credential.secretKey = model.credentials.tmpSecretKey;
|
||||
credential.token = model.credentials.sessionToken;
|
||||
// 设置临时密钥
|
||||
put.credential = credential;
|
||||
put.bucket = bucket;
|
||||
put.object = [NSString stringWithFormat:@"%@%@",IMG_FILE_BASE_PATH,objectKeys[i]];
|
||||
if ([file isKindOfClass:[UIImage class]]) {
|
||||
NSData *data = UIImageJPEGRepresentation(file, 0.3);
|
||||
put.body = data;
|
||||
}else if ([file isKindOfClass:[NSData class]]){
|
||||
put.body = file;
|
||||
}else if ([file isKindOfClass:[NSURL class]]){
|
||||
put.body = (NSURL *)file;
|
||||
}
|
||||
// 监听上传进度
|
||||
[put setSendProcessBlock:^(int64_t bytesSent,
|
||||
int64_t totalBytesSent,
|
||||
int64_t totalBytesExpectedToSend) {
|
||||
// bytesSent 本次要发送的字节数(一个大文件可能要分多次发送)
|
||||
// totalBytesSent 已发送的字节数
|
||||
// totalBytesExpectedToSend 本次上传要发送的总字节数(即一个文件大小)
|
||||
}];
|
||||
|
||||
// 监听上传结果
|
||||
[put setFinishBlock:^(QCloudUploadObjectResult *result, NSError *error) {
|
||||
if (!error) {
|
||||
NSLog(@"upload object success!");
|
||||
} else {
|
||||
NSLog(@"upload object failed, error: %@" , error);
|
||||
}
|
||||
NSString * fileUrl = result.location;
|
||||
[callBackNames addObject:fileUrl];
|
||||
if (isAsync) {
|
||||
if (i == files.count-1) {
|
||||
NSLog(@"upload object finished!");
|
||||
if (complete) {
|
||||
complete([NSArray arrayWithArray:callBackNames] ,QXCOSUploadImageSuccess);
|
||||
}
|
||||
}
|
||||
}
|
||||
}];
|
||||
[[QCloudCOSTransferMangerService defaultCOSTransferManager] UploadObject:put];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} fail:^(NSError *error, NSString *msg, NSURLSessionDataTask *task) {
|
||||
|
||||
}];
|
||||
}
|
||||
- (NSString *)currentDate {
|
||||
NSTimeInterval interval = [[NSDate date] timeIntervalSince1970];
|
||||
long long timestampInMilliseconds = interval * 1000;
|
||||
return [NSString stringWithFormat:@"%lld",timestampInMilliseconds];
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@implementation QXCOSUploadModel
|
||||
|
||||
+(NSDictionary<NSString *,id> *)modelContainerPropertyGenericClass{
|
||||
return @{
|
||||
@"credentials" : @"QXCOSUploadCredentialsModel",
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation QXCOSUploadCredentialsModel
|
||||
|
||||
|
||||
|
||||
@end
|
||||