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

Merge commit '591a900a' into xiezhaolin

parents 098d2bb3 591a900a
......@@ -32,7 +32,7 @@ class YHHomePageViewController: YHBaseViewController {
collectinoView.register(YHHomeCollectionViewCell.self, forCellWithReuseIdentifier:YHHomeCollectionViewCell.cellReuseIdentifier)
collectinoView.delegate = self
collectinoView.dataSource = self
collectinoView.bounces = false
// collectinoView.bounces = false
collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true
return collectinoView
......@@ -55,30 +55,57 @@ class YHHomePageViewController: YHBaseViewController {
let view = YHHomeHeadView()
return view
}()
}
private extension YHHomePageViewController {
@objc func didSearchBarClicked() {
let vc = YHSearchInfomationVC()
self.navigationController?.pushViewController(vc)
}
func getData() {
viewModel.getHomeNewsList {[weak self] success, error in
loadFirstData()
viewModel.getHomeBanner(0) {[weak self] success, error in
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()
}
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 }
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() {
gk_navigationBar.isHidden = true
view.backgroundColor = .white
NotificationCenter.default.addObserver(self, selector: #selector(homepageRefresh), name:YhConstant.YhNotification.refreshHomePageNotifiction, object: nil)
view.addSubview(searchView)
searchView.snp.makeConstraints { make in
make.top.equalTo(k_Height_safeAreaInsetsTop() + 6)
......@@ -97,15 +124,22 @@ private extension YHHomePageViewController {
homeCollectView.addSubview(homeHeaderView)
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 {
self.loadMoreData()
}
homeCollectView.reloadData()
}
func loadFirstItem() {
@objc func homepageRefresh() {
loadFirstData()
}
}
extension YHHomePageViewController: UICollectionViewDelegate, UICollectionViewDataSource {
......
......@@ -10,8 +10,7 @@ import UIKit
class YHHomePageViewModel : YHBaseViewModel {
//数据源
var configModel:YHConfigModel?
var configModel:YHConfigModel?//app相关配置
var arrHomeNewsData: [YHHomeListModel]?
var banners: [YHBannerModel]?
var classify: [YHHomeClassifyModel]?
......@@ -19,7 +18,8 @@ class YHHomePageViewModel : YHBaseViewModel {
//首页相关参数
private var curPageIndex : Int = 1
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 {
}
}
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]
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 _ = YHNetRequest.getRequest(url: strUrl,params: params) { [weak self] json, code in
guard let self = self else { return }
......@@ -62,7 +73,22 @@ extension YHHomePageViewModel {
for item in result.data {
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)
} else {
self.arrHomeNewsData = []
......
......@@ -49,13 +49,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
return imageV
}()
lazy var heartImageView:UIImageView = {
let imageV = UIImageView(image: UIImage(named: "home_grey_heart"))
imageV.contentMode = .scaleAspectFill
return imageV
}()
lazy var heartImageViewBtn : UIButton = {
let btn : UIButton = UIButton(type: .custom)
btn.setImage(UIImage(named: "home_grey_heart"), for: .normal)
......@@ -143,14 +136,6 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
make.bottom.equalTo(-36)
}
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
}
......@@ -177,6 +162,8 @@ class YHHomeCollectionViewCell: UICollectionViewCell {
}
}
}
NotificationCenter.default.post(name:YhConstant.YhNotification.refreshHomePageNotifiction, object: nil)
} else {
let vc = UINavigationController(rootVC: YHPhoneLoginViewController())
vc.modalPresentationStyle = .custom
......
......@@ -49,9 +49,6 @@ class YHServiceTableFootView: UIView {
myCollectView.snp.makeConstraints { make in
make.top.left.right.bottom.equalToSuperview()
}
// self.myCollectView.es.addInfiniteScrolling {
// self.loadFakeData()
// }
}
}
......
......@@ -11,7 +11,9 @@ import AttributedString
class YHInformationFillCell: UITableViewCell {
static let cellReuseIdentifier = "YHInformationFillCell"
static let unreadPointWidth = 6.0
var whiteView:UIView!
var titleLabel:UILabel!
var detailLabel:UILabel!
......@@ -31,9 +33,12 @@ class YHInformationFillCell: UITableViewCell {
func setupUI() {
self.selectionStyle = .none
contentView.backgroundColor = .white
contentView.backgroundColor = UIColor(hex:0xF8F8F8)
whiteView = UIView()
whiteView.backgroundColor = .white
whiteView.layer.cornerRadius = 6.0
whiteView.clipsToBounds = true
contentView.addSubview(whiteView)
titleLabel = UILabel()
......@@ -51,14 +56,12 @@ class YHInformationFillCell: UITableViewCell {
detailLabel = UILabel()
detailLabel.textColor = UIColor(hex: 0x222222)
detailLabel.textAlignment = .left
detailLabel.font = UIFont.PFSC_M(ofSize:17)
detailLabel.text = "资料填写提醒".local
detailLabel.numberOfLines = 0
whiteView.addSubview(detailLabel)
lineView = UIView()
lineView.backgroundColor = UIColor(hex: 0x888F98)
lineView.backgroundColor = UIColor(hex:0xF8F8F8)
whiteView.addSubview(lineView)
bottomBtn = UIButton()
......@@ -69,7 +72,9 @@ class YHInformationFillCell: UITableViewCell {
whiteView.addSubview(bottomBtn)
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
......@@ -98,9 +103,12 @@ class YHInformationFillCell: UITableViewCell {
}
bottomBtn.snp.makeConstraints { make in
make.top.equalTo(lineView.snp.bottom)
make.left.right.bottom.equalToSuperview()
make.height.equalTo(52)
}
updateModel()
}
@objc func didBottomBtnClicked() {
......
......@@ -9,11 +9,116 @@
import UIKit
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() {
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 {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vc = YHInformationFillVC()
self.navigationController?.pushViewController(vc)
}
private func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> CGFloat {
......
......@@ -159,8 +159,10 @@ extension YhConstant {
//退出成功
public static let didLogoutSuccessNotifiction = Notification.Name(rawValue: "com.usleep.health.logout.success")
//token 过期
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