YBMsgC2CListVC.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. //
  2. // YBMsgC2CListVC.m
  3. // YBHiMo
  4. //
  5. // Created by YB007 on 2021/8/20.
  6. // Copyright © 2021 YB007. All rights reserved.
  7. //
  8. #import "YBMsgC2CListVC.h"
  9. #import "TConversationCell.h"
  10. #import "THeader.h"
  11. #import "TUIKit.h"
  12. #import "TChatC2CController.h"
  13. #import "MessageHeaderV.h"
  14. #import "MessageListCell.h"
  15. #import "MessageListModel.h"
  16. #import "JCHATConversationViewController.h"
  17. #import "MessageFansVC.h"
  18. #import "MsgTopPubVC.h"
  19. #import "SelPeopleV.h"
  20. #import "JCHATAlertViewWait.h"
  21. #import "MsgSysVC.h"
  22. #import "OrderMessageVC.h"
  23. @interface YBMsgC2CListVC ()<UIGestureRecognizerDelegate, UITableViewDelegate, UITableViewDataSource, UIPopoverPresentationControllerDelegate,V2TIMConversationListener>{
  24. dispatch_group_t _imgListGroup;
  25. SelPeopleV * _selV;
  26. TConversationCellData *conver_admin1;//官方通知
  27. TConversationCellData *conver_admin2;//系统通知
  28. TConversationCellData *_conversation_fans; //顶部-粉丝
  29. TConversationCellData *_conversation_zan; //顶部-赞
  30. TConversationCellData *_conversation_at; //顶部-@
  31. TConversationCellData *_conversation_comment; //顶部-评论
  32. TConversationCellData *_conversation_ctr; //风控管理员
  33. TConversationCellData *_conversation_goodsorder;
  34. }
  35. @property (nonatomic, strong) UITableView *tableView;
  36. @property (nonatomic, strong) NSArray *data;
  37. @property(nonatomic,strong)MessageHeaderV *headerV;
  38. @end
  39. @implementation YBMsgC2CListVC
  40. #pragma mark --消息监听
  41. - (void)onTotalUnreadMessageCountChanged:(UInt64)totalUnreadCount {
  42. [self updateConversations];
  43. }
  44. -(void)clearUnreadNum {
  45. for (int i = 0; i < _data.count; i ++) {
  46. TConversationCellData *data = _data[i];
  47. data.unRead = 0;
  48. NSMutableArray *new_a = [NSMutableArray arrayWithArray:_data];
  49. [new_a replaceObjectAtIndex:i withObject:data];
  50. _data = [NSArray arrayWithArray:new_a];
  51. }
  52. [_tableView reloadData];
  53. }
  54. - (UIStatusBarStyle)preferredStatusBarStyle {
  55. if (@available(iOS 13.0,*)) {
  56. return UIStatusBarStyleDarkContent;
  57. }
  58. return UIStatusBarStyleDefault;
  59. }
  60. - (void)viewWillAppear:(BOOL)animated {
  61. [super viewWillAppear:animated];
  62. [[PublicObj publicInstance]addCusDelayedRemove];
  63. [self updateConversations];
  64. }
  65. - (void)viewDidAppear:(BOOL)animated{
  66. [super viewDidAppear:animated];
  67. }
  68. - (void)viewDidLoad {
  69. [super viewDidLoad];
  70. self.navigationController.navigationBar.hidden = YES;
  71. self.view.backgroundColor = RGB(245, 245, 245);
  72. self.subNavi.backgroundColor= UIColor.whiteColor;
  73. _data = [NSArray array];
  74. _imgListGroup = dispatch_group_create();
  75. _sysDic = [[NSUserDefaults standardUserDefaults] objectForKey:@"sysnotice"];
  76. self.titleL.text = YZMsg(@"消息");
  77. self.titleL.textColor= UIColor.blackColor;
  78. self.leftBtn.hidden = NO;
  79. [self.leftBtn setImage:[UIImage imageNamed:@"msg_linkman"] forState:0];
  80. self.rightBtn.hidden = NO;
  81. [self.rightBtn setTitle:YZMsg(@"全部已读") forState:0];
  82. [self.rightBtn setTitleColor:[UIColor blackColor] forState:0];
  83. self.rightBtn.contentEdgeInsets = UIEdgeInsetsMake(0, 8, 0, 0);
  84. _headerV = [[[NSBundle mainBundle]loadNibNamed:@"MessageHeaderV" owner:nil options:nil]objectAtIndex:0];
  85. float botSpace = _isPush?0:tabBarHeight;
  86. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64+statusbarHeight, _window_width, _window_height-naviHight-botSpace)];
  87. _tableView.tableFooterView = [[UIView alloc] init];
  88. _tableView.backgroundColor = RGB(245, 245, 245);
  89. _tableView.delegate = self;
  90. _tableView.dataSource = self;
  91. _tableView.separatorStyle = 0;
  92. _tableView.showsVerticalScrollIndicator = NO;
  93. [self.view addSubview:_tableView];
  94. [self addNoti];
  95. }
  96. - (void)clickNaviLeftBtn {
  97. [self selPeopleFun];
  98. }
  99. - (void)clickNaviRightBtn {
  100. int unread = 0;
  101. for (TConversationCellData *conversation in _data){
  102. unread += conversation.unRead;
  103. [[YBImManager shareInstance] clearUnreadConvId:conversation.convId sendNot:NO];
  104. }
  105. unread += [_conversation_fans unRead];
  106. unread += [_conversation_zan unRead];
  107. unread += [_conversation_at unRead];
  108. unread += [_conversation_comment unRead];
  109. unread += [_conversation_ctr unRead];
  110. [[YBImManager shareInstance] clearUnreadConvId:_conversation_fans.convId sendNot:NO];
  111. [[YBImManager shareInstance] clearUnreadConvId:_conversation_zan.convId sendNot:NO];
  112. [[YBImManager shareInstance] clearUnreadConvId:_conversation_at.convId sendNot:NO];
  113. [[YBImManager shareInstance] clearUnreadConvId:_conversation_comment.convId sendNot:NO];
  114. [_headerV clearRedPoint];
  115. if (unread == 0) {
  116. [MBProgressHUD showPop:YZMsg(@"当前暂无未读消息")];
  117. }else {
  118. [MBProgressHUD showPop:YZMsg(@"已经忽略未读消息")];
  119. /*
  120. UITabBarItem *item = [self.tabBarController.tabBar.items objectAtIndex:2];
  121. item.badgeValue = nil;
  122. */
  123. [PublicObj setTabbarBadgeValue:0];
  124. [self updateConversations];
  125. }
  126. }
  127. -(void)addNoti {
  128. [[V2TIMManager sharedInstance] addConversationListener:self];
  129. // [self removeNoti];
  130. // NSNotificationCenter *notCenter = [NSNotificationCenter defaultCenter];
  131. // [notCenter addObserver:self selector:@selector(onRefreshConversations:) name:TUIKitNotification_TIMRefreshListener object:nil];
  132. }
  133. -(void)removeNoti {
  134. [[NSNotificationCenter defaultCenter] removeObserver:self];
  135. }
  136. - (void)dealloc {
  137. [self removeNoti];
  138. }
  139. - (void)onRefreshConversations:(NSNotification *)notification {
  140. //NSLog(@"xxxxxxokokokokokoko");
  141. [self updateConversations];
  142. }
  143. - (void)updateConversations{
  144. YBWeakSelf;
  145. _data = [NSMutableArray array];
  146. [[YBImManager shareInstance]getAllConversationList:^(NSMutableArray *CovList, BOOL isSuccess) {
  147. if(isSuccess){
  148. dispatch_async(dispatch_get_main_queue(), ^{
  149. [weakSelf goReload:CovList];
  150. });
  151. }
  152. }];
  153. // YBWeakSelf;
  154. // [[YBImManager shareInstance] getLastDisplayStringWith:_imgListGroup finish:^(NSArray *transformArray) {
  155. // dispatch_async(dispatch_get_main_queue(), ^{
  156. // [weakSelf goReload:transformArray];
  157. // });
  158. // }];
  159. }
  160. -(void)goReload:(NSArray *)reloadA {
  161. /*
  162. NSMutableDictionary *sortDic = [NSMutableDictionary dictionary];
  163. for (TConversationCellData *cellData in reloadA) {
  164. if (cellData && cellData.timestamp) {
  165. NSLog(@"xxxx-chat-have:%@==uid:%@",cellData.timestamp,cellData.convId);
  166. [sortDic setObject:cellData forKey:cellData.timestamp];
  167. }else{
  168. NSLog(@"xxxx-chat-not:%@",cellData);
  169. }
  170. }
  171. NSArray *sortAllKey = [sortDic allKeys];
  172. NSArray *sortResult = [sortAllKey sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
  173. return [obj2 compare:obj1];
  174. }];
  175. */
  176. NSSortDescriptor * sortDes = [NSSortDescriptor sortDescriptorWithKey:@"timestamp" ascending:NO];
  177. NSArray *sortResult = [reloadA sortedArrayUsingDescriptors:@[sortDes]];
  178. NSMutableArray *m_group_array = [NSMutableArray array];
  179. NSMutableArray *m_c2c_array = [NSMutableArray array];
  180. for (TConversationCellData *sortData in sortResult) {
  181. //TConversationCellData *sortData = (TConversationCellData*)[sortDic objectForKey:key];
  182. //NSLog(@"xxxx-chat-have:%@==uid:%@",sortData.timestamp,sortData.convId);
  183. if(sortData.convType == TConv_Type_Group){
  184. [m_group_array addObject:sortData];
  185. }else if (sortData.convType == TConv_Type_C2C){
  186. NSString *imName = sortData.convId;
  187. if ([imName isEqual:@"dsp_admin_1"]) {
  188. // 因为总要admi1在第一位这里暂时不加入,for循环结束再插入
  189. //[m_c2c_array insertObject:sortData atIndex:0];
  190. conver_admin1 = sortData;
  191. }else if ([imName isEqual:@"dsp_admin_2"]){
  192. // 因为总要admi2在第二位这里暂时不加入,for循环结束再插入
  193. //[m_c2c_array insertObject:sortData atIndex:1];
  194. conver_admin2 = sortData;
  195. }else if ([imName isEqual:@"dsp_fans"]) {
  196. //粉丝
  197. _conversation_fans = sortData;
  198. }else if ([imName isEqual:@"dsp_like"]){
  199. //赞
  200. _conversation_zan = sortData;
  201. }else if ([imName isEqual:@"dsp_at"]){
  202. //@
  203. _conversation_at = sortData;
  204. }else if ([imName isEqual:@"dsp_comment"]){
  205. //评论
  206. _conversation_comment = sortData;
  207. }else if ([imName isEqual:@"dsp_admin_control"]){
  208. //风控管理员
  209. _conversation_ctr = sortData;
  210. }else if([imName containsString:@"dsp_user_"]){
  211. // dsp_user_live 【用于推送】
  212. }else if ([imName isEqual:@"goodsorder_admin"]){
  213. //订单管理员【未要求具体排序这里add即可】
  214. _conversation_goodsorder = sortData;
  215. [m_c2c_array addObject:sortData];
  216. }else{
  217. [m_c2c_array addObject:sortData];
  218. }
  219. }
  220. }
  221. // 检查dsp_admin_1、dsp_admin_2是否缺失
  222. if (!conver_admin2) {
  223. conver_admin2 = [[YBImManager shareInstance] createEmptyCellDataWithId:@"dsp_admin_2"];
  224. }
  225. if (!conver_admin1) {
  226. conver_admin1 = [[YBImManager shareInstance] createEmptyCellDataWithId:@"dsp_admin_1"];
  227. }
  228. if (_conversation_ctr) {
  229. conver_admin2.unRead += _conversation_ctr.unRead;
  230. }
  231. [m_c2c_array insertObject:conver_admin2 atIndex:0];
  232. [m_c2c_array insertObject:conver_admin1 atIndex:0];
  233. // 刷新顶部
  234. [self reloadTopUnread];
  235. [self requestUserMessage:[m_c2c_array mutableCopy]];
  236. }
  237. - (void)requestUserMessage:(NSArray *)msgArray{
  238. NSString *uids = @"";
  239. for (TConversationCellData *data in msgArray) {
  240. uids = [uids stringByAppendingFormat:@"%@,",data.convId];
  241. }
  242. if (uids.length > 0) {
  243. //去掉最后一个逗号
  244. uids = [uids substringToIndex:[uids length] - 1];
  245. }
  246. NSMutableArray *m_array = [NSMutableArray array];
  247. [YBNetworking postWithUrl:[NSString stringWithFormat:@"User.getMultiInfo&uids=%@",uids] Dic:@{} Suc:^(int code, id info, NSString *msg) {
  248. if (code == 0) {
  249. for (int i = 0; i < [info count]; i ++) {
  250. NSDictionary *plantSubDic = info[i];
  251. for (TConversationCellData *data in msgArray) {
  252. if ([data.convId isEqual:strFormat([plantSubDic valueForKey:@"id"])]) {
  253. [data updateUserInfo:plantSubDic];
  254. [m_array addObject:data];
  255. }
  256. }
  257. }
  258. _data = [NSArray arrayWithArray:m_array];
  259. [_tableView reloadData];
  260. }
  261. } Fail:^(id fail) {
  262. }];
  263. }
  264. #pragma mark - Table view data source
  265. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  266. return 1;
  267. }
  268. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  269. return _data.count;
  270. }
  271. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  272. return [TConversationCell getSize].height;
  273. }
  274. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  275. if (section == 0) {
  276. return _window_width/4+5;
  277. }
  278. return 0.0;
  279. }
  280. -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  281. if (section == 0) {
  282. //_headerV = [[[NSBundle mainBundle]loadNibNamed:@"MessageHeaderV" owner:nil options:nil]objectAtIndex:0];
  283. _headerV.frame = CGRectMake(0, 0, _window_width, _window_width/4+5);
  284. _headerV.backgroundColor = UIColor.whiteColor;
  285. _headerV.headerBgV.backgroundColor = UIColor.whiteColor;
  286. _headerV.fansBtn = [PublicObj setUpImgDownText:_headerV.fansBtn space:15];
  287. _headerV.zanBtn = [PublicObj setUpImgDownText:_headerV.zanBtn space:15];
  288. _headerV.aiTeBtn = [PublicObj setUpImgDownText:_headerV.aiTeBtn space:15];
  289. _headerV.commentBtn = [PublicObj setUpImgDownText:_headerV.commentBtn space:15];
  290. YBWeakSelf;
  291. _headerV.msgEvent = ^(NSString *type) {
  292. [weakSelf msgClickEvent:type];
  293. };
  294. return _headerV;
  295. }
  296. return nil;
  297. }
  298. -(void)msgClickEvent:(NSString *)type {
  299. //rk_顶部红点
  300. if ([type isEqual:@"粉丝"]) {//=====>不需要翻译
  301. [[YBImManager shareInstance]clearUnreadConvId:_conversation_fans.convId sendNot:YES];
  302. _headerV.fansPoint.hidden = YES;
  303. }else if ([type isEqual:@"赞"]){
  304. [[YBImManager shareInstance]clearUnreadConvId:_conversation_zan.convId sendNot:YES];
  305. _headerV.zanPoint.hidden = YES;
  306. }else if ([type isEqual:@"@我的"]){
  307. [[YBImManager shareInstance]clearUnreadConvId:_conversation_at.convId sendNot:YES];
  308. _headerV.atPoint.hidden = YES;
  309. }else if ([type isEqual:@"评论"]){
  310. [[YBImManager shareInstance]clearUnreadConvId:_conversation_comment.convId sendNot:YES];
  311. _headerV.comPoint.hidden = YES;
  312. }
  313. if ([type isEqual:@"粉丝"]) {
  314. MessageFansVC *fansVC = [[MessageFansVC alloc]init];
  315. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:fansVC animated:YES];
  316. NSLog(@"==粉丝==");
  317. }else {
  318. //赞、@我的、评论
  319. MsgTopPubVC *pubVC = [[MsgTopPubVC alloc]init];
  320. pubVC.type = type;
  321. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:pubVC animated:YES];
  322. NSLog(@"==赞==@我的==评论==");
  323. }
  324. }
  325. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
  326. return 0;
  327. }
  328. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
  329. return nil;
  330. }
  331. - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath{
  332. if (indexPath.row>1) {
  333. return YES;
  334. }
  335. return NO;
  336. }
  337. - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
  338. return UITableViewCellEditingStyleDelete;
  339. }
  340. - (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath{
  341. return YZMsg(@"删除");
  342. }
  343. - (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath{
  344. return NO;
  345. }
  346. - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
  347. TConversationCellData *conv = _data[indexPath.row];
  348. NSMutableArray *new_a = [NSMutableArray arrayWithArray:_data];
  349. [new_a removeObjectAtIndex:indexPath.row];
  350. _data = [NSArray arrayWithArray:new_a];
  351. [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationNone];
  352. [[YBImManager shareInstance]clearUnreadConvId:conv.convId sendNot:YES];
  353. NSString *userid = [NSString stringWithFormat:@"c2c_%@",conv.convId];
  354. [[V2TIMManager sharedInstance] deleteConversation:userid succ:^{
  355. NSLog(@"success");
  356. } fail:^(int code, NSString *desc) {
  357. NSLog(@"failure, code:%d, desc:%@", code, desc);
  358. }];
  359. // dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  360. // [[NSNotificationCenter defaultCenter] postNotificationName:TUIKitNotification_TIMCancelunread object:nil];
  361. // });
  362. }
  363. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  364. [tableView deselectRowAtIndexPath:indexPath animated:NO];
  365. TConversationCellData *conversation = [_data objectAtIndex:indexPath.row];
  366. [[YBImManager shareInstance] clearUnreadConvId:conversation.convId sendNot:YES];
  367. if ([conversation.convId isEqual:@"dsp_admin_1"]||[conversation.convId isEqual:@"dsp_admin_2"]) {
  368. if ([conversation.convId isEqual:@"dsp_admin_2"]) {
  369. [[YBImManager shareInstance] clearUnreadConvId:_conversation_ctr.convId sendNot:NO];
  370. NSDate *currentDate = [NSDate date];//获取当前时间,日期
  371. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  372. [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
  373. NSString *dataStr = [dateFormatter stringFromDate:currentDate];
  374. [[NSUserDefaults standardUserDefaults]setObject:dataStr forKey:@"sys_time_2"];
  375. }else{
  376. NSDate *currentDate = [NSDate date];//获取当前时间,日期
  377. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  378. [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
  379. NSString *dataStr = [dateFormatter stringFromDate:currentDate];
  380. [[NSUserDefaults standardUserDefaults]setObject:dataStr forKey:@"sys_time_1"];
  381. }
  382. NSMutableDictionary *dic = [NSMutableDictionary dictionary];
  383. [dic setObject:conversation.userHeader forKey:@"avatar"];
  384. [dic setObject:conversation.convId forKey:@"id"];
  385. [dic setObject:conversation.userName forKey:@"user_nickname"];
  386. //[dic setObject:conversation.lastConv forKey:@"conversation"];
  387. MessageListModel *model = [MessageListModel modelWithDic:dic];
  388. MsgSysVC *sysVC = [[MsgSysVC alloc]init];
  389. sysVC.isWhiteStyle = YES;
  390. sysVC.listModel = model;
  391. sysVC.uiFrom = UiFrom_Default;
  392. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:sysVC animated:YES];
  393. }else if([conversation.convId isEqual:@"goodsorder_admin"]){
  394. OrderMessageVC *order = [[OrderMessageVC alloc]init];
  395. [[YBBaseAppDelegate sharedAppDelegate]pushViewController:order animated:YES];
  396. }else{
  397. TChatC2CController *chat = [[TChatC2CController alloc] init];
  398. chat.conversation = _data[indexPath.row];
  399. [[YBBaseAppDelegate sharedAppDelegate] pushViewController:chat animated:YES];
  400. }
  401. }
  402. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  403. TConversationCell *cell = [tableView dequeueReusableCellWithIdentifier:TConversationCell_ReuseId];
  404. if(!cell){
  405. cell = [[TConversationCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TConversationCell_ReuseId];
  406. }
  407. TConversationCellData *celldata =[_data objectAtIndex:indexPath.row];
  408. [cell setData:celldata];
  409. return cell;
  410. }
  411. - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
  412. return UIModalPresentationNone;
  413. }
  414. -(void)selPeopleFun {
  415. YBWeakSelf;
  416. if (!_selV) {
  417. _selV = [[SelPeopleV alloc]initWithFrame:CGRectMake(0, _window_height, _window_width, _window_height) showType:@"1" selUser:^(NSString *state, MessageListModel *userModel) {
  418. [weakSelf selCallBack:state uModel:userModel];
  419. }];
  420. [self.view addSubview:_selV];
  421. }
  422. [UIView animateWithDuration:0.3 animations:^{
  423. _selV.frame = CGRectMake(0, 0, _window_width, _window_height);
  424. self.tabBarController.tabBar.hidden = YES;
  425. }];
  426. }
  427. -(void)selCallBack:(NSString *)state uModel:(MessageListModel *)model{
  428. if ([state isEqual:@"关闭"]) {
  429. [UIView animateWithDuration:0.3 animations:^{
  430. _selV.frame = CGRectMake(0, _window_height, _window_width, _window_height);
  431. } completion:^(BOOL finished) {
  432. self.tabBarController.tabBar.hidden = NO;
  433. [_selV removeFromSuperview];
  434. _selV = nil;
  435. }];
  436. }else {
  437. //单聊
  438. [UIView animateWithDuration:0.3 animations:^{
  439. _selV.frame = CGRectMake(0, _window_height, _window_width, _window_height);
  440. } completion:^(BOOL finished) {
  441. self.tabBarController.tabBar.hidden = NO;
  442. [_selV removeFromSuperview];
  443. _selV = nil;
  444. //去单聊页面
  445. NSLog(@"===去单聊页面===%@",model.uidStr);
  446. NSDictionary *userDic = @{
  447. @"id":model.uidStr,
  448. @"user_nickname":model.unameStr,
  449. @"avatar":model.iconStr,
  450. };
  451. [[YBMessageManager shareManager] chatWithUser:userDic];
  452. }];
  453. }
  454. }
  455. #pragma mark - 刷新顶部未读状态
  456. -(void)reloadTopUnread {
  457. if (_conversation_fans.unRead > 0) {
  458. _headerV.fansPoint.hidden = NO;
  459. _headerV.fansPoint.text = [NSString stringWithFormat:@"%d",_conversation_fans.unRead];
  460. //个位数显示圆点,两位及以上显示椭圆
  461. if (_conversation_fans.unRead < 10) {
  462. _headerV.fanPointWidth.constant = _headerV.fansPoint.frame.size.height;
  463. }else{
  464. _headerV.fanPointWidth.constant = _headerV.fansPoint.frame.size.height+8;
  465. }
  466. }
  467. if (_conversation_zan.unRead > 0) {
  468. _headerV.zanPoint.hidden = NO;
  469. _headerV.zanPoint.text = [NSString stringWithFormat:@"%d",_conversation_zan.unRead];
  470. //个位数显示圆点,两位及以上显示椭圆
  471. if (_conversation_zan.unRead < 10) {
  472. _headerV.zanPointWidth.constant = _headerV.zanPoint.frame.size.height;
  473. }else{
  474. _headerV.zanPointWidth.constant = _headerV.zanPoint.frame.size.height+8;
  475. }
  476. }
  477. if (_conversation_at.unRead > 0) {
  478. _headerV.atPoint.hidden = NO;
  479. _headerV.atPoint.text = [NSString stringWithFormat:@"%d",_conversation_at.unRead];
  480. //个位数显示圆点,两位及以上显示椭圆
  481. if (_conversation_at.unRead < 10) {
  482. _headerV.atPointWidth.constant = _headerV.atPoint.frame.size.height;
  483. }else{
  484. _headerV.atPointWidth.constant = _headerV.atPoint.frame.size.height+8;
  485. }
  486. }
  487. if (_conversation_comment.unRead > 0) {
  488. _headerV.comPoint.hidden = NO;
  489. _headerV.comPoint.text = [NSString stringWithFormat:@"%d",_conversation_comment.unRead];
  490. //个位数显示圆点,两位及以上显示椭圆
  491. if (_conversation_comment.unRead < 10) {
  492. _headerV.comPointWidth.constant = _headerV.comPoint.frame.size.height;
  493. }else{
  494. _headerV.comPointWidth.constant = _headerV.comPoint.frame.size.height+8;
  495. }
  496. }
  497. }
  498. @end