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

// 消息入口更改

parent e40e68fc
...@@ -21,7 +21,6 @@ class YHTabBarViewController: ESTabBarController { ...@@ -21,7 +21,6 @@ class YHTabBarViewController: ESTabBarController {
handleTabBarLine() handleTabBarLine()
addObservers() addObservers()
if YHLoginManager.shared.isLogin() { if YHLoginManager.shared.isLogin() {
getTotalUnreadMsgCount()
reportDeviceInfo() reportDeviceInfo()
} }
} }
...@@ -30,7 +29,6 @@ class YHTabBarViewController: ESTabBarController { ...@@ -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(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(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(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 { ...@@ -46,7 +44,6 @@ extension YHTabBarViewController {
@objc func loginSuccess() { @objc func loginSuccess() {
printLog("登录成功,进行相应的 UI刷新操作") printLog("登录成功,进行相应的 UI刷新操作")
getTotalUnreadMsgCount()
} }
@objc func logoutSuccess() { @objc func logoutSuccess() {
...@@ -56,36 +53,9 @@ extension YHTabBarViewController { ...@@ -56,36 +53,9 @@ extension YHTabBarViewController {
@objc func clearAllUnreadBadge() { @objc func clearAllUnreadBadge() {
DispatchQueue.main.async { DispatchQueue.main.async {
if let vcs = self.viewControllers, let msgListVC = vcs[safe: 2] {
msgListVC.tabBarItem.badgeValue = nil
UIApplication.shared.applicationIconBadgeNumber = 0 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
}
}
}
}
func reportDeviceInfo() { func reportDeviceInfo() {
if !YHLoginManager.shared.isLogin() { if !YHLoginManager.shared.isLogin() {
......
...@@ -19,6 +19,8 @@ class YHHomePageViewController: YHBaseViewController { ...@@ -19,6 +19,8 @@ class YHHomePageViewController: YHBaseViewController {
return viewModel return viewModel
}() }()
let msgViewModel: YHMsgViewModel = YHMsgViewModel()
let serviceCenterMainReqVM : YHServiceCenterMainViewModel = YHServiceCenterMainViewModel() let serviceCenterMainReqVM : YHServiceCenterMainViewModel = YHServiceCenterMainViewModel()
var homeHeaderViewHeight = YHHomeHeadView.fixViewH var homeHeaderViewHeight = YHHomeHeadView.fixViewH
...@@ -60,6 +62,7 @@ class YHHomePageViewController: YHBaseViewController { ...@@ -60,6 +62,7 @@ class YHHomePageViewController: YHBaseViewController {
//获取OSS密钥 //获取OSS密钥
YHOSSManager.share.getOSSID() YHOSSManager.share.getOSSID()
updateDefaultSearchKeyWord() updateDefaultSearchKeyWord()
getTotalUnreadMsgCount()
} }
...@@ -262,7 +265,8 @@ private extension YHHomePageViewController { ...@@ -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(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(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) view.addSubview(searchView)
searchView.snp.makeConstraints { make in searchView.snp.makeConstraints { make in
...@@ -317,6 +321,7 @@ private extension YHHomePageViewController { ...@@ -317,6 +321,7 @@ private extension YHHomePageViewController {
@objc func logoutSuccess() { @objc func logoutSuccess() {
showOrderTipsView(false) showOrderTipsView(false)
self.msgUnreadView.unreadCount = 0
getData() getData()
} }
} }
...@@ -431,3 +436,26 @@ extension YHHomePageViewController { ...@@ -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 { ...@@ -65,6 +65,10 @@ class YHMessageBellView: UIView {
} }
func createUI() { func createUI() {
let tap = UITapGestureRecognizer(target: self, action: #selector(didBellBtnClicked))
self.addGestureRecognizer(tap)
self.addSubview(self.bellImgV) self.addSubview(self.bellImgV)
self.addSubview(self.unreadLabel) self.addSubview(self.unreadLabel)
...@@ -82,4 +86,9 @@ class YHMessageBellView: UIView { ...@@ -82,4 +86,9 @@ class YHMessageBellView: UIView {
} }
} }
@objc func didBellBtnClicked() {
let vc = YHMessageListVC()
UIViewController.current?.navigationController?.pushViewController(vc)
}
} }
...@@ -285,7 +285,8 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource { ...@@ -285,7 +285,8 @@ extension YHMyViewController : UITableViewDelegate, UITableViewDataSource {
switch item.type { switch item.type {
case .myMessage://我的消息 case .myMessage://我的消息
printLog("我的消息") printLog("我的消息")
goTabBarBy(tabType: .message) let vc = YHMessageListVC()
self.navigationController?.pushViewController(vc)
case .scoreCenter:////积分中心 case .scoreCenter:////积分中心
printLog("积分中心") printLog("积分中心")
if let param = YHLoginManager.shared.userModel?.token,param.count>5 { 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