Pārlūkot izejas kodu

Merge branch 'develop' of http://git.caihongxingqiu.net/rainbow/platform-ios into develop

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

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

@@ -645,6 +645,7 @@
 		BDF47D822282B3D100941AB9 /* ShoppingCartHotSaleTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF47D812282B3D100941AB9 /* ShoppingCartHotSaleTableViewCell.swift */; };
 		BDF47D852282C59F00941AB9 /* ShoppingCartListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF47D842282C59F00941AB9 /* ShoppingCartListTableViewCell.swift */; };
 		BDF47D872282C92200941AB9 /* ShoppingCartListTableViewHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF47D862282C92200941AB9 /* ShoppingCartListTableViewHeader.swift */; };
+		BDF7C5D922D70B6E007F3B79 /* CommunityVideoMajorCommentCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF7C5D822D70B6E007F3B79 /* CommunityVideoMajorCommentCell.swift */; };
 		BDF8629C228E4125000DEF84 /* OrderCommentController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF8629B228E4125000DEF84 /* OrderCommentController.swift */; };
 		BDF862A1228E41CC000DEF84 /* OrderLogisticsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF8629E228E41CC000DEF84 /* OrderLogisticsController.swift */; };
 		BDF862A2228E41CC000DEF84 /* OrderLogisticsInfoCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF862A0228E41CC000DEF84 /* OrderLogisticsInfoCell.swift */; };
@@ -1417,6 +1418,7 @@
 		BDF47D812282B3D100941AB9 /* ShoppingCartHotSaleTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartHotSaleTableViewCell.swift; sourceTree = "<group>"; };
 		BDF47D842282C59F00941AB9 /* ShoppingCartListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartListTableViewCell.swift; sourceTree = "<group>"; };
 		BDF47D862282C92200941AB9 /* ShoppingCartListTableViewHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartListTableViewHeader.swift; sourceTree = "<group>"; };
+		BDF7C5D822D70B6E007F3B79 /* CommunityVideoMajorCommentCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommunityVideoMajorCommentCell.swift; sourceTree = "<group>"; };
 		BDF8629B228E4125000DEF84 /* OrderCommentController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCommentController.swift; sourceTree = "<group>"; };
 		BDF8629E228E41CC000DEF84 /* OrderLogisticsController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderLogisticsController.swift; sourceTree = "<group>"; };
 		BDF862A0228E41CC000DEF84 /* OrderLogisticsInfoCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderLogisticsInfoCell.swift; sourceTree = "<group>"; };
@@ -4737,6 +4739,7 @@
 				BD37E38222CDF5BA003A14A2 /* CommunityVideoTopicView.swift */,
 				BD37E38422CDF91A003A14A2 /* CommunityVideoSelTopicCell.swift */,
 				BD37E38622CE200E003A14A2 /* CommunityAllCommentView.swift */,
+				BDF7C5D822D70B6E007F3B79 /* CommunityVideoMajorCommentCell.swift */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -6058,6 +6061,7 @@
 				A7FF1557228AC3E800A85748 /* ProductAllCommentViewController.swift in Sources */,
 				A7A98E02227E8900005306E9 /* ProductSearchListModel.swift in Sources */,
 				A7A98E17227EED76005306E9 /* SpecialViewController.swift in Sources */,
+				BDF7C5D922D70B6E007F3B79 /* CommunityVideoMajorCommentCell.swift in Sources */,
 				A7778CB32244D73400C7C47A /* RegisterLoginViewController.swift in Sources */,
 				BD7AB8432284390B0030646A /* OrderPaySelfPickInfoCell.swift in Sources */,
 				A7D5F26522C118F100F8E9AF /* CMSMemberListModel.swift in Sources */,

+ 12 - 2
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityAllCommentView.swift

