|
@@ -1,72 +1,15 @@
|
|
|
//
|
|
|
// KSChatConversationViewController.m
|
|
|
-// KulexiuForTeacher
|
|
|
+// GuanYueTeamManager
|
|
|
//
|
|
|
-// Created by Kyle on 2022/3/23.
|
|
|
+// Created by 王智 on 2023/8/2.
|
|
|
//
|
|
|
|
|
|
#import "KSChatConversationViewController.h"
|
|
|
-#import "GroupSettingViewController.h"
|
|
|
-#import "KSTabBarViewController.h"
|
|
|
-#import "UIButton+EnlargeEdge.h"
|
|
|
-#import "CustomNavViewController.h"
|
|
|
-#import <AVFoundation/AVFoundation.h>
|
|
|
-#import "KSBaseWKWebViewController.h"
|
|
|
-#import "WMPlayer.h"
|
|
|
-#import "KSRCloudMediaManager.h"
|
|
|
-#import "KSSelectConversationViewController.h"
|
|
|
-#import "GroupMemberModel.h"
|
|
|
|
|
|
-#import "KSChatLiveMessage.h"
|
|
|
-#import "KSChatLiveShareCell.h"
|
|
|
-#import "KSChatMusicShareCell.h"
|
|
|
-#import "KSChatMusicMessage.h"
|
|
|
+@interface KSChatConversationViewController ()
|
|
|
|
|
|
-#import "KSEnterLiveroomManager.h"
|
|
|
-#import "KSAccompanyWebViewController.h"
|
|
|
-
|
|
|
-#import "KSPublicAlertView.h"
|
|
|
-#import "KSGroupTagImageView.h"
|
|
|
-#import "KSChatUserDetailViewController.h"
|
|
|
-
|
|
|
-#define SHARE_MUSIC_TAG (2001)
|
|
|
-
|
|
|
-@interface RCNaviDataInfo : NSObject
|
|
|
-
|
|
|
-@property (nonatomic, assign) NSTimeInterval uploadVideoDurationLimit;
|
|
|
-
|
|
|
-@end
|
|
|
-
|
|
|
-@interface RCNaviDataManager : NSObject
|
|
|
-
|
|
|
-@property (nonatomic, strong) RCNaviDataInfo *naviData;
|
|
|
-
|
|
|
-+ (instancetype)sharedInstance;
|
|
|
-
|
|
|
-@end
|
|
|
-
|
|
|
-@interface RCSightMessage ()
|
|
|
-
|
|
|
-@property (nonatomic, readonly) AVAsset *asset;
|
|
|
-
|
|
|
-@property (nonatomic, assign) long long size;
|
|
|
-
|
|
|
-+ (instancetype)messageWithAsset:(AVAsset *)asset thumbnail:(UIImage *)image duration:(NSUInteger)duration;
|
|
|
-@end
|
|
|
-
|
|
|
-
|
|
|
-@interface KSChatConversationViewController ()<RCMessageCellDelegate,UIAlertViewDelegate,UIActionSheetDelegate,WMPlayerDelegate>
|
|
|
-{
|
|
|
- WMPlayer *_wmPlayer;
|
|
|
- CGRect _playerFrame;
|
|
|
-}
|
|
|
-
|
|
|
-@property (nonatomic, strong) UIView *bgView;
|
|
|
-@property (nonatomic, assign) BOOL isRatation;
|
|
|
-
|
|
|
-@property (nonatomic, assign) BOOL isFirstLoad;
|
|
|
-
|
|
|
-@property (nonatomic, strong) KSPublicAlertView *alertView;
|
|
|
+@property (nonatomic, strong) TUIC2CChatViewController *vc;
|
|
|
|
|
|
@end
|
|
|
|
|
@@ -75,759 +18,57 @@
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
// Do any additional setup after loading the view.
|
|
|
- if (self.conversationType == ConversationType_PRIVATE) {
|
|
|
- self.displayUserNameInCell = NO;
|
|
|
- }
|
|
|
- else if (self.conversationType == ConversationType_SYSTEM) {
|
|
|
- self.displayUserNameInCell = NO;
|
|
|
- self.chatSessionInputBarControl.hidden = YES;
|
|
|
- self.conversationMessageCollectionView.frame = CGRectMake(0, kNaviBarHeight, kScreenWidth, kScreenHeight - iPhoneXSafeBottomMargin - kNaviBarHeight);
|
|
|
- }
|
|
|
-
|
|
|
- if (self.conversationType != ConversationType_APPSERVICE &&
|
|
|
- self.conversationType != ConversationType_PUBLICSERVICE) {
|
|
|
- //加号区域增加发送文件功能,Kit中已经默认实现了该功能,但是为了SDK向后兼容性,目前SDK默认不开启该入口,可以参考以下代码在加号区域中增加发送文件功能。
|
|
|
- UIImage *imageFile = [UIImage imageNamed:@"actionbar_file_icon"];
|
|
|
- RCPluginBoardView *pluginBoardView = self.chatSessionInputBarControl.pluginBoardView;
|
|
|
- [pluginBoardView insertItem:imageFile
|
|
|
- highlightedImage:imageFile
|
|
|
- title:@"文件"
|
|
|
- atIndex:3
|
|
|
- tag:PLUGIN_BOARD_ITEM_FILE_TAG];
|
|
|
- }
|
|
|
-
|
|
|
- // 注册自定义消息
|
|
|
- [self registerClass:[KSChatLiveShareCell class] forMessageClass:[KSChatLiveMessage class]];
|
|
|
- [self registerClass:[KSChatMusicShareCell class] forMessageClass:[KSChatMusicMessage class]];
|
|
|
-
|
|
|
- [self leftRightButton];
|
|
|
- [self refreshUserInfoOrGroupInfo];
|
|
|
- self.isFirstLoad = YES;
|
|
|
- [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
|
|
|
+ [self configUI];
|
|
|
+ [self clearConversation];
|
|
|
+ [self requestData];
|
|
|
}
|
|
|
|
|
|
-- (void)allocTitle:(NSString *)Ntitle withColor:(UIColor *)color {
|
|
|
- UILabel *natext= [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
|
|
|
- natext.textAlignment = NSTextAlignmentCenter;
|
|
|
- natext.font = [UIFont systemFontOfSize:18.0f weight:UIFontWeightMedium];
|
|
|
- natext.textColor = color;
|
|
|
- natext.text = Ntitle;
|
|
|
- self.navigationItem.titleView = natext;
|
|
|
+- (void)configUI {
|
|
|
+ self.vc = [[TUIC2CChatViewController alloc] init];
|
|
|
+ if (![NSString isEmptyString:self.highlightKeyword]) {
|
|
|
+ self.vc.highlightKeyword = self.highlightKeyword;
|
|
|
+ self.vc.locateMessage = self.locateMessage;
|
|
|
+ }
|
|
|
+ self.vc.conversationData = self.conversation;
|
|
|
+ [self addChildViewController:self.vc];
|
|
|
+ [self.view addSubview:self.vc.view];
|
|
|
}
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
[super viewWillAppear:animated];
|
|
|
- if (self.isFirstLoad == NO) {
|
|
|
- [self refreshUserInfoOrGroupInfo];
|
|
|
- }
|
|
|
- [self refreshTitle];
|
|
|
-}
|
|
|
|
|
|
-- (void)viewDidAppear:(BOOL)animated {
|
|
|
- [super viewDidAppear:animated];
|
|
|
- self.isFirstLoad = NO;
|
|
|
- [IQKeyboardManager sharedManager].enableAutoToolbar = NO;
|
|
|
+ //TODO: 页面appear 禁用
|
|
|
+ [[IQKeyboardManager sharedManager] setEnable:NO];
|
|
|
}
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
[super viewWillDisappear:animated];
|
|
|
- int unreadMsgCount = [[RCIMClient sharedRCIMClient] getUnreadCount:@[
|
|
|
- @(ConversationType_PRIVATE), @(ConversationType_APPSERVICE), @(ConversationType_GROUP),@(ConversationType_SYSTEM)
|
|
|
- ]];
|
|
|
- if (unreadMsgCount >= 1) {
|
|
|
- [(KSTabBarViewController *)self.tabBarController noteNewsWithIndex:2 count:unreadMsgCount];
|
|
|
- } else {
|
|
|
- [(KSTabBarViewController *)self.tabBarController clearNewsWithIndex:2];
|
|
|
- }
|
|
|
-
|
|
|
- [IQKeyboardManager sharedManager].enableAutoToolbar = YES;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)notifyUpdateUnreadMessageCount {
|
|
|
- if (self.allowsMessageCellSelection) {
|
|
|
- [super notifyUpdateUnreadMessageCount];
|
|
|
- return;
|
|
|
- }
|
|
|
- [self leftRightButton];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)leftRightButton {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- UIBarButtonItem *leftButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back_black"] style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
|
|
|
- leftButton.imageInsets = UIEdgeInsetsMake(0, -5, 0, 0);
|
|
|
- leftButton.tintColor = [UIColor blackColor];
|
|
|
- self.navigationItem.leftBarButtonItem = leftButton;
|
|
|
- if (self.conversationType == ConversationType_GROUP) {
|
|
|
- [self rightButtonWithImage:@"group_setting"];
|
|
|
- }
|
|
|
- else if (self.conversationType == ConversationType_SYSTEM || self.conversationType == ConversationType_PRIVATE) {
|
|
|
- self.navigationItem.rightBarButtonItem = nil;
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-- (void)rightButtonWithImage:(NSString *)imageName {
|
|
|
- UIButton *rightBt = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
- rightBt.frame =CGRectMake(0, 0, 80, 40);
|
|
|
- rightBt.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -40);
|
|
|
- [rightBt setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
|
|
|
- rightBt.titleLabel.font = [UIFont systemFontOfSize:16];
|
|
|
- [rightBt setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
|
|
- [rightBt setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
|
|
|
- [rightBt addTarget:self action:@selector(rightBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
|
|
- UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightBt];
|
|
|
- self.navigationItem.rightBarButtonItem = rightItem;
|
|
|
-}
|
|
|
|
|
|
-- (void)backAction {
|
|
|
- [self.navigationController popViewControllerAnimated:YES];
|
|
|
-}
|
|
|
-- (void)rightBtnClick {
|
|
|
- GroupSettingViewController *groupVC = [[GroupSettingViewController alloc] init];
|
|
|
- groupVC.groupId = self.targetId;
|
|
|
- [self.navigationController pushViewController:groupVC animated:YES];
|
|
|
-}
|
|
|
-
|
|
|
-- (NSArray<UIMenuItem *> *)getLongTouchMessageCellMenuList:(RCMessageModel *)model {
|
|
|
- if (self.conversationType == ConversationType_SYSTEM) {
|
|
|
- return [NSArray array];
|
|
|
- }
|
|
|
- return [super getLongTouchMessageCellMenuList:model];
|
|
|
-}
|
|
|
-
|
|
|
-// 转发
|
|
|
-- (void)forwardMessage:(NSInteger)index
|
|
|
- completed:(void (^)(NSArray<RCConversation *> *conversationList))completedBlock {
|
|
|
- KSSelectConversationViewController *forwardSelectedVC = [[KSSelectConversationViewController alloc]
|
|
|
- initSelectConversationViewControllerCompleted:^(NSArray<RCConversation *> *conversationList) {
|
|
|
- completedBlock(conversationList);
|
|
|
- }];
|
|
|
- [self.navigationController pushViewController:forwardSelectedVC animated:NO];
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark override
|
|
|
-// 点击消息的处理
|
|
|
-- (void)didTapMessageCell:(RCMessageModel *)model {
|
|
|
- if ([model.objectName isEqualToString:@"RC:CHATSHARE:LIVE"]) { // 直播消息
|
|
|
- KSChatLiveMessage *liveShareMsg = (KSChatLiveMessage *)model.content;
|
|
|
- [KSEnterLiveroomManager joinLiveWithRoomId:liveShareMsg.roomUID inController:(CustomNavViewController *)self.navigationController callback:^{
|
|
|
-
|
|
|
- }];
|
|
|
- }
|
|
|
- else if ([model.objectName isEqualToString:@"RC:CHATSHARE:MUSIC"]) { // 曲谱消息
|
|
|
- KSChatMusicMessage *musicShareMsg = (KSChatMusicMessage *)model.content;
|
|
|
- KSAccompanyWebViewController *detailCtrl = [[KSAccompanyWebViewController alloc] init];
|
|
|
- detailCtrl.url = [NSString stringWithFormat:@"%@/accompany?id=%@",hostURL, musicShareMsg.songId];
|
|
|
- detailCtrl.hiddenNavBar = YES;
|
|
|
- detailCtrl.parmDic = @{@"isOpenLight" : @(YES), @"orientation" : @(0),@"isHideTitle" : @(YES)};
|
|
|
- [self.navigationController pushViewController:detailCtrl animated:YES];
|
|
|
- }
|
|
|
- else {
|
|
|
- [super didTapMessageCell:model];
|
|
|
- }
|
|
|
+ //TODO: 页面Disappear 启用
|
|
|
+ [[IQKeyboardManager sharedManager] setEnable:YES];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-- (void)playVideoWithUrl:(NSString *)fileUrl {
|
|
|
- fileUrl = [fileUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
|
- _playerFrame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
- _wmPlayer = [[WMPlayer alloc] initWithFrame:_playerFrame];
|
|
|
- WMPlayerModel *playModel = [[WMPlayerModel alloc] init];
|
|
|
- playModel.videoURL = [NSURL URLWithString:fileUrl];
|
|
|
- _wmPlayer.playerModel = playModel;
|
|
|
- _wmPlayer.delegate = self;
|
|
|
- _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
|
|
|
- _bgView.backgroundColor = [UIColor blackColor];
|
|
|
- [[UIApplication sharedApplication].keyWindow addSubview:_bgView];
|
|
|
- [[UIApplication sharedApplication].keyWindow addSubview:_wmPlayer];
|
|
|
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:_wmPlayer];
|
|
|
+- (void)clearConversation {
|
|
|
|
|
|
- [_wmPlayer play];
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-- (void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)backBtn {
|
|
|
- [wmplayer removePlayer];
|
|
|
- [_bgView removeFromSuperview];
|
|
|
- [self setNeedsStatusBarAppearanceUpdate];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn {
|
|
|
- self.isRatation = !self.isRatation;
|
|
|
-
|
|
|
- if (self.isRatation) {
|
|
|
- [wmplayer removeFromSuperview];
|
|
|
- [UIView animateWithDuration:1.0f animations:^{
|
|
|
- wmplayer.transform = CGAffineTransformMakeRotation(M_PI_2);
|
|
|
-
|
|
|
- } completion:^(BOOL finished) {
|
|
|
- wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
- [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
|
|
|
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
|
|
|
- }];
|
|
|
- }
|
|
|
- else {
|
|
|
- [wmplayer removeFromSuperview];
|
|
|
+ NSString *conversationID = [NSString stringWithFormat:@"c2c_%@",self.conversation.userID];
|
|
|
+ [[V2TIMManager sharedInstance] cleanConversationUnreadMessageCount:conversationID cleanTimestamp:0 cleanSequence:0 succ:^{
|
|
|
|
|
|
- [UIView animateWithDuration:1.0f animations:^{
|
|
|
- // 复原
|
|
|
- wmplayer.transform = CGAffineTransformIdentity;
|
|
|
-
|
|
|
- } completion:^(BOOL finished) {
|
|
|
- wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
- [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
|
|
|
- [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
|
|
|
- }];
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-- (void)didTapUrlInMessageCell:(NSString *)url model:(RCMessageModel *)model {
|
|
|
- if ([url containsString:@"dayaedu"]) {
|
|
|
+ } fail:^(int code, NSString *desc) {
|
|
|
|
|
|
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
|
|
|
- ctrl.url = url;
|
|
|
- [self.navigationController pushViewController:ctrl animated:YES];
|
|
|
- }
|
|
|
- else if ([url containsString:@"daya"] && [url hasSuffix:@".mp4"]) {
|
|
|
- [self playVideoWithUrl:url];
|
|
|
- }
|
|
|
- else {
|
|
|
- [super didTapUrlInMessageCell:url model:model];
|
|
|
- }
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-- (RCMessageContent *)willSendMessage:(RCMessageContent *)messageContent {
|
|
|
- //可以在这里修改将要发送的消息
|
|
|
- if ([messageContent isMemberOfClass:[RCTextMessage class]]) {
|
|
|
- // RCTextMessage *textMsg = (RCTextMessage *)messageContent;
|
|
|
- // textMsg.extra = @"";
|
|
|
- }
|
|
|
- return messageContent;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)resendMessage:(RCMessageContent *)messageContent {
|
|
|
- if ([messageContent isKindOfClass:[RCSightMessage class]]) {
|
|
|
- RCSightMessage *sightMsg = (RCSightMessage *)messageContent;
|
|
|
- [self sendMediaMessage:sightMsg pushContent:nil appUpload:YES];
|
|
|
- }
|
|
|
- else {
|
|
|
- [super resendMessage:messageContent];
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark --- refresh
|
|
|
-- (void)refreshUserInfoOrGroupInfo {
|
|
|
-
|
|
|
- if (self.conversationType == ConversationType_PRIVATE) {
|
|
|
- if (![self.targetId isEqualToString:[RCIM sharedRCIM].currentUserInfo.userId]) {
|
|
|
- [KSNetworkingManager imUserFriendQueryDetail:KS_POST userId:self.targetId success:^(NSDictionary * _Nonnull dic) {
|
|
|
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
|
|
|
- NSDictionary *userDic = [dic ks_dictionaryValueForKey:@"data"];
|
|
|
- RCUserInfo *user = [[RCUserInfo alloc] initWithUserId:self.targetId name:[userDic ks_stringValueForKey:@"friendNickname"] portrait:[userDic ks_stringValueForKey:@"friendAvatar"]];
|
|
|
- // 附加字段
|
|
|
- NSMutableDictionary *extraDic = [NSMutableDictionary dictionary];
|
|
|
- [extraDic setValue:[userDic ks_stringValueForKey:@"roleType"] forKey:@"role"];
|
|
|
- user.extra = [extraDic mj_JSONString];
|
|
|
-
|
|
|
- [[RCIM sharedRCIM] refreshUserInfoCache:user withUserId:self.targetId];
|
|
|
- [self refreshTitle];
|
|
|
- }
|
|
|
- else {
|
|
|
-
|
|
|
- }
|
|
|
- } faliure:^(NSError * _Nonnull error) {
|
|
|
-
|
|
|
- }];
|
|
|
+- (void)requestData {
|
|
|
+ [KSNetworkingManager imUserFriendQueryDetail:KS_POST userId:self.conversation.userID success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
|
|
|
+ NSDictionary *userDic = [dic ks_dictionaryValueForKey:@"data"];
|
|
|
+ NSString *userName = [userDic ks_stringValueForKey:@"friendNickname"];
|
|
|
+ [self allocTitle:userName];
|
|
|
}
|
|
|
- }
|
|
|
- else if (self.conversationType == ConversationType_GROUP) {
|
|
|
- // 获取群成员
|
|
|
- [KSNetworkingManager imGroupMemberAllRequest:KS_POST groupId:self.targetId success:^(NSDictionary * _Nonnull dic) {
|
|
|
-
|
|
|
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
|
|
|
- NSArray *sourceArray = [dic ks_arrayValueForKey:@"data"];
|
|
|
- for (NSDictionary *parm in sourceArray) {
|
|
|
- if ([parm isKindOfClass:[NSNull class]]) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- GroupMemberModel *model = [[GroupMemberModel alloc] initWithDictionary:parm];
|
|
|
- // 刷新缓存
|
|
|
- RCUserInfo *user = [[RCUserInfo alloc] initWithUserId:model.imUserId name:model.nickname portrait:model.avatar];
|
|
|
- // 附加字段
|
|
|
- NSMutableDictionary *extraDic = [NSMutableDictionary dictionary];
|
|
|
- if (model.isAdmin) {
|
|
|
- [extraDic setValue:@"owner" forKey:@"groupOwner"];
|
|
|
- }
|
|
|
- [extraDic setValue:model.roleType forKey:@"role"];
|
|
|
- user.extra = [extraDic mj_JSONString];
|
|
|
-
|
|
|
- [[RCIM sharedRCIM] refreshGroupUserInfoCache:user withUserId:model.imUserId withGroupId:self.targetId];
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } faliure:^(NSError * _Nonnull error) {
|
|
|
-
|
|
|
- }];
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
|
|
|
- // 获取群组信息
|
|
|
- [KSNetworkingManager queryGroupDetail:KS_POST groupId:self.targetId success:^(NSDictionary * _Nonnull dic) {
|
|
|
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
|
|
|
- NSDictionary *result = [dic ks_dictionaryValueForKey:@"data"];
|
|
|
- RCGroup *groupInfo = [[RCGroup alloc] initWithGroupId:self.targetId groupName:[result ks_stringValueForKey:@"name"] portraitUri:[result ks_stringValueForKey:@"img"]];
|
|
|
- [[RCIM sharedRCIM] refreshGroupInfoCache:groupInfo withGroupId:self.targetId];
|
|
|
- [self refreshTitle];
|
|
|
- }
|
|
|
- else if ([dic ks_integerValueForKey:@"code"] == 204) {
|
|
|
- // 弹窗提示是否删除群组
|
|
|
- MJWeakSelf;
|
|
|
- self.alertView = [KSPublicAlertView shareInstanceWithTitle:@"提示" descMessage:@"当前群组已被解散,是否删除聊天记录?" leftTitle:@"取消" rightTitle:@"确定" cancelAction:^{
|
|
|
-
|
|
|
- } sureAction:^{
|
|
|
- [weakSelf removeNoExistGroup];
|
|
|
- }];
|
|
|
- }
|
|
|
- } faliure:^(NSError * _Nonnull error) {
|
|
|
-
|
|
|
- }];
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-- (void)removeNoExistGroup {
|
|
|
- [[RCIMClient sharedRCIMClient] removeConversation:ConversationType_GROUP targetId:self.targetId];
|
|
|
- [self.navigationController popToRootViewControllerAnimated:YES];
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-- (void)refreshTitle {
|
|
|
- if (self.conversationType == ConversationType_GROUP) {
|
|
|
- RCGroup *group = [[RCIM sharedRCIM] getGroupInfoCache:self.targetId];
|
|
|
- if (![NSString isEmptyString:group.groupName]) {
|
|
|
- [self allocTitle:group.groupName withColor:[UIColor blackColor]];
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- RCUserInfo *userInfo = [[RCIM sharedRCIM] getUserInfoCache:self.targetId];
|
|
|
- if (![NSString isEmptyString:userInfo.name]) {
|
|
|
- [self allocTitle:userInfo.name withColor:[UIColor blackColor]];
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-- (void)pluginBoardView:(RCPluginBoardView *)pluginBoardView clickedItemWithTag:(NSInteger)tag {
|
|
|
- switch (tag) {
|
|
|
- case SHARE_MUSIC_TAG: // 曲谱分享
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- default:
|
|
|
- {
|
|
|
- [RCNaviDataManager sharedInstance].naviData.uploadVideoDurationLimit = 480.0f;
|
|
|
- [super pluginBoardView:pluginBoardView clickedItemWithTag:tag];
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-- (void)willDisplayMessageCell:(RCMessageBaseCell *)cell atIndexPath:(NSIndexPath *)indexPath {
|
|
|
- if ([cell isKindOfClass:[RCMessageCell class]]) {
|
|
|
- UIImageView *imageView = (UIImageView *)((RCMessageCell *)cell).portraitImageView;
|
|
|
- imageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
- imageView.layer.masksToBounds = YES;
|
|
|
-
|
|
|
- if (self.conversationType == ConversationType_GROUP) {
|
|
|
- UIView *contentView = (UIView *)((RCMessageCell *)cell).messageContentView;
|
|
|
- RCMessageModel *model = self.conversationDataRepository[indexPath.row];
|
|
|
- for (UIView *subView in contentView.subviews) {
|
|
|
- if ([subView isKindOfClass:[KSGroupTagImageView class]]) {
|
|
|
- [subView removeFromSuperview];
|
|
|
- }
|
|
|
- }
|
|
|
- RCUserInfo *user = [[RCIM sharedRCIM] getGroupUserInfoCache:model.senderUserId withGroupId:self.targetId];
|
|
|
- NSDictionary *extraDic = [user.extra mj_JSONObject];
|
|
|
-
|
|
|
- if ([[extraDic ks_stringValueForKey:@"role"] isEqualToString:@"TEACHER"]) {
|
|
|
- KSGroupTagImageView *avatarImage = [[KSGroupTagImageView alloc] initWithImage:[UIImage imageNamed:@"chat_collegeTag"]];
|
|
|
- [contentView addSubview:avatarImage];
|
|
|
- [avatarImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.width.mas_equalTo(40);
|
|
|
- make.height.mas_equalTo(13);
|
|
|
- make.centerX.mas_equalTo(imageView.mas_centerX);
|
|
|
- make.bottom.mas_equalTo(imageView.mas_bottom);
|
|
|
- }];
|
|
|
- }
|
|
|
- // owner
|
|
|
- if ([[extraDic ks_stringValueForKey:@"groupOwner"] isEqualToString:@"owner"]) {
|
|
|
-
|
|
|
- RCMessageCell *baseCell = (RCMessageCell *)cell;
|
|
|
-
|
|
|
- KSGroupTagImageView *ownerTagView = [[KSGroupTagImageView alloc] initWithImage:[UIImage imageNamed:@"group_ownerTag"]];
|
|
|
- [contentView addSubview:ownerTagView];
|
|
|
- [ownerTagView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.width.mas_equalTo(24);
|
|
|
- make.height.mas_equalTo(14);
|
|
|
- make.centerY.mas_equalTo(baseCell.nicknameLabel.mas_centerY);
|
|
|
- make.left.mas_equalTo(baseCell.bubbleBackgroundView.mas_left);
|
|
|
- }];
|
|
|
- [baseCell.nicknameLabel mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.mas_equalTo(ownerTagView.mas_right).offset(4);
|
|
|
- }];
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else if (self.conversationType == ConversationType_PRIVATE) {
|
|
|
- UIView *contentView = (UIView *)((RCMessageCell *)cell).messageContentView;
|
|
|
- for (UIView *subView in contentView.subviews) {
|
|
|
- if ([subView isKindOfClass:[KSGroupTagImageView class]]) {
|
|
|
- [subView removeFromSuperview];
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- RCMessageModel *model = self.conversationDataRepository[indexPath.row];
|
|
|
- RCUserInfo *user = [[RCIM sharedRCIM] getUserInfoCache:model.senderUserId];
|
|
|
- NSDictionary *extraDic = [user.extra mj_JSONObject];
|
|
|
- if ([[extraDic ks_stringValueForKey:@"role"] isEqualToString:@"TEACHER"]) {
|
|
|
- KSGroupTagImageView *avatarImage = [[KSGroupTagImageView alloc] initWithImage:[UIImage imageNamed:@"chat_collegeTag"]];
|
|
|
- [contentView addSubview:avatarImage];
|
|
|
- [avatarImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.width.mas_equalTo(40);
|
|
|
- make.height.mas_equalTo(13);
|
|
|
- make.centerX.mas_equalTo(imageView.mas_centerX);
|
|
|
- make.bottom.mas_equalTo(imageView.mas_bottom);
|
|
|
- }];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-#pragma mark ----- chatSessionInputBarControl delegate
|
|
|
-- (void)sightDidFinishRecord:(NSString *)url thumbnail:(UIImage *)image duration:(NSUInteger)duration {
|
|
|
- RCSightMessage *sightMessage = [RCSightMessage messageWithLocalPath:url thumbnail:image duration:duration];
|
|
|
+ }];
|
|
|
|
|
|
- [self sendMediaMessage:sightMessage pushContent:nil appUpload:YES];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)imageDataDidSelect:(NSArray *)selectedImages fullImageRequired:(BOOL)full {
|
|
|
-
|
|
|
- [self becomeFirstResponder];
|
|
|
- __weak KSChatConversationViewController *weakSelf = self;
|
|
|
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
- for (int i = 0; i < selectedImages.count; i++) {
|
|
|
- @autoreleasepool {
|
|
|
- id item = [selectedImages objectAtIndex:i];
|
|
|
- if ([item isKindOfClass:NSData.class]) {
|
|
|
- NSData *imageData = (NSData *)item;
|
|
|
- UIImage *image = [UIImage imageWithData:imageData];
|
|
|
- image = [RCKitUtility fixOrientation:image];
|
|
|
- // 保留原有逻辑并添加大图缩小的功能
|
|
|
- [[KSRCloudMediaManager sharedManager] downsizeImage:image completionBlock:^(UIImage * _Nullable outimage, BOOL doNothing) {
|
|
|
- RCImageMessage *imagemsg;
|
|
|
- if (doNothing || !outimage) {
|
|
|
- imagemsg = [RCImageMessage messageWithImage:image];
|
|
|
- imagemsg.full = full;
|
|
|
- } else if (outimage) {
|
|
|
- NSData *newImageData = UIImageJPEGRepresentation(outimage, 1);
|
|
|
- imagemsg = [RCImageMessage messageWithImageData:newImageData];
|
|
|
- imagemsg.full = full;
|
|
|
- }
|
|
|
- [weakSelf sendMessage:imagemsg pushContent:nil];
|
|
|
- } progressBlock:^(UIImage * _Nullable outimage, BOOL doNothing) {
|
|
|
-
|
|
|
- }];
|
|
|
-
|
|
|
- }
|
|
|
- else if ([item isKindOfClass:NSDictionary.class]) {
|
|
|
- NSDictionary *assertInfo = item;
|
|
|
- if ([assertInfo objectForKey:@"avAsset"]) {
|
|
|
- AVAsset *model = assertInfo[@"avAsset"];
|
|
|
- UIImage *image = assertInfo[@"thumbnail"];
|
|
|
- NSString *localPath = assertInfo[@"localPath"];
|
|
|
- if (![localPath isKindOfClass:[NSString class]]) {
|
|
|
- localPath = @"";
|
|
|
- }
|
|
|
- dispatch_sync(dispatch_get_main_queue(), ^{
|
|
|
- NSUInteger duration = round(CMTimeGetSeconds(model.duration));
|
|
|
- RCSightMessage *sightMsg =
|
|
|
- [RCSightMessage messageWithAsset:model thumbnail:image duration:duration];
|
|
|
- sightMsg.localPath = localPath;
|
|
|
- [weakSelf sendMediaMessage:sightMsg pushContent:nil appUpload:YES];
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- [NSThread sleepForTimeInterval:0.5];
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-- (void)uploadMedia:(RCMessage *)message uploadListener:(RCUploadMediaStatusListener *)uploadListener {
|
|
|
- // 获取 asset
|
|
|
- if ([message.content isKindOfClass:[RCSightMessage class]]) {
|
|
|
- RCSightMessage *sightMessage = (RCSightMessage *)message.content;
|
|
|
- NSString *fileName = [NSString stringWithFormat:@"sight_%@", [[sightMessage.name componentsSeparatedByString:@"_"] lastObject]];
|
|
|
- NSString *savePath = [[self getSightSavePath] stringByAppendingPathComponent:fileName];
|
|
|
- // 判断文件是否存在于该文件夹
|
|
|
- if ([[NSFileManager defaultManager] fileExistsAtPath:savePath]) {
|
|
|
- sightMessage.localPath = savePath;
|
|
|
- [self submitFileWithMessage:sightMessage uploadListener:uploadListener];
|
|
|
- }
|
|
|
- else {
|
|
|
- if (([sightMessage.localPath containsString:@"var/mobile/Media/"])) {
|
|
|
- NSURL *fileUrl = [NSURL fileURLWithPath:sightMessage.localPath];
|
|
|
- AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:fileUrl options:nil];
|
|
|
- [self startExportVideoWithVideoAsset:avAsset presetName:AVAssetExportPreset960x540 savePath:savePath success:^(NSString *outputPath) {
|
|
|
- sightMessage.localPath = savePath;
|
|
|
-
|
|
|
- [self submitFileWithMessage:sightMessage uploadListener:uploadListener];
|
|
|
- } failure:^(NSString *errorMessage, NSError *error) {
|
|
|
- // 导出失败 直接拷贝上传
|
|
|
- [self copyFileToPath:savePath uploadListener:uploadListener];
|
|
|
- }];
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- // 复制文件到指定文件夹
|
|
|
- [self copyFileToPath:savePath uploadListener:uploadListener];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- uploadListener.errorBlock(INVALID_PARAMETER);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-- (void)copyFileToPath:(NSString *)savePath uploadListener:(RCUploadMediaStatusListener *)uploadListener {
|
|
|
- RCMessage *message = uploadListener.currentMessage;
|
|
|
- if ([message.content isKindOfClass:[RCSightMessage class]]) {
|
|
|
- RCSightMessage *sightMessage = (RCSightMessage *)message.content;
|
|
|
- // 复制文件到指定文件夹
|
|
|
- BOOL isSuccess = [self copyMediaFile:sightMessage.localPath toPath:savePath];
|
|
|
- if (isSuccess) {
|
|
|
- sightMessage.localPath = savePath;
|
|
|
- [self submitFileWithMessage:sightMessage uploadListener:uploadListener];
|
|
|
- }
|
|
|
- else {
|
|
|
- uploadListener.errorBlock(INVALID_PARAMETER);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-- (void)startExportVideoWithVideoAsset:(AVURLAsset *)videoAsset presetName:(NSString *)presetName savePath:(NSString *)savePath success:(void (^)(NSString *outputPath))success failure:(void (^)(NSString *errorMessage, NSError *error))failure {
|
|
|
- NSArray *presets = [AVAssetExportSession exportPresetsCompatibleWithAsset:videoAsset];
|
|
|
- if ([presets containsObject:presetName]) {
|
|
|
-
|
|
|
- NSError *error = nil;
|
|
|
- AVAssetTrack *assetVideoTrack = nil;
|
|
|
- AVAssetTrack *assetAudioTrack = nil;
|
|
|
- CMTime start = CMTimeMakeWithSeconds(0, videoAsset.duration.timescale);
|
|
|
-
|
|
|
- CMTimeRange range = CMTimeRangeMake(start, videoAsset.duration);
|
|
|
- // Check if the asset contains video and audio tracks
|
|
|
- if ([[videoAsset tracksWithMediaType:AVMediaTypeVideo] count] != 0) {
|
|
|
- assetVideoTrack = [videoAsset tracksWithMediaType:AVMediaTypeVideo][0];
|
|
|
- }
|
|
|
-
|
|
|
- if ([[videoAsset tracksWithMediaType:AVMediaTypeAudio] count] != 0) {
|
|
|
- assetAudioTrack = [videoAsset tracksWithMediaType:AVMediaTypeAudio][0];
|
|
|
- }
|
|
|
-
|
|
|
- CMTime insertionPoint = kCMTimeZero;
|
|
|
-
|
|
|
- AVMutableComposition *composition = [[AVMutableComposition alloc] init];
|
|
|
-
|
|
|
- // Insert the video and audio tracks from AVAsset
|
|
|
- if (assetVideoTrack != nil) {
|
|
|
- // 视频通道 工程文件中的轨道,有音频轨、视频轨等,里面可以插入各种对应的素材
|
|
|
- AVMutableCompositionTrack *compositionVideoTrack = [composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
|
|
|
- // 视频方向
|
|
|
- [compositionVideoTrack setPreferredTransform:assetVideoTrack.preferredTransform];
|
|
|
- // 把视频轨道数据加入到可变轨道中 这部分可以做视频裁剪TimeRange
|
|
|
- [compositionVideoTrack insertTimeRange:range ofTrack:assetVideoTrack atTime:insertionPoint error:&error];
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (assetAudioTrack != nil) {
|
|
|
- AVMutableCompositionTrack *compositionAudioTrack = [composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
|
|
|
- compositionAudioTrack.preferredTransform = assetAudioTrack.preferredTransform;
|
|
|
- [compositionAudioTrack insertTimeRange:range ofTrack:assetAudioTrack atTime:insertionPoint error:&error];
|
|
|
- }
|
|
|
-
|
|
|
- AVAssetExportSession *session = [[AVAssetExportSession alloc] initWithAsset:composition presetName:presetName];
|
|
|
- // Optimize for network use.
|
|
|
- session.shouldOptimizeForNetworkUse = YES;
|
|
|
- NSArray *supportedTypeArray = session.supportedFileTypes;
|
|
|
- if ([supportedTypeArray containsObject:AVFileTypeMPEG4]) {
|
|
|
- session.outputFileType = AVFileTypeMPEG4;
|
|
|
- } else if (supportedTypeArray.count == 0) {
|
|
|
- if (failure) {
|
|
|
- failure(@"该视频类型暂不支持导出", nil);
|
|
|
- }
|
|
|
- NSLog(@"No supported file types 视频类型暂不支持导出");
|
|
|
- return;
|
|
|
- } else {
|
|
|
- session.outputFileType = [supportedTypeArray objectAtIndex:0];
|
|
|
- if (videoAsset.URL && videoAsset.URL.lastPathComponent) {
|
|
|
- savePath = [savePath stringByReplacingOccurrencesOfString:@".mp4" withString:[NSString stringWithFormat:@"-%@", videoAsset.URL.lastPathComponent]];
|
|
|
- }
|
|
|
- }
|
|
|
- session.outputURL = [NSURL fileURLWithPath:savePath];
|
|
|
- [session exportAsynchronouslyWithCompletionHandler:^{
|
|
|
- dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
- switch (session.status) {
|
|
|
- case AVAssetExportSessionStatusUnknown: {
|
|
|
- NSLog(@"AVAssetExportSessionStatusUnknown");
|
|
|
- } break;
|
|
|
- case AVAssetExportSessionStatusWaiting: {
|
|
|
- NSLog(@"AVAssetExportSessionStatusWaiting");
|
|
|
- } break;
|
|
|
- case AVAssetExportSessionStatusExporting: {
|
|
|
- NSLog(@"AVAssetExportSessionStatusExporting");
|
|
|
- } break;
|
|
|
- case AVAssetExportSessionStatusCompleted: {
|
|
|
- NSLog(@"AVAssetExportSessionStatusCompleted");
|
|
|
- if (success) {
|
|
|
- success(savePath);
|
|
|
- }
|
|
|
- } break;
|
|
|
- case AVAssetExportSessionStatusFailed: {
|
|
|
- NSLog(@"AVAssetExportSessionStatusFailed");
|
|
|
- if (failure) {
|
|
|
- failure(@"视频导出失败", session.error);
|
|
|
- }
|
|
|
- } break;
|
|
|
- case AVAssetExportSessionStatusCancelled: {
|
|
|
- NSLog(@"AVAssetExportSessionStatusCancelled");
|
|
|
- if (failure) {
|
|
|
- failure(@"导出任务已被取消", nil);
|
|
|
- }
|
|
|
- } break;
|
|
|
- default: break;
|
|
|
- }
|
|
|
- });
|
|
|
- }];
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- if (failure) {
|
|
|
- NSString *errorMessage = [NSString stringWithFormat:@"当前设备不支持该预设:%@", presetName];
|
|
|
- failure(errorMessage, nil);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-- (void)submitFileWithMessage:(RCSightMessage *)sightMessage uploadListener:(RCUploadMediaStatusListener *)uploadListener {
|
|
|
- NSURL *fileUrl = [NSURL fileURLWithPath:sightMessage.localPath];
|
|
|
- NSData *fileData = [NSData dataWithContentsOfURL:fileUrl];
|
|
|
-
|
|
|
- if (fileData.length) {
|
|
|
- NSString *suffix = [NSString stringWithFormat:@".%@",[fileUrl pathExtension]];
|
|
|
- [[KSUploadManager shareInstance] configBucketName:@"i-m"];
|
|
|
- [[KSUploadManager shareInstance] videoUpload:fileData fileName:@"sightVideo" fileSuffix:suffix progress:^(int64_t bytesWritten, int64_t totalBytes) {
|
|
|
- int progress = (int)(bytesWritten / totalBytes * 100);
|
|
|
- uploadListener.updateBlock(progress);
|
|
|
- } successCallback:^(NSMutableArray * _Nonnull fileUrlArray) {
|
|
|
- NSString *videoUrl = [fileUrlArray lastObject];
|
|
|
- sightMessage.remoteUrl = videoUrl;
|
|
|
- sightMessage.size = fileData.length;
|
|
|
- uploadListener.successBlock(sightMessage);
|
|
|
- } faliure:^(NSError * _Nullable error, NSString * _Nullable descMessaeg) {
|
|
|
- uploadListener.errorBlock(ERRORCODE_TIMEOUT);
|
|
|
- }];
|
|
|
- }
|
|
|
- else {
|
|
|
- uploadListener.errorBlock(INVALID_PARAMETER);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-- (BOOL)copyMediaFile:(NSString *)sourcePath toPath:(NSString *)toPath
|
|
|
-{
|
|
|
- BOOL retVal = YES;
|
|
|
- if ([[NSFileManager defaultManager] fileExistsAtPath:sourcePath]) { // 如果原文件存在
|
|
|
-
|
|
|
- if (![[NSFileManager defaultManager] fileExistsAtPath:toPath])
|
|
|
- {
|
|
|
- retVal = [[NSFileManager defaultManager] copyItemAtPath:sourcePath toPath:toPath error:NULL];
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- retVal = NO;
|
|
|
- }
|
|
|
-
|
|
|
- return retVal;
|
|
|
-}
|
|
|
-
|
|
|
-- (NSString *)getSightSavePath {
|
|
|
- NSString *componentString = [NSString stringWithFormat:@"RongCloud/%@/RCSightCache", self.targetId];
|
|
|
- NSString *path = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)lastObject] stringByAppendingPathComponent:componentString];
|
|
|
- NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
|
- BOOL isDir = FALSE;
|
|
|
- BOOL isDirExist = [fileManager fileExistsAtPath:path isDirectory:&isDir];
|
|
|
- if(!(isDirExist && isDir)) {
|
|
|
- BOOL bCreateDir = [fileManager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
|
|
|
- if(!bCreateDir){
|
|
|
- NSLog(@"创建文件夹失败!");
|
|
|
- }
|
|
|
- NSLog(@"创建文件夹成功,文件路径%@",path);
|
|
|
- }
|
|
|
- NSLog(@"文件路径%@",path);
|
|
|
- return path;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)didTapCellPortrait:(NSString *)userId {
|
|
|
- if ([userId isEqualToString:UserDefault(RongCloudID)]) {
|
|
|
- [self displayStudent:userId];
|
|
|
- }
|
|
|
- else {
|
|
|
-// RCUserInfo *user = nil;
|
|
|
- if (self.conversationType == ConversationType_PRIVATE) {
|
|
|
- RCUserInfo *user = [[RCIM sharedRCIM] getUserInfoCache:userId];
|
|
|
-
|
|
|
- NSDictionary *extraDic = [user.extra mj_JSONObject];
|
|
|
- if ([[extraDic ks_stringValueForKey:@"role"] isEqualToString:@"TEACHER"]) {
|
|
|
- [self displayTeacher:userId];
|
|
|
- }
|
|
|
- else {
|
|
|
- [self displayStudent:userId];
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- RCUserInfo *user = [[RCIM sharedRCIM] getGroupUserInfoCache:userId withGroupId:self.targetId];
|
|
|
- NSDictionary *extraDic = [user.extra mj_JSONObject];
|
|
|
- if ([[extraDic ks_stringValueForKey:@"role"] isEqualToString:@"TEACHER"]) {
|
|
|
- [self displayTeacher:userId];
|
|
|
- }
|
|
|
- else {
|
|
|
- [self displayStudent:userId];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-- (void)displayStudent:(NSString *)stuentId {
|
|
|
- KSChatUserDetailViewController *ctrl = [[KSChatUserDetailViewController alloc] init];
|
|
|
- ctrl.rongCloudId = stuentId;
|
|
|
- [self.navigationController pushViewController:ctrl animated:YES];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)displayTeacher:(NSString *)teacherId {
|
|
|
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
|
|
|
- ctrl.url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/teacherHome?teacherId=",teacherId];
|
|
|
- [self.navigationController pushViewController:ctrl animated:YES];
|
|
|
}
|
|
|
|
|
|
/*
|