|
@@ -132,7 +132,6 @@ class CommunityAllCommentView: FWPopupView {
|
|
tableView.estimatedRowHeight = 0.000001
|
|
tableView.estimatedRowHeight = 0.000001
|
|
tableView.estimatedSectionFooterHeight = 0.000001
|
|
tableView.estimatedSectionFooterHeight = 0.000001
|
|
tableView.estimatedSectionHeaderHeight = 0.000001
|
|
tableView.estimatedSectionHeaderHeight = 0.000001
|
|
- tableView.isScrollEnabled = false
|
|
|
|
return tableView
|
|
return tableView
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -141,15 +140,18 @@ class CommunityAllCommentView: FWPopupView {
|
|
extension CommunityAllCommentView : UITableViewDelegate, UITableViewDataSource {
|
|
extension CommunityAllCommentView : UITableViewDelegate, UITableViewDataSource {
|
|
|
|
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
- return 3
|
|
|
|
|
|
+ return communityPostCommentModels.isEmpty ? 1 : communityPostCommentModels.count
|
|
}
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
- if indexPath.row == 0 {
|
|
|
|
- let cell = CommunityMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
- return cell
|
|
|
|
|
|
+ if communityPostCommentModels.isEmpty {
|
|
|
|
+ return UITableViewCell()
|
|
} else {
|
|
} else {
|
|
- let cell = CommunityReplyCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
|
|
+ let cell = RecommendMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
|
+ cell.communityPostCommentModel = communityPostCommentModels[indexPath.row]
|
|
|
|
+ cell.frame = tableView.bounds
|
|
|
|
+ cell.layoutIfNeeded()
|
|
|
|
+ cell.reloadData()
|
|
return cell
|
|
return cell
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -159,7 +161,11 @@ extension CommunityAllCommentView : UITableViewDelegate, UITableViewDataSource {
|
|
}
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
|
- return UITableView.automaticDimension
|
|
|
|
|
|
+ if communityPostCommentModels.isEmpty {
|
|
|
|
+ return 0
|
|
|
|
+ }else {
|
|
|
|
+ return communityPostCommentModels[indexPath.row].height ?? 0
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
|
@@ -186,12 +192,18 @@ extension CommunityAllCommentView {
|
|
/// - postId: 内容id
|
|
/// - postId: 内容id
|
|
/// - page: 分页
|
|
/// - page: 分页
|
|
func communityPostCommentApi(page:Int) {
|
|
func communityPostCommentApi(page:Int) {
|
|
|
|
+
|
|
SwiftMoyaNetWorkServiceCommunity.shared().communityPostCommentApi(postId: postId ?? 0, page: page) {
|
|
SwiftMoyaNetWorkServiceCommunity.shared().communityPostCommentApi(postId: postId ?? 0, page: page) {
|
|
[weak self] (communityPostCommentsModel) -> (Void) in
|
|
[weak self] (communityPostCommentsModel) -> (Void) in
|
|
-
|
|
|
|
let commentsMdl = communityPostCommentsModel as? CommunityPostCommentsModel
|
|
let commentsMdl = communityPostCommentsModel as? CommunityPostCommentsModel
|
|
self?.communityPostCommentsModel = commentsMdl
|
|
self?.communityPostCommentsModel = commentsMdl
|
|
|
|
|
|
|
|
+ if self?.communityPostCommentsModel?.pagination?.currentPage == 1{
|
|
|
|
+ self?.communityPostCommentModels.removeAll()
|
|
|
|
+ }
|
|
|
|
+ self?.communityPostCommentModels = (self?.communityPostCommentModels)! + (self?.communityPostCommentsModel?.data!)!
|
|
|
|
+ self?.tableView.reloadData()
|
|
|
|
+
|
|
let totalComments: Int = commentsMdl?.pagination?.total ?? 0
|
|
let totalComments: Int = commentsMdl?.pagination?.total ?? 0
|
|
self?.titleLabel.text = "全部评论 \(totalComments)"
|
|
self?.titleLabel.text = "全部评论 \(totalComments)"
|
|
if totalComments == 0 {
|
|
if totalComments == 0 {
|
|
@@ -201,15 +213,7 @@ extension CommunityAllCommentView {
|
|
self?.tableView.isHidden = false
|
|
self?.tableView.isHidden = false
|
|
self?.noCommentsLabel.isHidden = true
|
|
self?.noCommentsLabel.isHidden = true
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-// if self?.communityPostCommentsModel?.pagination?.currentPage == 1{
|
|
|
|
-// self?.communityPostCommentModels.removeAll()
|
|
|
|
-// }
|
|
|
|
-// self?.communityPostCommentModels = (self?.communityPostCommentModels)! + (self?.communityPostCommentsModel?.data!)!
|
|
|
|
-// self?.tableView.reloadData()
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|