|
@@ -13,6 +13,7 @@ class CommunityFollowViewController: UIViewController {
|
|
|
|
|
|
var cellHeightsDictionary = Dictionary<IndexPath, Any>()
|
|
|
var communityFollowDataModels = Array<CommunityFollowDataModel>()
|
|
|
+ var communityFollowDataModel : CommunityFollowDataModel?
|
|
|
/// 关注数组
|
|
|
var cmsMemberModels = Array<CMSMemberModel>()
|
|
|
deinit {
|
|
@@ -55,6 +56,11 @@ class CommunityFollowViewController: UIViewController {
|
|
|
return followTableHeaderView
|
|
|
}()
|
|
|
|
|
|
+ lazy var commentInputView: CommentInputView = {
|
|
|
+ let commentInputView = CommentInputView(isHidden: true)
|
|
|
+ return commentInputView
|
|
|
+ }()
|
|
|
+
|
|
|
func setupData() {
|
|
|
//下拉刷新
|
|
|
tableView.addHeaderWithHeader(withBeginRefresh: true, animation: false) {
|
|
@@ -66,6 +72,10 @@ class CommunityFollowViewController: UIViewController {
|
|
|
SwiftProgressHUD.shared().showWait()
|
|
|
self?.communityFollowFeedApi(page: page)
|
|
|
}
|
|
|
+ commentInputView.commentInputViewClosure = {
|
|
|
+ [weak self] text in
|
|
|
+ self?.communityPostCommentApi(text: text)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -128,6 +138,37 @@ extension CommunityFollowViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// 评论
|
|
|
+ func communityPostCommentApi(text:String) {
|
|
|
+ let communityCustomCommnetModel = CommunityCustomCommnetModel()
|
|
|
+ communityCustomCommnetModel.postId = communityFollowDataModel?.relateData?.id ?? 0
|
|
|
+ communityCustomCommnetModel.content = text
|
|
|
+
|
|
|
+ SwiftMoyaNetWorkServiceCommunity.shared().communityPostCommentApi(communityCustomCommnetModel: communityCustomCommnetModel) {
|
|
|
+ [weak self] (communityPostCommentIdModel) -> (Void) in
|
|
|
+
|
|
|
+ let communityPostCommentIdModel = communityPostCommentIdModel as? CommunityPostCommentIdModel
|
|
|
+
|
|
|
+ let communityFollowPostCommentModel = CommunityFollowPostCommentModel()
|
|
|
+ communityFollowPostCommentModel.content = text
|
|
|
+ communityFollowPostCommentModel.id = communityPostCommentIdModel?.id
|
|
|
+ communityFollowPostCommentModel.username = UserModel.shared().getModel()?.username
|
|
|
+
|
|
|
+ if self?.communityFollowDataModel?.relateData?.postComment?.isEmpty ?? true {
|
|
|
+ self?.communityFollowDataModel?.relateData?.postComment = Array<CommunityFollowPostCommentModel>()
|
|
|
+ }
|
|
|
+
|
|
|
+ self?.communityFollowDataModel?.relateData?.postComment?.insert(communityFollowPostCommentModel, at: 0)
|
|
|
+
|
|
|
+ VirusViewModel.shared.comment(communityFollowDataModel: self?.communityFollowDataModel, id: communityPostCommentIdModel?.id ?? 0)
|
|
|
+ let count = self?.communityFollowDataModel?.relateData?.commentCount ?? 0 + 1
|
|
|
+ self?.communityFollowDataModel?.relateData?.commentCount = count
|
|
|
+ self?.tableView.reloadData()
|
|
|
+ self?.commentInputView.sendSuccess()
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
extension CommunityFollowViewController : UITableViewDelegate,UITableViewDataSource {
|
|
@@ -274,7 +315,9 @@ extension CommunityFollowViewController : UITableViewDelegate,UITableViewDataSou
|
|
|
case 5:
|
|
|
let cell = CardContentCommnetTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
|
|
|
cell.addCommnetClosureName = {
|
|
|
-
|
|
|
+ [weak self] in
|
|
|
+ self?.communityFollowDataModel = self?.communityFollowDataModels[indexPath.section]
|
|
|
+ self?.commentInputView.inputTextView.becomeFirstResponder()
|
|
|
}
|
|
|
return cell
|
|
|
default:
|