@@ -165,7 +165,8 @@ extension CommunityAllCommentView : UITableViewDelegate, UITableViewDataSource {
         if communityPostCommentModels.isEmpty {
             return UITableViewCell()
         } else {
-            let cell = RecommendMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
+            let cell = CommunityVideoMajorCommentCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.communityVideoItemModel = videoItemModel
             cell.communityPostCommentModel = communityPostCommentModels[indexPath.row]
             cell.frame = tableView.bounds
             cell.layoutIfNeeded()
@@ -175,7 +176,16 @@ extension CommunityAllCommentView : UITableViewDelegate, UITableViewDataSource {
     }
     
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
-        print("点击了----\(indexPath.row)")
+        if !communityPostCommentModels.isEmpty {
+            communityPostCommentModel = self.communityPostCommentModels[indexPath.row]
+            AlertSheetView.sheetCommentReplyView(userName: communityPostCommentModel?.username ?? "", content: communityPostCommentModel?.content ?? "") {
+                [weak self] in
+                self?.commentInputView.inputTextView.becomeFirstResponder()
+                self?.communityPostCommentModel = self?.communityPostCommentModels[indexPath.row]
+                self?.commentInputView.inputTextView.placeholder = "回复:@\(self?.communityPostCommentModel?.username ?? "")"
+            }
+        }
+        
     }
     
     func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {

+ 252 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/View/CommunityVideoMajorCommentCell.swift

@@ -0,0 +1,252 @@
+//
+//  CommunityVideoMajorCommentCell.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/7/11.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  视频播放评论の主Cell
+
+import UIKit
+import RxSwift
+
+class CommunityVideoMajorCommentCell: UITableViewCell {
+    
+    let disposeBag = DisposeBag()
+    
+    /// 相关推荐高度
+    var heightModel1 = HeightModel()
+    
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> CommunityVideoMajorCommentCell {
+        let ID = "CommunityVideoMajorCommentCell"
+        tableView.register(CommunityVideoMajorCommentCell.self, forCellReuseIdentifier: ID)
+        let cell : CommunityVideoMajorCommentCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! CommunityVideoMajorCommentCell
+        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(iconButton)
+        addSubview(titleLabel)
+        addSubview(contentLabel)
+        addSubview(timeLabel)
+        addSubview(tableView)
+    }
+    
+    private func setupLayouts() {
+        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(iconButton.snp_right).offset(10)
+            make.right.equalToSuperview().offset(-26)
+            make.centerY.equalTo(iconButton)
+            make.height.equalTo(17)
+        }
+        
+        contentLabel.snp.makeConstraints { (make) in
+            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.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)
+        }
+    }
+    
+    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: UILabel = {
+        let contentLabel = UILabel()
+        contentLabel.textColor = k333333Color
+        contentLabel.font = kRegularFont14
+        contentLabel.textAlignment = .left
+        contentLabel.numberOfLines = 0
+        return contentLabel
+    }()
+    
+    private lazy var timeLabel: UILabel = {
+        let timeLabel = UILabel()
+        timeLabel.textColor = kbbbbbbColor
+        timeLabel.font = kRegularFont12
+        timeLabel.textAlignment = .left
+        return timeLabel
+    }()
+    
+    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
+    }()
+    var tableViewHeight : CGFloat?
+    
+    //加载数据
+    func reloadData() {
+        //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
+            reloadData()
+        }
+    }
+    
+    /// 帖子Id
+    var communityVideoItemModel : CommunityVideoItemModel?
+}
+
+
+// MARK: - tableView dataSource && delegate
+extension CommunityVideoMajorCommentCell: UITableViewDataSource, UITableViewDelegate {
+    
+    func numberOfSections(in tableView: UITableView) -> Int {
+        return 1
+    }
+    
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        let reply = communityPostCommentModel?.reply?.prefix(2)
+        return reply?.count ?? 0
+    }
+    
+    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 tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        pushCommunitySubCommentVC()
+    }
+    
+    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 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 {
+            if  communityPostCommentModel?.replyCount ?? 0 > 2 {
+                return 30
+            }else {
+                return 10
+            }
+        }
+        
+    }
+    
+    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
+        if  communityPostCommentModel?.replyCount ?? 0 > 2 {
+            let footer = RecommendSubCommentTableViewFooter(frame: CGRect(x: 0, y: 0, width: kScreenWidth-48-14, height: 30))
+            footer.communityPostCommentModel = communityPostCommentModel
+            footer.unfoldClosure = {
+                [weak self] in
+                self?.pushCommunitySubCommentVC()
+            }
+            return footer
+        }else {
+            return UIView()
+        }
+    }
+    
+    func pushCommunitySubCommentVC() {
+        let paraDic = ["commmentModel": communityPostCommentModel, "detailModel": communityVideoItemModel]
+        NotificationCenter.default.post(name: NSNotification.Name("JumpToSubCommentController"), object: paraDic)        
+    }
+    
+}

+ 13 - 0
RainbowPlanet/RainbowPlanet/Modules/CommunityModule/CommunityVideoContent/ViewController/CommunityVideoListController.swift

@@ -62,6 +62,19 @@ class CommunityVideoListController: BaseViewController {
             [weak self] (notification) in
             self?.startPlay(self?.prePlayCell)
         })
+        
+        // 子评论页面
+        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("JumpToSubCommentController"), object: nil, queue: OperationQueue.main) {
+            [weak self] (notification) in
+            let paraDic = notification.object as! [String:Any]
+            
+            let vc = CommunitySubCommentController()
+            vc.communityPostCommentModel = paraDic["commmentModel"] as? CommunityPostCommentModel
+            vc.communityPostDetailModel = paraDic["detailModel"] as? CommunityPostDetailModel
+            self?.navigationController?.pushViewController(vc, animated: true)
+            
+//            let paraDic = ["commmentModel": communityPostCommentModel, "detailModel": communityVideoItemModel]
+        }
     }
     
     override func setupViews() {        

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

@@ -448,7 +448,6 @@ extension VirusViewModel {
         }
         virueRecordAddParameterModel.postType = communityPostDetailModel.type
         virueRecordAddParameterModel.postCover = communityPostDetailModel.img
-        virueRecordAddParameterModel.targetId = "\((UserModel.shared().getModel()?.uid)!)"
         
         virueRecordAddParameterModel.actionId = "\(id)"
 
@@ -479,7 +478,6 @@ extension VirusViewModel {
         }
         virueRecordAddParameterModel.postType = communityVideoItemModel.type
         virueRecordAddParameterModel.postCover = communityVideoItemModel.img
-        virueRecordAddParameterModel.targetId = "\((UserModel.shared().getModel()?.uid)!)"
         
         virueRecordAddParameterModel.actionId = "\(id)"