Browse Source

no message

南鑫林 6 years ago
parent
commit
9d745f2dea

+ 1 - 9
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -822,7 +822,6 @@
 		A70B2C39228819CA00B2449F /* Cell */ = {
 			isa = PBXGroup;
 			children = (
-				A70B2C6522887B1600B2449F /* ProductDetailEvaluationList */,
 				A70B2C3A228819DC00B2449F /* ProductDetailProductInfo */,
 				A70B2C38228819B500B2449F /* ProductDetailProductSku */,
 				A70B2C3C2288259200B2449F /* ProductDetailEvaluation */,
@@ -945,14 +944,6 @@
 			path = ViewController;
 			sourceTree = "<group>";
 		};
-		A70B2C6522887B1600B2449F /* ProductDetailEvaluationList */ = {
-			isa = PBXGroup;
-			children = (
-				A70B2C6622887B2B00B2449F /* ProductDetailEvaluationListTableViewCell.swift */,
-			);
-			path = ProductDetailEvaluationList;
-			sourceTree = "<group>";
-		};
 		A70B2C692288810700B2449F /* PickView */ = {
 			isa = PBXGroup;
 			children = (
@@ -2531,6 +2522,7 @@
 			isa = PBXGroup;
 			children = (
 				A7FF1554228AC27600A85748 /* ProductAllCommentView.swift */,
+				A70B2C6622887B2B00B2449F /* ProductDetailEvaluationListTableViewCell.swift */,
 			);
 			path = View;
 			sourceTree = "<group>";

+ 142 - 6
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductAllComment/View/ProductAllCommentView.swift

@@ -9,13 +9,149 @@
 import UIKit
 
 class ProductAllCommentView: BaseView {
+    
+    var productAllCommentArray : Array<ProductCommentModel>? {
+        didSet {
+            if productAllCommentArray?.isEmpty ?? true {
+                tableView.isHiddenFooter(true)
+            }else {
+                tableView.isHiddenFooter(false)
+            }
+            tableView.reloadData()
+        }
+    }
 
-    /*
-    // Only override draw() if you perform custom drawing.
-    // An empty implementation adversely affects performance during animation.
-    override func draw(_ rect: CGRect) {
-        // Drawing code
+    
+    override func setupViews() {
+        addSubview(bottomBgView)
+        bottomBgView.addSubview(cartButton)
+        cartButton.addSubview(cartImageView)
+        bottomBgView.addSubview(addCartButton)
+        bottomBgView.addSubview(buyButton)
+        addSubview(tableView)
+        let emptyView =  EmptyView.shared.diyCustomEmptyViewStyle2(iconStr: "page04", titleStr: "当前暂无数据")
+        emptyView.contentViewY = kScaleValue(value: 182)
+        tableView.ly_emptyView = emptyView
+    }
+    
+    override func setupLayouts() {
+        bottomBgView.snp.makeConstraints { (make) in
+            make.left.bottom.right.equalToSuperview()
+            make.height.equalTo(50 + kSafeTabBarHeight)
+        }
+        cartButton.snp.makeConstraints { (make) in
+            make.top.left.equalToSuperview()
+            make.width.equalTo(71 * kScaleWidth)
+            make.bottom.equalTo(-kSafeTabBarHeight)
+        }
+        cartImageView.snp.makeConstraints { (make) in
+            make.center.equalToSuperview()
+        }
+        addCartButton.snp.makeConstraints { (make) in
+            make.left.equalTo(cartButton.snp.right)
+            make.top.bottom.equalTo(cartButton)
+            make.width.equalTo(152 * kScaleWidth)
+        }
+        buyButton.snp.makeConstraints { (make) in
+            make.left.equalTo(addCartButton.snp.right)
+            make.top.bottom.equalTo(cartButton)
+            make.width.equalTo(152 * kScaleWidth)
+        }
+        tableView.snp.makeConstraints { (make) in
+            make.top.left.right.equalToSuperview()
+            make.bottom.equalTo(bottomBgView.snp.top)
+        }
     }
-    */
+    
+    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.estimatedRowHeight = 0.000001
+        return tableView
+    }()
+    
+    private lazy var bottomBgView: UIView = {
+        let bottomBgView = UIView()
+        return bottomBgView
+    }()
+    
+    private lazy var cartButton : UIButton = {
+        let cartButton = UIButton()
+        return cartButton
+    }()
+    
+    private lazy var cartImageView: UIImageView = {
+        let cartImageView = UIImageView()
+        cartImageView.image = kImage(name: "tabbar_shopping")
+        cartImageView.pp.addBadge(number: 2)
+        //        shoppingCarButton.pp.setBadge(height: 14)
+        //        shoppingCarButton.pp.badgeView.font = kRegularFont10
+        cartImageView.pp.badgeView.backgroundColor = kfe352bColor
+        cartImageView.pp.moveBadge(x: -2, y: 2)
+        return cartImageView
+    }()
+    
+    private lazy var addCartButton : UIButton = {
+        let addCartButton = UIButton(type: UIButton.ButtonType.custom)
+        addCartButton.setTitle("加入购物车", for: UIControl.State.normal)
+        addCartButton.setTitleColor(UIColor.white, for: UIControl.State.normal)
+        addCartButton.backgroundColor = k404040Color
+        addCartButton.titleLabel?.font = kRegularFont16
+        return addCartButton
+    }()
+    
+    private lazy var buyButton : UIButton = {
+        let buyButton = UIButton(type: UIButton.ButtonType.custom)
+        buyButton.setTitle("立即购买", for: UIControl.State.normal)
+        buyButton.setTitleColor(UIColor.white, for: UIControl.State.normal)
+        buyButton.backgroundColor = kFFA42FColor
+        buyButton.titleLabel?.font = kRegularFont16
+        buyButton.rx.tap.subscribe(onNext: {
+            [weak self](data) in
+//            self?.productDetailSkuView()
+        }).disposed(by: disposeBag)
+        return buyButton
+    }()
+
+}
 
+extension ProductAllCommentView : UITableViewDelegate, UITableViewDataSource {
+    func numberOfSections(in tableView: UITableView) -> Int {
+        return productAllCommentArray?.isEmpty ?? true ? 0 : 1
+    }
+    
+    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return productAllCommentArray?.isEmpty ?? true ? 0 : productAllCommentArray?.count ?? 0
+    }
+    
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        
+        let cell = ProductDetailEvaluationListTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+        cell.productCommentModel = productAllCommentArray?[indexPath.row]
+        return cell
+    }
+    
+    
+    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
+        return UITableView.automaticDimension
+    }
+    
+    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
+            return 10
+    }
+    
+    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
+            return nil
+    }
+    
+    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
+        return 10
+    }
+    
+    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
+        return nil
+    }
 }

