浏览代码

推荐详情 -- to be continued

Chris 5 年之前
父节点
当前提交
f687c8c00d

+ 16 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -410,6 +410,10 @@
 		BDAA40FB228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40FA228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift */; };
 		BDAA40FD228E9CD600CF841D /* OrderApplyRefundPhoneCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40FC228E9CD600CF841D /* OrderApplyRefundPhoneCell.swift */; };
 		BDAA40FF228EA37900CF841D /* OrderApplyRefundPhotoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAA40FE228EA37900CF841D /* OrderApplyRefundPhotoCell.swift */; };
+		BDAF83A222B330540004BCC3 /* RecommendSimilarCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAF83A122B330540004BCC3 /* RecommendSimilarCell.swift */; };
+		BDAF83A622B334D90004BCC3 /* RecommendSimilarCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAF83A522B334D90004BCC3 /* RecommendSimilarCollectionCell.swift */; };
+		BDAF83A822B343C50004BCC3 /* RecommendBottomCommentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAF83A722B343C50004BCC3 /* RecommendBottomCommentView.swift */; };
+		BDAF83AA22B388F20004BCC3 /* RecommendDefaultBackCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDAF83A922B388F20004BCC3 /* RecommendDefaultBackCell.swift */; };
 		BDD22F0B228FAA5B00D43BFB /* ImageUrlModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDD22F0A228FAA5B00D43BFB /* ImageUrlModel.swift */; };
 		BDD4FB1222840597006FE833 /* ShoppingCartPayOrderController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDD4FB1122840597006FE833 /* ShoppingCartPayOrderController.swift */; };
 		BDD4FB1422840954006FE833 /* ShoppingCartOrderPayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDD4FB1322840954006FE833 /* ShoppingCartOrderPayView.swift */; };
