南鑫林 5 yıl önce
ebeveyn
işleme
d9b121d2c0

+ 20 - 8
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -193,6 +193,7 @@
 		A7636AC822682BAF00374F9E /* LocationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7636AC722682BAF00374F9E /* LocationView.swift */; };
 		A76390EB2248E27A0067EEE0 /* UserNotifications.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A76390EA2248E27A0067EEE0 /* UserNotifications.framework */; };
 		A7649B6922977A4300BCE9D1 /* ShopSectionHeaderModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7649B6822977A4300BCE9D1 /* ShopSectionHeaderModel.swift */; };
+		A76B786922CE04940047EC1B /* CommunityRecommendDetailHTMLTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A76B786822CE04940047EC1B /* CommunityRecommendDetailHTMLTableViewCell.swift */; };
 		A771F07C226D4E1C007999DB /* AddressPOITableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A771F07B226D4E1C007999DB /* AddressPOITableViewCell.swift */; };
 		A773D02F229FDC3B007A5751 /* DIYEmptyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A773D02E229FDC3B007A5751 /* DIYEmptyView.swift */; };
 		A775CBFE2237493600EBDCF8 /* ShoppingMallNavigationBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A775CBFD2237493600EBDCF8 /* ShoppingMallNavigationBarView.swift */; };
@@ -461,8 +462,8 @@
 		BD12204122AF8E320051C7C2 /* MessagePlanetNotiTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12204022AF8E320051C7C2 /* MessagePlanetNotiTableCell.swift */; };
 		BD12204422AF996E0051C7C2 /* MessageListController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12204322AF996E0051C7C2 /* MessageListController.swift */; };
 		BD12204622AF997E0051C7C2 /* MessageListTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12204522AF997E0051C7C2 /* MessageListTableCell.swift */; };
-		BD12B66922B47D4800AEB10B /* RecommendSubCommentCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B66822B47D4700AEB10B /* RecommendSubCommentCollectionCell.swift */; };
-		BD12B66B22B4A01300AEB10B /* RecommendSubCommentCollectionFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B66A22B4A01300AEB10B /* RecommendSubCommentCollectionFooter.swift */; };
+		BD12B66922B47D4800AEB10B /* RecommendSubCommentTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B66822B47D4700AEB10B /* RecommendSubCommentTableViewCell.swift */; };
+		BD12B66B22B4A01300AEB10B /* RecommendSubCommentTableViewFooter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B66A22B4A01300AEB10B /* RecommendSubCommentTableViewFooter.swift */; };
 		BD12B67422B4EC9700AEB10B /* KSMediaPickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B67322B4EC9700AEB10B /* KSMediaPickerController.swift */; };
 		BD12B67822B4ED9200AEB10B /* KSMediaPickerOutputModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B67722B4ED9200AEB10B /* KSMediaPickerOutputModel.swift */; };
 		BD12B67C22B4EE6D00AEB10B /* KSMediaPickerAlbumModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD12B67A22B4EE6C00AEB10B /* KSMediaPickerAlbumModel.swift */; };