+ 14 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailEvaluationList/ProductDetailEvaluationListTableViewCell.swift

@@ -10,7 +10,7 @@ import UIKit
 
 class ProductDetailEvaluationListTableViewCell: UITableViewCell {
     
-    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> UITableViewCell {
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailEvaluationListTableViewCell {
         let ID = "ProductDetailEvaluationListTableViewCell"
         tableView.register(ProductDetailEvaluationListTableViewCell.self, forCellReuseIdentifier: ID)
         let cell : ProductDetailEvaluationListTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! ProductDetailEvaluationListTableViewCell
@@ -127,5 +127,18 @@ class ProductDetailEvaluationListTableViewCell: UITableViewCell {
         lineLabel.backgroundColor = kf5f5f5Color
         return lineLabel
     }()
+    
+    var productCommentModel: ProductCommentModel? {
+        didSet {
+//            shopImageView.kf.setImage(with: kURLImage(name: productCommentModel?.logoImg ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            nameLabel.text = productCommentModel?.username
+            timeLabel.text = productCommentModel?.createdAt
+            let attributeString = NSMutableAttributedString(string:productCommentModel?.content ?? "")
+            attributeString.changeAllLineSpacing(2)
+            infoLabel.attributedText = attributeString
+            skuLabel.text = "规格:"
+            
+        }
+    }
 
 }

+ 71 - 12
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductAllComment/ViewController/ProductAllCommentViewController.swift

@@ -9,22 +9,81 @@
 import UIKit
 
 class ProductAllCommentViewController: BaseViewController {
-
+    
+    var productModel : ProductModel?
+    
+    var productSearchModel : ProductSearchModel?
+    
+    var productAllCommentArray = Array<ProductCommentModel>()
+    
     override func viewDidLoad() {
         super.viewDidLoad()
-
-        // Do any additional setup after loading the view.
+        setupViews()
+        setupLayouts()
+        setupData()
     }
     
-
-    /*
-    // MARK: - Navigation
-
-    // In a storyboard-based application, you will often want to do a little preparation before navigation
-    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
-        // Get the new view controller using segue.destination.
-        // Pass the selected object to the new view controller.
+    override func setupViews() {
+        navigationBar.title = "全部评价"
+        view.addSubview(productAllCommentView)
+    }
+    
+    override func setupLayouts() {
+        productAllCommentView.snp.makeConstraints { (make) in
+            make.left.right.bottom.equalToSuperview()
+            make.top.equalTo(kNavBarTotalHeight)
+        }
+    }
+    
+    override func setupData() {
+        productAllCommentView.tableView.addHeaderWithHeader(withBeginRefresh: true, animation: false) { [weak self] (page) in
+            self?.productCommentListApi(page:page)
+        }
+        productAllCommentView.tableView.addFooterWithWithHeader(withAutomaticallyRefresh: true) { [weak self] (page) in
+            self?.productCommentListApi(page:page)
+        }
+    }
+    
+    private lazy var productAllCommentView: ProductAllCommentView = {
+        let productAllCommentView = ProductAllCommentView()
+        return productAllCommentView
+    }()
+    
+    func productCommentListApi(page:Int = 1) {
+        if self.productModel != nil {
+            SwiftMoyaNetWorkServiceProduct.shared().productCommentListApi(page:page,productId: productModel?.id ?? 0) {
+                [weak self] (productCommentListModel) -> (Void) in
+                let productCommentListModel = productCommentListModel as? ProductCommentListModel
+                if productCommentListModel?.pagination?.currentPage ?? 1  <= productCommentListModel?.pagination?.totalPages ?? 1 {
+                    if productCommentListModel?.pagination?.currentPage == 1{
+                        self?.productAllCommentArray.removeAll()
+                        self?.productAllCommentView.tableView.resetNoMoreData()
+                    }
+                    self?.productAllCommentArray = (self?.productAllCommentArray)! + (productCommentListModel?.data!)!
+                    self?.productAllCommentView.productAllCommentArray = self?.productAllCommentArray
+                }else {
+                    self?.productAllCommentView.tableView.endFooterNoMoreData()
+                }
+                
+            }
+        }
+        
+        if self.productSearchModel != nil {
+            SwiftMoyaNetWorkServiceProduct.shared().productCommentListApi(page:page,productId: productSearchModel?.id ?? 0) { [weak self] (productCommentListModel) -> (Void) in
+                let productCommentListModel = productCommentListModel as? ProductCommentListModel
+                if productCommentListModel?.pagination?.currentPage ?? 1  <= productCommentListModel?.pagination?.totalPages ?? 1 {
+                    if productCommentListModel?.pagination?.currentPage == 1{
+                        self?.productAllCommentArray.removeAll()
+                        self?.productAllCommentView.tableView.resetNoMoreData()
+                    }
+                    self?.productAllCommentArray = (self?.productAllCommentArray)! + (productCommentListModel?.data!)!
+                    self?.productAllCommentView.productAllCommentArray = self?.productAllCommentArray
+                }else {
+                    self?.productAllCommentView.tableView.endFooterNoMoreData()
+                }
+                
+            }
+        }
     }
-    */
 
 }

+ 12 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailHeader/ProductDetailSectionHeader.swift

@@ -7,8 +7,14 @@
 //
 
 import UIKit
+import RxSwift
 
 class ProductDetailSectionHeader: BaseView {
+    
+    let disposeBags = DisposeBag()
+    
+    typealias LookAllCommentClosure = () -> Void
+    var lookAllCommentClosure : LookAllCommentClosure?
 
     override func setupViews() {
         backgroundColor = UIColor.white
@@ -72,6 +78,12 @@ class ProductDetailSectionHeader: BaseView {
         goButton.setImage(kImage(name: "my_arrows_unfold"), for:
             UIControl.State.normal)
         goButton.isHidden = false
+        goButton.rx.tap.subscribe(onNext: {
+             [weak self](data) in
+            if let lookAllCommentClosure = self?.lookAllCommentClosure {
+                lookAllCommentClosure()
+            }
+        }).disposed(by: disposeBags)
         return goButton
     }()
     

+ 12 - 6
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailView.swift

@@ -12,7 +12,11 @@ import FWPopupView
 
 class ProductDetailView: BaseView {
     
-    var section : Int = 0
+    typealias LookAllCommentClosure = () -> Void
+    var lookAllCommentClosure : LookAllCommentClosure?
+    
+    
+    var titles = ["","","商品评价","","热销排行","商品参数","商品详情"]
     
     var index : Int? {
         didSet {
@@ -27,7 +31,6 @@ class ProductDetailView: BaseView {
         }
     }
     
-    var titles = ["","","商品评价","","热销排行","商品参数","商品详情"]
     var productDetailModel : ProductDetailModel? {
         didSet {
             tableView.ly_startLoading()
@@ -286,6 +289,13 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
             let view = ProductDetailSectionHeader(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 44))
             view.section = section
             view.titles = titles
+            view.lookAllCommentClosure = {
+                [weak self] in
+                if let lookAllCommentClosure = self?.lookAllCommentClosure {
+                    lookAllCommentClosure()
+                }
+            }
+            
             return view
         default:
             return nil
@@ -300,10 +310,6 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
         return nil
     }
     
-    func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
-        
-    }
-    
     func scrollViewDidScroll(_ scrollView: UIScrollView) {
         var offset = scrollView.contentOffset
         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ProductDetailView"), object: offset)

+ 12 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/ViewController/ProductDetailViewController.swift

@@ -71,6 +71,18 @@ class ProductDetailViewController: BaseViewController {
                 self?.segmentedView.selectItemAt(index: item/2)
             }
         }
+        
+        productDetailView.lookAllCommentClosure = {
+            [weak self] in
+            let vc = ProductAllCommentViewController()
+            if self?.productModel != nil {
+                vc.productModel = self?.productModel
+            }
+            if self?.productSearchModel != nil {
+                vc.productSearchModel = self?.productSearchModel
+            }
+            self?.navigationController?.pushViewController(vc, animated: true)
+        }
     }
     
     private func productDetailApi() {