@@ -880,6 +884,10 @@
 		BDAA40FA228E9CC300CF841D /* OrderApplyRefundNoteInfoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundNoteInfoCell.swift; sourceTree = "<group>"; };
 		BDAA40FC228E9CD600CF841D /* OrderApplyRefundPhoneCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundPhoneCell.swift; sourceTree = "<group>"; };
 		BDAA40FE228EA37900CF841D /* OrderApplyRefundPhotoCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderApplyRefundPhotoCell.swift; sourceTree = "<group>"; };
+		BDAF83A122B330540004BCC3 /* RecommendSimilarCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSimilarCell.swift; sourceTree = "<group>"; };
+		BDAF83A522B334D90004BCC3 /* RecommendSimilarCollectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendSimilarCollectionCell.swift; sourceTree = "<group>"; };
+		BDAF83A722B343C50004BCC3 /* RecommendBottomCommentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendBottomCommentView.swift; sourceTree = "<group>"; };
+		BDAF83A922B388F20004BCC3 /* RecommendDefaultBackCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecommendDefaultBackCell.swift; sourceTree = "<group>"; };
 		BDD22F0A228FAA5B00D43BFB /* ImageUrlModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageUrlModel.swift; sourceTree = "<group>"; };
 		BDD4FB1122840597006FE833 /* ShoppingCartPayOrderController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartPayOrderController.swift; sourceTree = "<group>"; };
 		BDD4FB1322840954006FE833 /* ShoppingCartOrderPayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartOrderPayView.swift; sourceTree = "<group>"; };
@@ -3303,10 +3311,14 @@
 		BD2FCBE022B21C600006D974 /* View */ = {
 			isa = PBXGroup;
 			children = (
+				BDAF83A922B388F20004BCC3 /* RecommendDefaultBackCell.swift */,
 				BD2FCBE322B244250006D974 /* RecommendDetailContentCell.swift */,
 				BD2FCBE522B2586C0006D974 /* CommunityTagCollectionCell.swift */,
 				BD2FCBE922B267280006D974 /* RecommendNoneCommentCell.swift */,
 				BD2FCBEB22B274020006D974 /* RecommendCommentCell.swift */,
+				BDAF83A122B330540004BCC3 /* RecommendSimilarCell.swift */,
+				BDAF83A522B334D90004BCC3 /* RecommendSimilarCollectionCell.swift */,
+				BDAF83A722B343C50004BCC3 /* RecommendBottomCommentView.swift */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -3792,6 +3804,7 @@
 				A72A72C522321DE000B21995 /* WKWebViewConfig.swift in Sources */,
 				A72A72BB22321DE000B21995 /* Extension+UILabel.swift in Sources */,
 				A70B2C372288177300B2449F /* ProductDetailProductLabelIconCollectionViewCell.swift in Sources */,
+				BDAF83A822B343C50004BCC3 /* RecommendBottomCommentView.swift in Sources */,
 				A77F2C9E2231FDDC001BD3F6 /* BaseViewController.swift in Sources */,
 				A7284A75225465DD000BAEC4 /* SwiftMoyaNetWorkServicePay.swift in Sources */,
 				A77F2CC722320627001BD3F6 /* WRNavigationBar.swift in Sources */,
@@ -3892,6 +3905,7 @@
 				A75C474E22938B3900139C0C /* OrderFreightTableViewCell.swift in Sources */,
 				A7FF1592228C918100A85748 /* OrderRefunddetailsStatusTableViewCell.swift in Sources */,
 				A7CC74E62270628B003C4F38 /* DeliveryMethodTypeModel.swift in Sources */,
+				BDAF83A222B330540004BCC3 /* RecommendSimilarCell.swift in Sources */,
 				BDAA40FD228E9CD600CF841D /* OrderApplyRefundPhoneCell.swift in Sources */,
 				BD2FCBE222B21CF70006D974 /* CommunityRecommendController.swift in Sources */,
 				A71AA51F22729F35008FF1A5 /* AuthorizationSwift.swift in Sources */,
@@ -3922,6 +3936,7 @@
 				A7FF156A228C6E3600A85748 /* OrderProductTableViewCell.swift in Sources */,
 				A7931DF022AF4C9100297D0A /* BaseBouncesContentView.swift in Sources */,
 				A715333E22980CC60017C861 /* ConfigModel.swift in Sources */,
+				BDAF83A622B334D90004BCC3 /* RecommendSimilarCollectionCell.swift in Sources */,
 				A70EBBC022561179000AD74F /* Extension+UITableView.swift in Sources */,
 				A72A72B022321DE000B21995 /* CGView.swift in Sources */,
 				A7A98E0B227EBD04005306E9 /* CategorySearchView.swift in Sources */,
@@ -4071,6 +4086,7 @@
 				A7CC74E222704429003C4F38 /* MineServiceCollectionViewCell.swift in Sources */,
 				A738D202225AD6AD00EEE860 /* Extension+UICollectionView.swift in Sources */,
 				A7CC74D6226FF421003C4F38 /* MineNavigationBarView.swift in Sources */,
+				BDAF83AA22B388F20004BCC3 /* RecommendDefaultBackCell.swift in Sources */,
 				A71AF0BC226F099B001730FE /* ProductHBigTableViewCell.swift in Sources */,
 				BD108C9622A60C2100837DAB /* HGImagePickerCell.swift in Sources */,
 				A7A98E3C228036D7005306E9 /* ShoppingMallCategoryCollectionViewCell.swift in Sources */,

+ 48 - 5
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/Controller/CommunityRecommendController.swift

@@ -20,14 +20,21 @@ class CommunityRecommendController: BaseViewController {
         navigationBar.title = "推荐详情"
         view.backgroundColor = kf7f8faColor
         
+        view.addSubview(commentView)
         view.addSubview(tableView)
     }
     
     override func setupLayouts() {
+        commentView.snp.makeConstraints { (make) in
+            make.left.right.equalToSuperview()
+            make.height.equalTo(48)
+            make.bottom.equalToSuperview().offset(-kSafeTabBarHeight)
+        }
         tableView.snp.makeConstraints { (make) in
             make.top.equalToSuperview().offset(kNavBarTotalHeight)
-            make.left.right.bottom.equalTo(0)
-        }
+            make.left.right.equalToSuperview()
+            make.bottom.equalTo(commentView.snp_top).offset(0)
+        }        
     }
     
     override func setupData() {
@@ -46,13 +53,31 @@ class CommunityRecommendController: BaseViewController {
         return tableView
     }()
     
+    lazy var commentView: RecommendBottomCommentView = {
+        let commentView = RecommendBottomCommentView()
+        commentView.bottomClickClosure = {
+            [weak self] (clickType) in
+            switch clickType {
+            case BottomClickType.typeComment:
+                print("添加评论")
+            case BottomClickType.typeLike:
+                print("添加喜欢")
+            case BottomClickType.typeCollect:
+                print("添加收藏")
+            default:
+                print("添加收藏")
+            }
+        }
+        return commentView
+    }()
+    
 }
 
 // MARK: - tableView dataSource && delegate
 extension CommunityRecommendController: UITableViewDataSource, UITableViewDelegate {
     
     func numberOfSections(in tableView: UITableView) -> Int {
-        return 2
+        return 4
     }
     
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
@@ -62,7 +87,7 @@ extension CommunityRecommendController: UITableViewDataSource, UITableViewDelega
         case 1:
             return 1
         case 2:
-            return 3
+            return 1
         default:
             return 1
         }
@@ -79,7 +104,17 @@ extension CommunityRecommendController: UITableViewDataSource, UITableViewDelega
             let cell = RecommendNoneCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
             return cell
         case 2:
-            return UITableViewCell()
+            let cell = RecommendDefaultBackCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.jumpClosure = {
+                [weak self] in
+                print("跳转至首页")
+            }
+            return cell
+        case 3:
+            let cell = RecommendSimilarCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.layoutIfNeeded()
+            cell.reloadData()
+            return cell
         default:
             return UITableViewCell()
         }
