Ver código fonte

评论完成

南鑫林 5 anos atrás
pai
commit
c614424f34

+ 3 - 0
RainbowPlanet/RainbowPlanet/Model/UserModel/FollowStatusModel.swift

@@ -11,6 +11,9 @@ class FollowStatusModel : NSObject, Mappable{
 	var isFollowStatus : Int?
     var uid : Int?
     var postId : Int?
+    var commnetId : Int?
+    var commentLikeCount : Int?
+    
 
 	class func newInstance(map: Map) -> Mappable?{
 		return FollowStatusModel()

+ 19 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/ViewController/Follow/CommunityFollowViewController.swift

@@ -152,6 +152,25 @@ class CommunityFollowViewController: BaseViewController {
             self?.tableView.reloadData()
         }
         
+        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("isCommnetLikeApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
+            let followStatusModel = notification.object as? FollowStatusModel
+            if !(self?.communityFollowDataModels?.isEmpty ?? true) {
+                for communityRecommendDataModel in (self?.communityFollowDataModels)! {
+                    if communityRecommendDataModel.relateData?.id == followStatusModel?.postId {
+                        if !(communityRecommendDataModel.relateData?.postComment?.isEmpty ?? true ){
+                            for communityFollowPostCommentModel in (communityRecommendDataModel.relateData?.postComment)!{
+                                if communityFollowPostCommentModel.id == followStatusModel?.commnetId {
+                                    communityFollowPostCommentModel.isLike = followStatusModel?.isFollowStatus
+                                    communityFollowPostCommentModel.likeCount = followStatusModel?.commentLikeCount
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            self?.tableView.reloadData()
+        }
+        
         observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("communityDeletePostApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
             let postId = notification.object as? Int
             if !(self?.communityFollowDataModels?.isEmpty ?? true) {

+ 21 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/Community/ViewController/Recommend/CommunityRecommnendViewController.swift

@@ -125,6 +125,27 @@ class CommunityRecommnendViewController: UIViewController {
             self?.tableView.reloadData()
         }
         
+        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("isCommnetLikeApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
+            let followStatusModel = notification.object as? FollowStatusModel
+            if !(self?.communityRecommendDataModels.isEmpty ?? true) {
+                for communityRecommendDataModel in (self?.communityRecommendDataModels)! {
+                    if communityRecommendDataModel.id == followStatusModel?.postId {
+                        if !(communityRecommendDataModel.comment?.isEmpty ?? true ){
+                            for communityRecommendCommentModel in communityRecommendDataModel.comment! {
+                                if communityRecommendCommentModel.id == followStatusModel?.commnetId {
+                                    communityRecommendCommentModel.isLike = followStatusModel?.isFollowStatus
+                                    communityRecommendCommentModel.likeCount = followStatusModel?.commentLikeCount
+
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+         self?.tableView.reloadData()
+        }
+        
+        
         observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("communityDeletePostApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
                 let postId = notification.object as? Int
                 if !(self?.communityRecommendDataModels.isEmpty ?? true) {

+ 19 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityFeaturedTopics/ViewController/CommunityFeaturedTopicsViewController.swift

@@ -243,6 +243,25 @@ class CommunityFeaturedTopicsViewController: BaseViewController {
             self?.tableView.reloadData()
         }
         
+        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("isCommnetLikeApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
+            let followStatusModel = notification.object as? FollowStatusModel
+            if !(self?.communityRecommendDataModels.isEmpty ?? true) {
+                for communityRecommendDataModel in (self?.communityRecommendDataModels)! {
+                    if communityRecommendDataModel.id == followStatusModel?.postId {
+                        if !(communityRecommendDataModel.comment?.isEmpty ?? true ){
+                            for communityRecommendCommentModel in communityRecommendDataModel.comment! {
+                                if communityRecommendCommentModel.id == followStatusModel?.commnetId {
+                                    communityRecommendCommentModel.isLike = followStatusModel?.isFollowStatus
+                                    communityRecommendCommentModel.likeCount = followStatusModel?.commentLikeCount
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            self?.tableView.reloadData()
+        }
+        
         observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("communityDeletePostApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
             let postId = notification.object as? Int
             if !(self?.communityRecommendDataModels.isEmpty ?? true) {

+ 13 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/Controller/CommunityRecommendController.swift

@@ -273,6 +273,19 @@ class CommunityRecommendController: BaseViewController {
             }
             self?.tableView.reloadData()
         }
+        
+        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("isCommnetLikeApi"), object: nil, queue: OperationQueue.main) { [weak self] (notification) in
+            let followStatusModel = notification.object as? FollowStatusModel
+            if !(self?.communityPostCommentModels.isEmpty ?? true) {
+                for communityPostCommentModel in (self?.communityPostCommentModels)! {
+                    if communityPostCommentModel.id == followStatusModel?.postId {
+                        communityPostCommentModel.isLike = followStatusModel?.isFollowStatus
+                        communityPostCommentModel.likeCount = followStatusModel?.commentLikeCount
+                    }
+                }
+            }
+            self?.tableView.reloadData()
+        }
     }
     
     /// 显示键盘

+ 11 - 0
RainbowPlanet/RainbowPlanet/ViewModel/Virus/VirusViewModel.swift

@@ -942,19 +942,30 @@ extension VirusViewModel {
         
         SwiftMoyaNetWorkServiceVirus.shared().virueRecordAddApi(virueRecordAddParameterModel: virueRecordAddParameterModel, completion: {
             [weak button,weak label] (data) -> (Void) in
+            let followStatusModel = FollowStatusModel()
+
             if isCommentLike == 1 {
                 button?.isSelected = false
                 let commentLikeCount = (commentLikeCount ?? 0) - 1
                 label?.text = "\(commentLikeCount)"
+                followStatusModel.isFollowStatus = 0
+                followStatusModel.commentLikeCount = commentLikeCount
                 completion(0)
 
             }else {
                 button?.isSelected = true
                 let commentLikeCount = ((commentLikeCount ?? 0) + 1)
                 label?.text = "\(commentLikeCount)"
+                followStatusModel.isFollowStatus = 1
+                followStatusModel.commentLikeCount = commentLikeCount
                 completion(1)
 
             }
+            followStatusModel.uid = commentUId
+            followStatusModel.postId = postId
+            followStatusModel.commnetId = commentId
+            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "isCommnetLikeApi"), object: followStatusModel)
+
         }, fail: {_ in})
     }
 }