Commit 767e344b authored by David黄金龙's avatar David黄金龙
parents 0ccfb68e 096a9edc
...@@ -10,7 +10,12 @@ import UIKit ...@@ -10,7 +10,12 @@ import UIKit
class YHInformationFillVC: YHBaseViewController { class YHInformationFillVC: YHBaseViewController {
var msgArr:[String] = ["","","",""] var msgArr:[YHDetailMessageModel] = []
lazy var viewModel = {
let model = YHMsgViewModel()
return model
}()
lazy var navBar: YHCustomNavigationBar = { lazy var navBar: YHCustomNavigationBar = {
let bar = YHCustomNavigationBar.navBar() let bar = YHCustomNavigationBar.navBar()
...@@ -51,6 +56,11 @@ class YHInformationFillVC: YHBaseViewController { ...@@ -51,6 +56,11 @@ class YHInformationFillVC: YHBaseViewController {
setupUI() setupUI()
} }
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
getMsgList()
}
func setupUI() { func setupUI() {
gk_navigationBar.isHidden = true gk_navigationBar.isHidden = true
...@@ -69,6 +79,18 @@ class YHInformationFillVC: YHBaseViewController { ...@@ -69,6 +79,18 @@ class YHInformationFillVC: YHBaseViewController {
} }
} }
func getMsgList() {
YHHUD.show(.progress(message: "加载中..."))
self.viewModel.getMsgDetailList {
[weak self] success, error in
YHHUD.hide()
guard let self = self else { return }
msgArr.removeAll()
msgArr.append(contentsOf: self.viewModel.msgDetailList)
self.tableView.reloadData()
}
}
} }
extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource { extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource {
......
...@@ -47,7 +47,8 @@ class YHMsgViewController: YHBaseViewController { ...@@ -47,7 +47,8 @@ class YHMsgViewController: YHBaseViewController {
[weak self] in [weak self] in
guard let self = self else { return } guard let self = self else { return }
YHCommonAlertView.show("清除未读", "确定要清除所有未读提示吗?", "取消", "确认") { YHCommonAlertView.show("清除未读", "确定要清除所有未读提示吗?", "取消", "确认") {
let vc = YHInformationFillVC()
self.navigationController?.pushViewController(vc)
} }
} }
return bar return bar
...@@ -117,18 +118,22 @@ class YHMsgViewController: YHBaseViewController { ...@@ -117,18 +118,22 @@ class YHMsgViewController: YHBaseViewController {
msgArr.removeAll() msgArr.removeAll()
// 资料填写 // 资料填写
if let infoMsg = msgList.information { if let infoMsg = msgList.information {
infoMsg.customType = .infoFill
msgArr.append(infoMsg) msgArr.append(infoMsg)
} }
// 证件上传 // 证件上传
if let cerMsg = msgList.certificate { if let cerMsg = msgList.certificate {
cerMsg.customType = .cerUpload
msgArr.append(cerMsg) msgArr.append(cerMsg)
} }
// 文书定稿 // 文书定稿
if let dratMsg = msgList.draft { if let dratMsg = msgList.draft {
dratMsg.customType = .draft
msgArr.append(dratMsg) msgArr.append(dratMsg)
} }
// 文件签字 // 文件签字
if let signMsg = msgList.signature { if let signMsg = msgList.signature {
signMsg.customType = .fileSign
msgArr.append(signMsg) msgArr.append(signMsg)
} }
self.tableView.reloadData() self.tableView.reloadData()
...@@ -219,5 +224,4 @@ extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -219,5 +224,4 @@ extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource {
} }
return view return view
} }
} }
...@@ -9,12 +9,26 @@ ...@@ -9,12 +9,26 @@
import UIKit import UIKit
import SmartCodable import SmartCodable
struct YHMessageInfoModel: Codable { enum YHMessageType: Int {
case none = 0
case infoFill = 1 // 资料填写
case cerUpload = 2 // 证件上传
case draft = 3 // 文书定稿
case fileSign = 4 // 文件签字
}
class YHMessageInfoModel: SmartCodable {
var unreadCount: Int = 0 var unreadCount: Int = 0
var lastMessage: String = "" var lastMessage: String = ""
var lastMessageTime: Int = 0 var lastMessageTime: Int = 0
var type: Int = 0 var type: Int = 0
var customType: YHMessageType = .none
required init() {
}
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case unreadCount = "unread_count" case unreadCount = "unread_count"
case lastMessage = "last_message" case lastMessage = "last_message"
...@@ -33,3 +47,15 @@ class YHMsgListModel: SmartCodable { ...@@ -33,3 +47,15 @@ class YHMsgListModel: SmartCodable {
} }
} }
class YHDetailMessageModel: SmartCodable {
var id: String = ""
var title: String = ""
var content: String = ""
var time: Int = 0
var isRead: Bool = false
required init() {
}
}
...@@ -31,6 +31,23 @@ class YHMessageSessionCell: UITableViewCell { ...@@ -31,6 +31,23 @@ class YHMessageSessionCell: UITableViewCell {
} }
func updateModel(_ model: YHMessageInfoModel) { func updateModel(_ model: YHMessageInfoModel) {
if model.customType == .infoFill {
self.nameLabel.text = "资料填写"
} else if model.customType == .cerUpload {
self.nameLabel.text = "证件上传"
} else if model.customType == .draft {
self.nameLabel.text = "文书定稿"
} else if model.customType == .fileSign {
self.nameLabel.text = "文件签字"
} else {
self.nameLabel.text = ""
}
self.badgeLabel.text = (model.unreadCount < 100 ? String(model.unreadCount) : "99+") self.badgeLabel.text = (model.unreadCount < 100 ? String(model.unreadCount) : "99+")
self.detailLabel.text = model.lastMessage self.detailLabel.text = model.lastMessage
self.timeLabel.text = formatTimestamp(Double(model.lastMessageTime)) self.timeLabel.text = formatTimestamp(Double(model.lastMessageTime))
...@@ -108,11 +125,6 @@ class YHMessageSessionCell: UITableViewCell { ...@@ -108,11 +125,6 @@ class YHMessageSessionCell: UITableViewCell {
bottomLineView.backgroundColor = UIColor(hex: 0xF0F3F7) bottomLineView.backgroundColor = UIColor(hex: 0xF0F3F7)
contentView.addSubview(bottomLineView) contentView.addSubview(bottomLineView)
badgeLabel.text = "5"
nameLabel.text = "资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写资料填写"
detailLabel.text = "尊敬的用户,您好~很高兴通知您进行资料填写列尊敬的用户,您好~很高兴通知您进行资料填写列尊敬的用户,您好~很高兴通知您进行资料填写列"
timeLabel.text = "2024-01-01"
iconContentView.snp.makeConstraints { make in iconContentView.snp.makeConstraints { make in
make.left.equalToSuperview().offset(20) make.left.equalToSuperview().offset(20)
make.size.equalTo(CGSize(width: 44, height: 44)) make.size.equalTo(CGSize(width: 44, height: 44))
......
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
// //
import UIKit import UIKit
import SmartCodable
class YHMsgViewModel: NSObject { class YHMsgViewModel: NSObject {
var msgList: YHMsgListModel? var msgList: YHMsgListModel?
var msgDetailList : [YHDetailMessageModel] = []
func getUnreadMsgList(_ callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) { func getUnreadMsgList(_ callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
...@@ -40,4 +42,38 @@ class YHMsgViewModel: NSObject { ...@@ -40,4 +42,38 @@ class YHMsgViewModel: NSObject {
callBackBlock(false, error) callBackBlock(false, error)
} }
} }
func getMsgDetailList(_ callBackBlock:@escaping (_ success: Bool, _ error:YHErrorModel?)->()) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.msgDetaiList
let _ = YHNetRequest.getRequest(url: strUrl) { json, code in
let dic = json.data
printLog("model 是 ==> \(json)")
if json.code == 200 {
guard let arr = [YHDetailMessageModel].deserialize(array: dic as? [Any]) else {
let error = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
self.msgDetailList = []
callBackBlock(false, error)
return
}
self.msgDetailList.removeAll()
for item in arr {
if let item = item {
self.msgDetailList.append(item)
}
}
callBackBlock(true, nil)
} else {
self.msgDetailList = []
let error : YHErrorModel = YHErrorModel(errorCode:Int32(json.code), errorMsg: json.msg)
callBackBlock(false, error)
}
} failBlock: { error in
self.msgDetailList = []
callBackBlock(false, error)
}
}
} }
...@@ -259,5 +259,7 @@ class YHAllApiName { ...@@ -259,5 +259,7 @@ class YHAllApiName {
struct Message { struct Message {
// 获取未读消息列表 // 获取未读消息列表
static let unreadMsgList = "infoflow/unread-message" static let unreadMsgList = "infoflow/unread-message"
// 具体业务消息列表
static let msgDetaiList = "infoflow/message/list"
} }
} }
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