| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798 |
- //
- // MOChatViewController.m
- // MiMoLive
- //
- // Created by SuperC on 2023/11/5.
- //
- #import "MOChatViewController.h"
- #import "MOWebViewController.h"
- #import "MOUserHomePageVC.h"
- #import "MODiaWinRoundDetailView.h"
- #import "MOUserSetDataModels.h"
- #import "MOChatLimitView.h"
- #import "MOChatSendLimitView.h"
- #import "MOReportSomeOneView.h"//举报他人View
- #import "MOChatFollowView.h"//关注View
- #import "MOChatTitleView.h"//顶部标题View
- #import "TUIChatConfig.h"
- #import "TUIChatConfig_Classic.h"
- #import "MOChatViewController+MoreMenu.h"
- @interface MOChatViewController ()<TUIChatEventListener,TUIBaseChatViewControllerDelegate_Two>
- @property (nonatomic, strong) UILabel *titleLab;//废弃
- @property (nonatomic, strong) UIButton *blackBtn;
- @property (nonatomic, strong) MOUserSetBaseData *userSetData;
- @property (nonatomic, strong) UIImageView *bgImgView;
- @property (nonatomic, assign) BOOL isGetUserBase;//是否获取用户信息(接口返回成功为止)
- @property (nonatomic, strong) MOReportSomeOneView *reportView;//举报他人View
- @property (nonatomic, assign) BOOL isShowReport;
- @property (nonatomic, strong) MOChatFollowView *followView;//关注View
- @property (nonatomic, assign) BOOL reportPrivateChat;//是否向服务器请求私聊成功的接口(防止重复调接口)
- @property (nonatomic, strong) MOChatTitleView *titleView;//标题
- @end
- @implementation MOChatViewController
- - (void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
-
- [[IQKeyboardManager sharedManager] setEnable:NO];
- if(self.isLiveRoom){
- // [self.navigationController setNavigationBarHidden:YES animated:animated];
- [self.navigationController setNavigationBarHidden:NO animated:animated];
- [self mo_v2_setNavLeftItemWithImage:[UIImage imageNamed:@"v_2_icon_new_back_black"] andBackgroundImg:nil AndBgColor:nil];
- }
- else if (self.isHalfShow){
- [self.navigationController setNavigationBarHidden:YES animated:animated];
- }
- else
- {
- [self.navigationController setNavigationBarHidden:NO animated:animated];
-
- [self mo_v2_setNavLeftItemWithImage:[UIImage imageNamed:@"v_2_icon_new_back_black"] andBackgroundImg:nil AndBgColor:nil];
- }
-
- [[MOChatNotificationManager sharedManager] enterScene:MOChatNotificationSceneChatDetail];//进入聊天详情
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self setupUI];
-
- [self toGetUserSetData];
-
- [self addNotification];
-
- [MOChatHttpManage shareManager].userId = self.otherUserId;
- [MOChatHttpManage shareManager].isFirstHttp = YES;
-
- NSString *theUserId = self.otherUserId;
- //腾讯
- self.t_chatController.externalRequestBlock = ^(void (^ _Nonnull httpBlock)(BOOL)) {
- [[MOChatHttpManage shareManager] toSendSingleChatAndBlock:^(BOOL result) {
- // 回调完成,返回数据给库内部
- dispatch_async(dispatch_get_main_queue(), ^{
- httpBlock(result);
- });
- }];
- };
- theUserId = self.t_conversationData.userID;
-
- [self getUserInfoWith:theUserId];//获取用户信息
- }
- - (void)addNotification{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardHideOrShow:) name:UIKeyboardWillShowNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardHideOrShow:) name:UIKeyboardWillHideNotification object:nil];
-
- ReceiveNotification(@selector(toUpdataViewWithSendStatus:), @"MOCanOrNotSendMessage")//离开频道的通知
- ReceiveNotification(@selector(jumpLink:), @"MOChatJumpLink")//点击链接跳转
- ReceiveNotification(@selector(reportNewUserChat), @"kNotification_SendMessage")//新用户发送消息通知服务端
- }
- - (void)jumpLink:(NSNotification *)notification {
- NSString *link = notification.object;
-
- [self toShowUrlViewWith:link];
- }
- - (void)toUpdataViewWithSendStatus:(NSNotification *)notification{
- BOOL canSend = [notification.object boolValue];
-
- self.userSetData.canSend = canSend;
-
- [self updataTheSendStatus];
- }
- - (void)reportNewUserChat {
- MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo];
- NSTimeInterval timestamp = userInfoData.createAt / 1000.0;
- NSDate *date = [NSDate dateWithTimeIntervalSince1970:timestamp];
- NSCalendar *calendar = [NSCalendar currentCalendar];
- BOOL isToday = [calendar isDateInToday:date];
- if (!isToday) {//不是注册首日就不需要请求服务器了
- return;
- }
-
- if (self.reportPrivateChat) {
- return;
- }
-
- NSDictionary *dict = @{@"id":self.otherUserId};
- WEAKSELF
- [kHttpManager reportPrivateChatWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success) {
- weakSelf.reportPrivateChat = YES;
- }
- }];
- }
- - (void)keyboardHideOrShow:(NSNotification *)notification{
- WEAKSELF
-
- CGFloat bottomStatusHeight = HOME_KEY_HEIGHT + 42.0;
- CGFloat bottomSpacing = -bottomStatusHeight - 10.0;
-
- NSString *notificationName = notification.name;
- if ([notificationName isEqualToString:UIKeyboardWillShowNotification] == YES) {
- //展示
- CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
- bottomSpacing = bottomSpacing - keyboardFrame.size.height;
- [UIView animateWithDuration:0.5 delay:0 usingSpringWithDamping:1 initialSpringVelocity:1 options:UIViewAnimationOptionCurveLinear animations:^
- {
-
- if(weakSelf.isShowReport){
- [weakSelf.reportView mas_updateConstraints:^(MASConstraintMaker *make)
- {
- make.bottom.equalTo(self.view).offset(-keyboardFrame.size.height);
- }];
- }
-
- [weakSelf.view layoutIfNeeded];
- } completion:^(BOOL finished)
- {
-
- }];
- }
- else{
- //隐藏
- [UIView animateWithDuration:0.2 animations:^
- {
- if(weakSelf.isShowReport){
- [weakSelf.reportView mas_updateConstraints:^(MASConstraintMaker *make)
- {
- make.bottom.equalTo(self.view).offset(0);
- }];
- }
-
- [weakSelf.view layoutIfNeeded];
- }];
- }
- }
- - (void)toGetUserSetData{
- WEAKSELF
- if(self.otherUserId.length == 0){
- return;
- }
-
- self.userData = [MODataManager searchMOUserBaseWith:self.otherUserId];
- [self updateViewUI];
-
- NSDictionary *dict = @{@"id":self.otherUserId};
- [kHttpManager toGetChatSingleInfoWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- weakSelf.userSetData = [MOUserSetBaseData modelObjectWithDictionary:data[@"data"]];
- weakSelf.userData.blacklist = weakSelf.userSetData.userSetData.result;
- [weakSelf updateViewUI];
- [weakSelf updataTheSendStatus];
- }
- else{
- MOLogV(@"toGetChatSingleInfoWithParams 接口报错了");
- // kShowNetError(data)
- }
- }];
- }
- - (void)updateViewUI{
-
- WEAKSELF
- dispatch_async(dispatch_get_main_queue(), ^{
- if(weakSelf.userData.blacklist){
- weakSelf.blackBtn.hidden = NO;
- }
- else{
- weakSelf.blackBtn.hidden = YES;
- }
- });
- }
- - (void)updataTheSendStatus{
-
- WEAKSELF
- dispatch_async(dispatch_get_main_queue(), ^{
- [MOChatHttpManage shareManager].canSend = weakSelf.userSetData.canSend;
-
- //腾讯
- weakSelf.t_chatController.direction = weakSelf.userSetData.userSetData.direction;
- weakSelf.t_chatController.isBlackUser = weakSelf.userData.blacklist;
- weakSelf.t_chatController.canSend = !weakSelf.userData.blacklist;
- });
-
-
- }
- - (void)setupUI{
- self.titleView = [[MOChatTitleView alloc] initWithFrame:CGRectMake(0.0, 0.0, (SCREENWIDTH - 60.0 * 2.0), 44.0)];
- self.titleView.viewType = MOChatTitleViewNormalType;
- [self.titleView sizeToFit];
- self.navigationItem.titleView = self.titleView;
-
- [self setupTencentUI];
- }
- - (void)setupTencentUI {
-
- self.otherUserId = _t_conversationData.userID;
-
- //样式设置
- [TUIChatConfig defaultConfig].backgroudColor = [UIColor clearColor];
- [TUIChatConfig defaultConfig].enableWelcomeCustomMessage = NO;
- [TUIChatConfig defaultConfig].showFileButton = NO;//隐藏文件按钮
-
- //功能设置 - 先默认全屏蔽, 然后根据接口进行相应的调整
- [TUIChatConfig_Classic hideItemsWhenLongPressMessage:TUIChatItemWhenLongPressMessage_Classic_Forward |
- TUIChatItemWhenLongPressMessage_Classic_Select | TUIChatItemWhenLongPressMessage_Classic_Quote | TUIChatItemWhenLongPressMessage_Classic_Reply];
-
- WEAKSELF
- self.t_chatController = [[TUIC2CChatViewController alloc] init];
- self.t_chatController.delegate_Two = self;
- [self.t_chatController setConversationData:self.t_conversationData];
- self.t_chatController.theTypingBlock = ^(BOOL isTyping) {
- if(isTyping){
- weakSelf.titleView.viewType = MOChatTitleViewEntering;
- }
- else{
- [weakSelf toShowNavigationItemTitle];
- }
- };
-
- [self addChildViewController:self.t_chatController];
-
-
- if(self.isHalfShow){
- self.view.backgroundColor = [UIColor clearColor];
-
- UIView *bgView = [[UIView alloc] init];
- bgView.layer.cornerRadius = 16.0;
- bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
- bgView.layer.masksToBounds = YES;
- bgView.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:bgView];
- [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.view);
- make.left.right.equalTo(self.view);
- make.height.equalTo(@553.0);
- }];
-
- [bgView addSubview:self.bgImgView];
- [self.bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(bgView);
- }];
-
- NSArray *colorArr = @[[MOTools colorWithHexString:@"#F3F4FA" alpha:1.0],[MOTools colorWithHexString:@"#F3F4FA" alpha:1.0]];
- UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, SCREENWIDTH, 553.0) Colors:colorArr GradientType:1];
- [self.bgImgView setImage:image];
- [bgView addSubview:self.titleLab];
- [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.equalTo(@30.0);
- make.left.right.top.equalTo(bgView);
- }];
-
- [bgView addSubview:self.t_chatController.view];
-
- if([self.t_conversationData.userID isEqualToString:OfficialID] || [self.t_conversationData.userID isEqualToString:ActivityID]){
-
- CGFloat bottomStatusHeight = HOME_KEY_HEIGHT + 52.0;
-
- [self.t_chatController.view mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.trailing.equalTo(bgView);
- make.top.equalTo(self.titleLab.mas_bottom);
- make.bottom.equalTo(bgView).offset(bottomStatusHeight);
- }];
- }
- else{
- [self.t_chatController.view mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.trailing.bottom.equalTo(bgView);
- make.top.equalTo(self.titleLab.mas_bottom);
- }];
- }
-
- self.titleLab.text = @"Chat";
- }
- else{
- self.titleView.title = @"Chat";
-
- [self.view addSubview:self.bgImgView];
- [self.bgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.view);
- }];
-
- NSArray *colorArr = @[[MOTools colorWithHexString:@"#F3F4FA" alpha:1.0],[MOTools colorWithHexString:@"#F3F4FA" alpha:1.0]];
- UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, SCREENWIDTH, (SCREENHEIGHT - NAV_BAR_HEIGHT)) Colors:colorArr GradientType:1];
- [self.bgImgView setImage:image];
-
- [self.view addSubview:self.t_chatController.view];
-
- if([self.t_conversationData.userID isEqualToString:OfficialID] || [self.t_conversationData.userID isEqualToString:ActivityID]){
-
- CGFloat bottomStatusHeight = HOME_KEY_HEIGHT + 52.0;
-
- [self.t_chatController.view mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(0);
- make.leading.trailing.equalTo(self.view);
- make.bottom.equalTo(self.view).offset(bottomStatusHeight);
- }];
- }
- else{
- [self.t_chatController.view mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop).offset(0);
- make.leading.trailing.bottom.equalTo(self.view);
- }];
- }
-
- CGFloat followViewHeight = 40.0 + 10.0 * 2.0;
- [self.view addSubview:self.followView];
- [self.followView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
- make.height.equalTo(@(followViewHeight));
- make.left.right.equalTo(self.view);
- }];
- self.followView.hidden = YES;
- }
-
- self.t_chatController.view.backgroundColor = [UIColor clearColor];
-
- if([self.t_conversationData.userID isEqualToString:OfficialID] || [self.t_conversationData.userID isEqualToString:ActivityID]){
- //系统消息 不处理
- }
- else{
- CGFloat bottomStatusHeight = HOME_KEY_HEIGHT + 52.0;
- [self.view addSubview:self.blackBtn];
- [self.blackBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.bottom.right.equalTo(self.view);
- make.height.equalTo(@(bottomStatusHeight));
- }];
- self.blackBtn.hidden = YES;
-
- CGFloat bottomSpacing = -bottomStatusHeight - 10.0;
-
- CGFloat rightSpacing = 16.0 + 30.0 + 6.0 + 30.0 + 10.0;
- CGFloat leftSpacing = 16.0;
- CGFloat viewHeight = 52 - 2 * 6.5;
- }
-
- if([self.t_conversationData.userID isEqualToString:OfficialID] || [self.t_conversationData.userID isEqualToString:ActivityID]){
-
- if(self.isHalfShow){
- if([self.t_conversationData.userID isEqualToString:OfficialID] ){
- self.titleLab.text = @"Official News";
- }
- else{
- self.titleLab.text = @"Activity Notice";
- }
- }
- else{
- if([self.t_conversationData.userID isEqualToString:OfficialID] ){
- self.titleView.title = @"Official News";
- }
- else{
- self.titleView.title = @"Activity Notice";
- }
- }
- }
- else{
- [self toShowNavigationItemTitle];
- }
-
- TUIChatEventConfig *chatEvent = [[TUIChatEventConfig alloc] init];
- chatEvent.chatEventListener = self;
- [[TUIChatConfig defaultConfig] setEventConfig:chatEvent];
-
- }
- - (void)toShowNavigationItemTitle{
- NSString *nickName = self.nickNameStr;
- if(self.userData.userProfile.nickname.length > 0){
- nickName = self.userData.userProfile.nickname;
- if(self.userData.remark.length > 0){
- nickName = self.userData.remark;
- }
- }
-
- if(self.isHalfShow){
- self.titleLab.text = nickName;
- }
- else{
- self.titleView.title = nickName;
- self.titleView.viewType = MOChatTitleViewNormalType;
- }
- }
- - (void)toUpdataTheFollowStatus{
- //没关注
- if(!(self.isHalfShow || self.isLiveRoom)){
- //全屏
-
- if([self.t_conversationData.userID isEqualToString:OfficialID] || [self.t_conversationData.userID isEqualToString:ActivityID]){
-
-
- }
- else{
- if(!self.userData.follow){
- self.followView.hidden = NO;
- }
- else{
- self.followView.hidden = YES;
- }
- }
- }
- }
- //MARK: 用户数据
- - (void)toShowUrlViewWith:(NSString *)url{
-
- if(url.length == 0){
- return;
- }
-
- BOOL isURL = [url hasPrefix:@"http://"] || [url hasPrefix:@"https://"];
- if(isURL){
-
- BOOL isShowTitle = YES;
- if([url containsString:@"FullScreen=1"]){
- isShowTitle = NO;
- }
-
- MOWebViewController *vc = [[MOWebViewController alloc] init];
- vc.isShowTitle = isShowTitle;
- NSString *urlStr = url;
- vc.webUrl = [NSURL URLWithString:urlStr];
- [self.navigationController pushViewController:vc animated:YES];
- }
- else{
-
- if([url containsString:@"diamondWinnerDetail?id="]){
- [self toShowDiamondWinnerDetailWith:url];
- return;
- }
-
- if([url containsString:@"mimo://"]){
- NSURL *urlUrl = [NSURL URLWithString:url];
- if ([[UIApplication sharedApplication]respondsToSelector:@selector(openURL:options:completionHandler:)])
- {
- [[UIApplication sharedApplication] openURL:urlUrl options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@NO} completionHandler:^(BOOL success) {}];
- }
- }
- }
- }
- - (void)toShowDiamondWinnerDetailWith:(NSString *)url{
- NSArray *tempArr = [url componentsSeparatedByString:@"diamondWinnerDetail?id="];
- NSString *idStr = tempArr.lastObject;
-
- MODiaWinRoundDetailView *view = [MODiaWinRoundDetailView moDiaWinRoundDetailView];
- view.orderId = idStr;
-
- [self.view addSubview:view];
- [view showDiaWinRoundDetailView];
- [view getTheDetailData];
- }
- //MARK: 用户头像点击
- #pragma mark - 腾讯IM TUIChatEventListener
- - (BOOL)onUserIconClicked:(UIView *)view messageCellData:(TUIMessageCellData *)celldata{
-
- NSString *theUserId = celldata.innerMessage.sender;
- if([theUserId isEqualToString:OfficialID] || [theUserId isEqualToString:ActivityID]){
- return YES;
- }
- else{
- [self toPushUserHomePageWith:theUserId];
- }
- return YES;
- }
- - (void)toPushUserHomePageWith:(NSString *)userId{
-
- if([userId isEqualToString:OfficialID] || [userId isEqualToString:ActivityID]){
- return;
- }
-
- //收起键盘
- [self.t_chatController.inputController reset];
-
- WEAKSELF
- MOUserHomePageVC *vc = [[MOUserHomePageVC alloc] init];
- vc.userId = userId;
- vc.isLiveRoom = weakSelf.isLiveRoom;
- vc.goLivingRoomBlock = ^(NSString * _Nonnull liveRoomId) {
- if(weakSelf.isLiveRoom){
- weakSelf.goLivingRoomBlock ? weakSelf.goLivingRoomBlock(liveRoomId) : nil;
- }
- };
- [self.navigationController pushViewController:vc animated:YES];
- }
- - (V2TIMMessage *)baseChatViewController_Two:(TUIBaseMessageController *)controller onNewMessage:(V2TIMMessage *)message{
- if([message.sender isEqualToString:OfficialID] || [message.sender isEqualToString:ActivityID]){
- return nil;
- }
-
- NSString *showName;
- NSString *avatarURL;
- NSInteger headgearType = 0;
- NSString *headdress;
-
- NSMutableDictionary *dict = [NSMutableDictionary dictionary];
- if([message.sender isEqualToString:GetUserId]){
- showName = GetNickName;
- avatarURL = GetAvatar;
-
- MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo];
- headgearType = userInfoData.userProfile.adornment.headgearType;
- headdress = userInfoData.userProfile.adornment.headgearRes;
- }
- else{
- //普通用户
- if(self.userData){
- avatarURL = self.userData.userProfile.avatar;
- if(self.userData.remark.length > 0){
- showName = self.userData.remark;
- }
- else{
- showName = self.userData.userProfile.nickname;
- }
-
- headgearType = self.userData.userProfile.adornment.headgearType;
- headdress = self.userData.userProfile.adornment.headgearRes;
- }
- else{
- MOUserProfile *userModel = [MODataManager searchMOUserProfileWith:message.sender];
- if(userModel){
- avatarURL = userModel.avatar;
- showName = userModel.nickname;
- headgearType = userModel.adornment.headgearType;
- headdress = userModel.adornment.headgearRes;
-
- MOUserBase *userBase = [[MOUserBase alloc] init];
- userBase.userProfile = userModel;
- self.userData = userBase;
- }
- else{
- [self getUserInfoWith:message.sender];
- }
- }
- }
-
- if(avatarURL.length > 0){
- [dict setObject:avatarURL forKey:@"avatarURL"];
- }
-
- if(showName.length > 0 ){
- [dict setObject:showName forKey:@"showName"];
- }
-
- [dict setObject:@(headgearType) forKey:@"headgearType"];
-
- if(headdress.length > 0){
- [dict setObject:headdress forKey:@"headdress"];
- }
-
- NSError *error = nil;
- NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];
-
- if(data){
- message.localCustomData = data;
- return message;
- }
- else{
- return nil;
- }
- }
- #pragma mark - Other Thing
- - (void)getUserInfoWith:(NSString *)userId{
-
- if([userId isEqualToString:OfficialID] || [userId isEqualToString:ActivityID]){
- return;
- }
-
- if(userId.length == 0){
- return;
- }
-
- if(self.isGetUserBase)return;
- self.isGetUserBase = YES;//已经调用了接口了
-
- WEAKSELF
- NSDictionary *dict = @{@"list":@[userId]};
- [kHttpManager getUserInfoListWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
- // MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
- MOUserListData *baseModel = [MOUserListData modelObjectWithDictionary:data[@"data"]];
-
- if(baseModel.userBase.count > 0){
- MOUserBase *userBaseInfo = baseModel.userBase.firstObject;
- self.userData = userBaseInfo;
- [MODataManager saveUserBaseWith:userBaseInfo];
-
- //腾讯
- [weakSelf.t_chatController.messageController.tableView reloadData];
- }
- [weakSelf updateRightBarItem];//更新右侧按钮
- [weakSelf toUpdataTheFollowStatus];//更新关注View
- }
- else{
- weakSelf.isGetUserBase = NO;//已经调用了接口了
- kShowNetError(data)
- }
- }];
- }
- - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
-
- }
- - (void)showReportView{
- WEAKSELF
- self.isShowReport = YES;
- [self.view addSubview:self.reportView];
- [self.reportView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(0);
- make.width.equalTo(@(SCREENWIDTH));
- make.height.equalTo(@445.0);
- make.bottom.equalTo(self.view);
- }];
- self.reportView.userId = self.otherUserId;
- [self.reportView showReportSomeOneView];
- self.reportView.dismissReportViewBlock = ^{
- weakSelf.isShowReport = NO;
- };
- }
- #pragma mark - Lazy
- - (UILabel *)titleLab{
- if (!_titleLab)
- {
- _titleLab = [[UILabel alloc] init];
- _titleLab.text = @"";
- _titleLab.font = [UIFont systemFontOfSize:15.0];
- _titleLab.textColor = [MOTools colorWithHexString:@"#333333" alpha:1.0];
- _titleLab.textAlignment = NSTextAlignmentCenter;
- _titleLab.numberOfLines = 1;
- _titleLab.backgroundColor = [UIColor whiteColor];
-
- }
- return _titleLab;
- }
- - (UIButton *)blackBtn{
- if(!_blackBtn){
- _blackBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _blackBtn.backgroundColor = [UIColor clearColor];
- [_blackBtn addTarget:self action:@selector(blackBtnClick) forControlEvents:UIControlEventTouchUpInside];
- }
- return _blackBtn;
- }
- - (void)blackBtnClick{
- return;
- }
- - (void)dealloc{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [[MOChatNotificationManager sharedManager] leaveScene:MOChatNotificationSceneChatDetail];//离开聊天详情
- }
- - (UIImageView *)bgImgView{
- if(!_bgImgView){
- _bgImgView = [[UIImageView alloc] init];
- _bgImgView.contentMode = UIViewContentModeScaleToFill;
- }
- return _bgImgView;
- }
- - (MORightBarItemView *)rightBarItemView{
- if(!_rightBarItemView){
- _rightBarItemView = [[MORightBarItemView alloc] initWithFrame:CGRectMake(0, 0, 92, 44)];
- }
- return _rightBarItemView;
- }
- - (MOReportSomeOneView *)reportView{
- if(!_reportView){
- _reportView = [MOReportSomeOneView moReportSomeOneView];
- _reportView.isAnimationTwo = YES;
- }
- return _reportView;
- }
- - (MOChatFollowView *)followView{
- if(!_followView){
- CGFloat viewHeight = 40.0 + 10.0 * 2.0;
- _followView = [[MOChatFollowView alloc] initWithFrame:CGRectMake(0, 0, (SCREENWIDTH - 12.0 * 2.0), viewHeight)];
- _followView.hidden = YES;
- WEAKSELF
- _followView.closeClickBlock = ^{
- weakSelf.followView.hidden = YES;
- };
-
- _followView.followClickBlock = ^{
- [weakSelf followSomeOneWith:weakSelf.otherUserId];
- };
- }
- return _followView;
- }
- - (void)followSomeOneWith:(NSString *)targetId{
- if(targetId.length == 0){
- return;
- }
-
- if([targetId isEqualToString:GetUserId]){
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_common_cannot_to_yourself")];
- return;
- }
-
- NSArray *targetArr = @[targetId];
- NSDictionary *dict;
-
-
- if(self.userData.follow){
- dict = @{@"type":@"2",
- @"target":targetArr};
- }
- else{
- dict = @{@"type":@"1",
- @"target":targetArr};
- }
-
- WEAKSELF
- [kHttpManager toSubmitForFollowWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
-
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_common_success")];
-
- weakSelf.userData.follow = YES;
- weakSelf.followView.hidden = YES;
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- @end
|