Commit d5f09da1 authored by pete谢兆麟's avatar pete谢兆麟

邀请有礼 加载更多

parent bf5b0e91
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
import UIKit import UIKit
class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell { class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell {
var centerView: UIView! var centerView: UIView!
var titleLeftImageView: UIImageView! var titleLeftImageView: UIImageView!
var titleRightImageView: UIImageView! var titleRightImageView: UIImageView!
...@@ -27,7 +26,10 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell { ...@@ -27,7 +26,10 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell {
var peopleFourView: YHInvitationPeopleItemView! var peopleFourView: YHInvitationPeopleItemView!
var peopleFiveView: YHInvitationPeopleItemView! var peopleFiveView: YHInvitationPeopleItemView!
var tableView: UITableView! var tableView: UITableView!
var viewModel: YHInvitationWithGiftsViewModel = YHInvitationWithGiftsViewModel()
var page = 1
var list: [YHShareRecordListModel] = []
var headData: YHShareOverviewModel? { var headData: YHShareOverviewModel? {
didSet { didSet {
guard let model = headData else { return } guard let model = headData else { return }
...@@ -54,6 +56,11 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell { ...@@ -54,6 +56,11 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell {
} else { } else {
self.tableView.tableFooterView = UIView() self.tableView.tableFooterView = UIView()
} }
if tableData?.page_count == 1 {
self.tableView.es.noticeNoMoreData()
self.tableView.footer?.alpha = 1
}
self.list = tableData?.list ?? []
self.tableView.reloadData() self.tableView.reloadData()
} }
} }
...@@ -323,7 +330,6 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell { ...@@ -323,7 +330,6 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell {
tableView.showsVerticalScrollIndicator = false tableView.showsVerticalScrollIndicator = false
tableView.dataSource = self tableView.dataSource = self
tableView.delegate = self tableView.delegate = self
tableView.bounces = false
tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 0.01)) tableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: 0.01))
tableView.register(cellWithClass: YHInvitationWithGiftsPeopleTableViewCell.self) tableView.register(cellWithClass: YHInvitationWithGiftsPeopleTableViewCell.self)
return tableView return tableView
...@@ -335,18 +341,33 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell { ...@@ -335,18 +341,33 @@ class YHInvitationWithGiftsSecondTableViewCell: UITableViewCell {
make.left.equalTo(15) make.left.equalTo(15)
make.right.equalTo(-15) make.right.equalTo(-15)
} }
tableView.es.addInfiniteScrolling {
self.viewModel.postRecord(page: self.page + 1) {[weak self] success, error in
guard let self = self else { return }
self.page = self.page + 1
self.tableView.es.stopLoadingMore()
if self.viewModel.recordModel.page_count == self.page {
self.tableView.es.noticeNoMoreData()
self.tableView.footer?.alpha = 1
}
for item in self.viewModel.recordModel.list {
self.list.append(item)
}
self.tableView.reloadData()
}
}
} }
} }
extension YHInvitationWithGiftsSecondTableViewCell: UITableViewDelegate, UITableViewDataSource { extension YHInvitationWithGiftsSecondTableViewCell: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableData?.list.count ?? 0 return list.count
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withClass: YHInvitationWithGiftsPeopleTableViewCell.self) let cell = tableView.dequeueReusableCell(withClass: YHInvitationWithGiftsPeopleTableViewCell.self)
cell.dataSource = tableData?.list[indexPath.row] cell.dataSource = list[indexPath.row]
return cell return cell
} }
......
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