Commit 171bc22e authored by pete谢兆麟's avatar pete谢兆麟

加载优化

parent bc801dc6
...@@ -261,8 +261,6 @@ ...@@ -261,8 +261,6 @@
049A48A82B49417300D0C641 /* YHAboutUsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */; }; 049A48A82B49417300D0C641 /* YHAboutUsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */; };
049A48AA2B49536000D0C641 /* YHAboutUsAdvantageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A92B49536000D0C641 /* YHAboutUsAdvantageCell.swift */; }; 049A48AA2B49536000D0C641 /* YHAboutUsAdvantageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049A48A92B49536000D0C641 /* YHAboutUsAdvantageCell.swift */; };
049AC4C62BC3E55300F857F4 /* YHServiceSectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4C52BC3E55300F857F4 /* YHServiceSectionView.swift */; }; 049AC4C62BC3E55300F857F4 /* YHServiceSectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4C52BC3E55300F857F4 /* YHServiceSectionView.swift */; };
049AC4C82BC513AB00F857F4 /* YHOrderListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4C72BC513AB00F857F4 /* YHOrderListView.swift */; };
049AC4CA2BC5141600F857F4 /* YHServerNoOrderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4C92BC5141600F857F4 /* YHServerNoOrderView.swift */; };
049AC4CC2BC6615500F857F4 /* YHHomeListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */; }; 049AC4CC2BC6615500F857F4 /* YHHomeListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */; };
049AC4CE2BC674A700F857F4 /* YHHomeClassifyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4CD2BC674A700F857F4 /* YHHomeClassifyModel.swift */; }; 049AC4CE2BC674A700F857F4 /* YHHomeClassifyModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 049AC4CD2BC674A700F857F4 /* YHHomeClassifyModel.swift */; };
04A271232BABFF3200652B1B /* YHCertificateUploadTypeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A271222BABFF3200652B1B /* YHCertificateUploadTypeCell.swift */; }; 04A271232BABFF3200652B1B /* YHCertificateUploadTypeCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04A271222BABFF3200652B1B /* YHCertificateUploadTypeCell.swift */; };
...@@ -712,8 +710,6 @@ ...@@ -712,8 +710,6 @@
049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsViewController.swift; sourceTree = "<group>"; }; 049A48A72B49417300D0C641 /* YHAboutUsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsViewController.swift; sourceTree = "<group>"; };
049A48A92B49536000D0C641 /* YHAboutUsAdvantageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsAdvantageCell.swift; sourceTree = "<group>"; }; 049A48A92B49536000D0C641 /* YHAboutUsAdvantageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHAboutUsAdvantageCell.swift; sourceTree = "<group>"; };
049AC4C52BC3E55300F857F4 /* YHServiceSectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceSectionView.swift; sourceTree = "<group>"; }; 049AC4C52BC3E55300F857F4 /* YHServiceSectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServiceSectionView.swift; sourceTree = "<group>"; };
049AC4C72BC513AB00F857F4 /* YHOrderListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHOrderListView.swift; sourceTree = "<group>"; };
049AC4C92BC5141600F857F4 /* YHServerNoOrderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHServerNoOrderView.swift; sourceTree = "<group>"; };
049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeListModel.swift; sourceTree = "<group>"; }; 049AC4CB2BC6615500F857F4 /* YHHomeListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeListModel.swift; sourceTree = "<group>"; };
049AC4CD2BC674A700F857F4 /* YHHomeClassifyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeClassifyModel.swift; sourceTree = "<group>"; }; 049AC4CD2BC674A700F857F4 /* YHHomeClassifyModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHHomeClassifyModel.swift; sourceTree = "<group>"; };
04A271222BABFF3200652B1B /* YHCertificateUploadTypeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadTypeCell.swift; sourceTree = "<group>"; }; 04A271222BABFF3200652B1B /* YHCertificateUploadTypeCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YHCertificateUploadTypeCell.swift; sourceTree = "<group>"; };
...@@ -2138,8 +2134,6 @@ ...@@ -2138,8 +2134,6 @@
049AC4C52BC3E55300F857F4 /* YHServiceSectionView.swift */, 049AC4C52BC3E55300F857F4 /* YHServiceSectionView.swift */,
044414042BC3B9DE00784A14 /* YHServiceTableFootView.swift */, 044414042BC3B9DE00784A14 /* YHServiceTableFootView.swift */,
04CC2EEF2BC3DDB2000305DD /* YHServiceBannerView.swift */, 04CC2EEF2BC3DDB2000305DD /* YHServiceBannerView.swift */,
049AC4C72BC513AB00F857F4 /* YHOrderListView.swift */,
049AC4C92BC5141600F857F4 /* YHServerNoOrderView.swift */,
048787D02BCE61B20036E221 /* YHServiceNoOrderView.swift */, 048787D02BCE61B20036E221 /* YHServiceNoOrderView.swift */,
048787D62BCE96F50036E221 /* YHServiceOrderProgressTableViewCell.swift */, 048787D62BCE96F50036E221 /* YHServiceOrderProgressTableViewCell.swift */,
048787D82BCF68530036E221 /* YHProgressView.swift */, 048787D82BCF68530036E221 /* YHProgressView.swift */,
...@@ -2544,7 +2538,6 @@ ...@@ -2544,7 +2538,6 @@
044413FB2BC27E6F00784A14 /* YHHomeWebBottomButton.swift in Sources */, 044413FB2BC27E6F00784A14 /* YHHomeWebBottomButton.swift in Sources */,
045EEEB32B9F171A0022A143 /* YHWorkFileSyncTableViewCell.swift in Sources */, 045EEEB32B9F171A0022A143 /* YHWorkFileSyncTableViewCell.swift in Sources */,
045EEEF12B9F171A0022A143 /* YHChildInfoContainerVC.swift in Sources */, 045EEEF12B9F171A0022A143 /* YHChildInfoContainerVC.swift in Sources */,
049AC4C82BC513AB00F857F4 /* YHOrderListView.swift in Sources */,
049AC4CC2BC6615500F857F4 /* YHHomeListModel.swift in Sources */, 049AC4CC2BC6615500F857F4 /* YHHomeListModel.swift in Sources */,
045EEF0B2B9F171A0022A143 /* YHBasicInfoFillViewController.swift in Sources */, 045EEF0B2B9F171A0022A143 /* YHBasicInfoFillViewController.swift in Sources */,
A582B2452BBA4CF9009D098C /* YHHKPlanDocModel.swift in Sources */, A582B2452BBA4CF9009D098C /* YHHKPlanDocModel.swift in Sources */,
...@@ -2702,7 +2695,6 @@ ...@@ -2702,7 +2695,6 @@
A5ACE9552B4564F7002C94D2 /* YHTabBarViewController.swift in Sources */, A5ACE9552B4564F7002C94D2 /* YHTabBarViewController.swift in Sources */,
045EEF0A2B9F171A0022A143 /* YHBasicInfoSessionModel.swift in Sources */, 045EEF0A2B9F171A0022A143 /* YHBasicInfoSessionModel.swift in Sources */,
045EEF022B9F171A0022A143 /* YHFormItemDegreeInfoCell.swift in Sources */, 045EEF022B9F171A0022A143 /* YHFormItemDegreeInfoCell.swift in Sources */,
049AC4CA2BC5141600F857F4 /* YHServerNoOrderView.swift in Sources */,
045EEEF72B9F171A0022A143 /* YHFormItemAddCell.swift in Sources */, 045EEEF72B9F171A0022A143 /* YHFormItemAddCell.swift in Sources */,
045EEEC82B9F171A0022A143 /* YHOtherSelecteItemView.swift in Sources */, 045EEEC82B9F171A0022A143 /* YHOtherSelecteItemView.swift in Sources */,
0480976B2BA15269000B9DCA /* YHCertificateInfoCell.swift in Sources */, 0480976B2BA15269000B9DCA /* YHCertificateInfoCell.swift in Sources */,
......
...@@ -77,6 +77,7 @@ extension YHFourKingViewController { ...@@ -77,6 +77,7 @@ extension YHFourKingViewController {
view.block = {[weak self] model in view.block = {[weak self] model in
guard let self = self else { return } guard let self = self else { return }
self.tableFootView.myCollectView.es.resetNoMoreData() self.tableFootView.myCollectView.es.resetNoMoreData()
self.tableFootView.myCollectView.setContentOffset(CGPoint.zero, animated: false)
self.classId = model.id self.classId = model.id
self.homeViewModel.getList(true, model.id) {[weak self] success, error in self.homeViewModel.getList(true, model.id) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
...@@ -100,11 +101,15 @@ extension YHFourKingViewController { ...@@ -100,11 +101,15 @@ extension YHFourKingViewController {
guard let self = self else { return } guard let self = self else { return }
self.homeViewModel.getList(false, self.classId) {[weak self] success, error in self.homeViewModel.getList(false, self.classId) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
self.tableFootView.myCollectView.es.stopLoadingMore() DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.35, execute: {
self.dataSouce = self.homeViewModel.arrHomeNewsData ?? [] CATransaction.setDisableActions(true)
if self.homeViewModel.hasMoreForHomeNews == false { self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
self.tableFootView.myCollectView.es.noticeNoMoreData() CATransaction.commit()
} self.tableFootView.myCollectView.es.stopLoadingMore()
if self.homeViewModel.hasMoreForHomeNews == false {
self.tableFootView.myCollectView.es.noticeNoMoreData()
}
})
} }
} }
view.addSubview(tableFootView) view.addSubview(tableFootView)
......
...@@ -32,6 +32,7 @@ class YHServerHKLifeViewController: YHBaseViewController { ...@@ -32,6 +32,7 @@ class YHServerHKLifeViewController: YHBaseViewController {
tableView.showsVerticalScrollIndicator = false tableView.showsVerticalScrollIndicator = false
tableView.rowHeight = UITableView.automaticDimension tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 81.0 tableView.estimatedRowHeight = 81.0
tableView.bounces = false
tableView.register(YHServerHKLifeViewCell.self,forCellReuseIdentifier: YHServerHKLifeViewCell.cellReuseIdentifier) tableView.register(YHServerHKLifeViewCell.self,forCellReuseIdentifier: YHServerHKLifeViewCell.cellReuseIdentifier)
return tableView return tableView
}() }()
...@@ -86,7 +87,8 @@ extension YHServerHKLifeViewController { ...@@ -86,7 +87,8 @@ extension YHServerHKLifeViewController {
let view = YHServiceSectionView() let view = YHServiceSectionView()
view.block = {[weak self] model in view.block = {[weak self] model in
guard let self = self else { return } guard let self = self else { return }
self.homeTableView.es.resetNoMoreData() self.cell.tableFootView.myCollectView.es.resetNoMoreData()
self.cell.tableFootView.myCollectView.setContentOffset(CGPoint.zero, animated: false)
self.classId = model.id self.classId = model.id
self.homeViewModel.getList(true, model.id) {[weak self] success, error in self.homeViewModel.getList(true, model.id) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
...@@ -110,17 +112,6 @@ extension YHServerHKLifeViewController { ...@@ -110,17 +112,6 @@ extension YHServerHKLifeViewController {
} }
homeTableView.delegate = self homeTableView.delegate = self
homeTableView.dataSource = self homeTableView.dataSource = self
homeTableView.es.addInfiniteScrolling {[weak self] in
guard let self = self else { return }
self.homeViewModel.getList(false, self.classId) {[weak self] success, error in
guard let self = self else { return }
self.homeTableView.es.stopLoadingMore()
self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
if self.homeViewModel.hasMoreForHomeNews == false {
self.homeTableView.es.noticeNoMoreData()
}
}
}
} }
} }
...@@ -156,13 +147,29 @@ extension YHServerHKLifeViewController : UITableViewDelegate,UITableViewDataSour ...@@ -156,13 +147,29 @@ extension YHServerHKLifeViewController : UITableViewDelegate,UITableViewDataSour
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return KScreenHeight // return KScreenHeight - k_Height_NavigationtBarAndStatuBar - 48 - k_Height_safeAreaInsetsBottom() - 50
return self.view.frame.height - 48
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
cell = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self) cell = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell.moreBlock = {[weak self] in
guard let self = self else { return }
self.homeViewModel.getList(false, self.classId) {[weak self] success, error in
guard let self = self else { return }
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.35, execute: {
CATransaction.setDisableActions(true)
self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
CATransaction.commit()
self.cell.tableFootView.myCollectView.es.stopLoadingMore()
if self.homeViewModel.hasMoreForHomeNews == false {
self.cell.tableFootView.myCollectView.es.noticeNoMoreData()
}
})
}
}
cell.tableFootView.items = dataSouce cell.tableFootView.items = dataSouce
cell.tableFootView.myCollectView.es.removeRefreshFooter() // cell.tableFootView.myCollectView.es.removeRefreshFooter()
cell.selectionStyle = .none cell.selectionStyle = .none
return cell return cell
} }
...@@ -227,8 +234,11 @@ extension YHServerHKLifeViewCell { ...@@ -227,8 +234,11 @@ extension YHServerHKLifeViewCell {
block() block()
} }
} }
tableFootView.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight) // tableFootView.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight)
contentView.addSubview(tableFootView) contentView.addSubview(tableFootView)
tableFootView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalToSuperview()
}
} }
} }
...@@ -10,10 +10,33 @@ import UIKit ...@@ -10,10 +10,33 @@ import UIKit
import JXSegmentedView import JXSegmentedView
class YHServiceListViewController: YHBaseViewController { class YHServiceListViewController: YHBaseViewController {
let homeViewModel: YHHomePageViewModel = YHHomePageViewModel() let homeViewModel: YHHomePageViewModel = YHHomePageViewModel()
var normalView: YHServerNoOrderView! var tableHeadView: YHServerTableHeadView!
var tableFootView: YHServiceTableFootView!
var sectionView: YHServiceSectionView!
var classId: Int = 0 var classId: Int = 0
var cell: YHServerHKLifeViewCell!
var dataSouce: [YHHomeListModel?] = [] {
didSet {
cell.tableFootView.items = dataSouce
}
}
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = 0
}
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 81.0
tableView.bounces = false
tableView.register(YHServerHKLifeViewCell.self,forCellReuseIdentifier: YHServerHKLifeViewCell.cellReuseIdentifier)
return tableView
}()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
...@@ -27,11 +50,11 @@ class YHServiceListViewController: YHBaseViewController { ...@@ -27,11 +50,11 @@ class YHServiceListViewController: YHBaseViewController {
extension YHServiceListViewController { extension YHServiceListViewController {
func loadData() { func loadData() {
self.normalView.tableHeadView.bannarView.dataArr = [YHBannerModel.localDefaultItem()] self.tableHeadView.bannarView.dataArr = [YHBannerModel.localDefaultItem()]
homeViewModel.getHomeBanner(1){[weak self] success, error in homeViewModel.getHomeBanner(1){[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
self.normalView.tableHeadView.bannarView.dataArr = self.homeViewModel.banners ?? [YHBannerModel.localDefaultItem()] self.tableHeadView.bannarView.dataArr = self.homeViewModel.banners ?? [YHBannerModel.localDefaultItem()]
} }
homeViewModel.getHomeClassify{[weak self] success, error in homeViewModel.getHomeClassify{[weak self] success, error in
...@@ -39,15 +62,15 @@ extension YHServiceListViewController { ...@@ -39,15 +62,15 @@ extension YHServiceListViewController {
for item in classify { for item in classify {
let model = item as YHHomeClassifyModel let model = item as YHHomeClassifyModel
if model.id == 1 { if model.id == 1 {
self.normalView.sectionView.items = model.children self.sectionView.items = model.children
if self.classId == 0 { if self.classId == 0 {
let classifyID = model.children.first?.id ?? 0 let classifyID = model.children.first?.id ?? 0
self.classId = classifyID self.classId = classifyID
self.homeViewModel.getList(true, classifyID) {[weak self] success, error in self.homeViewModel.getList(true, classifyID) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
self.normalView.dataSouce = self.homeViewModel.arrHomeNewsData ?? [] self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
if self.homeViewModel.hasMoreForHomeNews == false { if self.homeViewModel.hasMoreForHomeNews == false {
self.normalView.homeTableView.es.noticeNoMoreData() self.homeTableView.es.noticeNoMoreData()
} }
} }
} }
...@@ -60,38 +83,97 @@ extension YHServiceListViewController { ...@@ -60,38 +83,97 @@ extension YHServiceListViewController {
gk_navBarAlpha = 0 gk_navBarAlpha = 0
gk_navigationBar.isHidden = true gk_navigationBar.isHidden = true
normalView = { sectionView = {
let view = YHServerNoOrderView() let view = YHServiceSectionView()
view.sectionBlock = {[weak self] model in view.block = {[weak self] model in
guard let self = self else { return } guard let self = self else { return }
self.normalView.homeTableView.es.resetNoMoreData() self.cell.tableFootView.myCollectView.es.resetNoMoreData()
self.cell.tableFootView.myCollectView.setContentOffset(CGPoint.zero, animated: false)
self.classId = model.id self.classId = model.id
self.homeViewModel.getList(true, model.id) {[weak self] success, error in self.homeViewModel.getList(true, model.id) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
self.normalView.dataSouce = self.homeViewModel.arrHomeNewsData ?? [] self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
if self.homeViewModel.hasMoreForHomeNews == false {
self.normalView.homeTableView.es.noticeNoMoreData()
}
}
}
view.loadMoreBlock = {[weak self] model in
guard let self = self else { return }
self.homeViewModel.getList(false, self.classId) {[weak self] success, error in
guard let self = self else { return }
self.normalView.homeTableView.es.stopLoadingMore()
self.normalView.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
if self.homeViewModel.hasMoreForHomeNews == false { if self.homeViewModel.hasMoreForHomeNews == false {
self.normalView.homeTableView.es.noticeNoMoreData() self.homeTableView.es.noticeNoMoreData()
} }
} }
} }
return view return view
}() }()
view.addSubview(normalView)
normalView.snp.makeConstraints { make in tableHeadView = YHServerTableHeadView()
tableHeadView.titleLabel.text = "香港身份攻略"
tableHeadView.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: 365)
view.addSubview(homeTableView)
homeTableView.tableHeaderView = tableHeadView
homeTableView.tableFooterView = tableFootView
homeTableView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview() make.top.left.right.equalToSuperview()
make.bottom.equalToSuperview() make.bottom.equalToSuperview()
} }
homeTableView.delegate = self
homeTableView.dataSource = self
}
}
// MARK: - UITableViewDelegate 和 UITableViewDataSource
extension YHServiceListViewController : UITableViewDelegate,UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if sectionView.items.count == 1 {
return 0
}
return 48
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return sectionView
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.01
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return self.view.frame.height - 48
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
cell = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell.moreBlock = {[weak self] in
guard let self = self else { return }
self.homeViewModel.getList(false, self.classId) {[weak self] success, error in
guard let self = self else { return }
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.35, execute: {
CATransaction.setDisableActions(true)
self.dataSouce = self.homeViewModel.arrHomeNewsData ?? []
CATransaction.commit()
self.cell.tableFootView.myCollectView.es.stopLoadingMore()
if self.homeViewModel.hasMoreForHomeNews == false {
self.cell.tableFootView.myCollectView.es.noticeNoMoreData()
}
})
}
}
cell.tableFootView.items = dataSouce
cell.selectionStyle = .none
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
} }
} }
...@@ -100,8 +182,4 @@ extension YHServiceListViewController: JXSegmentedListContainerViewListDelegate ...@@ -100,8 +182,4 @@ extension YHServiceListViewController: JXSegmentedListContainerViewListDelegate
func listView() -> UIView { func listView() -> UIView {
return view return view
} }
func listWillAppear() {
loadData()
}
} }
//
// YHOrderListView.swift
// galaxy
//
// Created by EDY on 2024/4/9.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHOrderListView: UIView {
var dataSource: [YHContactItemModel] = [] {
didSet {
self.homeTableView.reloadData()
}
}
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .grouped)
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 81.0
tableView.register(YHContractCell.self,forCellReuseIdentifier: YHContractCell.cellReuseIdentifier)
return tableView
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupUI() {
addSubview(homeTableView)
homeTableView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalToSuperview()
}
homeTableView.delegate = self
homeTableView.dataSource = self
}
}
extension YHOrderListView : UITableViewDelegate,UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return self.dataSource.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return kMargin
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: kMargin))
return view
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 81
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell0 = tableView.dequeueReusableCell(withClass: YHContractCell.self)
cell0.selectionStyle = .none
if indexPath.section < self.dataSource.count {
cell0.dataModel = self.dataSource[indexPath.section]
}
return cell0
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
printLog("点击了 tableView Cell \(indexPath.section)")
//获取订单号
let orderId = dataSource[indexPath.section].id
UserDefaults.standard.set(orderId, forKey: "orderIdForPreview")
UserDefaults.standard.synchronize()
let vc = YHServiceCenterSecondViewController()
vc.orderId = orderId
vc.mobile = dataSource[indexPath.section].mobile
UIViewController.current?.navigationController?.pushViewController(vc)
}
}
//
// YHServerNoOrderView.swift
// galaxy
//
// Created by EDY on 2024/4/9.
// Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//
import UIKit
class YHServerNoOrderView: UIView {
typealias SectionBlock = (YHClassifyModel) -> ()
var sectionBlock: SectionBlock?
var loadMoreBlock: SectionBlock?
var cell: YHServerHKLifeViewCell!
var tableHeadView: YHServerTableHeadView!
var sectionView: YHServiceSectionView!
var dataSouce: [YHHomeListModel?] = [] {
didSet {
cell.tableFootView.items = dataSouce
}
}
var homeTableView: UITableView = {
let tableView = UITableView(frame: .zero, style: .plain)
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = 0
}
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.showsHorizontalScrollIndicator = false
tableView.showsVerticalScrollIndicator = false
tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 81.0
tableView.register(YHServerHKLifeViewCell.self,forCellReuseIdentifier: YHServerHKLifeViewCell.cellReuseIdentifier)
return tableView
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupUI()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupUI() {
sectionView = {
let view = YHServiceSectionView()
view.block = {[weak self] model in
guard let self = self else { return }
if let block = sectionBlock {
block(model)
}
}
return view
}()
tableHeadView = YHServerTableHeadView()
tableHeadView.titleLabel.text = "香港身份攻略"
tableHeadView.frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: 365)
addSubview(homeTableView)
homeTableView.tableHeaderView = tableHeadView
homeTableView.snp.makeConstraints { make in
make.top.left.right.equalToSuperview()
make.bottom.equalToSuperview()
}
homeTableView.delegate = self
homeTableView.dataSource = self
homeTableView.es.addInfiniteScrolling {[weak self] in
guard let self = self else { return }
if let block = self.loadMoreBlock {
block(YHClassifyModel())
}
}
}
}
// MARK: - UITableViewDelegate 和 UITableViewDataSource
extension YHServerNoOrderView : UITableViewDelegate,UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if sectionView.items.count == 1 {
return 0
}
return 48
}
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return sectionView
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 0.01
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return UIView()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return KScreenHeight
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
cell = tableView.dequeueReusableCell(withClass: YHServerHKLifeViewCell.self)
cell.tableFootView.items = dataSouce
cell.tableFootView.myCollectView.es.removeRefreshFooter()
cell.selectionStyle = .none
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
}
...@@ -32,6 +32,8 @@ class YHServiceTableFootView: UIView { ...@@ -32,6 +32,8 @@ class YHServiceTableFootView: UIView {
// collectinoView.bounces = false // collectinoView.bounces = false
collectinoView.translatesAutoresizingMaskIntoConstraints = false collectinoView.translatesAutoresizingMaskIntoConstraints = false
collectinoView.alwaysBounceVertical = true collectinoView.alwaysBounceVertical = true
collectinoView.showsVerticalScrollIndicator = false
collectinoView.showsHorizontalScrollIndicator = false
return collectinoView return collectinoView
}() }()
......
...@@ -68,22 +68,30 @@ extension YHMyLikeViewController { ...@@ -68,22 +68,30 @@ extension YHMyLikeViewController {
view.moreBlock = {[weak self] in view.moreBlock = {[weak self] in
guard let self = self else { return } guard let self = self else { return }
if id == 1 || id == 2 { if id == 1 || id == 2 {
self.tableFootView.myCollectView.es.stopLoadingMore()
self.viewModel.getList(false ,id) {[weak self] success, error in self.viewModel.getList(false ,id) {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
self.dataSouce = self.viewModel.arrHomeNewsData ?? [] DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.35, execute: {
if self.viewModel.hasMoreForHomeNews == false { CATransaction.setDisableActions(true)
self.tableFootView.myCollectView.es.noticeNoMoreData() self.dataSouce = self.viewModel.arrHomeNewsData ?? []
} CATransaction.commit()
self.tableFootView.myCollectView.es.stopLoadingMore()
if self.viewModel.hasMoreForHomeNews == false {
self.tableFootView.myCollectView.es.noticeNoMoreData()
}
})
} }
} else { } else {
self.tableFootView.myCollectView.es.stopLoadingMore()
self.viewModel.getList(false, callBackBlock: {[weak self] success, error in self.viewModel.getList(false, callBackBlock: {[weak self] success, error in
guard let self = self else { return } guard let self = self else { return }
self.dataSouce = self.viewModel.arrHomeNewsData ?? [] DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.35, execute: {
if self.viewModel.hasMoreForHomeNews == false { CATransaction.setDisableActions(true)
self.tableFootView.myCollectView.es.noticeNoMoreData() self.dataSouce = self.viewModel.arrHomeNewsData ?? []
} CATransaction.commit()
self.tableFootView.myCollectView.es.stopLoadingMore()
if self.viewModel.hasMoreForHomeNews == false {
self.tableFootView.myCollectView.es.noticeNoMoreData()
}
})
}) })
} }
} }
......
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