@@ -90,6 +125,10 @@ extension CommunityRecommendController: UITableViewDataSource, UITableViewDelega
     }
     
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        // testt
+        if indexPath.section == 2 {
+            return 312
+        }
         return UITableView.automaticDimension
     }
     
@@ -97,4 +136,8 @@ extension CommunityRecommendController: UITableViewDataSource, UITableViewDelega
         return 10
     }
     
+    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
+        return 0
+    }
+    
 }

+ 146 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/RecommendBottomCommentView.swift

@@ -0,0 +1,146 @@
+//
+//  RecommendBottomCommentView.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/14.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  推荐图文内容--底部评论View
+
+import UIKit
+import RxSwift
+
+enum BottomClickType {
+    case typeComment
+    case typeLike
+    case typeCollect
+}
+
+class RecommendBottomCommentView: BaseView {
+    
+    typealias BottomClickClosure = (_ clickType: BottomClickType) -> Void
+    var bottomClickClosure : BottomClickClosure?
+    
+    override func setupViews() {
+        self.backgroundColor = kffffffColor
+        
+        addSubview(commentView)
+        commentView.addSubview(commentLabel)
+        commentView.addSubview(textBtn)
+        addSubview(likeBtn)
+        addSubview(collectBtn)
+        addSubview(commentBtn)
+    }
+    
+    override func setupLayouts() {
+        commentBtn.snp.makeConstraints { (make) in
+            make.right.equalToSuperview().offset(-14)
+            make.centerY.equalToSuperview()
+            make.height.equalTo(24)
+        }
+        commentBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 5)
+        
+        collectBtn.snp.makeConstraints { (make) in
+            make.right.equalTo(commentBtn.snp_left).offset(-15)
+            make.centerY.equalToSuperview()
+            make.height.equalTo(37)
+        }
+        collectBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 5)
+        
+        likeBtn.snp.makeConstraints { (make) in
+            make.right.equalTo(collectBtn.snp_left).offset(-15)
+            make.centerY.equalToSuperview()
+            make.height.equalTo(37)
+        }
+        likeBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 5)
+        
+        commentView.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalToSuperview().offset(14)
+            make.right.equalTo(likeBtn.snp_left).offset(-10)
+            make.height.equalTo(28)
+        }
+        commentLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(15)
+            make.centerY.equalToSuperview()
+            make.width.equalTo(70)
+            make.height.equalTo(28)
+        }
+        textBtn.snp.makeConstraints { (make) in
+            make.edges.equalToSuperview()
+        }
+        
+    }
+    
+    private lazy var commentView: UIView = {
+        let commentView = UIView()
+        commentView.backgroundColor = kfafafaColor
+        commentView.cornerRadius = 15
+        commentView.masksToBounds = true
+        return commentView
+    }()
+    
+    private lazy var commentLabel: UILabel = {
+        let commentLabel = UILabel()
+        commentLabel.text = "添加评论..."
+        commentLabel.textColor = k999999Color
+        commentLabel.font = kRegularFont14
+        return commentLabel
+    }()
+    
+    private lazy var textBtn: UIButton = {
+        let textBtn = UIButton(type: UIButton.ButtonType.custom)
+        textBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
+            if let bottomClickClosure = self?.bottomClickClosure {
+                bottomClickClosure(BottomClickType.typeComment)
+            }
+        }).disposed(by: disposeBag)
+        return textBtn
+    }()
+    
+    private lazy var likeBtn: UIButton = {
+        let likeBtn = UIButton(type: UIButton.ButtonType.custom)
+        likeBtn.setTitle("8844", for: UIControl.State.normal)
+        likeBtn.setTitleColor(k313334Color, for: UIControl.State.normal)
+        likeBtn.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
+        likeBtn.setImage(kImage(name: "common_check_icon"), for: UIControl.State.selected)
+        likeBtn.titleLabel?.font = kRegularFont14
+        likeBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
+            likeBtn.isSelected = !likeBtn.isSelected
+            if let bottomClickClosure = self?.bottomClickClosure {
+                bottomClickClosure(BottomClickType.typeLike)
+            }
+        }).disposed(by: disposeBag)
+        return likeBtn
+    }()
+    
+    private lazy var collectBtn: UIButton = {
+        let collectBtn = UIButton(type: UIButton.ButtonType.custom)
+        collectBtn.setTitle("6124", for: UIControl.State.normal)
+        collectBtn.setTitleColor(k313334Color, for: UIControl.State.normal)
+        collectBtn.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
+        collectBtn.setImage(kImage(name: "common_check_icon"), for: UIControl.State.selected)
+        collectBtn.titleLabel?.font = kRegularFont14
+        collectBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
+            collectBtn.isSelected = !collectBtn.isSelected
+            if let bottomClickClosure = self?.bottomClickClosure {
+                bottomClickClosure(BottomClickType.typeCollect)
+            }
+        }).disposed(by: disposeBag)
+        return collectBtn
+    }()
+    
+    private lazy var commentBtn: UIButton = {
+        let commentBtn = UIButton(type: UIButton.ButtonType.custom)
+        commentBtn.setTitle("5178", for: UIControl.State.normal)
+        commentBtn.setTitleColor(k313334Color, for: UIControl.State.normal)
+        commentBtn.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
+        commentBtn.titleLabel?.font = kRegularFont14
+        commentBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
+            if let bottomClickClosure = self?.bottomClickClosure {
+                bottomClickClosure(BottomClickType.typeComment)
+            }
+        }).disposed(by: disposeBag)
+        return commentBtn
+    }()
+    
+}

