Commit 9ba596b7 authored by Steven杜宇's avatar Steven杜宇

// 推送资讯

parent b83e48b8
...@@ -1275,6 +1275,7 @@ ...@@ -1275,6 +1275,7 @@
04E507D62D6EE856005F758B /* YHUserLevelAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E507D52D6EE856005F758B /* YHUserLevelAlertView.swift */; }; 04E507D62D6EE856005F758B /* YHUserLevelAlertView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04E507D52D6EE856005F758B /* YHUserLevelAlertView.swift */; };
04EA376D2BEA06EF00DBAF64 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04EA376C2BEA06EF00DBAF64 /* WebKit.framework */; }; 04EA376D2BEA06EF00DBAF64 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04EA376C2BEA06EF00DBAF64 /* WebKit.framework */; };
04EA376F2BEA071600DBAF64 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 04EA376E2BEA070500DBAF64 /* libc++.tbd */; }; 04EA376F2BEA071600DBAF64 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 04EA376E2BEA070500DBAF64 /* libc++.tbd */; };
04F1924D2DE0125B004BDAAC /* YHNewsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04F1924C2DE0125B004BDAAC /* YHNewsModel.swift */; };
6203A87EDC96313BBE789D9C /* Pods_galaxy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */; }; 6203A87EDC96313BBE789D9C /* Pods_galaxy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 987C69D43AE8D85DC1930DCF /* Pods_galaxy.framework */; };
A5573EE92B317C0100D98EC0 /* galaxyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5573EE82B317C0100D98EC0 /* galaxyTests.swift */; }; A5573EE92B317C0100D98EC0 /* galaxyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5573EE82B317C0100D98EC0 /* galaxyTests.swift */; };
A5573EF32B317C0100D98EC0 /* galaxyUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5573EF22B317C0100D98EC0 /* galaxyUITests.swift */; }; A5573EF32B317C0100D98EC0 /* galaxyUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5573EF22B317C0100D98EC0 /* galaxyUITests.swift */; };
...@@ -2587,6 +2588,7 @@ ...@@ -2587,6 +2588,7 @@
04E507D52D6EE856005F758B /* YHUserLevelAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHUserLevelAlertView.swift; sourceTree = "<group>"; }; 04E507D52D6EE856005F758B /* YHUserLevelAlertView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHUserLevelAlertView.swift; sourceTree = "<group>"; };
04EA376C2BEA06EF00DBAF64 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; 04EA376C2BEA06EF00DBAF64 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
04EA376E2BEA070500DBAF64 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; 04EA376E2BEA070500DBAF64 /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
04F1924C2DE0125B004BDAAC /* YHNewsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHNewsModel.swift; sourceTree = "<group>"; };
04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = ATAuthSDK.bundle; path = "galaxy/Classes/Modules/AutoLogin(一键登录)/framework/ATAuthSDK_D.framework/ATAuthSDK.bundle"; sourceTree = "<group>"; }; 04FA8B2D2C084C7E00ABE43F /* ATAuthSDK.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = ATAuthSDK.bundle; path = "galaxy/Classes/Modules/AutoLogin(一键登录)/framework/ATAuthSDK_D.framework/ATAuthSDK.bundle"; sourceTree = "<group>"; };
19B28612265782F9DC1BE0B0 /* Pods-galaxy.testenv.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.testenv.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.testenv.xcconfig"; sourceTree = "<group>"; }; 19B28612265782F9DC1BE0B0 /* Pods-galaxy.testenv.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.testenv.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.testenv.xcconfig"; sourceTree = "<group>"; };
58C2405158A4A6632D0E7460 /* Pods-galaxy.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.debug.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.debug.xcconfig"; sourceTree = "<group>"; }; 58C2405158A4A6632D0E7460 /* Pods-galaxy.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-galaxy.debug.xcconfig"; path = "Target Support Files/Pods-galaxy/Pods-galaxy.debug.xcconfig"; sourceTree = "<group>"; };
...@@ -5789,6 +5791,7 @@ ...@@ -5789,6 +5791,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
045C0EC62D12CA5E00BD2DC0 /* YHMsgListModel.swift */, 045C0EC62D12CA5E00BD2DC0 /* YHMsgListModel.swift */,
04F1924C2DE0125B004BDAAC /* YHNewsModel.swift */,
); );
path = M; path = M;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -7915,6 +7918,7 @@ ...@@ -7915,6 +7918,7 @@
045C121F2D12CA5F00BD2DC0 /* YHCertificateTemplateSheetView.swift in Sources */, 045C121F2D12CA5F00BD2DC0 /* YHCertificateTemplateSheetView.swift in Sources */,
045C12202D12CA5F00BD2DC0 /* YHResignMaterialListVC.swift in Sources */, 045C12202D12CA5F00BD2DC0 /* YHResignMaterialListVC.swift in Sources */,
045C12212D12CA5F00BD2DC0 /* YHResignUploadTravelPassportTableViewCell.swift in Sources */, 045C12212D12CA5F00BD2DC0 /* YHResignUploadTravelPassportTableViewCell.swift in Sources */,
04F1924D2DE0125B004BDAAC /* YHNewsModel.swift in Sources */,
045C12222D12CA5F00BD2DC0 /* YHResignCertificatePassportTableViewCell.swift in Sources */, 045C12222D12CA5F00BD2DC0 /* YHResignCertificatePassportTableViewCell.swift in Sources */,
045C12232D12CA5F00BD2DC0 /* YHIncomeRecordItemCell.swift in Sources */, 045C12232D12CA5F00BD2DC0 /* YHIncomeRecordItemCell.swift in Sources */,
045C12242D12CA5F00BD2DC0 /* YHAdopterResidentViewController.swift in Sources */, 045C12242D12CA5F00BD2DC0 /* YHAdopterResidentViewController.swift in Sources */,
......
...@@ -49,6 +49,9 @@ class YHOrderTipsItemView: UIView { ...@@ -49,6 +49,9 @@ class YHOrderTipsItemView: UIView {
} else if msg.type == YHMessageType.business.rawValue { } else if msg.type == YHMessageType.business.rawValue {
return "银河商务" return "银河商务"
} else if msg.type == YHMessageType.article.rawValue {
return "银河资讯"
} else { } else {
return "--" return "--"
} }
......
...@@ -10,7 +10,12 @@ import UIKit ...@@ -10,7 +10,12 @@ import UIKit
class YHGalaxyNewsListViewController: YHBaseViewController { class YHGalaxyNewsListViewController: YHBaseViewController {
var newsArr: [String] = ["", "", ""] let type: Int = 10
var newsArr: [YHNewsModel] = []
var currentPage = 1
var isLastPage = false
let viewModel = YHMsgViewModel()
lazy var tableView: UITableView = { lazy var tableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped) let tableView = UITableView(frame: .zero, style: .grouped)
...@@ -27,11 +32,14 @@ class YHGalaxyNewsListViewController: YHBaseViewController { ...@@ -27,11 +32,14 @@ class YHGalaxyNewsListViewController: YHBaseViewController {
tableView.backgroundView = emptyDataTipsView tableView.backgroundView = emptyDataTipsView
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell") tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHGalaxyNewsCell.self, forCellReuseIdentifier: YHGalaxyNewsCell.cellReuseIdentifier) tableView.register(YHGalaxyNewsCell.self, forCellReuseIdentifier: YHGalaxyNewsCell.cellReuseIdentifier)
tableView.es.addInfiniteScrolling {
self.getMsgList(more: true)
}
return tableView return tableView
}() }()
lazy var emptyDataTipsView: YHEmptyDataView = { lazy var emptyDataTipsView: YHEmptyDataView = {
let view = YHEmptyDataView.createView("暂无消息", kEmptyMessageBgName) let view = YHEmptyDataView.createView("暂无资讯", kEmptyMessageBgName)
let topMargin = 310-k_Height_NavigationtBarAndStatuBar let topMargin = 310-k_Height_NavigationtBarAndStatuBar
view.topMargin = topMargin view.topMargin = topMargin
view.isHidden = true view.isHidden = true
...@@ -55,12 +63,69 @@ class YHGalaxyNewsListViewController: YHBaseViewController { ...@@ -55,12 +63,69 @@ class YHGalaxyNewsListViewController: YHBaseViewController {
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar) make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalToSuperview() make.bottom.equalToSuperview()
} }
getMsgList()
} }
@objc func didCleanBtnClicked() { @objc func didCleanBtnClicked() {
YHCommonAlertView.show("清除未读", "确定要清除所有未读提示吗?", "取消", "确认") { YHCommonAlertView.show("清除未读", "确定要清除所有未读提示吗?", "取消", "确认") {
} callBack: {
self.markAllMsgsRead()
}
}
func getMsgList(more: Bool = false) {
if isLastPage {
tableView.es.stopLoadingMore()
return
}
if more {
currentPage += 1
} else {
currentPage = 1
}
self.viewModel.getNewsDetailList(type: self.type, page: currentPage) { [weak self] _, isLastPage in
guard let self = self else { return }
newsArr.removeAll()
newsArr.append(contentsOf: self.viewModel.newsDetailList)
emptyDataTipsView.isHidden = newsArr.count > 0
self.isLastPage = isLastPage
tableView.es.stopLoadingMore()
if isLastPage {
self.tableView.es.noticeNoMoreData()
self.tableView.footer?.alpha = 1
}
self.tableView.reloadData { [weak self] in
guard let self = self else { return }
}
}
}
func markAllMsgsRead() {
YHHUD.show(.progress(message: "清除中..."))
self.viewModel.readMessages(type: self.type, msgIds: nil, isAllRead: true) { [weak self] success, error in
YHHUD.hide()
guard let self = self else { return }
if success {
YHHUD.flash(message: "清除成功")
for item in self.newsArr {
item.is_read = true
}
self.tableView.reloadData()
return
}
var msg = "清除失败"
if let error = error {
if error.errorMsg.count > 0 {
msg = error.errorMsg
}
}
YHHUD.flash(message: msg)
} }
} }
...@@ -77,7 +142,7 @@ extension YHGalaxyNewsListViewController: UITableViewDelegate, UITableViewDataSo ...@@ -77,7 +142,7 @@ extension YHGalaxyNewsListViewController: UITableViewDelegate, UITableViewDataSo
guard let cell = tableView.dequeueReusableCell(withIdentifier: YHGalaxyNewsCell.cellReuseIdentifier, for: indexPath) as? YHGalaxyNewsCell else { return UITableViewCell() } guard let cell = tableView.dequeueReusableCell(withIdentifier: YHGalaxyNewsCell.cellReuseIdentifier, for: indexPath) as? YHGalaxyNewsCell else { return UITableViewCell() }
if 0 <= indexPath.row && indexPath.row < newsArr.count { if 0 <= indexPath.row && indexPath.row < newsArr.count {
let item = newsArr[indexPath.row] let item = newsArr[indexPath.row]
cell.updateModel(item)
} }
return cell return cell
} }
...@@ -87,7 +152,25 @@ extension YHGalaxyNewsListViewController: UITableViewDelegate, UITableViewDataSo ...@@ -87,7 +152,25 @@ extension YHGalaxyNewsListViewController: UITableViewDelegate, UITableViewDataSo
} }
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if 0 <= indexPath.row && indexPath.row < newsArr.count {
let item = newsArr[indexPath.row]
if let id = Int(item.id) {
self.viewModel.readMessages(type: self.type, msgIds: [id], isAllRead: false) {
[weak self] success, _ in
guard let self = self else { return }
if success {
for msgItem in newsArr {
if msgItem.article_id == item.article_id, msgItem.id == item.id {
msgItem.is_read = true
break
}
}
self.tableView.reloadData()
return
}
}
}
}
} }
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat { private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
......
...@@ -177,7 +177,6 @@ class YHMessageListVC: YHBaseViewController { ...@@ -177,7 +177,6 @@ class YHMessageListVC: YHBaseViewController {
@objc func getUnreadMsgList() { @objc func getUnreadMsgList() {
if !YHLoginManager.shared.isLogin() { if !YHLoginManager.shared.isLogin() {
// 保留第一个元素银河管家,删除其他元素
msgArr.removeAll() msgArr.removeAll()
self.tableView.reloadData() self.tableView.reloadData()
emptyDataTipsView.isHidden = msgArr.count > 0 emptyDataTipsView.isHidden = msgArr.count > 0
...@@ -205,6 +204,9 @@ class YHMessageListVC: YHBaseViewController { ...@@ -205,6 +204,9 @@ class YHMessageListVC: YHBaseViewController {
msgArr.append(self.managerSession) msgArr.append(self.managerSession)
} }
// 银河资讯
msgArr.append(self.viewModel.msgList.article)
if success { if success {
var hasUnreadMsg = false var hasUnreadMsg = false
...@@ -437,13 +439,6 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource { ...@@ -437,13 +439,6 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// do {
// // test
// let vc = YHGalaxyNewsListViewController()
// self.navigationController?.pushViewController(vc)
// return
// }
if 0 <= indexPath.row && indexPath.row < msgArr.count { if 0 <= indexPath.row && indexPath.row < msgArr.count {
let msgItem = msgArr[indexPath.row] let msgItem = msgArr[indexPath.row]
...@@ -464,6 +459,12 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource { ...@@ -464,6 +459,12 @@ extension YHMessageListVC: UITableViewDelegate, UITableViewDataSource {
} }
return return
} }
if msgItem.type == YHMessageType.article.rawValue { // 银河资讯
let vc = YHGalaxyNewsListViewController()
self.navigationController?.pushViewController(vc)
return
}
let vc = YHMessageDetailListVC() let vc = YHMessageDetailListVC()
vc.type = msgItem.type vc.type = msgItem.type
vc.title = msgItem.getTitle() vc.title = msgItem.getTitle()
......
...@@ -20,6 +20,7 @@ enum YHMessageType: Int { ...@@ -20,6 +20,7 @@ enum YHMessageType: Int {
case goToHK = 7 // 赴港办证 case goToHK = 7 // 赴港办证
case renewal = 8 // 身份续签 case renewal = 8 // 身份续签
case business = 9 // 商务 case business = 9 // 商务
case article = 10 // 资讯
case yinheManager = 9527 // 银河管家 case yinheManager = 9527 // 银河管家
} }
...@@ -73,6 +74,9 @@ class YHMessageInfoModel: SmartCodable { ...@@ -73,6 +74,9 @@ class YHMessageInfoModel: SmartCodable {
} else if type == YHMessageType.business.rawValue { } else if type == YHMessageType.business.rawValue {
return "银河商务" return "银河商务"
} else if type == YHMessageType.article.rawValue {
return "银河资讯"
} }
return "" return ""
} }
...@@ -88,6 +92,7 @@ class YHMsgListModel: SmartCodable { ...@@ -88,6 +92,7 @@ class YHMsgListModel: SmartCodable {
var goToHK: YHMessageInfoModel = YHMessageInfoModel() var goToHK: YHMessageInfoModel = YHMessageInfoModel()
var renewal: YHMessageInfoModel = YHMessageInfoModel() var renewal: YHMessageInfoModel = YHMessageInfoModel()
var business: YHMessageInfoModel = YHMessageInfoModel() var business: YHMessageInfoModel = YHMessageInfoModel()
var article: YHMessageInfoModel = YHMessageInfoModel()
required init() { required init() {
self.information.type = YHMessageType.infoFill.rawValue self.information.type = YHMessageType.infoFill.rawValue
...@@ -99,10 +104,11 @@ class YHMsgListModel: SmartCodable { ...@@ -99,10 +104,11 @@ class YHMsgListModel: SmartCodable {
self.goToHK.type = YHMessageType.goToHK.rawValue self.goToHK.type = YHMessageType.goToHK.rawValue
self.renewal.type = YHMessageType.renewal.rawValue self.renewal.type = YHMessageType.renewal.rawValue
self.business.type = YHMessageType.business.rawValue self.business.type = YHMessageType.business.rawValue
self.article.type = YHMessageType.article.rawValue
} }
enum CodingKeys: String, CodingKey { enum CodingKeys: String, CodingKey {
case information, certificate, draft, signature, approval, renewal, business case information, certificate, draft, signature, approval, renewal, business, article
case dataSubmission = "data_submission" case dataSubmission = "data_submission"
case goToHK = "go_to_hk" case goToHK = "go_to_hk"
} }
......
//
// YHNewsModel.swift
// galaxy
//
// Created by Dufet on 2025/5/23.
// Copyright © 2025 https://www.galaxy-immi.com. All rights reserved.
//
import SmartCodable
class YHNewsListModel: SmartCodable {
var page_count: Int = 0
var list: [YHNewsModel] = []
required init() {
}
}
class YHNewsModel: SmartCodable {
var id: String = ""
var title: String = ""
var content: String = ""
var time: Int64 = 0
var is_read: Bool = false
var url: String = ""
var news_type: Int = 0 // 资讯类型:1视频 2图文 4 固定链接
var article_id: Int = 0
var type: Int = 0
var media_url: String = "" // 媒体链接
var media_transcode_url: String = "" // 媒体转码链接
var cover_img: String = "" // 封面图片链接
required init() {
}
}
...@@ -31,7 +31,9 @@ class YHGalaxyNewsCell: UITableViewCell { ...@@ -31,7 +31,9 @@ class YHGalaxyNewsCell: UITableViewCell {
lazy var coverImgV: UIImageView = { lazy var coverImgV: UIImageView = {
let imgV = UIImageView() let imgV = UIImageView()
imgV.contentMode = .scaleAspectFill
imgV.image = UIImage(named: "msg_news_cover_default") imgV.image = UIImage(named: "msg_news_cover_default")
imgV.clipsToBounds = true
return imgV return imgV
}() }()
...@@ -77,6 +79,16 @@ class YHGalaxyNewsCell: UITableViewCell { ...@@ -77,6 +79,16 @@ class YHGalaxyNewsCell: UITableViewCell {
setupUI() setupUI()
} }
func updateModel(_ model: YHNewsModel) {
timeLabel.text = formatTimestamp(Double(model.time))
coverImgV.sd_setImage(with: URL(string: model.cover_img), placeholderImage: UIImage(named: ""))
titleLabel.text = model.title
descLabel.text = model.content
redPointView.isHidden = model.is_read
playImgV.isHidden = model.news_type != 1
}
func setupUI() { func setupUI() {
self.selectionStyle = .none self.selectionStyle = .none
...@@ -136,4 +148,29 @@ class YHGalaxyNewsCell: UITableViewCell { ...@@ -136,4 +148,29 @@ class YHGalaxyNewsCell: UITableViewCell {
} }
func formatTimestamp(_ timestamp: TimeInterval) -> String {
let currentDate = Date()
let calendar = Calendar.current
let currentYear = calendar.component(.year, from: currentDate)
let currentDay = calendar.component(.day, from: currentDate)
let date = Date(timeIntervalSince1970: timestamp)
let year = calendar.component(.year, from: date)
let day = calendar.component(.day, from: date)
let dateFormatter = DateFormatter()
if year == currentYear {
if day == currentDay {
dateFormatter.dateFormat = "HH:mm"
} else {
dateFormatter.dateFormat = "MM-dd"
}
} else {
dateFormatter.dateFormat = "yyyy-MM-dd"
}
return dateFormatter.string(from: date)
}
} }
...@@ -33,6 +33,7 @@ class YHMessageSessionCell: UITableViewCell { ...@@ -33,6 +33,7 @@ class YHMessageSessionCell: UITableViewCell {
func updateModel(_ model: YHMessageInfoModel) { func updateModel(_ model: YHMessageInfoModel) {
self.nameLabel.text = model.getTitle() self.nameLabel.text = model.getTitle()
self.iconContentView.backgroundColor = UIColor(hex: 0xF4F6FA)
if model.type == YHMessageType.yinheManager.rawValue { if model.type == YHMessageType.yinheManager.rawValue {
self.iconImgView.image = UIImage(named: "msg_icon_yinhe_manager") self.iconImgView.image = UIImage(named: "msg_icon_yinhe_manager")
...@@ -63,6 +64,11 @@ class YHMessageSessionCell: UITableViewCell { ...@@ -63,6 +64,11 @@ class YHMessageSessionCell: UITableViewCell {
} else if model.type == YHMessageType.business.rawValue { } else if model.type == YHMessageType.business.rawValue {
self.iconImgView.image = UIImage(named: "msg_icon_business") self.iconImgView.image = UIImage(named: "msg_icon_business")
} else if model.type == YHMessageType.article.rawValue {
self.iconImgView.image = UIImage(named: "msg_icon_news")
self.iconContentView.backgroundColor = UIColor(hex: 0xF0F5FF)
} }
self.badgeLabel.isHidden = model.unreadCount <= 0 self.badgeLabel.isHidden = model.unreadCount <= 0
......
...@@ -10,6 +10,7 @@ import UIKit ...@@ -10,6 +10,7 @@ import UIKit
import SmartCodable import SmartCodable
let kMsgPageSize = 30 let kMsgPageSize = 30
let kNewsPageSize = 10
class YHMsgViewModel: NSObject { class YHMsgViewModel: NSObject {
...@@ -17,6 +18,9 @@ class YHMsgViewModel: NSObject { ...@@ -17,6 +18,9 @@ class YHMsgViewModel: NSObject {
var msgDetailList: [YHDetailMessageModel] = [] var msgDetailList: [YHDetailMessageModel] = []
var unreadTotalCount: Int = 0 var unreadTotalCount: Int = 0
var newsList: YHNewsListModel = YHNewsListModel()
var newsDetailList: [YHNewsModel] = []
func getUnreadMsgList(_ callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) { func getUnreadMsgList(_ callBackBlock: @escaping (_ success: Bool, _ error: YHErrorModel?) -> Void) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.unreadMsgListApi let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.unreadMsgListApi
...@@ -40,6 +44,7 @@ class YHMsgViewModel: NSObject { ...@@ -40,6 +44,7 @@ class YHMsgViewModel: NSObject {
self.msgList.goToHK.type = YHMessageType.goToHK.rawValue self.msgList.goToHK.type = YHMessageType.goToHK.rawValue
self.msgList.renewal.type = YHMessageType.renewal.rawValue self.msgList.renewal.type = YHMessageType.renewal.rawValue
self.msgList.business.type = YHMessageType.business.rawValue self.msgList.business.type = YHMessageType.business.rawValue
self.msgList.article.type = YHMessageType.article.rawValue
callBackBlock(true, nil) callBackBlock(true, nil)
} else { } else {
let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg) let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg)
...@@ -183,4 +188,52 @@ class YHMsgViewModel: NSObject { ...@@ -183,4 +188,52 @@ class YHMsgViewModel: NSObject {
} }
} }
func getNewsDetailList(type: Int, page: Int, _ callBackBlock: @escaping (_ success: Bool, _ isLastPage: Bool) -> Void) {
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Message.newsListApi
let params = ["type": type,
"page": page,
"page_size": kNewsPageSize]
_ = YHNetRequest.postRequest(url: strUrl, params: params) { json, _ in
guard let dic = json.data?.peel as? [String: Any], let totalPage = dic["page_count"] as? Int, let arrDict = dic["list"] as? [Any] else {
callBackBlock(false, false)
return
}
if json.code == 200 {
DispatchQueue.global().async {
guard let arr = [YHNewsModel].deserialize(from: arrDict) else {
DispatchQueue.main.async {
let error = YHErrorModel(errorCode: YHErrorCode.dictParseError.rawValue, errorMsg: YHErrorCode.dictParseError.description())
self.newsDetailList = []
callBackBlock(false, false)
}
return
}
DispatchQueue.main.async {
if page == 1 {
self.newsDetailList.removeAll()
}
for item in arr {
self.newsDetailList.append(item)
}
let currentPage = (self.newsDetailList.count+kMsgPageSize-1)/kMsgPageSize
callBackBlock(true, currentPage == totalPage)
}
}
} else {
self.newsDetailList = []
let error: YHErrorModel = YHErrorModel(errorCode: Int32(json.code), errorMsg: json.msg)
callBackBlock(false, false)
}
} failBlock: { _ in
self.newsDetailList = []
callBackBlock(false, false)
}
}
} }
...@@ -437,6 +437,8 @@ class YHAllApiName { ...@@ -437,6 +437,8 @@ class YHAllApiName {
static let unreadTotalCountApi = "infoflow/unread-total" static let unreadTotalCountApi = "infoflow/unread-total"
// 报备设备信息 // 报备设备信息
static let reportDeviceInfoApi = "infoflow/report-device-info" static let reportDeviceInfoApi = "infoflow/report-device-info"
// 银河资讯列表
static let newsListApi = "infoflow/message/article-list/v2"
} }
// 人脉 // 人脉
......
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Message_yinhezixun@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Message_yinhezixun@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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