Commit f60c05e1 authored by Steven杜宇's avatar Steven杜宇

// 消息

parent 94bd366b
...@@ -120,14 +120,15 @@ extension AppDelegate: JPUSHRegisterDelegate { ...@@ -120,14 +120,15 @@ extension AppDelegate: JPUSHRegisterDelegate {
goToMessagePage() goToMessagePage()
if let msgType = userInfo["msg_type"] as? Int, msgType == YHMessageType.article.rawValue { if let msgType = userInfo["msg_type"] as? Int, msgType == YHMessageType.article.rawValue {
let model = YHNewsModel() let model = YHNewsModel()
model.id = userInfo["msg_id"] as? String ?? ""
model.article_id = userInfo["article_id"] as? Int ?? 0 model.article_id = userInfo["article_id"] as? Int ?? 0
model.news_type = userInfo["news_type"] as? Int ?? 0 model.news_type = userInfo["news_type"] as? Int ?? 0
model.cover_img = userInfo["cover_img"] as? String ?? "" model.cover_img = userInfo["cover_img"] as? String ?? ""
model.url = userInfo["url"] as? String ?? "" model.url = userInfo["url"] as? String ?? ""
model.media_url = userInfo["media_url"] as? String ?? "" model.media_url = userInfo["media_url"] as? String ?? ""
model.media_transcode_url = userInfo["media_transcode_url"] as? String ?? "" model.media_transcode_url = userInfo["media_transcode_url"] as? String ?? ""
YHGalaxyNewsListViewController.enterDetail(model) yh_newsList.enterDetail(model)
yh_newsList.markRead(model)
} }
}) })
} }
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
import UIKit import UIKit
let yh_newsList = YHGalaxyNewsListViewController()
class YHGalaxyNewsListViewController: YHBaseViewController { class YHGalaxyNewsListViewController: YHBaseViewController {
let type: Int = YHMessageType.article.rawValue let type: Int = YHMessageType.article.rawValue
...@@ -32,6 +34,10 @@ class YHGalaxyNewsListViewController: YHBaseViewController { ...@@ -32,6 +34,10 @@ 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.addYHPullToRefresh {
self.getMsgList(more: false)
}
tableView.es.addInfiniteScrolling { tableView.es.addInfiniteScrolling {
self.getMsgList(more: true) self.getMsgList(more: true)
} }
...@@ -58,6 +64,7 @@ class YHGalaxyNewsListViewController: YHBaseViewController { ...@@ -58,6 +64,7 @@ class YHGalaxyNewsListViewController: YHBaseViewController {
view.backgroundColor = .init(hex: 0xF8F9FB) view.backgroundColor = .init(hex: 0xF8F9FB)
view.addSubview(tableView) view.addSubview(tableView)
tableView.snp.makeConstraints { make in tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar) make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
...@@ -78,12 +85,19 @@ class YHGalaxyNewsListViewController: YHBaseViewController { ...@@ -78,12 +85,19 @@ class YHGalaxyNewsListViewController: YHBaseViewController {
func getMsgList(more: Bool = false) { func getMsgList(more: Bool = false) {
if isLastPage { if isLastPage {
tableView.es.stopLoadingMore() if more {
tableView.es.stopLoadingMore()
} else {
tableView.es.stopPullToRefresh()
}
self.tableView.es.noticeNoMoreData()
self.tableView.footer?.isHidden = false
return return
} }
if more { if more {
currentPage += 1 currentPage += 1
} else { } else {
currentPage = 1 currentPage = 1
} }
...@@ -94,11 +108,14 @@ class YHGalaxyNewsListViewController: YHBaseViewController { ...@@ -94,11 +108,14 @@ class YHGalaxyNewsListViewController: YHBaseViewController {
newsArr.append(contentsOf: self.viewModel.newsDetailList) newsArr.append(contentsOf: self.viewModel.newsDetailList)
emptyDataTipsView.isHidden = newsArr.count > 0 emptyDataTipsView.isHidden = newsArr.count > 0
self.isLastPage = isLastPage self.isLastPage = isLastPage
tableView.es.stopLoadingMore() if more {
tableView.es.stopLoadingMore()
} else {
tableView.es.stopPullToRefresh()
}
if isLastPage { if isLastPage {
self.tableView.es.noticeNoMoreData() self.tableView.es.noticeNoMoreData()
self.tableView.footer?.alpha = 1 self.tableView.footer?.isHidden = false
} }
self.tableView.reloadData() self.tableView.reloadData()
} }
...@@ -128,7 +145,6 @@ class YHGalaxyNewsListViewController: YHBaseViewController { ...@@ -128,7 +145,6 @@ class YHGalaxyNewsListViewController: YHBaseViewController {
} }
func markRead(_ model: YHNewsModel) { func markRead(_ model: YHNewsModel) {
if let id = Int(model.id) { if let id = Int(model.id) {
self.viewModel.readMessages(type: self.type, msgIds: [id], isAllRead: false) { [weak self] success, _ in self.viewModel.readMessages(type: self.type, msgIds: [id], isAllRead: false) { [weak self] success, _ in
guard let self = self else { return } guard let self = self else { return }
...@@ -146,7 +162,7 @@ class YHGalaxyNewsListViewController: YHBaseViewController { ...@@ -146,7 +162,7 @@ class YHGalaxyNewsListViewController: YHBaseViewController {
} }
} }
static func enterDetail(_ item: YHNewsModel) { func enterDetail(_ item: YHNewsModel) {
if item.news_type == 2 { // 图文 if item.news_type == 2 { // 图文
let vc = YHHomeWebViewController() let vc = YHHomeWebViewController()
vc.url = YHBaseUrlManager.shared.curH5URL() + "articleDetail.html" + "?id=\(item.article_id)" vc.url = YHBaseUrlManager.shared.curH5URL() + "articleDetail.html" + "?id=\(item.article_id)"
...@@ -199,7 +215,7 @@ extension YHGalaxyNewsListViewController: UITableViewDelegate, UITableViewDataSo ...@@ -199,7 +215,7 @@ 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 { if 0 <= indexPath.row && indexPath.row < newsArr.count {
let item = newsArr[indexPath.row] let item = newsArr[indexPath.row]
Self.enterDetail(item) self.enterDetail(item)
self.markRead(item) self.markRead(item)
} }
} }
......
...@@ -82,7 +82,7 @@ class YHGalaxyNewsCell: UITableViewCell { ...@@ -82,7 +82,7 @@ class YHGalaxyNewsCell: UITableViewCell {
func updateModel(_ model: YHNewsModel) { func updateModel(_ model: YHNewsModel) {
timeLabel.text = formatTimestamp(Double(model.time)) timeLabel.text = formatTimestamp(Double(model.time))
coverImgV.sd_setImage(with: URL(string: model.cover_img), placeholderImage: UIImage(named: "")) coverImgV.sd_setImage(with: URL(string: model.cover_img), placeholderImage: UIImage(named: "msg_news_cover_default"))
titleLabel.text = model.title titleLabel.text = model.title
descLabel.text = model.content descLabel.text = model.content
redPointView.isHidden = model.is_read redPointView.isHidden = model.is_read
......
...@@ -219,7 +219,7 @@ class YHMsgViewModel: NSObject { ...@@ -219,7 +219,7 @@ class YHMsgViewModel: NSObject {
for item in arr { for item in arr {
self.newsDetailList.append(item) self.newsDetailList.append(item)
} }
let currentPage = (self.newsDetailList.count+kMsgPageSize-1)/kMsgPageSize let currentPage = (self.newsDetailList.count+kNewsPageSize-1)/kNewsPageSize
callBackBlock(true, currentPage == totalPage) callBackBlock(true, currentPage == totalPage)
} }
......
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