From aebeb945bc10de1ba2fc68b982f2ed8c27d089a5 Mon Sep 17 00:00:00 2001 From: fengshuo <963787902@qq.com> Date: Wed, 15 Mar 2023 17:27:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=9C=AA=E8=AF=BB=E4=B9=A6=E4=B8=8D=E4=BC=9A=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SessionList/SessionListViewController.m | 4 +- .../Main/Tabbar/View/TabbarViewController.m | 48 +++++++++++++++---- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m b/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m index db167337..06a68f6d 100644 --- a/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m +++ b/xplan-ios/Main/Message/View/SessionList/SessionListViewController.m @@ -397,9 +397,9 @@ NSString * const kMessageShowReadDotKey = @"kMessageShowReadDotKey"; return; } if (value > 0) { - [self.tabBarItem setBadgeValue:[NSString stringWithFormat:@"%ld", value]]; + [self.tabBarController.tabBar.items[3] setBadgeValue:[NSString stringWithFormat:@"%ld", value]]; } else { - [self.tabBarItem setBadgeValue:nil]; + [self.tabBarController.tabBar.items[3] setBadgeValue:@"0"]; } } diff --git a/xplan-ios/Main/Tabbar/View/TabbarViewController.m b/xplan-ios/Main/Tabbar/View/TabbarViewController.m index 02428fc0..3825385d 100644 --- a/xplan-ios/Main/Tabbar/View/TabbarViewController.m +++ b/xplan-ios/Main/Tabbar/View/TabbarViewController.m @@ -401,6 +401,12 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; [self.presenter logout]; } +- (void)onLogin:(NIMLoginStep)step { + if (step == NIMLoginStepLoginOK) { + [self addMessageBadge]; + } +} + - (void)onKickout:(NIMLoginKickoutResult *)result { [XCHUDTool showErrorWithMessage:@"您已被踢下线,若非正常行为,请及时修改密码"]; UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController; @@ -598,16 +604,16 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; #pragma mark - 动态 - (void)monentsUnReadCount { [Api monentsUnReadCount:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { - if (code == 200) { - MonentsUnReadModel * model = [MonentsUnReadModel modelWithDictionary:data.data]; - NSString *badge = model.total > 0 ? @(model.total).stringValue : nil; - if (model.total > 99) { - badge = @"99+"; - } - NSUInteger index = 1; - UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil; - [item setBadgeValue:badge]; - } +// if (code == 200) { +// MonentsUnReadModel * model = [MonentsUnReadModel modelWithDictionary:data.data]; +// NSString *badge = model.total > 0 ? @(model.total).stringValue : nil; +// if (model.total > 99) { +// badge = @"99+"; +// } +// NSUInteger index = 2; +// UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil; +// [item setBadgeValue:badge]; +// } } uid:[AccountInfoStorage instance].getUid]; } @@ -699,6 +705,28 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; [TTPopup popupView:view style:TTPopupStyleAlert]; } +- (void)addMessageBadge { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + NSArray * array = [NIMSDK sharedSDK].conversationManager.allRecentSessions; + __block int unreadCount = 0; + [array enumerateObjectsUsingBlock:^(NIMRecentSession * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (![[ClientConfig shareConfig].configInfo.officialMsgUids containsObject:obj.session.sessionId]) { + if (obj.session.sessionId.integerValue > 0) { + unreadCount += obj.unreadCount; + } + } + }]; + if (self.parentMode) { + unreadCount = 0; + } + if (unreadCount > 0) { + [self.tabBar.items[3] setBadgeValue:[NSString stringWithFormat:@"%d", unreadCount]]; + } else { + [self.tabBar.items[3] setBadgeValue:@"0"]; + } + }); +} + #pragma mark - 主播卡片弹窗 //新用户专享充值弹窗 - (void)showNewUserRecharge {