Commit ce8f7cff authored by pete谢兆麟's avatar pete谢兆麟

Merge commit '8d7cc252' into xiezhaolin

parents bff1ac0b 8d7cc252
......@@ -14,7 +14,6 @@
04174D642BCD52BD000BA46D /* YHTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D632BCD52BD000BA46D /* YHTestViewController.swift */; };
04174D732BCD5B74000BA46D /* YHMsgViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D672BCD5B74000BA46D /* YHMsgViewModel.swift */; };
04174D742BCD5B74000BA46D /* IMAppKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D692BCD5B74000BA46D /* IMAppKey.swift */; };
04174D752BCD5B74000BA46D /* YHMessageListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D6B2BCD5B74000BA46D /* YHMessageListModel.swift */; };
04174D762BCD5B74000BA46D /* YHMsgListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D6C2BCD5B74000BA46D /* YHMsgListModel.swift */; };
04174D772BCD5B74000BA46D /* YHMessageDetailListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D6E2BCD5B74000BA46D /* YHMessageDetailListVC.swift */; };
04174D782BCD5B74000BA46D /* YHMessageListVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04174D6F2BCD5B74000BA46D /* YHMessageListVC.swift */; };
......@@ -461,7 +460,6 @@
04174D632BCD52BD000BA46D /* YHTestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHTestViewController.swift; sourceTree = "<group>"; };
04174D672BCD5B74000BA46D /* YHMsgViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHMsgViewModel.swift; sourceTree = "<group>"; };
04174D692BCD5B74000BA46D /* IMAppKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IMAppKey.swift; sourceTree = "<group>"; };
04174D6B2BCD5B74000BA46D /* YHMessageListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHMessageListModel.swift; sourceTree = "<group>"; };
04174D6C2BCD5B74000BA46D /* YHMsgListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHMsgListModel.swift; sourceTree = "<group>"; };
04174D6E2BCD5B74000BA46D /* YHMessageDetailListVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHMessageDetailListVC.swift; sourceTree = "<group>"; };
04174D6F2BCD5B74000BA46D /* YHMessageListVC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YHMessageListVC.swift; sourceTree = "<group>"; };
......@@ -946,7 +944,6 @@
04174D6A2BCD5B74000BA46D /* M */ = {
isa = PBXGroup;
children = (
04174D6B2BCD5B74000BA46D /* YHMessageListModel.swift */,
04174D6C2BCD5B74000BA46D /* YHMsgListModel.swift */,
);
path = M;
......@@ -955,8 +952,8 @@
04174D6D2BCD5B74000BA46D /* C */ = {
isa = PBXGroup;
children = (
04174D6E2BCD5B74000BA46D /* YHMessageDetailListVC.swift */,
04174D6F2BCD5B74000BA46D /* YHMessageListVC.swift */,
04174D6E2BCD5B74000BA46D /* YHMessageDetailListVC.swift */,
);
path = C;
sourceTree = "<group>";
......@@ -2772,7 +2769,6 @@
045EEEEA2B9F171A0022A143 /* YHFamilyInitialInfo.swift in Sources */,
A5C382CF2B5F9A9100C5E65C /* YHServiceCenterMainViewModel.swift in Sources */,
045EEEA52B9F171A0022A143 /* YHImageViewController.swift in Sources */,
04174D752BCD5B74000BA46D /* YHMessageListModel.swift in Sources */,
045EEEF32B9F171A0022A143 /* YHFamilyMemberInfoListVC.swift in Sources */,
04EA230C2BB5199D009DA928 /* YHDocumentToActionTableViewCell.swift in Sources */,
A5ACE9572B4564F7002C94D2 /* YHBasicContentView.swift in Sources */,
......
......@@ -10,9 +10,23 @@ import UIKit
import ESTabBarController_swift
class YHTabBarViewController: ESTabBarController {
lazy var viewModel = {
let model = YHMsgViewModel()
return model
}()
override func viewDidLoad() {
super.viewDidLoad()
handleTabBarLine()
addObservers()
}
func addObservers() {
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(clearAllUnreadMsg), name: YhConstant.YhNotification.didMarkAllMessagesReadedNotifiction, object: nil)
}
}
......@@ -24,6 +38,44 @@ extension YHTabBarViewController {
@objc func showTabBar() -> Void {
self.tabBar.isHidden = false
}
@objc func loginSuccess() {
printLog("登录成功,进行相应的 UI刷新操作")
getTotalUnreadMsgCount()
}
@objc func logoutSuccess() {
printLog("登出成功")
}
func getTotalUnreadMsgCount() {
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] {
var count = self.viewModel.unreadTotalCount
var unreadText = String(count)
if count > 99 {
unreadText = "99+"
}
msgListVC.tabBarItem.badgeValue = unreadText
UIApplication.shared.applicationIconBadgeNumber = count
}
}
}
}
@objc func clearAllUnreadMsg() {
DispatchQueue.main.async {
if let vcs = self.viewControllers, let msgListVC = vcs[safe: 2] {
msgListVC.tabBarItem.badgeValue = ""
UIApplication.shared.applicationIconBadgeNumber = 0
}
}
}
}
extension YHTabBarViewController {
......
......@@ -21,7 +21,9 @@ class YHMessageDetailListVC: YHBaseViewController {
lazy var navBar: YHCustomNavigationBar = {
let bar = YHCustomNavigationBar.navBar()
bar.backgroundColor = .white
bar.title = "资料填写".local
if let title = self.title, !title.isEmpty {
bar.title = title
}
bar.showRightButtonType(.clean)
bar.backBlock = {
[weak self] in
......@@ -47,10 +49,37 @@ class YHMessageDetailListVC: YHBaseViewController {
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = UIColor(hex:0xF8F8F8)
tableView.backgroundView = emptyDataTipsView
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHInformationFillCell.self, forCellReuseIdentifier: YHInformationFillCell.cellReuseIdentifier)
return tableView
}()
lazy var emptyDataTipsView:UIView = {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 124))
view.isHidden = true
let imgView = UIImageView(image: UIImage(named: "msg_no_data"))
view.addSubview(imgView)
let label = UILabel()
label.textColor = UIColor(hex: 0x94A3B8)
label.font = UIFont.PFSC_R(ofSize: 14)
label.textAlignment = .center
label.text = "暂无新消息".local
view.addSubview(label)
imgView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(204)
make.width.height.equalTo(92)
make.centerX.equalTo(view)
}
label.snp.makeConstraints { make in
make.top.equalTo(imgView.snp.bottom).offset(12)
make.centerX.equalTo(view)
}
return view
}()
override func viewDidLoad() {
super.viewDidLoad()
......@@ -88,6 +117,7 @@ class YHMessageDetailListVC: YHBaseViewController {
guard let self = self else { return }
msgArr.removeAll()
msgArr.append(contentsOf: self.viewModel.msgDetailList)
emptyDataTipsView.isHidden = msgArr.count > 0
self.tableView.reloadData()
}
}
......
......@@ -109,6 +109,19 @@ class YHMessageListVC: YHBaseViewController {
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalToSuperview().offset(-k_Height_TabBar)
}
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)
}
@objc func loginSuccess() {
printLog("登录成功,进行相应的 UI刷新操作")
}
@objc func logoutSuccess() {
}
func getUnreadMsgList() {
......@@ -139,6 +152,7 @@ class YHMessageListVC: YHBaseViewController {
signMsg.customType = .fileSign
msgArr.append(signMsg)
}
emptyDataTipsView.isHidden = msgArr.count > 0
self.tableView.reloadData()
}
}
......@@ -156,6 +170,8 @@ class YHMessageListVC: YHBaseViewController {
item.unreadCount = 0
}
self.tableView.reloadData()
// 发送清空所有未读消息通知
NotificationCenter.default.post(name: YhConstant.YhNotification.didLoginSuccessNotifiction, object: nil)
return
}
......@@ -213,6 +229,7 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
let msgItem = msgArr[indexPath.row]
let vc = YHMessageDetailListVC()
vc.type = msgItem.type
vc.title = msgItem.getTitle()
self.navigationController?.pushViewController(vc)
}
}
......
//
// YHMessageListModel.swift
// galaxy
//
// Created by edy on 2024/4/15.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHMessageListModel: NSObject {
}
......@@ -35,6 +35,22 @@ class YHMessageInfoModel: SmartCodable {
case lastMessageTime = "last_message_time"
case type
}
func getTitle() -> String {
if customType == .infoFill {
return "资料填写"
} else if customType == .cerUpload {
return "证件上传"
} else if customType == .draft {
return "文书定稿"
} else if customType == .fileSign {
return "文件签字"
}
return ""
}
}
class YHMsgListModel: SmartCodable {
......
......@@ -32,25 +32,21 @@ class YHMessageSessionCell: UITableViewCell {
func updateModel(_ model: YHMessageInfoModel) {
self.nameLabel.text = model.getTitle()
if model.customType == .infoFill {
self.nameLabel.text = "资料填写"
self.iconImgView.image = UIImage(named: "msg_icon_info_fill")
} else if model.customType == .cerUpload {
self.nameLabel.text = "证件上传"
self.iconImgView.image = UIImage(named: "msg_icon_cer_upload")
} else if model.customType == .draft {
self.nameLabel.text = "文书定稿"
self.iconImgView.image = UIImage(named: "msg_icon_draft")
} else if model.customType == .fileSign {
self.nameLabel.text = "文件签字"
self.iconImgView.image = UIImage(named: "msg_icon_file_sign")
} else {
self.nameLabel.text = ""
}
self.badgeLabel.isHidden = model.unreadCount <= 0
let unreadCountText = (model.unreadCount < 100 ? String(model.unreadCount) : "99+")
self.badgeLabel.text = unreadCountText
......
......@@ -13,10 +13,11 @@ class YHMsgViewModel: NSObject {
var msgList: YHMsgListModel?
var msgDetailList : [YHDetailMessageModel] = []
var unreadTotalCount: Int = 0
func getUnreadMsgList(_ callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.unreadMsgList
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.unreadMsgListApi
let _ = YHNetRequest.getRequest(url: strUrl) { json, code in
var dic = json.data
......@@ -74,7 +75,7 @@ class YHMsgViewModel: NSObject {
}
func getMsgDetailList(type:Int, _ callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.msgDetaiList
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.msgDetaiListApi
let params = ["type": type]
let _ = YHNetRequest.postRequest(url: strUrl, params: params) { json, code in
......@@ -110,7 +111,7 @@ class YHMsgViewModel: NSObject {
func readMessages(type:Int?, msgIds:[Int]?, isAllRead:Bool?, _ callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.readMsg
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.readMsgApi
var params:[String : Any] = [:]
if let type = type {
......@@ -138,9 +139,35 @@ class YHMsgViewModel: NSObject {
}
} failBlock: { error in
self.msgList = nil
callBackBlock(false, error)
}
}
func requestTotalUnreadMsgCount(_ callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.unreadTotalCountApi
let _ = YHNetRequest.postRequest(url: strUrl) {
json, code in
let dic = json.data as? [String : Any]
printLog("model 是 ==> \(json)")
if json.code == 200 {
if let dic = dic, let total = dic["total"] as? Int {
self.unreadTotalCount = total
callBackBlock(true, nil)
} else {
self.unreadTotalCount = 0
callBackBlock(false, nil)
}
} else {
self.unreadTotalCount = 0
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { error in
self.unreadTotalCount = 0
callBackBlock(false, error)
}
}
}
......@@ -196,5 +196,8 @@ extension YhConstant {
//首页刷新通知
public static let refreshHomePageNotifiction = Notification.Name(rawValue: "com.yinhe.homePage.refresh")
//清空所有未读消息数
public static let didMarkAllMessagesReadedNotifiction = Notification.Name(rawValue: "com.yinhe.msgPage.readAll")
}
}
......@@ -260,10 +260,12 @@ class YHAllApiName {
// 消息
struct Message {
// 获取未读消息列表
static let unreadMsgList = "infoflow/unread-message"
static let unreadMsgListApi = "infoflow/unread-message"
// 具体业务消息列表
static let msgDetaiList = "infoflow/message/list"
static let msgDetaiListApi = "infoflow/message/list"
// 标记消息已读
static let readMsg = "infoflow/read-push"
static let readMsgApi = "infoflow/read-push"
// 获取未读消息总数
static let unreadTotalCountApi = "infoflow/unread-total"
}
}
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