@@ -865,6 +866,7 @@
 		A7636AC722682BAF00374F9E /* LocationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationView.swift; sourceTree = "<group>"; };
 		A76390EA2248E27A0067EEE0 /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
 		A7649B6822977A4300BCE9D1 /* ShopSectionHeaderModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShopSectionHeaderModel.swift; sourceTree = "<group>"; };
+		A76B786822CE04940047EC1B /* CommunityRecommendDetailHTMLTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityRecommendDetailHTMLTableViewCell.swift; sourceTree = "<group>"; };
 		A771F07B226D4E1C007999DB /* AddressPOITableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddressPOITableViewCell.swift; sourceTree = "<group>"; };
 		A773D02E229FDC3B007A5751 /* DIYEmptyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DIYEmptyView.swift; sourceTree = "<group>"; };
 		A775CBFD2237493600EBDCF8 /* ShoppingMallNavigationBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingMallNavigationBarView.swift; sourceTree = "<group>"; };
@@ -1164,8 +1166,8 @@
 		BD12204022AF8E320051C7C2 /* MessagePlanetNotiTableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessagePlanetNotiTableCell.swift; sourceTree = "<group>"; };
 		BD12204322AF996E0051C7C2 /* MessageListController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListController.swift; sourceTree = "<group>"; };
 		BD12204522AF997E0051C7C2 /* MessageListTableCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageListTableCell.swift; sourceTree = "<group>"; };
-		BD12B66822B47D4700AEB10B /* RecommendSubCommentCollectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSubCommentCollectionCell.swift; sourceTree = "<group>"; };
-		BD12B66A22B4A01300AEB10B /* RecommendSubCommentCollectionFooter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSubCommentCollectionFooter.swift; sourceTree = "<group>"; };
+		BD12B66822B47D4700AEB10B /* RecommendSubCommentTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSubCommentTableViewCell.swift; sourceTree = "<group>"; };
+		BD12B66A22B4A01300AEB10B /* RecommendSubCommentTableViewFooter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSubCommentTableViewFooter.swift; sourceTree = "<group>"; };
 		BD12B67322B4EC9700AEB10B /* KSMediaPickerController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerController.swift; sourceTree = "<group>"; };
 		BD12B67722B4ED9200AEB10B /* KSMediaPickerOutputModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerOutputModel.swift; sourceTree = "<group>"; };
 		BD12B67A22B4EE6C00AEB10B /* KSMediaPickerAlbumModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KSMediaPickerAlbumModel.swift; sourceTree = "<group>"; };
@@ -2619,6 +2621,14 @@
 			path = View;
 			sourceTree = "<group>";
 		};
+		A76B786722CE04730047EC1B /* HTMLCell */ = {
+			isa = PBXGroup;
+			children = (
+				A76B786822CE04940047EC1B /* CommunityRecommendDetailHTMLTableViewCell.swift */,
+			);
+			path = HTMLCell;
+			sourceTree = "<group>";
+		};
 		A773D02D229FD5B7007A5751 /* MainView */ = {
 			isa = PBXGroup;
 			children = (
@@ -4692,6 +4702,7 @@
 		BD2FCBE022B21C600006D974 /* View */ = {
 			isa = PBXGroup;
 			children = (
+				A76B786722CE04730047EC1B /* HTMLCell */,
 				BDAF83AE22B3B6150004BCC3 /* AllCommentCell */,
 				BDAF83A922B388F20004BCC3 /* RecommendDefaultBackCell.swift */,
 				BDAF83A722B343C50004BCC3 /* RecommendBottomCommentView.swift */,
@@ -5169,8 +5180,8 @@
 				BDAF83AF22B3B63B0004BCC3 /* RecommendCommentHeader.swift */,
 				BDAF83B122B3B67D0004BCC3 /* RecommendCommentFooter.swift */,
 				BDAF83B322B3B6DF0004BCC3 /* RecommendMajorCommentCell.swift */,
-				BD12B66822B47D4700AEB10B /* RecommendSubCommentCollectionCell.swift */,
-				BD12B66A22B4A01300AEB10B /* RecommendSubCommentCollectionFooter.swift */,
+				BD12B66822B47D4700AEB10B /* RecommendSubCommentTableViewCell.swift */,
+				BD12B66A22B4A01300AEB10B /* RecommendSubCommentTableViewFooter.swift */,
 			);
 			path = AllCommentCell;
 			sourceTree = "<group>";
@@ -5659,7 +5670,7 @@
 				A72A72BB22321DE000B21995 /* Extension+UILabel.swift in Sources */,
 				A70B2C372288177300B2449F /* ProductDetailProductLabelIconCollectionViewCell.swift in Sources */,
 				BDAF83A822B343C50004BCC3 /* RecommendBottomCommentView.swift in Sources */,
-				BD12B66B22B4A01300AEB10B /* RecommendSubCommentCollectionFooter.swift in Sources */,
+				BD12B66B22B4A01300AEB10B /* RecommendSubCommentTableViewFooter.swift in Sources */,
 				A77F2C9E2231FDDC001BD3F6 /* BaseViewController.swift in Sources */,
 				BD12B68122B4EF2600AEB10B /* KSMediaPickerViewVideoCell.swift in Sources */,
 				A7284A75225465DD000BAEC4 /* SwiftMoyaNetWorkServicePay.swift in Sources */,
@@ -5746,6 +5757,7 @@
 				A7FF1579228C82CE00A85748 /* OrderDetailViewController.swift in Sources */,
 				BD61229822C3605C00D3F513 /* AliyunResourceDownloadManager.m in Sources */,
 				A7FF159C228D9E3D00A85748 /* OrderRefundDetailModel.swift in Sources */,
+				A76B786922CE04940047EC1B /* CommunityRecommendDetailHTMLTableViewCell.swift in Sources */,
 				BD10FC0522C6F9880096A34E /* AliyunSVideoApi.m in Sources */,
 				A7C3DD1C226422D200FA262E /* SwiftMoyaNetWorkServiceSMS.swift in Sources */,
 				BDF862A2228E41CC000DEF84 /* OrderLogisticsInfoCell.swift in Sources */,
@@ -6063,7 +6075,7 @@
 				A7B4E73A228192D20012914A /* CMSTemplateModel.swift in Sources */,
 				A72A72C622321DE000B21995 /* WebView.swift in Sources */,
 				BD1FC1A622B1075F00D55081 /* LxButton.m in Sources */,
-				BD12B66922B47D4800AEB10B /* RecommendSubCommentCollectionCell.swift in Sources */,
+				BD12B66922B47D4800AEB10B /* RecommendSubCommentTableViewCell.swift in Sources */,
 				BDF862A1228E41CC000DEF84 /* OrderLogisticsController.swift in Sources */,
 				A72A73162232481600B21995 /* WeChatpayManager.swift in Sources */,
 				A7931E1822AFC1DF00297D0A /* CommunityFollowViewController.swift in Sources */,

+ 4 - 2
RainbowPlanet/RainbowPlanet/Model/CommunityModel/CommunityPostCommentsModel.swift

@@ -33,10 +33,11 @@ class CommunityPostCommentModel : NSObject, Mappable{
     var content : String?
     var createdAt : String?
     var id : Int?
-    var reply : [AnyObject]?
+    var reply : [CommunityPostReplyModel]?
     var replyCount : Int?
     var uid : Int?
     var username : String?
+    var height : CGFloat?
     
     
     class func newInstance(map: Map) -> Mappable?{
@@ -66,8 +67,9 @@ class CommunityPostReplyModel : NSObject, Mappable{
     var createdAt : String?
     var replyUsername : String?
     var uid : Int?
-    var username : AnyObject?
+    var username : String?
     var id : Int?
+    var height : CGFloat?
     
     class func newInstance(map: Map) -> Mappable?{
         return CommunityPostReplyModel()

+ 8 - 8
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/Controller/CommunityRecommendController.swift

@@ -24,6 +24,8 @@ class CommunityRecommendController: BaseViewController {
     var heightModel = HeightModel()
     /// 内容高度
     var heightModel1 = HeightModel()
+    /// 评价高度
+    var heightModel2 = HeightModel()
 
     
     override func viewDidLoad() {
@@ -149,6 +151,7 @@ class CommunityRecommendController: BaseViewController {
             [weak self] (page) in
             self?.communityPostDetailApi()
             self?.communityPostCommentApi(page: page)
+            self?.communityPostsApi(page: page)
         }
         tableView.addFooterWithWithHeader(withAutomaticallyRefresh: true) {
             [weak self] (page) in
@@ -199,7 +202,7 @@ extension CommunityRecommendController {
             }else {
                 self?.followButton.isHidden = true
             }
-            self?.communityPostsApi(page: 1)
+            self?.tableView.reloadData()
         }
     }
     
@@ -213,7 +216,7 @@ extension CommunityRecommendController {
             [weak self] (communityPostCommentsModel) -> (Void) in
             self?.communityPostCommentsModel = communityPostCommentsModel as? CommunityPostCommentsModel
             if self?.communityPostCommentsModel?.pagination?.currentPage == 1{
-                self?.communityPostDataModels.removeAll()
+                self?.communityPostCommentModels.removeAll()
             }
             self?.communityPostCommentModels = (self?.communityPostCommentModels)! + (self?.communityPostCommentsModel?.data!)!
             self?.tableView.reloadData()
@@ -290,8 +293,7 @@ extension CommunityRecommendController: UITableViewDataSource, UITableViewDelega
         case 0:
             return 1
         case 1:
-//            return communityPostCommentModels.isEmpty ? 1 : communityPostCommentModels.count
-            return 3
+            return communityPostCommentModels.isEmpty ? 1 : communityPostCommentModels.count
         case 2:
             return 1
         default:
@@ -328,9 +330,7 @@ extension CommunityRecommendController: UITableViewDataSource, UITableViewDelega
                 return cell
             }else {
                 let cell = RecommendMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
-                if indexPath.row == 2 || indexPath.row == 0 {
-                    cell.subCommentCount = 3
-                }
+                cell.communityPostCommentModel = communityPostCommentModels[indexPath.row]
                 cell.frame = tableView.bounds
                 cell.layoutIfNeeded()
                 cell.reloadData()
@@ -362,7 +362,7 @@ extension CommunityRecommendController: UITableViewDataSource, UITableViewDelega
             if communityPostCommentModels.isEmpty {
                 return 132
             }else {
-                return 0
+                return communityPostCommentModels[indexPath.row].height ?? 0
             }
         case 2:
             return heightModel.height ?? 0

+ 123 - 86
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendMajorCommentCell.swift

@@ -7,28 +7,14 @@
 //  推荐图文内容--主评论のCell
 
 import UIKit
+import RxSwift
 
 class RecommendMajorCommentCell: UITableViewCell {
     
-    var subCommentCount: Int = 0 {
-        didSet {
-            if subCommentCount != 0 {
-                self.addSubview(collectionView)
-                timeLabel.snp.remakeConstraints { (make) in
-                    make.top.equalTo(contentLabel.snp_bottom).offset(8)
-                    make.left.equalTo(titleLabel.snp_left)
-                    make.right.equalTo(contentLabel.snp_right)
-                    make.height.equalTo(15)
-                }
-                collectionView.snp.makeConstraints { (make) in
-                    make.top.equalTo(timeLabel.snp_bottom).offset(10)
-                    make.left.equalTo(contentLabel.snp_left)
-                    make.right.equalTo(contentLabel.snp_right)
-                    make.bottom.equalTo(-20)
-                }
-            }
-        }
-    }
+    let disposeBag = DisposeBag()
+    
+    /// 相关推荐高度
+    var heightModel1 = HeightModel()
     
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> RecommendMajorCommentCell {
         let ID = "RecommendMajorCommentCell"
@@ -59,46 +45,58 @@ class RecommendMajorCommentCell: UITableViewCell {
         self.selectionStyle = .none
         backgroundColor = kffffffColor
         
-        addSubview(iconImageView)
+        addSubview(iconButton)
         addSubview(titleLabel)
         addSubview(contentLabel)
         addSubview(timeLabel)
+        addSubview(tableView)
     }
     
     private func setupLayouts() {
-        iconImageView.snp.makeConstraints { (make) in
-            make.top.equalTo(10)
+        iconButton.snp.makeConstraints { (make) in
+            make.top.equalTo(0)
             make.left.equalTo(14)
             make.size.equalTo(24)
         }
         titleLabel.snp.makeConstraints { (make) in
-            make.left.equalTo(iconImageView.snp_right).offset(10)
+            make.left.equalTo(iconButton.snp_right).offset(10)
             make.right.equalToSuperview().offset(-26)
-            make.centerY.equalTo(iconImageView)
+            make.centerY.equalTo(iconButton)
             make.height.equalTo(17)
         }
+        
         contentLabel.snp.makeConstraints { (make) in
-            make.top.equalTo(titleLabel.snp_bottom).offset(10)
-            make.left.equalTo(titleLabel.snp_left)
+            make.top.equalTo(iconButton.snp_bottom).offset(6)
+            make.left.equalTo(48)
             make.right.equalToSuperview().offset(-14)
         }
         timeLabel.snp.makeConstraints { (make) in
             make.top.equalTo(contentLabel.snp_bottom).offset(8)
             make.left.equalTo(titleLabel.snp_left)
             make.right.equalTo(contentLabel.snp_right)
-            make.bottom.equalToSuperview().offset(-10)
+            make.height.equalTo(15)
+        }
+        tableView.snp.remakeConstraints { (make) in
+            make.top.equalTo(timeLabel.snp_bottom).offset(10)
+            make.left.equalTo(contentLabel.snp_left)
+            make.right.equalTo(contentLabel.snp_right)
+            make.height.equalTo(20)
         }
     }
     
-    lazy var iconImageView : UIImageView = {
-        let iconImageView = UIImageView()
-        iconImageView.image = kImage(name: "page05")
-        return iconImageView
+    private lazy var iconButton : UIButton = {
+        let iconButton = UIButton(type: UIButton.ButtonType.custom)
+        iconButton.setImage(kImage(name: "default_avatar"), for: UIControl.State.normal)
+        iconButton.cornerRadius = 12
+        iconButton.masksToBounds = true
+        iconButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            
+        }).disposed(by: disposeBag)
+        return iconButton
     }()
     
     private lazy var titleLabel: UILabel = {
         let titleLabel = UILabel()
-        titleLabel.text = "张吃饭"
         titleLabel.textColor = k999999Color
         titleLabel.font = kRegularFont14
         titleLabel.textAlignment = .left
@@ -107,7 +105,6 @@ class RecommendMajorCommentCell: UITableViewCell {
     
     private lazy var contentLabel: UILabel = {
         let contentLabel = UILabel()
-        contentLabel.text = "点击单条评时弹出选择操作框(目前仅支持回复),点击操作框后进行相应的操作"
         contentLabel.textColor = k333333Color
         contentLabel.font = kRegularFont14
         contentLabel.textAlignment = .left
@@ -117,87 +114,127 @@ class RecommendMajorCommentCell: UITableViewCell {
     
     private lazy var timeLabel: UILabel = {
         let timeLabel = UILabel()
-        timeLabel.text = "6个小时前"
         timeLabel.textColor = kbbbbbbColor
         timeLabel.font = kRegularFont12
         timeLabel.textAlignment = .left
         return timeLabel
     }()
     
-    private lazy var collectionView: UICollectionView = {
-        let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
-        collectionView.backgroundColor = kf7f8faColor
-        collectionView.delegate = self;
-        collectionView.dataSource = self;
-        collectionView.showsVerticalScrollIndicator = false
-        collectionView.showsHorizontalScrollIndicator = false
-        collectionView.bounces = false
-        collectionView.isScrollEnabled = false
-        return collectionView
+    lazy var tableView: UITableView = {
+        let tableView = UITableView(frame: CGRect.zero, style: UITableView.Style.grouped)
+        tableView.separatorStyle = .none
+        tableView.backgroundColor = kf7f8faColor
+        tableView.dataSource = self
+        tableView.delegate = self
+        tableView.estimatedSectionFooterHeight = 0
+        tableView.estimatedSectionHeaderHeight = 0
+        tableView.estimatedRowHeight = 0
+        tableView.isScrollEnabled = false
+        tableView.cornerRadius = 4
+        tableView.masksToBounds = true
+        return tableView
     }()
-    
-    private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
-        let collectionViewLayout = UICollectionViewLeftAlignedLayout.init()
-        collectionViewLayout.minimumLineSpacing = 0
-        collectionViewLayout.minimumInteritemSpacing =  0
-        collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
-        collectionViewLayout.estimatedItemSize = CGSize(width: kScreenWidth - 62, height: 50)
-        return collectionViewLayout
-    }()
-    
+    var tableViewHeight : CGFloat?
+
     //加载数据
     func reloadData() {
-        if subCommentCount != 0 {
-            //collectionView重新加载数据
-            self.collectionView.reloadData()
-            //更新collectionView的高度约束
-            let contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize
-            collectionView.snp.remakeConstraints { (make) in
-                make.top.equalTo(timeLabel.snp_bottom).offset(10)
-                make.left.equalTo(contentLabel.snp_left)
-                make.right.equalTo(contentLabel.snp_right)
-                make.bottom.equalTo(-20)
-                make.height.equalTo(contentSize.height)
-            }
-            self.collectionView.collectionViewLayout.invalidateLayout()
+        //collectionView重新加载数据
+        self.tableView.reloadData()
+        //更新collectionView的高度约束
+        let contentSize = self.tableView.contentSize
+        tableViewHeight = contentSize.height
+        tableView.snp.remakeConstraints { (make) in
+            make.top.equalTo(timeLabel.snp_bottom).offset(10)
+            make.left.equalTo(contentLabel.snp_left)
+            make.right.equalTo(contentLabel.snp_right)
+            make.height.equalTo(contentSize.height)
+        }
+        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
+            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
+            communityPostCommentModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
+        }
+    }
+    
+    var communityPostCommentModel : CommunityPostCommentModel? {
+        didSet {
+            iconButton.kf.setImage(with: kURLImage(name: communityPostCommentModel?.avatar ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
+            titleLabel.text = communityPostCommentModel?.username
+            contentLabel.text = communityPostCommentModel?.content
+            timeLabel.text = communityPostCommentModel?.createdAt
         }
     }
 }
 
-extension RecommendMajorCommentCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
-    func numberOfSections(in collectionView: UICollectionView) -> Int {
+
+// MARK: - tableView dataSource && delegate
+extension RecommendMajorCommentCell: UITableViewDataSource, UITableViewDelegate {
+    
+    func numberOfSections(in tableView: UITableView) -> Int {
         return 1
     }
     
-    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        return 2
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        let reply = communityPostCommentModel?.reply?.prefix(2)
+        return reply?.count ?? 0
     }
     
-    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        let cell = RecommendSubCommentCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        
+        let reply = communityPostCommentModel?.reply?.prefix(2)
+        let cell = RecommendSubCommentTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+        cell.communityPostReplyModel = reply?[indexPath.row]
         return cell
+        
     }
     
-    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-        print("点击了collection--\(indexPath.row)")
+    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        
     }
     
-    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
-        return CGSize(width:kScreenWidth - 62, height: 50)
+    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        let reply = communityPostCommentModel?.reply?.prefix(2)
+        return reply?[indexPath.row].height ?? 0
+    }
+    
+    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
+        return 0.000001
+
     }
     
-    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
-        if kind == UICollectionView.elementKindSectionFooter {
-            let footerView = RecommendSubCommentCollectionFooter.footerWith(collectionView: collectionView, kind: UICollectionView.elementKindSectionFooter, indexPath: indexPath)
-            return footerView
+    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
+        return UIView()
+    
+    }
+    
+    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
+        if communityPostCommentModel?.reply?.isEmpty ?? true {
+            return 0.000001
         }else {
-            return UICollectionReusableView()
-        }        
+            if  communityPostCommentModel?.reply?.count ?? 0 > 2 {
+                return 30
+            }else {
+                return 10
+            }
+        }
+        
     }
     
-    // 返回FooterView的宽高
-    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
-        return CGSize(width:kScreenWidth - 62, height: 40)
+    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
+        if  communityPostCommentModel?.reply?.count ?? 0 > 2 {
+            let footer = RecommendSubCommentTableViewFooter(frame: CGRect(x: 0, y: 0, width: kScreenWidth-48-14, height: 30))
+            footer.communityPostCommentModel = communityPostCommentModel
+            return footer
+        }else {
+            return UIView()
+        }
     }
     
 }
+

+ 0 - 109
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendSubCommentCollectionCell.swift

@@ -1,109 +0,0 @@
-//
-//  RecommendSubCommentCollectionCell.swift
-//  RainbowPlanet
-//
-//  Created by Christopher on 2019/6/15.
-//  Copyright © 2019 RainbowPlanet. All rights reserved.
-//  推荐图文内容--次级评论のCell
-
-import UIKit
-
-class RecommendSubCommentCollectionCell: UICollectionViewCell {
-    
-    class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> RecommendSubCommentCollectionCell {
-        let ID = "RecommendSubCommentCollectionCell"
-        collectionView.register(RecommendSubCommentCollectionCell.self, forCellWithReuseIdentifier: ID)
-        let cell : RecommendSubCommentCollectionCell = collectionView.dequeueReusableCell(withReuseIdentifier: ID, for: indexPath) as! RecommendSubCommentCollectionCell
-        cell.indexPath = indexPath
-        return cell
-    }
-    //MARK: - indexPath
-    var indexPath: IndexPath?{
-        didSet {
-            
-        }
-    }
-    //MARK: - 初始化
-    override init(frame: CGRect) {
-        super.init(frame: frame)
-        backgroundColor = kffffffColor
-        setupViews()
-        setupLayouts()
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        fatalError("init(coder:) has not been implemented")
-    }
-    
-    //MRAK: - 设置View
-    private func setupViews() {
-        backgroundColor = kf7f8faColor
-        
-        addSubview(iconImageView)
-        addSubview(titleLabel)
-        addSubview(contentLabel)
-        addSubview(timeLabel)
-    }
-    
-    private func setupLayouts() {
-        iconImageView.snp.makeConstraints { (make) in
-            make.top.equalTo(10)
-            make.left.equalTo(10)
-            make.size.equalTo(24)
-        }
-        titleLabel.snp.makeConstraints { (make) in
-            make.left.equalTo(iconImageView.snp_right).offset(10)
-            make.right.equalToSuperview().offset(-10)
-            make.centerY.equalTo(iconImageView)
-            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)
-        }
-        timeLabel.snp.makeConstraints { (make) in
-            make.top.equalTo(contentLabel.snp_bottom).offset(8)
-            make.left.equalTo(titleLabel.snp_left)
-            make.right.equalTo(contentLabel.snp_right)
-            make.height.equalTo(15)
-            make.bottom.equalToSuperview()
-        }
-    }
-    
-    lazy var iconImageView : UIImageView = {
-        let iconImageView = UIImageView()
-        iconImageView.image = kImage(name: "page05")
-        return iconImageView
-    }()
-    
-    private lazy var titleLabel: UILabel = {
-        let titleLabel = UILabel()
-        titleLabel.text = "Monster"
-        titleLabel.textColor = k999999Color
-        titleLabel.font = kRegularFont14
-        titleLabel.textAlignment = .left
-        return titleLabel
-    }()
-    
-    private lazy var contentLabel: UILabel = {
-        let contentLabel = UILabel()
-        contentLabel.text = "我也觉得好看"
-        contentLabel.textColor = k333333Color
-        contentLabel.font = kRegularFont14
-        contentLabel.textAlignment = .left
-        contentLabel.numberOfLines = 0
-        return contentLabel
-    }()
-    
-    lazy var timeLabel: UILabel = {
-        let timeLabel = UILabel()
-        timeLabel.text = "6个小时前"
-        timeLabel.textColor = kbbbbbbColor
-        timeLabel.font = kRegularFont12
-        timeLabel.textAlignment = .left
-        return timeLabel
-    }()
-    
-}

+ 143 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendSubCommentTableViewCell.swift

@@ -0,0 +1,143 @@
+//
+//  RecommendSubCommentCollectionCell.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/15.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  推荐图文内容--次级评论のCell
+
+import UIKit
+import RxSwift
+
+class RecommendSubCommentTableViewCell: UITableViewCell {
+    
+    let disposeBag = DisposeBag()
+    
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> RecommendSubCommentTableViewCell {
+        let ID = "RecommendSubCommentTableViewCell"
+        tableView.register(RecommendSubCommentTableViewCell.self, forCellReuseIdentifier: ID)
+        let cell : RecommendSubCommentTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! RecommendSubCommentTableViewCell
+        cell.indexPath = indexPath
+        return cell
+    }
+    
+    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+        super.init(style: style, reuseIdentifier: reuseIdentifier)
+        setupViews()
+        setupLayouts()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    var indexPath: IndexPath? {
+        didSet {
+            
+        }
+    }
+
+    
+
+    
+    //MRAK: - 设置View
+    private func setupViews() {
+        self.selectionStyle = .none
+
+        backgroundColor = kf7f8faColor
+        
+        addSubview(iconButton)
+        addSubview(titleLabel)
+        addSubview(contentLabel)
+        addSubview(timeLabel)
+    }
+    
+    private func setupLayouts() {
+        iconButton.snp.makeConstraints { (make) in
+            make.top.equalTo(10)
+            make.left.equalTo(10)
+            make.size.equalTo(24)
+        }
+        titleLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(iconButton.snp_right).offset(10)
+            make.right.equalToSuperview().offset(-10)
+            make.centerY.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)
+        }
+        timeLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(contentLabel.snp_bottom).offset(8)
+            make.left.equalTo(titleLabel.snp_left)
+            make.right.equalTo(contentLabel.snp_right)
+            make.height.equalTo(15)
+            make.bottom.equalToSuperview()
+        }
+    }
+    
+    private lazy var iconButton : UIButton = {
+        let iconButton = UIButton(type: UIButton.ButtonType.custom)
+        iconButton.setImage(kImage(name: "default_avatar"), for: UIControl.State.normal)
+        iconButton.cornerRadius = 12
+        iconButton.masksToBounds = true
+        iconButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            
+        }).disposed(by: disposeBag)
+        return iconButton
+    }()
+    
+    private lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.textColor = k999999Color
+        titleLabel.font = kRegularFont14
+        titleLabel.textAlignment = .left
+        return titleLabel
+    }()
+    
+    private lazy var contentLabel: FMLinkLabel = {
+        let contentLabel = FMLinkLabel()
+        contentLabel.textColor = k333333Color
+        contentLabel.font = kRegularFont14
+        contentLabel.textAlignment = .left
+        contentLabel.numberOfLines = 0
+        return contentLabel
+    }()
+    
+    lazy var timeLabel: UILabel = {
+        let timeLabel = UILabel()
+        timeLabel.textColor = kbbbbbbColor
+        timeLabel.font = kRegularFont12
+        timeLabel.textAlignment = .left
+        return timeLabel
+    }()
+    
+    var communityPostReplyModel: CommunityPostReplyModel? {
+        didSet {
+            iconButton.kf.setImage(with: kURLImage(name: communityPostReplyModel?.avatar ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
+            
+            titleLabel.text = communityPostReplyModel?.username
+            
+            let replyUsername = "回复 @\(communityPostReplyModel?.replyUsername ?? ""):"
+            let content = "\(communityPostReplyModel?.content ?? "")"
+            if communityPostReplyModel?.replyUsername != "" && communityPostReplyModel?.replyUsername != nil  {
+                contentLabel.text =  replyUsername + content
+                contentLabel.addClickText("@\(communityPostReplyModel?.replyUsername ?? "")", attributeds: [NSAttributedString.Key.font:kMediumFont14 as Any], transmitBody: nil) {
+                    (data) in
+                }
+            }else {
+                contentLabel.text = content
+            }
+            
+            timeLabel.text = communityPostReplyModel?.createdAt
+            let contentLabelHeight = contentLabel.text?.heightForComment(font: kRegularFont14!, width: kScreenWidth - 24 - 92)
+            let subViewHeight = 24.0 + (contentLabelHeight ?? 0) + 15.0
+            let spacHeight = 10.0 + 8.0 + 8.0
+            communityPostReplyModel?.height = CGFloat(subViewHeight) + CGFloat(spacHeight)
+        }
+    }
+    
+}

+ 12 - 32
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/AllCommentCell/RecommendSubCommentCollectionFooter.swift

@@ -7,47 +7,19 @@
 //  推荐图文内容--次级评论のFooter
 
 import UIKit
-import RxSwift
 
-class RecommendSubCommentCollectionFooter: UICollectionReusableView {
-    
-    let disposeBag = DisposeBag()
+class RecommendSubCommentTableViewFooter: BaseView {
     
     typealias UnfoldClosure = () -> Void
     var unfoldClosure : UnfoldClosure?
     
-    class func footerWith(collectionView:UICollectionView,kind: String,indexPath: IndexPath) -> RecommendSubCommentCollectionFooter {
-        let ID = "RecommendSubCommentCollectionFooter"
-        collectionView.register(RecommendSubCommentCollectionFooter.self, forSupplementaryViewOfKind: kind, withReuseIdentifier: ID)
-        let footerView : RecommendSubCommentCollectionFooter = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: ID, for: indexPath) as! RecommendSubCommentCollectionFooter
-        footerView.indexPath = indexPath
-        return footerView
-    }
-    
-    var indexPath : IndexPath? {
-        didSet {
-            
-        }
-    }
-    override init(frame: CGRect) {
-        super.init(frame: frame)
-        
-        setupViews()
-        setupLayouts()
-    }
-    
-    required init?(coder aDecoder: NSCoder) {
-        fatalError("init(coder:) has not been implemented")
-    }
-    
-    //MARK: - 设置View
-    private func setupViews() {
+    //MRAK: - 设置View
+    override func setupViews() {
         backgroundColor = kf7f8faColor
-        
         addSubview(unfoldBtn)
     }
     
-    private func setupLayouts() {
+    override func setupLayouts() {
         unfoldBtn.snp.makeConstraints { (make) in
             make.left.equalTo(44)
             make.centerY.equalToSuperview()            
@@ -68,4 +40,12 @@ class RecommendSubCommentCollectionFooter: UICollectionReusableView {
         
         return unfoldBtn
     }()
+    
+    var communityPostCommentModel : CommunityPostCommentModel? {
+        didSet {
+            unfoldBtn.setTitle("展开\(communityPostCommentModel?.reply?.count ?? 0 - 2)条回复", for: .normal)
+
+        }
+    }
+    
 }

+ 325 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/HTMLCell/CommunityRecommendDetailHTMLTableViewCell.swift

@@ -0,0 +1,325 @@
+//
+//  CommunityRecommendDetailHTMLTableViewCell.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/7/4.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import WebKit
+
+class CommunityRecommendDetailHTMLTableViewCell: UITableViewCell {
+
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> UITableViewCell {
+        let ID = "CommunityRecommendDetailHTMLTableViewCell"
+        tableView.register(CommunityRecommendDetailHTMLTableViewCell.self, forCellReuseIdentifier: ID)
+        let cell : CommunityRecommendDetailHTMLTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! CommunityRecommendDetailHTMLTableViewCell
+        cell.indexPath = indexPath
+        return cell
+    }
+    
+    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+        super.init(style: style, reuseIdentifier: reuseIdentifier)
+        setupViews()
+        setupLayouts()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    var indexPath: IndexPath? {
+        didSet {
+            
+        }
+    }
+    //MRAK: - 设置View
+    private func setupViews() {
+        self.selectionStyle = .none
+        addSubview(titleLabel)
+        addSubview(avatarbgView)
+        avatarbgView.addSubview(avatarButton)
+        avatarbgView.addSubview(nameButton)
+        avatarbgView.addSubview(followButton)
+        addSubview(beanImageView)
+        addSubview(beanLabel)
+        addSubview(timeReadLabel)
+        addSubview(webView)
+        addSubview(collectionView)
+        addSubview(locationButton)
+    }
+    
+    private func setupLayouts() {
+        titleLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(10)
+            make.right.equalTo(-14)
+            make.left.equalTo(14)
+        }
+        avatarbgView.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLabel.snp_bottom).offset(10)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(44)
+        }
+        avatarButton.snp.makeConstraints { (make) in
+            make.left.equalTo(14)
+            make.centerY.equalToSuperview()
+            make.size.equalTo(30)
+        }
+        nameButton.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalTo(avatarButton.snp.right).offset(5)
+        }
+        followButton.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.right.equalTo(-14)
+            make.height.equalTo(26)
+            make.width.equalTo(64)
+        }
+        beanLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(avatarbgView.snp_bottom).offset(10)
+            make.left.equalTo(32)
+            make.height.equalTo(16)
+        }
+        beanImageView.snp.makeConstraints { (make) in
+            make.centerY.equalTo(beanLabel)
+            make.right.equalTo(beanLabel.snp_left).offset(-3)
+        }
+        timeReadLabel.snp.makeConstraints { (make) in
+            make.centerY.equalTo(beanLabel)
+            make.left.equalTo(beanLabel.snp.right)
+        }
+        webView.snp.makeConstraints { (make) in
+            make.top.equalTo(beanLabel.snp_bottom).offset(20)
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            make.height.equalTo(10)
+        }
+        collectionView.snp.makeConstraints { (make) in
+            make.top.equalTo(webView.snp_bottom).offset(15)
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            make.height.equalTo(10)
+        }
+        locationButton.snp.makeConstraints { (make) in
+            make.left.equalTo(-14)
+            make.top.equalTo(collectionView.snp_bottom).offset(15)
+            make.height.equalTo(15)
+        }
+    }
+    
+    private lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.textColor = k262626Color
+        titleLabel.font = kMediumFont16
+        titleLabel.textAlignment = .left
+        titleLabel.numberOfLines = 0
+        return titleLabel
+    }()
+    
+    lazy var avatarbgView: UIView = {
+        let avatarbgView = UIView()
+        return avatarbgView
+    }()
+    
+    lazy var avatarButton: UIButton = {
+        let avatarButton = UIButton(type: UIButton.ButtonType.custom)
+        avatarButton.setImage(kImage(name: "default_avatar"), for: UIControl.State.normal)
+        avatarButton.cornerRadius = 15
+        avatarButton.masksToBounds = true
+        return avatarButton
+    }()
+    
+    lazy var nameButton: UIButton = {
+        let nameButton = UIButton(type: UIButton.ButtonType.custom)
+        nameButton.setTitle("昵称", for: UIControl.State.normal)
+        nameButton.setTitleColor(k262626Color, for: UIControl.State.normal)
+        nameButton.titleLabel?.font = kRegularFont14
+        return nameButton
+    }()
+    
+    lazy var followButton: UIButton = {
+        let followButton = UIButton(type: UIButton.ButtonType.custom)
+        followButton.titleLabel?.font = kMediumFont13
+        followButton.cornerRadius = 12
+        followButton.masksToBounds = true
+        followButton.layer.borderWidth = 0.5
+        followButton.isHidden = true
+        return followButton
+    }()
+    
+    private lazy var beanImageView : UIImageView = {
+        let beanImageView = UIImageView()
+        beanImageView.image = kImage(name: "navbar_bean_org")
+        return beanImageView
+    }()
+    
+    private lazy var beanLabel: UILabel = {
+        let beanLabel = UILabel()
+        beanLabel.textColor = kFFA42FColor
+        beanLabel.font = kRegularFont13
+        beanLabel.textAlignment = .left
+        return beanLabel
+    }()
+    
+    private lazy var timeReadLabel: UILabel = {
+        let timeReadLabel = UILabel()
+        timeReadLabel.textColor = kbbbbbbColor
+        timeReadLabel.font = kRegularFont12
+        timeReadLabel.textAlignment = .left
+        return timeReadLabel
+    }()
+    
+    lazy var webView: WKWebView = {
+        let webView = WKWebView()
+//        webView.scrollView.isScrollEnabled = false
+        webView.scrollView.bounces = false
+        webView.scrollView.showsVerticalScrollIndicator = false
+        webView.autoresizingMask = UIView.AutoresizingMask.flexibleHeight
+        webView.scrollView.addObserver(self, forKeyPath: "contentSize", options: NSKeyValueObservingOptions.new, context: nil)
+        return webView
+    }()
+    
+    private lazy var collectionView: UICollectionView = {
+        let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
+        collectionView.backgroundColor = kffffffColor
+        collectionView.delegate = self
+        collectionView.dataSource = self
+        collectionView.showsVerticalScrollIndicator = false
+        collectionView.showsHorizontalScrollIndicator = false
+        collectionView.bounces = false
+        collectionView.isScrollEnabled = false
+        return collectionView
+    }()
+    
+    private lazy var collectionViewLayout: UICollectionViewLeftAlignedLayout = {
+        let collectionViewLayout = UICollectionViewLeftAlignedLayout.init()
+        collectionViewLayout.minimumLineSpacing = 10
+        collectionViewLayout.minimumInteritemSpacing =  10
+        collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
+        collectionViewLayout.estimatedItemSize = CGSize(width: ((kScreenWidth - 28) - 30)/4, height: 24)
+        collectionViewLayout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
+        return collectionViewLayout
+    }()
+    
+    lazy var locationButton: UIButton = {
+        let locationButton = UIButton(type: UIButton.ButtonType.custom)
+        locationButton.setImage(kImage(name: "btn_address"), for: UIControl.State.normal)
+        locationButton.setTitleColor(kbbbbbbColor, for: UIControl.State.normal)
+        locationButton.titleLabel?.font = kRegularFont12
+        return locationButton
+    }()
+    
+    var collectionViewheight : CGFloat = 0
+    //加载数据
+    func reloadData() {
+        //collectionView重新加载数据
+        self.collectionView.reloadData()
+        //更新collectionView的高度约束
+        let contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize
+        collectionViewheight = contentSize.height
+        collectionView.snp.remakeConstraints { (make) in
+            make.top.equalTo(webView.snp_bottom).offset(15)
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            make.height.equalTo(contentSize.height)
+            make.bottom.lessThanOrEqualToSuperview()
+        }
+        self.collectionView.collectionViewLayout.invalidateLayout()
+    }
+    
+    var communityPostDetailModel : CommunityPostDetailModel? {
+        didSet {
+            
+            avatarButton.kf.setImage(with: kURLImage(name: communityPostDetailModel?.avatar ?? ""), for: UIControl.State.normal, placeholder: kImage(name: "default_avatar"))
+            nameButton.setTitle(communityPostDetailModel?.username, for: UIControl.State.normal)
+            CommunityFollowUserViewModel.shared.setFollowType(followButton: followButton, followType: FollowType(rawValue: communityPostDetailModel?.isFollow ?? 0) ?? .futureFollow)
+            beanLabel.text = "\(communityPostDetailModel?.availableBean ?? 0)彩虹豆待收获"
+            timeReadLabel.text = "I \(communityPostDetailModel?.createdAt ?? "") I 阅读·\(communityPostDetailModel?.pv ?? 0)"
+            webView.load(URLRequest(url: URL(string: communityPostDetailModel?.descUrl ?? "")!))
+            
+            
+            if communityPostDetailModel?.title == nil || communityPostDetailModel?.title == "" {
+                avatarbgView.snp.remakeConstraints { (make) in
+                    make.top.equalTo(0)
+                    make.height.equalTo(44)
+                    make.left.right.equalToSuperview()
+                }
+            }else {
+                titleLabel.snp.makeConstraints { (make) in
+                    make.top.equalTo(10)
+                    make.right.equalTo(-14)
+                    make.left.equalTo(14)
+                }
+                avatarbgView.snp.makeConstraints { (make) in
+                    make.top.equalTo(titleLabel.snp_bottom).offset(10)
+                    make.left.right.equalToSuperview()
+                    make.height.equalTo(44)
+                }
+                titleLabel.text = communityPostDetailModel?.title
+            }
+            
+            if communityPostDetailModel?.location == nil || communityPostDetailModel?.location == "" {
+                locationButton.isHidden = true
+            }else {
+                locationButton.isHidden = false
+                locationButton.setTitle(communityPostDetailModel?.location, for: UIControl.State.normal)
+                locationButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 3)
+            }
+        }
+    }
+    
+    var webViewCellHeight : CGFloat?
+    
+    var heightModel : HeightModel? {
+        didSet {
+            let contentLabelHeight = communityPostDetailModel?.content?.heightForComment(font: kRegularFont15!, width: kScreenWidth - 28)
+            let subViewHeight = 24.0 + (contentLabelHeight ?? 0) + collectionViewheight + 15.0
+            if communityPostDetailModel?.title == nil || communityPostDetailModel?.title == "" {
+                
+                let spacHeight = 20.0 + 10.0 + 15.0 + 15.0 + 20.0
+                heightModel?.height = subViewHeight + CGFloat(spacHeight)
+            }else {
+                let titleHeight = communityPostDetailModel?.title?.heightForComment(font: kMediumFont16!, width: kScreenWidth - 28)
+                let spacHeight = 20.0 + 10.0 + 10.0 + 15.0 + 15.0 + 20.0
+                heightModel?.height = subViewHeight + CGFloat(spacHeight) + (titleHeight ?? 0)
+            }
+        }
+    }
+
+}
+
+extension CommunityRecommendDetailHTMLTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
+    func numberOfSections(in collectionView: UICollectionView) -> Int {
+        return 1
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+        return communityPostDetailModel?.topic?.count ?? 0
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        let cell = CommunityTagCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        cell.communityPostDetailTopicModel = communityPostDetailModel?.topic?[indexPath.row]
+        return cell
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        let communityPostDetailTopicModel = communityPostDetailModel?.topic?[indexPath.row]
+        if let id = communityPostDetailTopicModel?.id {
+            let vc = CommunityFeaturedTopicsViewController()
+            vc.id = id
+            findViewController().navigationController?.pushViewController(vc, animated: true)
+        }
+    }
+}
+
+extension CommunityRecommendDetailHTMLTableViewCell {
+    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
+        if keyPath == "contentSize" {
+            webViewCellHeight = self.webView.scrollView.contentSize.height
+        }
+    }
+}
+
+