Commit 921ffcf6 authored by Steven杜宇's avatar Steven杜宇

// 消息

parent 3adbc068
......@@ -47,8 +47,22 @@ class YHMessageSessionCell: UITableViewCell {
} else {
self.nameLabel.text = ""
}
self.badgeLabel.isHidden = model.unreadCount <= 0
let unreadCountText = (model.unreadCount < 100 ? String(model.unreadCount) : "99+")
self.badgeLabel.text = unreadCountText
self.badgeLabel.snp.updateConstraints { make in
var width = badgeHeight
if unreadCountText.count < 2 { // 个位数
width = badgeHeight
} else if unreadCountText.count == 2 { // 两位数
width = 22.0
} else if unreadCountText.count >= 3 { // 三位数
width = 30.0
}
make.width.equalTo(width)
}
self.badgeLabel.text = (model.unreadCount < 100 ? String(model.unreadCount) : "99+")
self.detailLabel.text = model.lastMessage
self.timeLabel.text = formatTimestamp(Double(model.lastMessageTime))
}
......
......@@ -19,7 +19,37 @@ class YHMsgViewModel: NSObject {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.unreadMsgList
let _ = YHNetRequest.getRequest(url: strUrl) { json, code in
let dic = json.data
var dic = json.data
var json = json
json.code = 200
dic = [
"information": [
"unread_count": 0,
"last_message": "阿法守法所发生的法师打发",
"last_message_time": 1586507545,
"type": 0
],
"certificate": [
"unread_count": 3,
"last_message": "发生发顺丰大声道发生大发萨法沙发沙发沙发沙发阿斯顿发生发顺丰阿凡达放大第三方",
"last_message_time": 1586507545,
"type": 0
],
"draft": [
"unread_count": 100,
"last_message": "发生发顺丰大声道发生大发",
"last_message_time": 1712737945,
"type": 0
],
"signature": [
"unread_count": 87,
"last_message": "发生发",
"last_message_time": 1713236425,
"type": 0
]
]
printLog("model 是 ==> \(json)")
if json.code == 200 {
guard let result = YHMsgListModel.deserialize(dict: dic as? Dictionary ) else {
......
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