瀏覽代碼

评论参数传递

Chris 5 年之前
父節點
當前提交
99e8769bcc

+ 35 - 6
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityAllCommentView.swift

@@ -21,13 +21,11 @@ class CommunityAllCommentView: FWPopupView {
     typealias ConfirmPayBlock = (_ pType: PayType) -> Void
     var confirmPayBlock : ConfirmPayBlock?
     
-    var curPayType : PayType = PayType.wechatPay
+    var postId: Int?
     
-    var paymentAmount:String? {
-        didSet {
-            tableView.reloadData()
-        }
-    }
+    // 评论
+    var communityPostCommentsModel : CommunityPostCommentsModel?
+    var communityPostCommentModels = Array<CommunityPostCommentModel>()
     
     override init(frame: CGRect) {
         super.init(frame: frame)
@@ -39,6 +37,7 @@ class CommunityAllCommentView: FWPopupView {
         addSubview(tableView)
         
         setupLayouts()
+        setupData()
     }
     
     required init?(coder aDecoder: NSCoder) {
@@ -68,6 +67,17 @@ class CommunityAllCommentView: FWPopupView {
         }
     }
     
+    func setupData() {
+        tableView.addHeaderWithHeader(withBeginRefresh: true, animation: false) {
+            [weak self] (page) in
+            self?.communityPostCommentApi(page: page)
+        }
+        tableView.addFooterWithWithHeader(withAutomaticallyRefresh: true) {
+            [weak self] (page) in
+            
+        }
+    }
+    
     private lazy var topView: UIView = {
         let topView = UIView()
         topView.backgroundColor = kffffffColor
@@ -148,3 +158,22 @@ extension CommunityAllCommentView : UITableViewDelegate, UITableViewDataSource {
     }
     
 }
+
+extension CommunityAllCommentView {
+    /// 评论
+    ///
+    /// - Parameters:
+    ///   - postId: 内容id
+    ///   - page: 分页
+    func communityPostCommentApi(page:Int) {
+        SwiftMoyaNetWorkServiceCommunity.shared().communityPostCommentApi(postId: postId ?? 0, page: page) {
+            [weak self] (communityPostCommentsModel) -> (Void) in
+//            self?.communityPostCommentsModel = communityPostCommentsModel as? CommunityPostCommentsModel
+//            if self?.communityPostCommentsModel?.pagination?.currentPage == 1{
+//                self?.communityPostCommentModels.removeAll()
+//            }
+//            self?.communityPostCommentModels = (self?.communityPostCommentModels)! + (self?.communityPostCommentsModel?.data!)!
+//            self?.tableView.reloadData()
+        }
+    }
+}

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/ViewController/CommunityVideoListController.swift

@@ -209,7 +209,7 @@ extension CommunityVideoListController {
     
     func showCommentView() {
         
-        AlertSheetView.commentAlertSheetView(paymentAmount: "20", cancelClosure: {
+        AlertSheetView.commentAlertSheetView(postId: contentId ?? 0, cancelClosure: {
             [weak self] in
             
         }) {

+ 2 - 2
RainbowPlanet/RainbowPlanet/Tools/AlertSheetView/AlertSheetView.swift

@@ -114,9 +114,9 @@ class AlertSheetView: NSObject {
     }
     
     /// 自定义评论View
-    class func commentAlertSheetView(paymentAmount:String, cancelClosure:@escaping () -> Void, sureClosure:@escaping (_ pType: PayType) -> Void) {
+    class func commentAlertSheetView(postId:Int, cancelClosure:@escaping () -> Void, sureClosure:@escaping (_ pType: PayType) -> Void) {
         let commentView = CommunityAllCommentView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: kSafeTabBarHeight + 500))
-        commentView.paymentAmount = paymentAmount
+        commentView.postId = postId
         let vProperty = FWPopupViewProperty()
         vProperty.popupCustomAlignment = .bottomCenter
         vProperty.popupAnimationType = .frame