+ 103 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/RecommendDefaultBackCell.swift

@@ -0,0 +1,103 @@
+//
+//  RecommendDefaultBackCell.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/14.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  推荐图文内容--缺省Cell
+
+import UIKit
+import RxSwift
+
+class RecommendDefaultBackCell: UITableViewCell {
+    
+    let disposeBag = DisposeBag()
+    
+    typealias JumpClosure = () -> Void
+    var jumpClosure : JumpClosure?
+    
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> RecommendDefaultBackCell {
+        let ID = "RecommendDefaultBackCell"
+        tableView.register(RecommendDefaultBackCell.self, forCellReuseIdentifier: ID)
+        let cell : RecommendDefaultBackCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! RecommendDefaultBackCell
+        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 = kffffffColor
+        
+        addSubview(backImageView)
+        addSubview(contentLabel)
+        addSubview(jumpBtn)
+    }
+    
+    private func setupLayouts() {        
+        backImageView.snp.makeConstraints { (make) in
+            make.top.equalTo(50)
+            make.centerX.equalToSuperview()
+            make.size.equalTo(120)
+        }
+        contentLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(backImageView.snp_bottom).offset(20)
+            make.centerX.equalToSuperview()
+            make.height.equalTo(20)
+        }
+        jumpBtn.snp.makeConstraints { (make) in
+            make.top.equalTo(contentLabel.snp_bottom).offset(20)
+            make.centerX.equalToSuperview()
+            make.width.equalTo(180)
+            make.height.equalTo(32)
+        }
+    }
+    
+    private lazy var backImageView : UIImageView = {
+        let backImageView = UIImageView()
+        backImageView.image = kImage(name: "page05")
+        return backImageView
+    }()
+    
+    private lazy var contentLabel: UILabel = {
+        let contentLabel = UILabel()
+        contentLabel.text = "内容飞走了,去看看别的吧"
+        contentLabel.textColor = k666666Color
+        contentLabel.font = kRegularFont14
+        contentLabel.textAlignment = .center
+        return contentLabel
+    }()
+    
+    private lazy var jumpBtn: UIButton = {
+        let jumpBtn = UIButton(type: UIButton.ButtonType.custom)
+        jumpBtn.backgroundColor = k62cc74Color
+        jumpBtn.setTitle("去首页", for: .normal)
+        jumpBtn.setTitleColor(kffffffColor, for: .normal)
+        jumpBtn.titleLabel?.font = kMediumFont16
+        jumpBtn.cornerRadius = 16
+        jumpBtn.masksToBounds = true
+        jumpBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
+            if let jumpClosure = self?.jumpClosure {
+                jumpClosure()
+            }
+        }).disposed(by: disposeBag)
+        return jumpBtn
+    }()
+    
+}

+ 0 - 4
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/RecommendDetailContentCell.swift

@@ -22,8 +22,6 @@ class RecommendDetailContentCell: UITableViewCell {
         super.init(style: style, reuseIdentifier: reuseIdentifier)
         setupViews()
         setupLayouts()
-        
-//        collectionView.reloadData()
     }
     
     required init?(coder aDecoder: NSCoder) {
@@ -173,7 +171,6 @@ class RecommendDetailContentCell: UITableViewCell {
         let collectionViewLayout = UICollectionViewLeftAlignedLayout.init()
         collectionViewLayout.minimumLineSpacing = 10
         collectionViewLayout.minimumInteritemSpacing =  10
-//        collectionViewLayout.sectionInset = UIEdgeInsets(top: 10, left: 14, bottom: 10, right: 14)
         collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
         collectionViewLayout.estimatedItemSize = CGSize(width: ((kScreenWidth - 28) - 3*10)/4, height: 24)
         return collectionViewLayout
@@ -215,4 +212,3 @@ extension RecommendDetailContentCell: UICollectionViewDelegateFlowLayout,UIColle
     }
     
 }
-

+ 128 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/RecommendSimilarCell.swift

@@ -0,0 +1,128 @@
+//
+//  RecommendSimilarCell.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/14.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  推荐图文内容--相关推荐のCell
+
+import UIKit
+
+class RecommendSimilarCell: UITableViewCell {
+    
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> RecommendSimilarCell {
+        let ID = "RecommendSimilarCell"
+        tableView.register(RecommendSimilarCell.self, forCellReuseIdentifier: ID)
+        let cell : RecommendSimilarCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! RecommendSimilarCell
+        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(titleLabel)
+        addSubview(collectionView)
+    }
+    
+    private func setupLayouts() {
+        titleLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(10)
+            make.left.equalTo(14)
+            make.right.equalTo(-14)            
+            make.height.equalTo(22)
+        }
+        collectionView.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLabel.snp_bottom).offset(20)
+            make.left.equalTo(5)
+            make.right.equalTo(-5)
+            make.bottom.equalTo(0)
+        }
+    }
+    
+    private lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.text = "相关推荐"
+        titleLabel.textColor = k333333Color
+        titleLabel.font = kMediumFont18
+        titleLabel.textAlignment = .left
+        return titleLabel
+    }()
+    
+    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
+    }()
+    
+    private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
+        let collectionViewLayout = UICollectionViewLeftAlignedLayout.init()
+        collectionViewLayout.minimumLineSpacing = 5
+        collectionViewLayout.minimumInteritemSpacing =  5
+                collectionViewLayout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 20, right: 0)
+        collectionViewLayout.scrollDirection = UICollectionView.ScrollDirection.vertical
+        collectionViewLayout.estimatedItemSize = CGSize(width: ((kScreenWidth - 10) - 5)/2, height: 250)
+        return collectionViewLayout
+    }()
+    
+    //加载数据
+    func reloadData() {
+        //collectionView重新加载数据
+        self.collectionView.reloadData()
+        //更新collectionView的高度约束
+        let contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize
+        collectionView.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLabel.snp_bottom).offset(20)
+            make.left.equalTo(5)
+            make.right.equalTo(-5)
+            make.bottom.equalTo(0)
+            make.height.equalTo(contentSize.height)
+        }
+        self.collectionView.collectionViewLayout.invalidateLayout()
+    }
+    
+}
+
+extension RecommendSimilarCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
+    func numberOfSections(in collectionView: UICollectionView) -> Int {
+        return 1
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+        return 5
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        let cell = RecommendSimilarCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        return cell
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        print("点击了collection----\(indexPath.row)")
+    }
+    
+}

+ 130 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityRecommendDetail/View/RecommendSimilarCollectionCell.swift

@@ -0,0 +1,130 @@
+//
+//  RecommendSimilarCollectionCell.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/14.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  相关推荐のCollectionCell
+
+import UIKit
+import RxSwift
+
+class RecommendSimilarCollectionCell: UICollectionViewCell {
+    
+    let disposeBag = DisposeBag()
+    
+    typealias LikeSelectBlock = (_ isLiked: Int) -> Void
+    var likeSelectBlock : LikeSelectBlock?
+    
+    class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> RecommendSimilarCollectionCell {
+        let ID = "RecommendSimilarCollectionCell"
+        collectionView.register(RecommendSimilarCollectionCell.self, forCellWithReuseIdentifier: ID)
+        let cell : RecommendSimilarCollectionCell = collectionView.dequeueReusableCell(withReuseIdentifier: ID, for: indexPath) as! RecommendSimilarCollectionCell
+        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() {
+        addSubview(contentImageView)
+        addSubview(titleLabel)
+        addSubview(iconImageView)
+        addSubview(nameLabel)
+        addSubview(likeBtn)
+    }
+    
+    private func setupLayouts() {
+        contentImageView.snp.makeConstraints { (make) in
+            make.top.left.right.equalToSuperview()
+        }
+        titleLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(contentImageView.snp_bottom).offset(15)
+            make.left.equalTo(10)
+            make.right.equalTo(-10)
+        }
+        iconImageView.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLabel.snp_bottom).offset(10)
+            make.left.equalToSuperview().offset(10)
+            make.bottom.equalToSuperview().offset(-15)
+            make.size.equalTo(18)
+        }
+        likeBtn.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLabel.snp_bottom).offset(12)
+            make.right.equalTo(-13)
+            make.height.equalTo(15)
+        }
+        likeBtn.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.left, imageTitleSpace: 5)
+        nameLabel.snp.makeConstraints { (make) in
+            make.centerY.equalTo(iconImageView.snp_centerY)
+            make.left.equalTo(iconImageView.snp_right).offset(5)
+            make.right.equalTo(likeBtn.snp_left).offset(-10)
+            make.height.equalTo(16)
+        }
+    }
+    
+    private lazy var contentImageView: UIImageView = {
+        let contentImageView = UIImageView()
+        contentImageView.image = kImage(name: "pic_preload")
+        return contentImageView
+    }()
+    
+    private lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.text = "Criterium du Dauphine: Van Aert wins stage 4"
+        titleLabel.textColor = k262626Color
+        titleLabel.font = kMediumFont13
+        titleLabel.textAlignment = .left
+        titleLabel.numberOfLines = 0
+        return titleLabel
+    }()
+    
+    private lazy var iconImageView: UIImageView = {
+        let iconImageView = UIImageView()
+        iconImageView.image = kImage(name: "pic_preload")
+        return iconImageView
+    }()
+    
+    private lazy var nameLabel: UILabel = {
+        let nameLabel = UILabel()
+        nameLabel.text = "Steven Kruijswijk"
+        nameLabel.textColor = k262626Color
+        nameLabel.font = kRegularFont12
+        nameLabel.textAlignment = .left
+        return nameLabel
+    }()
+    
+    private lazy var likeBtn: UIButton = {
+        let likeBtn = UIButton(type: UIButton.ButtonType.custom)
+        likeBtn.setTitle("8844", for: UIControl.State.normal)
+        likeBtn.setTitleColor(k999999Color, for: UIControl.State.normal)
+        likeBtn.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
+        likeBtn.setImage(kImage(name: "common_check_icon"), for: UIControl.State.selected)
+        likeBtn.titleLabel?.font = kRegularFont12
+        likeBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
+            likeBtn.isSelected = !likeBtn.isSelected
+            if let likeSelectBlock = self?.likeSelectBlock {
+                let isLikeSel: Int = likeBtn.isSelected == true ? 1 : 0
+                likeSelectBlock(isLikeSel)
+            }
+        }).disposed(by: disposeBag)
+        return likeBtn
+    }()
+    
+}