Commit 8932aa9a authored by Steven杜宇's avatar Steven杜宇

// 消息入口更改

parent e40e68fc
......@@ -21,7 +21,6 @@ class YHTabBarViewController: ESTabBarController {
handleTabBarLine()
addObservers()
if YHLoginManager.shared.isLogin() {
getTotalUnreadMsgCount()
reportDeviceInfo()
}
}
......@@ -30,7 +29,6 @@ class YHTabBarViewController: ESTabBarController {
NotificationCenter.default.addObserver(self, selector: #selector(loginSuccess), name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(logoutSuccess), name: YhConstant.YhNotification.didLogoutSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(clearAllUnreadBadge), name: YhConstant.YhNotification.didMarkAllMessagesReadedNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getTotalUnreadMsgCount), name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
}
}
......@@ -46,7 +44,6 @@ extension YHTabBarViewController {
@objc func loginSuccess() {
printLog("登录成功,进行相应的 UI刷新操作")
getTotalUnreadMsgCount()
}
@objc func logoutSuccess() {
......@@ -56,37 +53,10 @@ extension YHTabBarViewController {
@objc func clearAllUnreadBadge() {
DispatchQueue.main.async {
if let vcs = self.viewControllers, let msgListVC = vcs[safe: 2] {
msgListVC.tabBarItem.badgeValue = nil
UIApplication.shared.applicationIconBadgeNumber = 0
}
}
}
// 请求未读消息总数
@objc func getTotalUnreadMsgCount() {
if !YHLoginManager.shared.isLogin() {
return
}
self.viewModel.requestTotalUnreadMsgCount {
[weak self] success, error in
guard let self = self else { return }
DispatchQueue.main.async {
if let vcs = self.viewControllers, let msgListVC = vcs[safe: 2] {
let count = self.viewModel.unreadTotalCount
var unreadText:String? = nil
if 0 < count && count <= 99 {
unreadText = String(count)
} else if count > 99 {
unreadText = "99+"
}
msgListVC.tabBarItem.badgeValue = unreadText
}
}
UIApplication.shared.applicationIconBadgeNumber = 0
}
}
func reportDeviceInfo() {
if !YHLoginManager.shared.isLogin() {
return
......
......@@ -19,6 +19,8 @@ class YHHomePageViewController: YHBaseViewController {
return viewModel
}()
let msgViewModel: YHMsgViewModel = YHMsgViewModel()
let serviceCenterMainReqVM : YHServiceCenterMainViewModel = YHServiceCenterMainViewModel()
var homeHeaderViewHeight = YHHomeHeadView.fixViewH
......@@ -60,6 +62,7 @@ class YHHomePageViewController: YHBaseViewController {
//获取OSS密钥
YHOSSManager.share.getOSSID()
updateDefaultSearchKeyWord()
getTotalUnreadMsgCount()
}
......@@ -262,7 +265,8 @@ private extension YHHomePageViewController {
NotificationCenter.default.addObserver(self, selector: #selector(loginSuccess), name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(logoutSuccess), name: YhConstant.YhNotification.didLogoutSuccessNotifiction, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(getTotalUnreadMsgCount), name: YhConstant.YhNotification.didRequestUnreadMsgTotalCountNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(clearUnreadBadge), name: YhConstant.YhNotification.didMarkAllMessagesReadedNotifiction, object: nil)
view.addSubview(searchView)
searchView.snp.makeConstraints { make in
......@@ -317,6 +321,7 @@ private extension YHHomePageViewController {
@objc func logoutSuccess() {
showOrderTipsView(false)
self.msgUnreadView.unreadCount = 0
getData()
}
}
......@@ -431,3 +436,26 @@ extension YHHomePageViewController {
}
}
}
extension YHHomePageViewController {
// 请求未读消息总数
@objc func getTotalUnreadMsgCount() {
if !YHLoginManager.shared.isLogin() {
return
}
self.msgViewModel.requestTotalUnreadMsgCount {
[weak self] success, error in
guard let self = self else { return }
DispatchQueue.main.async {
self.msgUnreadView.unreadCount = self.msgViewModel.unreadTotalCount
}
}
}
@objc func clearUnreadBadge() {
DispatchQueue.main.async {
self.msgUnreadView.unreadCount = 0
}
}
}
......@@ -65,6 +65,10 @@ class YHMessageBellView: UIView {
}
func createUI() {
let tap = UITapGestureRecognizer(target: self, action: #selector(didBellBtnClicked))
self.addGestureRecognizer(tap)
self.addSubview(self.bellImgV)
self.addSubview(self.unreadLabel)
......@@ -81,5 +85,10 @@ class YHMessageBellView: UIView {
make.width.equalTo(16.0)
}
}
@objc func didBellBtnClicked() {
let vc = YHMessageListVC()
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
......@@ -285,7 +285,8 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
switch item.type {
case .myMessage://我的消息
printLog("我的消息")
goTabBarBy(tabType: .message)
let vc = YHMessageListVC()
self.navigationController?.pushViewController(vc)
case .scoreCenter:////积分中心
printLog("积分中心")
if let param = YHLoginManager.shared.userModel?.token,param.count>5 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment