Commit 032a33a9 authored by pete谢兆麟's avatar pete谢兆麟

Merge commit '591a900a' into xiezhaolin

parents 098d2bb3 591a900a
...@@ -32,7 +32,7 @@ class YHHomePageViewController: YHBaseViewController { ...@@ -32,7 +32,7 @@ class YHHomePageViewController: YHBaseViewController {
collectinoView.register(YHHomeCollectionViewCell.self, forCellWithReuseIdentifier:YHHomeCollectionViewCell.cellReuseIdentifier) collectinoView.register(YHHomeCollectionViewCell.self, forCellWithReuseIdentifier:YHHomeCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self collectinoView.delegate = self
collectinoView.dataSource = self collectinoView.dataSource = self
collectinoView.bounces = false // collectinoView.bounces = false
collectinoView.translatesAutoresizingMaskIntoConstraints = false collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true collectinoView.alwaysBounceVertical = true
return collectinoView return collectinoView
...@@ -55,30 +55,57 @@ class YHHomePageViewController: YHBaseViewController { ...@@ -55,30 +55,57 @@ class YHHomePageViewController: YHBaseViewController {
let view = YHHomeHeadView() let view = YHHomeHeadView()
return view return view
}() }()
}
private extension YHHomePageViewController {
@objc func didSearchBarClicked() { @objc func didSearchBarClicked() {
let vc = YHSearchInfomationVC() let vc = YHSearchInfomationVC()
self.navigationController?.pushViewController(vc) self.navigationController?.pushViewController(vc)
} }
func getData() { func getData() {
viewModel.getHomeNewsList {[weak self] success, error in
loadFirstData()
viewModel.getHomeBanner(0) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
self.homeHeaderView.homeBannerView.dataArr = self.viewModel.banners ?? []
}
}
func loadMoreData() {
viewModel.getHomeNewsList(firstPageFlag : false) {[weak self] success, error in
guard let self = self else { return }
homeCollectView.es.stopLoadingMore()
if self.viewModel.hasMoreForHomeNews == false {
homeCollectView.es.noticeNoMoreData()
}
self.homeCollectView.reloadData() self.homeCollectView.reloadData()
} }
viewModel.getHomeBanner(0) {[weak self] success, error in }
func loadFirstData() {
viewModel.getHomeNewsList(firstPageFlag : true) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
self.homeHeaderView.homeBannerView.dataArr = self.viewModel.banners ?? [] homeCollectView.es.stopPullToRefresh()
if self.viewModel.hasMoreForHomeNews == false {
homeCollectView.es.noticeNoMoreData()
}
self.homeCollectView.reloadData()
} }
} }
}
private extension YHHomePageViewController {
func setupUI() { func setupUI() {
gk_navigationBar.isHidden = true gk_navigationBar.isHidden = true
view.backgroundColor = .white view.backgroundColor = .white
NotificationCenter.default.addObserver(self, selector: #selector(homepageRefresh), name:YhConstant.YhNotification.refreshHomePageNotifiction, object: nil)
view.addSubview(searchView) view.addSubview(searchView)
searchView.snp.makeConstraints { make in searchView.snp.makeConstraints { make in
make.top.equalTo(k_Height_safeAreaInsetsTop() + 6) make.top.equalTo(k_Height_safeAreaInsetsTop() + 6)
...@@ -97,15 +124,22 @@ private extension YHHomePageViewController { ...@@ -97,15 +124,22 @@ private extension YHHomePageViewController {
homeCollectView.addSubview(homeHeaderView) homeCollectView.addSubview(homeHeaderView)
homeCollectView.contentInset = UIEdgeInsets(top: YHHomeHeadView.viewH, left: 0, bottom: 20, right: 0) homeCollectView.contentInset = UIEdgeInsets(top: YHHomeHeadView.viewH, left: 0, bottom: 20, right: 0)
let tmpHeadView = homeCollectView.es.addPullToRefresh {
self.loadFirstData()
}
var r = tmpHeadView.frame
r.origin.y = r.origin.y - YHHomeHeadView.viewH
tmpHeadView.frame = r
homeCollectView.es.addInfiniteScrolling { homeCollectView.es.addInfiniteScrolling {
self.loadMoreData()
} }
homeCollectView.reloadData()
} }
func loadFirstItem() { @objc func homepageRefresh() {
loadFirstData()
} }
} }
extension YHHomePageViewController: UICollectionViewDelegate, UICollectionViewDataSource { extension YHHomePageViewController: UICollectionViewDelegate, UICollectionViewDataSource {
......
...@@ -10,8 +10,7 @@ import UIKit ...@@ -10,8 +10,7 @@ import UIKit
class YHHomePageViewModel : YHBaseViewModel { class YHHomePageViewModel : YHBaseViewModel {
//数据源 //数据源
var configModel:YHConfigModel? var configModel:YHConfigModel?//app相关配置
var arrHomeNewsData: [YHHomeListModel]? var arrHomeNewsData: [YHHomeListModel]?
var banners: [YHBannerModel]? var banners: [YHBannerModel]?
var classify: [YHHomeClassifyModel]? var classify: [YHHomeClassifyModel]?
...@@ -19,7 +18,8 @@ class YHHomePageViewModel : YHBaseViewModel { ...@@ -19,7 +18,8 @@ class YHHomePageViewModel : YHBaseViewModel {
//首页相关参数 //首页相关参数
private var curPageIndex : Int = 1 private var curPageIndex : Int = 1
private var page_Size : Int = 10 private var page_Size : Int = 10
private var hasMoreForHomeNews : Bool = true private var totalCount : Int = 0
var hasMoreForHomeNews : Bool = true
} }
//接口 //接口
...@@ -44,9 +44,20 @@ extension YHHomePageViewModel { ...@@ -44,9 +44,20 @@ extension YHHomePageViewModel {
} }
} }
func getHomeNewsList(callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) { /*
let params: [String : Any] = ["page": curPageIndex, firstPageFlag true - 首页 false - 更多
*/
func getHomeNewsList(firstPageFlag : Bool,callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
var params: [String : Any] = ["page": curPageIndex,
"page_size": page_Size] "page_size": page_Size]
if firstPageFlag {
params = ["page": curPageIndex,
"page_size": page_Size]
} else {
params = ["page": curPageIndex + 1,
"page_size": page_Size]
}
let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.consult let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Common.consult
let _ = YHNetRequest.getRequest(url: strUrl,params: params) { [weak self] json, code in let _ = YHNetRequest.getRequest(url: strUrl,params: params) { [weak self] json, code in
guard let self = self else { return } guard let self = self else { return }
...@@ -62,7 +73,22 @@ extension YHHomePageViewModel { ...@@ -62,7 +73,22 @@ extension YHHomePageViewModel {
for item in result.data { for item in result.data {
item.calHeightParam() item.calHeightParam()
} }
self.arrHomeNewsData = result.data
if firstPageFlag {
self.totalCount = result.total
self.arrHomeNewsData = result.data
} else {
self.arrHomeNewsData?.append(contentsOf: result.data)
}
if let count = self.arrHomeNewsData?.count {
if count == self.totalCount {
self.hasMoreForHomeNews = false
} else {
self.hasMoreForHomeNews = true
}
}
callBackBlock(true, nil) callBackBlock(true, nil)
} else { } else {
self.arrHomeNewsData = [] self.arrHomeNewsData = []
......
...@@ -49,13 +49,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell { ...@@ -49,13 +49,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
return imageV return imageV
}() }()
lazy var heartImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_grey_heart"))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var heartImageViewBtn : UIButton = { lazy var heartImageViewBtn : UIButton = {
let btn : UIButton = UIButton(type: .custom) let btn : UIButton = UIButton(type: .custom)
btn.setImage(UIImage(named: "home_grey_heart"), for: .normal) btn.setImage(UIImage(named: "home_grey_heart"), for: .normal)
...@@ -143,14 +136,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell { ...@@ -143,14 +136,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
make.bottom.equalTo(-36) make.bottom.equalTo(-36)
} }
numLable.text = listModel.collect_count.string numLable.text = listModel.collect_count.string
// if listModel.is_like {
// headImageView.image = UIImage(named: "home_red_heart")
// } else {
// headImageView.image = UIImage(named: "home_grey_heart")
// }
heartImageViewBtn.isSelected = listModel.is_like heartImageViewBtn.isSelected = listModel.is_like
} }
...@@ -177,6 +162,8 @@ class YHHomeCollectionViewCell: UICollectionViewCell { ...@@ -177,6 +162,8 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
} }
} }
} }
NotificationCenter.default.post(name:YhConstant.YhNotification.refreshHomePageNotifiction, object: nil)
} else { } else {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController()) let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
vc.modalPresentationStyle = .custom vc.modalPresentationStyle = .custom
......
...@@ -49,9 +49,6 @@ class YHServiceTableFootView: UIView { ...@@ -49,9 +49,6 @@ class YHServiceTableFootView: UIView {
myCollectView.snp.makeConstraints { make in myCollectView.snp.makeConstraints { make in
make.top.left.right.bottom.equalToSuperview() make.top.left.right.bottom.equalToSuperview()
} }
// self.myCollectView.es.addInfiniteScrolling {
// self.loadFakeData()
// }
} }
} }
......
...@@ -11,7 +11,9 @@ import AttributedString ...@@ -11,7 +11,9 @@ import AttributedString
class YHInformationFillCell: UITableViewCell { class YHInformationFillCell: UITableViewCell {
static let cellReuseIdentifier = "YHInformationFillCell"
static let unreadPointWidth = 6.0 static let unreadPointWidth = 6.0
var whiteView:UIView! var whiteView:UIView!
var titleLabel:UILabel! var titleLabel:UILabel!
var detailLabel:UILabel! var detailLabel:UILabel!
...@@ -31,9 +33,12 @@ class YHInformationFillCell: UITableViewCell { ...@@ -31,9 +33,12 @@ class YHInformationFillCell: UITableViewCell {
func setupUI() { func setupUI() {
self.selectionStyle = .none self.selectionStyle = .none
contentView.backgroundColor = .white contentView.backgroundColor = UIColor(hex:0xF8F8F8)
whiteView = UIView() whiteView = UIView()
whiteView.backgroundColor = .white
whiteView.layer.cornerRadius = 6.0
whiteView.clipsToBounds = true
contentView.addSubview(whiteView) contentView.addSubview(whiteView)
titleLabel = UILabel() titleLabel = UILabel()
...@@ -51,14 +56,12 @@ class YHInformationFillCell: UITableViewCell { ...@@ -51,14 +56,12 @@ class YHInformationFillCell: UITableViewCell {
detailLabel = UILabel() detailLabel = UILabel()
detailLabel.textColor = UIColor(hex: 0x222222)
detailLabel.textAlignment = .left detailLabel.textAlignment = .left
detailLabel.font = UIFont.PFSC_M(ofSize:17) detailLabel.numberOfLines = 0
detailLabel.text = "资料填写提醒".local
whiteView.addSubview(detailLabel) whiteView.addSubview(detailLabel)
lineView = UIView() lineView = UIView()
lineView.backgroundColor = UIColor(hex: 0x888F98) lineView.backgroundColor = UIColor(hex:0xF8F8F8)
whiteView.addSubview(lineView) whiteView.addSubview(lineView)
bottomBtn = UIButton() bottomBtn = UIButton()
...@@ -69,7 +72,9 @@ class YHInformationFillCell: UITableViewCell { ...@@ -69,7 +72,9 @@ class YHInformationFillCell: UITableViewCell {
whiteView.addSubview(bottomBtn) whiteView.addSubview(bottomBtn)
whiteView.snp.makeConstraints { make in whiteView.snp.makeConstraints { make in
make.edges.equalToSuperview() make.left.equalToSuperview().offset(16)
make.right.equalToSuperview().offset(-16)
make.top.bottom.equalToSuperview()
} }
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
...@@ -98,9 +103,12 @@ class YHInformationFillCell: UITableViewCell { ...@@ -98,9 +103,12 @@ class YHInformationFillCell: UITableViewCell {
} }
bottomBtn.snp.makeConstraints { make in bottomBtn.snp.makeConstraints { make in
make.top.equalTo(lineView.snp.bottom)
make.left.right.bottom.equalToSuperview()
make.height.equalTo(52)
} }
updateModel()
} }
@objc func didBottomBtnClicked() { @objc func didBottomBtnClicked() {
......
...@@ -9,11 +9,116 @@ ...@@ -9,11 +9,116 @@
import UIKit import UIKit
class YHInformationFillVC: YHBaseViewController { class YHInformationFillVC: YHBaseViewController {
var msgArr:[String] = ["","","",""]
lazy var navBar: YHCustomNavigationBar = {
let bar = YHCustomNavigationBar.navBar()
bar.backgroundColor = .white
bar.title = "资料填写".local
bar.showRightButtonType(.clean)
bar.backBlock = {
[weak self] in
guard let self = self else { return }
self.navigationController?.popViewController(animated: true)
}
bar.rightBtnClick = {
[weak self] in
guard let self = self else { return }
}
return bar
}()
lazy var tableView: UITableView = {
let tableView = UITableView(frame:.zero, style:.grouped)
tableView.sectionHeaderHeight = 46.0
tableView.estimatedSectionFooterHeight = 1.0
tableView.showsVerticalScrollIndicator = false
tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
tableView.backgroundColor = UIColor(hex:0xF8F8F8)
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "UITableViewCell")
tableView.register(YHInformationFillCell.self, forCellReuseIdentifier: YHInformationFillCell.cellReuseIdentifier)
return tableView
}()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupUI()
}
func setupUI() {
gk_navigationBar.isHidden = true
view.backgroundColor = .white
view.addSubview(tableView)
view.addSubview(navBar)
navBar.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_statusBar())
make.height.equalTo(k_Height_NavContentBar)
}
tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalToSuperview()
}
}
}
// Do any additional setup after loading the view. extension YHInformationFillVC: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return msgArr.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHInformationFillCell.cellReuseIdentifier, for: indexPath) as! YHInformationFillCell
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
} }
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
return 46.0
}
private func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> CGFloat {
return 1.0
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView()
let label = UILabel()
label.textColor = UIColor(hex: 0x121A26, alpha: 0.3)
label.textAlignment = .center
label.font = UIFont.PFSC_R(ofSize:12)
label.text = "2023-09-13"
view.addSubview(label)
label.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
return view
}
} }
...@@ -96,6 +96,8 @@ extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -96,6 +96,8 @@ extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = YHInformationFillVC()
self.navigationController?.pushViewController(vc)
} }
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat { private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
......
...@@ -159,8 +159,10 @@ extension YhConstant { ...@@ -159,8 +159,10 @@ extension YhConstant {
//退出成功 //退出成功
public static let didLogoutSuccessNotifiction = Notification.Name(rawValue: "com.usleep.health.logout.success") public static let didLogoutSuccessNotifiction = Notification.Name(rawValue: "com.usleep.health.logout.success")
//token 过期 //token 过期
public static let tokenInvalidateNotifiction = Notification.Name(rawValue: "com.usleep.health.token.invalidate") public static let tokenInvalidateNotifiction = Notification.Name(rawValue: "com.usleep.health.token.invalidate")
//首页刷新通知
public static let refreshHomePageNotifiction = Notification.Name(rawValue: "com.yinhe.homePage.refresh")
} }
} }
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