123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- //
- // KSTXBaseChatViewController.m
- // KulexiuForTeacher
- //
- // Created by 王智 on 2023/8/10.
- //
- #import "KSTXBaseChatViewController.h"
- #import <AVFoundation/AVFoundation.h>
- #import <AssetsLibrary/AssetsLibrary.h>
- #import <MobileCoreServices/MobileCoreServices.h>
- #import <Photos/Photos.h>
- #import <TIMCommon/NSString+TUIEmoji.h>
- #import <TIMCommon/TIMDefine.h>
- #import <TUICore/NSDictionary+TUISafe.h>
- #import <TUICore/TUICore.h>
- #import <TUICore/TUILogin.h>
- #import <TUICore/TUIThemeManager.h>
- #import <TUICore/TUITool.h>
- #import "ReactiveObjC/ReactiveObjC.h"
- #import "TUIAIDenoiseSignatureManager.h"
- #import "TUIBaseMessageController.h"
- #import "TUICameraViewController.h"
- #import "TUIChatConfig.h"
- #import "TUIChatDataProvider.h"
- #import "TUIChatMediaDataProvider.h"
- #import "TUIChatModifyMessageHelper.h"
- #import "TUICloudCustomDataTypeCenter.h"
- #import "TUIFileMessageCellData.h"
- #import "TUIImageMessageCellData.h"
- #import "TUIJoinGroupMessageCell.h"
- #import "TUIMessageController.h"
- #import "TUIMessageDataProvider.h"
- #import "TUIMessageMultiChooseView.h"
- #import "TUIMessageReadViewController.h"
- #import "TUIReplyMessageCellData.h"
- #import "TUITextMessageCellData.h"
- #import "TUIVideoMessageCellData.h"
- #import "TUIVoiceMessageCellData.h"
- #import "KSChatUserDetailViewController.h"
- #import "ShareMusicViewController.h"
- #import "MinePageViewController.h"
- #import "KSBaseWKWebViewController.h"
- #import "KSAccompanyWebViewController.h"
- #import "KSEnterLiveroomManager.h"
- #import "RecordCheckManager.h"
- #import "KSPremissionAlert.h"
- static UIView *gCustomTopView;
- @interface KSTXBaseChatViewController ()
- @end
- @implementation KSTXBaseChatViewController
- #pragma mark - Life Cycle
- - (void)messageController:(TUIBaseMessageController *)controller willDisplayCell:(TUIMessageCell *)cell withData:(TUIMessageCellData *)cellData {
- cell.avatarView.contentMode = UIViewContentModeScaleAspectFill;
- }
- - (void)messageController:(TUIBaseMessageController *)controller onSelectMessageAvatar:(TUIMessageCell *)cell {
- /*
- NSString *userID = nil;
- if (cell.messageData.innerMessage.groupID.length > 0) {
- userID = cell.messageData.innerMessage.sender;
- } else {
- if (cell.messageData.isUseMsgReceiverAvatar) {
- if (cell.messageData.innerMessage.isSelf) {
- userID = cell.messageData.innerMessage.userID;
- } else {
- userID = V2TIMManager.sharedInstance.getLoginUser;
- }
- } else {
- userID = cell.messageData.innerMessage.sender;
- }
- }
-
- if (userID == nil) {
- return;
- }
- // 跳转到用户详情
- if ([userID isEqualToString:UserDefault(IM_USERID)]) {
- [self displayMineInfo];
- }
- else { // 显示其他
- if ([userID containsString:@"STUDENT"]) {
- [self displayStudent:userID];
- }
- else {
- [self displayTeacherInfo:userID];
- }
- }
- */
- }
- - (void)displayMineInfo {
- MinePageViewController *pageCtrl = [[MinePageViewController alloc] init];
- [self.navigationController pushViewController:pageCtrl animated:YES];
- }
- - (void)displayTeacherInfo:(NSString *)teacherId {
- KSBaseWKWebViewController *ctrl = [[KSBaseWKWebViewController alloc] init];
- ctrl.url = [NSString stringWithFormat:@"%@%@%@", WEBHOST, @"/#/teacherHome?teacherId=", teacherId];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)displayStudent:(NSString *)stuentId {
- KSChatUserDetailViewController *ctrl = [[KSChatUserDetailViewController alloc] init];
- ctrl.rongCloudId = stuentId;
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)onShareMusicMoreCellData { // 分享曲谱
- MJWeakSelf;
- ShareMusicViewController *ctrl = [[ShareMusicViewController alloc] init];
- [ctrl shareSongChooseCallback:^(MusicMessageModel * _Nonnull chooseModel) {
- [weakSelf shareSongAction:chooseModel];
- }];
- [self.navigationController pushViewController:ctrl animated:YES];
- }
- - (void)shareSongAction:(MusicMessageModel *)musicModel {
- NSMutableDictionary *parm = [NSMutableDictionary dictionary];
- [parm setValue:@"TC_CHATSHARE_MUSIC" forKey:BussinessID];
- [parm setValue:[NSString returnNoNullStringWithString:musicModel.musicSheetName] forKey:@"songName"];
- [parm setValue:musicModel.chargeType forKey:@"chargeType"];
- [parm setValue:musicModel.composer forKey:@"songAuth"];
- [parm setValue:[musicModel.addUserAvatar getUrlEndcodeString] forKey:@"teacherAvatar"];
- [parm setValue:[NSString returnNoNullStringWithString:musicModel.musicSheetName] forKey:@"songName"];
- NSString *owner = @"";
- if ([NSString isEmptyString:musicModel.addName]) {
- owner = [NSString stringWithFormat:@"游客%.0f",musicModel.userId];
- }
- else {
- owner = musicModel.addName;
- }
- [parm setValue:owner forKey:@"teacherName"];
- [parm setValue:musicModel.subjectNames forKey:@"musicTagNames"];
- [parm setValue:[NSString stringWithFormat:@"%.0f",musicModel.internalBaseClassIdentifier] forKey:@"songId"];
-
- NSData *data = [NSJSONSerialization dataWithJSONObject:parm options:0 error:nil];
- V2TIMMessage *message = [[V2TIMManager sharedInstance] createCustomMessage:data];
- [self sendMessage:message];
- }
- - (void)messageController:(TUIBaseMessageController *)controller onSelectMessageContent:(TUIMessageCell *)cell {
- cell.disableDefaultSelectAction = NO;
- if (cell.disableDefaultSelectAction) {
- return;
- }
- V2TIMMessage *message = cell.messageData.innerMessage;
- if (message.elemType == V2TIM_ELEM_TYPE_CUSTOM) {
- NSDictionary *param = [NSJSONSerialization JSONObjectWithData:message.customElem.data options:NSJSONReadingAllowFragments error:nil];
-
- if ([[param ks_stringValueForKey:@"businessID"] isEqualToString:@"TC_CHATSHARE_MUSIC"]) {
- NSString *musicSongId = [param ks_stringValueForKey:@"songId"];
- [self showMusic:musicSongId];
- }
- else if ([[param ks_stringValueForKey:@"businessID"] isEqualToString:@"TC_CHATSHARE_LIVE"]) {
- NSString *roomId = [param ks_stringValueForKey:@"roomUID"];
- NSString *liveDesc = [param ks_stringValueForKey:@"liveDescMessage"];
- [self enterLiveRoom:roomId desc:liveDesc];
- }
- }
-
- }
- - (void)enterLiveRoom:(NSString *)roomId desc:(NSString *)liveDesc {
- // 查询房间信息
- [KSEnterLiveroomManager queryLiveStatusConfig:roomId liveContent:liveDesc inController:(CustomNavViewController *)self.navigationController callback:^(ENTER_CALLTYPE type) {
-
- }];
- }
- - (void)showMusic:(NSString *)songId {
- PREMISSIONTYPE micEnable = [RecordCheckManager checkPermissionShowAlert:NO showInView:nil];
- PREMISSIONTYPE cameraEnable = [RecordCheckManager checkCameraPremissionAvaiable:NO showInView:nil];
- if (micEnable == PREMISSIONTYPE_YES && cameraEnable == PREMISSIONTYPE_YES) {
- KSAccompanyWebViewController *detailCtrl = [[KSAccompanyWebViewController alloc] init];
- detailCtrl.url = [NSString stringWithFormat:@"%@/accompany?id=%@",hostURL, songId];
- detailCtrl.parmDic = @{@"isOpenLight" : @(YES), @"orientation" : @(0),@"isHideTitle" : @(YES)};
- [self.navigationController pushViewController:detailCtrl animated:YES];
- }
- else {
- if (micEnable == PREMISSIONTYPE_NO && cameraEnable == PREMISSIONTYPE_NO) { // 如果麦克风权限和摄像头权限都没有
- [self showAlertWithMessage:@"请开启相机和麦克风访问权限" type:CHECKDEVICETYPE_BOTH];
- }
- else if (micEnable == PREMISSIONTYPE_NO) { // 如果没有麦克风权限
- [self showAlertWithMessage:@"请开启麦克风访问权限" type:CHECKDEVICETYPE_MIC];
- }
- else if (cameraEnable == PREMISSIONTYPE_NO) { // 如果没有摄像头权限
- [self showAlertWithMessage:@"请开启相机访问权限" type:CHECKDEVICETYPE_CAMREA];
- }
- }
- }
- - (void)showAlertWithMessage:(NSString *)message type:(CHECKDEVICETYPE)deviceType {
- [KSPremissionAlert shareInstanceDisplayImage:deviceType message:message showInView:self.view cancel:^{
-
- } confirm:^{
- [self openSettingView];
- }];
-
- }
- - (void)openSettingView {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|