Pārlūkot izejas kodu

点赞完成/缺发送通知

南鑫林 5 gadi atpakaļ
vecāks
revīzija
733d99e46b

+ 10 - 0
RainbowPlanet/RainbowPlanet/Model/CommunityModel/CommunityPostCommentsModel.swift

@@ -39,6 +39,9 @@ class CommunityPostCommentModel : NSObject, Mappable{
     var username : String?
     var height : CGFloat?
     var isDelete : Int?
+    var isLike : Int?
+    var likeCount : Int?
+    
     
     
     class func newInstance(map: Map) -> Mappable?{
@@ -58,6 +61,8 @@ class CommunityPostCommentModel : NSObject, Mappable{
         uid <- map["uid"]
         username <- map["username"]
         isDelete <- map["is_delete"]
+        isLike <- map["is_like"]
+        likeCount <- map["like_count"]
         
     }
 }
@@ -73,6 +78,9 @@ class CommunityPostReplyModel : NSObject, Mappable{
     var id : Int?
     var height : CGFloat?
     var isDelete : Int?
+    var isLike : Int?
+    var likeCount : Int?
+    
     
     class func newInstance(map: Map) -> Mappable?{
         return CommunityPostReplyModel()
@@ -90,6 +98,8 @@ class CommunityPostReplyModel : NSObject, Mappable{
         uid <- map["uid"]
         username <- map["username"]
         isDelete <- map["is_delete"]
+        isLike <- map["is_like"]
+        likeCount <- map["like_count"]
 
         
     }

+ 78 - 8
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendMajorCommentCell.swift

@@ -51,6 +51,8 @@ class RecommendMajorCommentCell: UITableViewCell {
         addSubview(titleLabel)
         addSubview(contentLabel)
         addSubview(timeLabel)
+        addSubview(likeButton)
+        addSubview(likeCountLabel)
         addSubview(tableView)
     }
     
@@ -58,18 +60,18 @@ class RecommendMajorCommentCell: UITableViewCell {
         iconButton.snp.makeConstraints { (make) in
             make.top.equalTo(0)
             make.left.equalTo(14)
-            make.size.equalTo(24)
+            make.size.equalTo(38)
         }
         titleLabel.snp.makeConstraints { (make) in
             make.left.equalTo(iconButton.snp_right).offset(10)
             make.right.equalToSuperview().offset(-26)
-            make.centerY.equalTo(iconButton)
+            make.top.equalTo(iconButton)
             make.height.equalTo(17)
         }
         
         contentLabel.snp.makeConstraints { (make) in
-            make.top.equalTo(iconButton.snp_bottom).offset(6)
-            make.left.equalTo(48)
+            make.top.equalTo(titleLabel.snp_bottom).offset(8)
+            make.left.equalTo(titleLabel)
             make.right.equalToSuperview().offset(-14)
         }
         timeLabel.snp.makeConstraints { (make) in
@@ -78,6 +80,15 @@ class RecommendMajorCommentCell: UITableViewCell {
             make.right.equalTo(contentLabel.snp_right)
             make.height.equalTo(15)
         }
+        likeCountLabel.snp.makeConstraints { (make) in
+            make.centerY.equalTo(timeLabel)
+            make.right.equalTo(-14)
+        }
+        likeButton.snp.makeConstraints { (make) in
+            make.right.equalTo(likeCountLabel.snp.left).offset(-5)
+            make.centerY.equalTo(timeLabel)
+
+        }
         tableView.snp.remakeConstraints { (make) in
             make.top.equalTo(timeLabel.snp_bottom).offset(10)
             make.left.equalTo(contentLabel.snp_left)
@@ -124,6 +135,50 @@ class RecommendMajorCommentCell: UITableViewCell {
         return timeLabel
     }()
     
+    lazy var likeButton: UIButton = {
+        let likeButton = UIButton(type: UIButton.ButtonType.custom)
+        likeButton.setImage(kImage(name: "btn_praise"), for: UIControl.State.normal)
+        likeButton.setImage(kImage(name: "btn_praise_pre_36px"), for: UIControl.State.selected)
+        likeButton.addTarget(self, action: #selector(likeAction), for: UIControl.Event.touchUpInside)
+        
+        return likeButton
+    }()
+    
+    lazy var likeCountLabel: UILabel = {
+        let likeCountLabel = UILabel()
+        likeCountLabel.textColor = k313334Color
+        likeCountLabel.font = kRegularFont14
+        likeCountLabel.addTapGesture(1, target: self, action:  #selector(likeAction))
+        
+        return likeCountLabel
+    }()
+    
+    @objc func likeAction() {
+        VirusViewModel.shared.commentlikeVirueRecordApi(button: likeButton,
+                                                        label: likeCountLabel,
+                                                        isCommentLike: communityPostCommentModel?.isLike,
+                                                        postId: communityPostDetailModel?.id,
+                                                        postAuthorUid: "\(communityPostDetailModel?.uid ?? 0)",
+            title: communityPostDetailModel?.title,
+            content: communityPostDetailModel?.content,
+            postCover: communityPostDetailModel?.img,
+            actionId: "\(communityPostDetailModel?.id ?? 0)",
+            postType: communityPostDetailModel?.type,
+            commentContent: communityPostCommentModel?.content,
+            commentId: communityPostCommentModel?.id,
+            commentUId: communityPostCommentModel?.uid,
+            commentLikeCount: communityPostCommentModel?.likeCount) {
+                [weak self] (isCommentLike) in
+                self?.communityPostCommentModel?.isLike = isCommentLike
+                if isCommentLike == 1 {
+                    self?.communityPostCommentModel?.likeCount = (self?.communityPostCommentModel?.likeCount ?? 0) + 1
+                }
+                if isCommentLike == 0 {
+                    self?.communityPostCommentModel?.likeCount = (self?.communityPostCommentModel?.likeCount ?? 0) - 1
+                }
+        }
+    }
+    
     lazy var tableView: UITableView = {
         [unowned self] in
         let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
@@ -153,13 +208,13 @@ class RecommendMajorCommentCell: UITableViewCell {
         }
         let contentLabelHeight = communityPostCommentModel?.content?.heightForComment(font: kRegularFont14!, width: kScreenWidth - 14 - 48)
         if communityPostCommentModel?.reply?.isEmpty ?? true {
-            let subViewHeight = 24.0 + (contentLabelHeight ?? 0) + 15.0
-            let spacHeight = 6.0 + 8.0 + 20.0
+            let subViewHeight = 17 + (contentLabelHeight ?? 0) + 15.0
+            let spacHeight = 8.0 + 8.0 + 20.0
             communityPostCommentModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
         }else {
             let autoHeight = (contentLabelHeight ?? 0) + (tableViewHeight ?? 0)
-            let subViewHeight = 24.0 +  autoHeight + 15.0
-            let spacHeight = 6.0 + 8.0 + 10.0  + 20.0
+            let subViewHeight = 17.0 +  autoHeight + 15.0
+            let spacHeight = 8.0 + 8.0 + 10.0  + 20.0
             communityPostCommentModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
         }
     }
@@ -171,6 +226,20 @@ class RecommendMajorCommentCell: UITableViewCell {
             titleLabel.text = communityPostCommentModel?.username
             contentLabel.text = communityPostCommentModel?.content
             timeLabel.text = communityPostCommentModel?.createdAt
+            let likeCount = "\(communityPostCommentModel?.likeCount ?? 0)"
+            likeCountLabel.text = likeCount
+            if communityPostCommentModel?.isLike == 1 {
+                likeButton.isSelected = true
+            }else {
+                likeButton.isSelected = false
+            }
+            if communityPostCommentModel?.isDelete == 1 {
+                likeCountLabel.isHidden = true
+                likeButton.isHidden = true
+            }else {
+                likeCountLabel.isHidden = false
+                likeButton.isHidden = false
+            }
             reloadData()
         }
     }
@@ -197,6 +266,7 @@ extension RecommendMajorCommentCell: UITableViewDataSource, UITableViewDelegate
         let reply = communityPostCommentModel?.reply?.prefix(2)
         let cell = RecommendSubCommentTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
         cell.communityPostReplyModel = reply?[indexPath.row]
+        cell.communityPostDetailModel = communityPostDetailModel
         return cell
         
     }

+ 77 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendSubCommentTableViewCell.swift

@@ -52,6 +52,8 @@ class RecommendSubCommentTableViewCell: UITableViewCell {
         addSubview(titleLabel)
         addSubview(contentLabel)
         addSubview(timeLabel)
+        addSubview(likeButton)
+        addSubview(likeCountLabel)
     }
     
     private func setupLayouts() {
@@ -72,6 +74,7 @@ class RecommendSubCommentTableViewCell: UITableViewCell {
             make.right.equalToSuperview().offset(-10)
             make.width.equalTo(kScreenWidth-62-54)
         }
+        
         timeLabel.snp.makeConstraints { (make) in
             make.top.equalTo(contentLabel.snp_bottom).offset(8)
             make.left.equalTo(titleLabel.snp_left)
@@ -79,6 +82,16 @@ class RecommendSubCommentTableViewCell: UITableViewCell {
             make.height.equalTo(15)
             make.bottom.equalToSuperview()
         }
+        
+        likeCountLabel.snp.makeConstraints { (make) in
+            make.centerY.equalTo(timeLabel)
+            make.right.equalTo(-14)
+        }
+        likeButton.snp.makeConstraints { (make) in
+            make.right.equalTo(likeCountLabel.snp.left).offset(-5)
+            make.centerY.equalTo(timeLabel)
+            
+        }
     }
     
     private lazy var iconButton : UIButton = {
@@ -120,6 +133,53 @@ class RecommendSubCommentTableViewCell: UITableViewCell {
         return timeLabel
     }()
     
+    lazy var likeButton: UIButton = {
+        let likeButton = UIButton(type: UIButton.ButtonType.custom)
+        likeButton.setImage(kImage(name: "btn_praise"), for: UIControl.State.normal)
+        likeButton.setImage(kImage(name: "btn_praise_pre_36px"), for: UIControl.State.selected)
+        likeButton.addTarget(self, action: #selector(likeAction), for: UIControl.Event.touchUpInside)
+        
+        return likeButton
+    }()
+    
+    lazy var likeCountLabel: UILabel = {
+        let likeCountLabel = UILabel()
+        likeCountLabel.textColor = k313334Color
+        likeCountLabel.font = kRegularFont14
+        likeCountLabel.addTapGesture(1, target: self, action:  #selector(likeAction))
+        
+        return likeCountLabel
+    }()
+    
+    @objc func likeAction() {
+        VirusViewModel.shared.commentlikeVirueRecordApi(button: likeButton,
+                                                        label: likeCountLabel,
+                                                        isCommentLike: communityPostReplyModel?.isLike,
+                                                        postId: communityPostDetailModel?.id,
+                                                        postAuthorUid: "\(communityPostDetailModel?.uid ?? 0)",
+            title: communityPostDetailModel?.title,
+            content: communityPostDetailModel?.content,
+            postCover: communityPostDetailModel?.img,
+            actionId: "\(communityPostDetailModel?.id ?? 0)",
+            postType: communityPostDetailModel?.type,
+            commentContent: communityPostReplyModel?.content,
+            commentId: communityPostReplyModel?.id,
+            commentUId: communityPostReplyModel?.uid,
+            commentLikeCount: communityPostReplyModel?.likeCount) {
+                [weak self] (isCommentLike) in
+                self?.communityPostReplyModel?.isLike = isCommentLike
+                if isCommentLike == 1 {
+                    self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) + 1
+                }
+                if isCommentLike == 0 {
+                    self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) - 1
+                }
+        }
+    }
+    
+    /// 帖子Id
+    var communityPostDetailModel : CommunityPostDetailModel?
+    
     var communityPostReplyModel: CommunityPostReplyModel? {
         didSet {
             iconButton.kf.setImage(with: kURLImage(name: communityPostReplyModel?.avatar ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
@@ -140,8 +200,24 @@ class RecommendSubCommentTableViewCell: UITableViewCell {
             }
             
             timeLabel.text = communityPostReplyModel?.createdAt
+            
+            let likeCount = "\(communityPostReplyModel?.likeCount ?? 0)"
+            likeCountLabel.text = likeCount
+            if communityPostReplyModel?.isLike == 1 {
+                likeButton.isSelected = true
+            }else {
+                likeButton.isSelected = false
+            }
+            if communityPostReplyModel?.isDelete == 1 {
+                likeCountLabel.isHidden = true
+                likeButton.isHidden = true
+            }else {
+                likeCountLabel.isHidden = false
+                likeButton.isHidden = false
+            }
+            
             let contentLabelHeight = contentLabel.text?.heightForComment(font: kRegularFont14!, width: kScreenWidth - 24 - 92)
-            let subViewHeight = 24.0 + (contentLabelHeight ?? 0) + 15.0
+            let subViewHeight = 17.0 + (contentLabelHeight ?? 0) + 15.0
             let spacHeight = 10.0 + 8.0 + 8.0
             communityPostReplyModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
         }

+ 112 - 7
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunitySubComment/View/CommunityMajorCommentCell.swift

@@ -45,24 +45,26 @@ class CommunityMajorCommentCell: UITableViewCell {
         addSubview(titleLabel)
         addSubview(contentLabel)
         addSubview(timeLabel)
+        addSubview(likeButton)
+        addSubview(likeCountLabel)
     }
     
     private func setupLayouts() {
         iconButton.snp.makeConstraints { (make) in
-            make.top.equalTo(20)
+            make.top.equalTo(0)
             make.left.equalTo(14)
-            make.size.equalTo(24)
+            make.size.equalTo(38)
         }
         titleLabel.snp.makeConstraints { (make) in
             make.left.equalTo(iconButton.snp_right).offset(10)
             make.right.equalToSuperview().offset(-26)
-            make.centerY.equalTo(iconButton)
+            make.top.equalTo(iconButton)
             make.height.equalTo(17)
         }
         
         contentLabel.snp.makeConstraints { (make) in
-            make.top.equalTo(iconButton.snp_bottom).offset(6)
-            make.left.equalTo(48)
+            make.top.equalTo(titleLabel.snp_bottom).offset(8)
+            make.left.equalTo(titleLabel)
             make.right.equalToSuperview().offset(-14)
         }
         timeLabel.snp.makeConstraints { (make) in
@@ -71,6 +73,15 @@ class CommunityMajorCommentCell: UITableViewCell {
             make.right.equalTo(contentLabel.snp_right)
             make.height.equalTo(15)
         }
+        likeCountLabel.snp.makeConstraints { (make) in
+            make.centerY.equalTo(timeLabel)
+            make.right.equalTo(-14)
+        }
+        likeButton.snp.makeConstraints { (make) in
+            make.right.equalTo(likeCountLabel.snp.left).offset(-5)
+            make.centerY.equalTo(timeLabel)
+            
+        }
     }
     
     private lazy var iconButton : UIButton = {
@@ -109,6 +120,86 @@ class CommunityMajorCommentCell: UITableViewCell {
         return timeLabel
     }()
     
+    lazy var likeButton: UIButton = {
+        let likeButton = UIButton(type: UIButton.ButtonType.custom)
+        likeButton.setImage(kImage(name: "btn_praise"), for: UIControl.State.normal)
+        likeButton.setImage(kImage(name: "btn_praise_pre_36px"), for: UIControl.State.selected)
+        likeButton.addTarget(self, action: #selector(likeAction), for: UIControl.Event.touchUpInside)
+        
+        return likeButton
+    }()
+    
+    lazy var likeCountLabel: UILabel = {
+        let likeCountLabel = UILabel()
+        likeCountLabel.textColor = k313334Color
+        likeCountLabel.font = kRegularFont14
+        likeCountLabel.addTapGesture(1, target: self, action:  #selector(likeAction))
+        
+        return likeCountLabel
+    }()
+    
+    @objc func likeAction() {
+        if communityPostDetailModel != nil {
+            VirusViewModel.shared.commentlikeVirueRecordApi(button: likeButton,
+                                                            label: likeCountLabel,
+                                                            isCommentLike: communityPostCommentModel?.isLike,
+                                                            postId: communityPostDetailModel?.id,
+                                                            postAuthorUid: "\(communityPostDetailModel?.uid ?? 0)",
+                title: communityPostDetailModel?.title,
+                content: communityPostDetailModel?.content,
+                postCover: communityPostDetailModel?.img,
+                actionId: "\(communityPostDetailModel?.id ?? 0)",
+                postType: communityPostDetailModel?.type,
+                commentContent: communityPostCommentModel?.content,
+                commentId: communityPostCommentModel?.id,
+                commentUId: communityPostCommentModel?.uid,
+                commentLikeCount: communityPostCommentModel?.likeCount) {
+                    [weak self] (isCommentLike) in
+                    self?.communityPostCommentModel?.isLike = isCommentLike
+                    if isCommentLike == 1 {
+                        self?.communityPostCommentModel?.likeCount = (self?.communityPostCommentModel?.likeCount ?? 0) + 1
+                    }
+                    if isCommentLike == 0 {
+                        self?.communityPostCommentModel?.likeCount = (self?.communityPostCommentModel?.likeCount ?? 0) - 1
+                    }
+            }
+        }
+        
+        if communityVideoItemModel != nil {
+            VirusViewModel.shared.commentlikeVirueRecordApi(button: likeButton,
+                                                            label: likeCountLabel,
+                                                            isCommentLike: communityPostCommentModel?.isLike,
+                                                            postId: communityVideoItemModel?.id,
+                                                            postAuthorUid: "\(communityVideoItemModel?.uid ?? 0)",
+                title: communityVideoItemModel?.title,
+                content: communityVideoItemModel?.content,
+                postCover: communityVideoItemModel?.img,
+                actionId: "\(communityVideoItemModel?.id ?? 0)",
+                postType: communityVideoItemModel?.type,
+                commentContent: communityPostCommentModel?.content,
+                commentId: communityPostCommentModel?.id,
+                commentUId: communityPostCommentModel?.uid,
+                commentLikeCount: communityPostCommentModel?.likeCount) {
+                    [weak self] (isCommentLike) in
+                    self?.communityPostCommentModel?.isLike = isCommentLike
+                    if isCommentLike == 1 {
+                        self?.communityPostCommentModel?.likeCount = (self?.communityPostCommentModel?.likeCount ?? 0) + 1
+                    }
+                    if isCommentLike == 0 {
+                        self?.communityPostCommentModel?.likeCount = (self?.communityPostCommentModel?.likeCount ?? 0) - 1
+                    }
+            }
+        }
+        
+    }
+    
+    /// 帖子Id
+    var communityPostDetailModel : CommunityPostDetailModel?
+    ///  视频
+    var communityVideoItemModel : CommunityVideoItemModel?
+    
+    
+    
     var communityPostCommentModel : CommunityPostCommentModel? {
         didSet {
             iconButton.kf.setImage(with: kURLImage(name: communityPostCommentModel?.avatar ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
@@ -116,9 +207,23 @@ class CommunityMajorCommentCell: UITableViewCell {
             titleLabel.text = communityPostCommentModel?.username
             contentLabel.text = communityPostCommentModel?.content
             timeLabel.text = communityPostCommentModel?.createdAt
+            let likeCount = "\(communityPostCommentModel?.likeCount ?? 0)"
+            likeCountLabel.text = likeCount
+            if communityPostCommentModel?.isLike == 1 {
+                likeButton.isSelected = true
+            }else {
+                likeButton.isSelected = false
+            }
+            if communityPostCommentModel?.isDelete == 1 {
+                likeCountLabel.isHidden = true
+                likeButton.isHidden = true
+            }else {
+                likeCountLabel.isHidden = false
+                likeButton.isHidden = false
+            }
             let contentLabelHeight = communityPostCommentModel?.content?.heightForComment(font: kRegularFont14!, width: kScreenWidth - 14 - 48)
-            let subViewHeight = 24.0 + (contentLabelHeight ?? 0) + 15.0
-            let spacHeight = 20 + 6.0 + 8.0 + 20.0
+            let subViewHeight = 17.0 + (contentLabelHeight ?? 0) + 15.0
+            let spacHeight = 20 + 8.0 + 8.0 + 20.0
             communityPostCommentModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
         }
     }

+ 115 - 9
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunitySubComment/View/CommunityReplyCommentCell.swift

@@ -47,25 +47,27 @@ class CommunityReplyCommentCell: UITableViewCell {
         addSubview(titleLabel)
         addSubview(contentLabel)
         addSubview(timeLabel)
+        addSubview(likeButton)
+        addSubview(likeCountLabel)
     }
     
     private func setupLayouts() {
         iconButton.snp.makeConstraints { (make) in
             make.top.equalTo(0)
-            make.left.equalTo(24)
-            make.size.equalTo(24)
+            make.left.equalTo(14)
+            make.size.equalTo(38)
         }
         titleLabel.snp.makeConstraints { (make) in
             make.left.equalTo(iconButton.snp_right).offset(10)
-            make.right.equalToSuperview().offset(-10)
-            make.centerY.equalTo(iconButton)
+            make.right.equalToSuperview().offset(-26)
+            make.top.equalTo(iconButton)
             make.height.equalTo(17)
         }
+        
         contentLabel.snp.makeConstraints { (make) in
-            make.top.equalTo(titleLabel.snp_bottom).offset(12)
-            make.left.equalTo(titleLabel.snp_left)
-            make.right.equalToSuperview().offset(-10)
-            make.width.equalTo(kScreenWidth-62-54)
+            make.top.equalTo(titleLabel.snp_bottom).offset(8)
+            make.left.equalTo(titleLabel)
+            make.right.equalToSuperview().offset(-14)
         }
         timeLabel.snp.makeConstraints { (make) in
             make.top.equalTo(contentLabel.snp_bottom).offset(8)
@@ -73,6 +75,15 @@ class CommunityReplyCommentCell: UITableViewCell {
             make.right.equalTo(contentLabel.snp_right)
             make.height.equalTo(15)
         }
+        likeCountLabel.snp.makeConstraints { (make) in
+            make.centerY.equalTo(timeLabel)
+            make.right.equalTo(-14)
+        }
+        likeButton.snp.makeConstraints { (make) in
+            make.right.equalTo(likeCountLabel.snp.left).offset(-5)
+            make.centerY.equalTo(timeLabel)
+            
+        }
     }
     
     private lazy var iconButton : UIButton = {
@@ -115,6 +126,86 @@ class CommunityReplyCommentCell: UITableViewCell {
         return timeLabel
     }()
     
+    lazy var likeButton: UIButton = {
+        let likeButton = UIButton(type: UIButton.ButtonType.custom)
+        likeButton.setImage(kImage(name: "btn_praise"), for: UIControl.State.normal)
+        likeButton.setImage(kImage(name: "btn_praise_pre_36px"), for: UIControl.State.selected)
+        likeButton.addTarget(self, action: #selector(likeAction), for: UIControl.Event.touchUpInside)
+        
+        return likeButton
+    }()
+    
+    lazy var likeCountLabel: UILabel = {
+        let likeCountLabel = UILabel()
+        likeCountLabel.textColor = k313334Color
+        likeCountLabel.font = kRegularFont14
+        likeCountLabel.addTapGesture(1, target: self, action:  #selector(likeAction))
+        
+        return likeCountLabel
+    }()
+    
+    @objc func likeAction() {
+        if communityPostDetailModel != nil {
+            VirusViewModel.shared.commentlikeVirueRecordApi(button: likeButton,
+                                                            label: likeCountLabel,
+                                                            isCommentLike: communityPostReplyModel?.isLike,
+                                                            postId: communityPostDetailModel?.id,
+                                                            postAuthorUid: "\(communityPostDetailModel?.uid ?? 0)",
+                title: communityPostDetailModel?.title,
+                content: communityPostDetailModel?.content,
+                postCover: communityPostDetailModel?.img,
+                actionId: "\(communityPostDetailModel?.id ?? 0)",
+                postType: communityPostDetailModel?.type,
+                commentContent: communityPostReplyModel?.content,
+                commentId: communityPostReplyModel?.id,
+                commentUId: communityPostReplyModel?.uid,
+                commentLikeCount: communityPostReplyModel?.likeCount) {
+                    [weak self] (isCommentLike) in
+                    self?.communityPostReplyModel?.isLike = isCommentLike
+                    if isCommentLike == 1 {
+                        self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) + 1
+                    }
+                    if isCommentLike == 0 {
+                        self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) - 1
+                    }
+            }
+        }
+        
+        if communityVideoItemModel != nil {
+            VirusViewModel.shared.commentlikeVirueRecordApi(button: likeButton,
+                                                            label: likeCountLabel,
+                                                            isCommentLike: communityPostReplyModel?.isLike,
+                                                            postId: communityVideoItemModel?.id,
+                                                            postAuthorUid: "\(communityVideoItemModel?.uid ?? 0)",
+                title: communityVideoItemModel?.title,
+                content: communityVideoItemModel?.content,
+                postCover: communityVideoItemModel?.img,
+                actionId: "\(communityVideoItemModel?.id ?? 0)",
+                postType: communityVideoItemModel?.type,
+                commentContent: communityPostReplyModel?.content,
+                commentId: communityPostReplyModel?.id,
+                commentUId: communityPostReplyModel?.uid,
+                commentLikeCount: communityPostReplyModel?.likeCount) {
+                    [weak self] (isCommentLike) in
+                    self?.communityPostReplyModel?.isLike = isCommentLike
+                    if isCommentLike == 1 {
+                        self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) + 1
+                    }
+                    if isCommentLike == 0 {
+                        self?.communityPostReplyModel?.likeCount = (self?.communityPostReplyModel?.likeCount ?? 0) - 1
+                    }
+            }
+        }
+        
+    }
+    
+    /// 帖子Id
+    var communityPostDetailModel : CommunityPostDetailModel?
+    /// 视频id
+    var communityVideoItemModel : CommunityVideoItemModel?
+    
+
+    
     var communityPostReplyModel: CommunityPostReplyModel? {
         didSet {
             iconButton.kf.setImage(with: kURLImage(name: communityPostReplyModel?.avatar ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
@@ -135,8 +226,23 @@ class CommunityReplyCommentCell: UITableViewCell {
             }
             
             timeLabel.text = communityPostReplyModel?.createdAt
+            let likeCount = "\(communityPostReplyModel?.likeCount ?? 0)"
+            likeCountLabel.text = likeCount
+            if communityPostReplyModel?.isLike == 1 {
+                likeButton.isSelected = true
+            }else {
+                likeButton.isSelected = false
+            }
+            if communityPostReplyModel?.isDelete == 1 {
+                likeCountLabel.isHidden = true
+                likeButton.isHidden = true
+            }else {
+                likeCountLabel.isHidden = false
+                likeButton.isHidden = false
+            }
+            
             let contentLabelHeight = contentLabel.text?.heightForComment(font: kRegularFont14!, width: kScreenWidth - 58 - 14)
-            let subViewHeight = 24.0 + (contentLabelHeight ?? 0) + 15.0
+            let subViewHeight = 17.0 + (contentLabelHeight ?? 0) + 15.0
             let spacHeight = 10.0 + 8.0 + 8.0
             communityPostReplyModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
         }

+ 2 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunitySubComment/ViewController/CommunitySubCommentController.swift

@@ -195,10 +195,12 @@ extension CommunitySubCommentController: UITableViewDataSource, UITableViewDeleg
         case 0:
             let cell = CommunityMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
             cell.communityPostCommentModel = communityPostCommentModel
+            cell.communityPostDetailModel = communityPostDetailModel
             return cell
         default:
             let cell = CommunityReplyCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
             cell.communityPostReplyModel = communityPostReplyModels[indexPath.row]
+            cell.communityPostDetailModel = communityPostDetailModel
             return cell
         }
         

+ 77 - 8
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoMajorCommentCell.swift

@@ -51,6 +51,8 @@ class CommunityVideoMajorCommentCell: UITableViewCell {
         addSubview(titleLabel)
         addSubview(contentLabel)
         addSubview(timeLabel)
+        addSubview(likeButton)
+        addSubview(likeCountLabel)
         addSubview(tableView)
     }
     
@@ -58,18 +60,18 @@ class CommunityVideoMajorCommentCell: UITableViewCell {
         iconButton.snp.makeConstraints { (make) in
             make.top.equalTo(0)
             make.left.equalTo(14)
-            make.size.equalTo(24)
+            make.size.equalTo(38)
         }
         titleLabel.snp.makeConstraints { (make) in
             make.left.equalTo(iconButton.snp_right).offset(10)
             make.right.equalToSuperview().offset(-26)
-            make.centerY.equalTo(iconButton)
+            make.top.equalTo(iconButton)
             make.height.equalTo(17)
         }
         
         contentLabel.snp.makeConstraints { (make) in
-            make.top.equalTo(iconButton.snp_bottom).offset(6)
-            make.left.equalTo(48)
+            make.top.equalTo(titleLabel.snp_bottom).offset(8)
+            make.left.equalTo(titleLabel)
             make.right.equalToSuperview().offset(-14)
         }
         timeLabel.snp.makeConstraints { (make) in
@@ -78,6 +80,15 @@ class CommunityVideoMajorCommentCell: UITableViewCell {
             make.right.equalTo(contentLabel.snp_right)
             make.height.equalTo(15)
         }
+        likeCountLabel.snp.makeConstraints { (make) in
+            make.centerY.equalTo(timeLabel)
+            make.right.equalTo(-14)
+        }
+        likeButton.snp.makeConstraints { (make) in
+            make.right.equalTo(likeCountLabel.snp.left).offset(-5)
+            make.centerY.equalTo(timeLabel)
+            
+        }
         tableView.snp.remakeConstraints { (make) in
             make.top.equalTo(timeLabel.snp_bottom).offset(10)
             make.left.equalTo(contentLabel.snp_left)
@@ -125,6 +136,50 @@ class CommunityVideoMajorCommentCell: UITableViewCell {
         return timeLabel
     }()
     
+    lazy var likeButton: UIButton = {
+        let likeButton = UIButton(type: UIButton.ButtonType.custom)
+        likeButton.setImage(kImage(name: "btn_praise"), for: UIControl.State.normal)
+        likeButton.setImage(kImage(name: "btn_praise_pre_36px"), for: UIControl.State.selected)
+        likeButton.addTarget(self, action: #selector(likeAction), for: UIControl.Event.touchUpInside)
+        
+        return likeButton
+    }()
+    
+    lazy var likeCountLabel: UILabel = {
+        let likeCountLabel = UILabel()
+        likeCountLabel.textColor = k313334Color
+        likeCountLabel.font = kRegularFont14
+        likeCountLabel.addTapGesture(1, target: self, action:  #selector(likeAction))
+        
+        return likeCountLabel
+    }()
+    
+    @objc func likeAction() {
+        VirusViewModel.shared.commentlikeVirueRecordApi(button: likeButton,
+                                                        label: likeCountLabel,
+                                                        isCommentLike: communityPostCommentModel?.isLike,
+                                                        postId: communityVideoItemModel?.id,
+                                                        postAuthorUid: "\(communityVideoItemModel?.uid ?? 0)",
+            title: communityVideoItemModel?.title,
+            content: communityVideoItemModel?.content,
+            postCover: communityVideoItemModel?.img,
+            actionId: "\(communityVideoItemModel?.id ?? 0)",
+            postType: communityVideoItemModel?.type,
+            commentContent: communityPostCommentModel?.content,
+            commentId: communityPostCommentModel?.id,
+            commentUId: communityPostCommentModel?.uid,
+            commentLikeCount: communityPostCommentModel?.likeCount) {
+                [weak self] (isCommentLike) in
+                self?.communityPostCommentModel?.isLike = isCommentLike
+                if isCommentLike == 1 {
+                    self?.communityPostCommentModel?.likeCount = (self?.communityPostCommentModel?.likeCount ?? 0) + 1
+                }
+                if isCommentLike == 0 {
+                    self?.communityPostCommentModel?.likeCount = (self?.communityPostCommentModel?.likeCount ?? 0) - 1
+                }
+        }
+    }
+    
     lazy var tableView: UITableView = {
         let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
         tableView.separatorStyle = .none
@@ -153,13 +208,13 @@ class CommunityVideoMajorCommentCell: UITableViewCell {
         }
         let contentLabelHeight = communityPostCommentModel?.content?.heightForComment(font: kRegularFont14!, width: kScreenWidth - 14 - 48)
         if communityPostCommentModel?.reply?.isEmpty ?? true {
-            let subViewHeight = 24.0 + (contentLabelHeight ?? 0) + 15.0
-            let spacHeight = 6.0 + 8.0 + 20.0
+            let subViewHeight = 17.0 + (contentLabelHeight ?? 0) + 15.0
+            let spacHeight = 8.0 + 8.0 + 20.0
             communityPostCommentModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
         }else {
             let autoHeight = (contentLabelHeight ?? 0) + (tableViewHeight ?? 0)
-            let subViewHeight = 24.0 +  autoHeight + 15.0
-            let spacHeight = 6.0 + 8.0 + 10.0  + 20.0
+            let subViewHeight = 17.0 +  autoHeight + 15.0
+            let spacHeight = 8.0 + 8.0 + 10.0  + 20.0
             communityPostCommentModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
         }
     }
@@ -171,6 +226,20 @@ class CommunityVideoMajorCommentCell: UITableViewCell {
             titleLabel.text = communityPostCommentModel?.username
             contentLabel.text = communityPostCommentModel?.content
             timeLabel.text = communityPostCommentModel?.createdAt
+            let likeCount = "\(communityPostCommentModel?.likeCount ?? 0)"
+            likeCountLabel.text = likeCount
+            if communityPostCommentModel?.isLike == 1 {
+                likeButton.isSelected = true
+            }else {
+                likeButton.isSelected = false
+            }
+            if communityPostCommentModel?.isDelete == 1 {
+                likeCountLabel.isHidden = true
+                likeButton.isHidden = true
+            }else {
+                likeCountLabel.isHidden = false
+                likeButton.isHidden = false
+            }
             reloadData()
         }
     }

+ 3 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoSubCommentController/CommunityVideoSubCommentController.swift

@@ -121,8 +121,6 @@ extension CommunityVideoSubCommentController {
         }) {
             [weak self] loadingStatus in
             MJRefreshManager.mjRefreshManagerLoadingStatus(tableView: self?.tableView,loadingStatus: loadingStatus)
-
-            
         }
     }
     
@@ -192,10 +190,13 @@ extension CommunityVideoSubCommentController: UITableViewDataSource, UITableView
         case 0:
             let cell = CommunityMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
             cell.communityPostCommentModel = communityPostCommentModel
+            cell.communityVideoItemModel = communityVideoItemModel
             return cell
         default:
             let cell = CommunityReplyCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
             cell.communityPostReplyModel = communityPostReplyModels[indexPath.row]
+            cell.communityVideoItemModel = communityVideoItemModel
+
             return cell
         }