Browse Source

Merge branch 'feature/dev_Chris' into develop

Chris 5 years ago
parent
commit
8aab1becc4

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderFinishPay/View/OrderFinishPayFailureCell.swift

@@ -133,7 +133,7 @@ class OrderFinishPayFailureCell: UITableViewCell {
     
     
     var configModel: ConfigModel? {
     var configModel: ConfigModel? {
         didSet {
         didSet {
-            describeLabel.text = "\(configModel?.orderExpiredTime ?? "15")未支付,系统自动判断失败"
+            describeLabel.text = "\(configModel?.orderExpiredTime ?? "15")分钟未支付,系统自动判断失败"
         }
         }
     }
     }
     
     

+ 4 - 2
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductAllComment/View/ProductAllCommentView.swift

@@ -128,10 +128,12 @@ extension ProductAllCommentView : UITableViewDelegate, UITableViewDataSource {
         return productAllCommentArray?.isEmpty ?? true ? 0 : productAllCommentArray?.count ?? 0
         return productAllCommentArray?.isEmpty ?? true ? 0 : productAllCommentArray?.count ?? 0
     }
     }
     
     
-    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        
+    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {        
         let cell = ProductDetailEvaluationListTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
         let cell = ProductDetailEvaluationListTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
         cell.productCommentModel = productAllCommentArray?[indexPath.row]
         cell.productCommentModel = productAllCommentArray?[indexPath.row]
+        cell.frame = tableView.bounds
+        cell.layoutIfNeeded()
+        cell.reloadData()
         return cell
         return cell
     }
     }
     
     

+ 7 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductAllComment/View/ProductDetailEvaluationImageCollectionViewCell.swift

@@ -9,6 +9,13 @@
 import UIKit
 import UIKit
 
 
 class ProductDetailEvaluationImageCollectionViewCell: UICollectionViewCell {
 class ProductDetailEvaluationImageCollectionViewCell: UICollectionViewCell {
+    
+    var imageUrl: String? {
+        didSet {
+            iconImageView.kf.setImage(with: kURLImage(name: imageUrl ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+        }
+    }
+    
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ProductDetailEvaluationImageCollectionViewCell {
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ProductDetailEvaluationImageCollectionViewCell {
         let ID = "ProductDetailEvaluationImageCollectionViewCell"
         let ID = "ProductDetailEvaluationImageCollectionViewCell"
         collectionView.register(ProductDetailEvaluationImageCollectionViewCell.self, forCellWithReuseIdentifier: ID)
         collectionView.register(ProductDetailEvaluationImageCollectionViewCell.self, forCellWithReuseIdentifier: ID)

+ 81 - 2
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductAllComment/View/ProductDetailEvaluationListTableViewCell.swift

@@ -10,6 +10,8 @@ import UIKit
 
 
 class ProductDetailEvaluationListTableViewCell: UITableViewCell {
 class ProductDetailEvaluationListTableViewCell: UITableViewCell {
     
     
+    var commentImages: Array<String> = []
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailEvaluationListTableViewCell {
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailEvaluationListTableViewCell {
         let ID = "ProductDetailEvaluationListTableViewCell"
         let ID = "ProductDetailEvaluationListTableViewCell"
         tableView.register(ProductDetailEvaluationListTableViewCell.self, forCellReuseIdentifier: ID)
         tableView.register(ProductDetailEvaluationListTableViewCell.self, forCellReuseIdentifier: ID)
@@ -36,13 +38,14 @@ class ProductDetailEvaluationListTableViewCell: UITableViewCell {
     //MRAK: - 设置View
     //MRAK: - 设置View
     private func setupViews() {
     private func setupViews() {
         self.selectionStyle = .none
         self.selectionStyle = .none
+        
         addSubview(avatarImagView)
         addSubview(avatarImagView)
         addSubview(nameLabel)
         addSubview(nameLabel)
         addSubview(timeLabel)
         addSubview(timeLabel)
         addSubview(infoLabel)
         addSubview(infoLabel)
+        addSubview(collectionView)
         addSubview(skuLabel)
         addSubview(skuLabel)
         addSubview(lineLabel)
         addSubview(lineLabel)
-        
     }
     }
     
     
     private func setupLayouts() {
     private func setupLayouts() {
@@ -65,8 +68,13 @@ class ProductDetailEvaluationListTableViewCell: UITableViewCell {
             make.left.equalTo(avatarImagView)
             make.left.equalTo(avatarImagView)
             make.right.equalTo(timeLabel)
             make.right.equalTo(timeLabel)
         }
         }
+        collectionView.snp.makeConstraints { (make) in
+            make.top.equalTo(infoLabel.snp_bottom)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(200)
+        }
         skuLabel.snp.makeConstraints { (make) in
         skuLabel.snp.makeConstraints { (make) in
-            make.top.equalTo(infoLabel.snp.bottom).offset(15)
+            make.top.equalTo(collectionView.snp.bottom).offset(15)
             make.left.equalTo(avatarImagView)
             make.left.equalTo(avatarImagView)
             make.right.equalTo(timeLabel)
             make.right.equalTo(timeLabel)
         }
         }
@@ -114,6 +122,23 @@ class ProductDetailEvaluationListTableViewCell: UITableViewCell {
         return infoLabel
         return infoLabel
     }()
     }()
     
     
+    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
+        return collectionView
+    }()
+    
+    private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
+        let collectionViewLayout = UICollectionViewFlowLayout.init()
+        collectionViewLayout.minimumLineSpacing = 10
+        collectionViewLayout.minimumInteritemSpacing = 0
+        return collectionViewLayout
+    }()
+    
     private lazy var skuLabel: UILabel = {
     private lazy var skuLabel: UILabel = {
         let skuLabel = UILabel()
         let skuLabel = UILabel()
         skuLabel.text = "规格:500g"
         skuLabel.text = "规格:500g"
@@ -138,7 +163,61 @@ class ProductDetailEvaluationListTableViewCell: UITableViewCell {
             infoLabel.attributedText = attributeString
             infoLabel.attributedText = attributeString
             skuLabel.text = "规格:\(productCommentModel?.skuName ?? "")"
             skuLabel.text = "规格:\(productCommentModel?.skuName ?? "")"
             
             
+            commentImages = productCommentModel?.imgs ?? []
+            if commentImages.count == 0 {
+                collectionView.snp.remakeConstraints { (make) in
+                    make.top.equalTo(infoLabel.snp_bottom)
+                    make.left.right.equalToSuperview()
+                    make.height.equalTo(0)
+                }
+            } else {
+                collectionView.reloadData()
+            }
+        }
+    }
+    
+    //加载数据
+    func reloadData() {
+        //collectionView重新加载数据
+        self.collectionView.reloadData()
+        //更新collectionView的高度约束
+        let contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize
+        collectionView.snp.remakeConstraints { (make) in
+            make.top.equalTo(infoLabel.snp_bottom)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(contentSize.height)
+            make.bottom.equalTo(skuLabel.snp_top).offset(-15)
         }
         }
+        self.collectionView.collectionViewLayout.invalidateLayout()
     }
     }
 
 
 }
 }
+
+extension ProductDetailEvaluationListTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,UICollectionViewDelegate {
+    func numberOfSections(in collectionView: UICollectionView) -> Int {
+        return 1
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+        return commentImages.count
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        let cell = ProductDetailEvaluationImageCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        cell.imageUrl = commentImages[indexPath.row]
+        return cell
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
+        return CGSize(width:(kScreenWidth-30-5*3)/4, height: (kScreenWidth-30-5*3)/4)
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
+        return UIEdgeInsets(top: 10, left: 15, bottom: 0, right: 15)
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        
+    }
+    
+}

+ 58 - 28
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailEvaluation/ProductDetailEvaluationTableViewCell.swift

@@ -10,6 +10,8 @@ import UIKit
 
 
 class ProductDetailEvaluationTableViewCell: UITableViewCell {
 class ProductDetailEvaluationTableViewCell: UITableViewCell {
     
     
+    var commentImages: Array<String> = []
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailEvaluationTableViewCell {
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailEvaluationTableViewCell {
         let ID = "ProductDetailEvaluationTableViewCell"
         let ID = "ProductDetailEvaluationTableViewCell"
         tableView.register(ProductDetailEvaluationTableViewCell.self, forCellReuseIdentifier: ID)
         tableView.register(ProductDetailEvaluationTableViewCell.self, forCellReuseIdentifier: ID)
@@ -39,6 +41,7 @@ class ProductDetailEvaluationTableViewCell: UITableViewCell {
         addSubview(avatarImageView)
         addSubview(avatarImageView)
         addSubview(nickNameLabel)
         addSubview(nickNameLabel)
         addSubview(evaluationLabel)
         addSubview(evaluationLabel)
+        addSubview(collectionView)
     }
     }
     
     
     private func setupLayouts() {
     private func setupLayouts() {
@@ -54,7 +57,13 @@ class ProductDetailEvaluationTableViewCell: UITableViewCell {
         evaluationLabel.snp.makeConstraints { (make) in
         evaluationLabel.snp.makeConstraints { (make) in
             make.top.equalTo(avatarImageView.snp.bottom).offset(5)
             make.top.equalTo(avatarImageView.snp.bottom).offset(5)
             make.left.equalTo(avatarImageView)
             make.left.equalTo(avatarImageView)
-            make.right.bottom.equalTo(-14)
+            make.right.equalTo(-14)
+        }
+        collectionView.snp.makeConstraints { (make) in
+            make.top.equalTo(evaluationLabel.snp_bottom)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(200)
+            make.bottom.equalToSuperview()
         }
         }
     }
     }
     
     
@@ -82,65 +91,86 @@ class ProductDetailEvaluationTableViewCell: UITableViewCell {
         return evaluationLabel
         return evaluationLabel
     }()
     }()
     
     
-    var productCommentModel : ProductCommentModel? {
-        didSet {
-            avatarImageView.kf.setImage(with: kURLImage(name: productCommentModel?.avatar ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
-            nickNameLabel.text = productCommentModel?.username
-            let attributeString = NSMutableAttributedString(string:productCommentModel?.content ?? "")
-            attributeString.changeAllLineSpacing(2)
-            evaluationLabel.attributedText = attributeString
-        }
-    }
-    
     private lazy var collectionView: UICollectionView = {
     private lazy var collectionView: UICollectionView = {
         let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
         let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
-        collectionView.backgroundColor = UIColor.white
+        collectionView.backgroundColor = kffffffColor
         collectionView.delegate = self;
         collectionView.delegate = self;
         collectionView.dataSource = self;
         collectionView.dataSource = self;
         collectionView.showsVerticalScrollIndicator = false
         collectionView.showsVerticalScrollIndicator = false
         collectionView.showsHorizontalScrollIndicator = false
         collectionView.showsHorizontalScrollIndicator = false
-        collectionView.cornerRadius = 4
-        collectionView.masksToBounds = true
         return collectionView
         return collectionView
     }()
     }()
     
     
     private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
     private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
         let collectionViewLayout = UICollectionViewFlowLayout.init()
         let collectionViewLayout = UICollectionViewFlowLayout.init()
-        collectionViewLayout.minimumLineSpacing = 7
+        collectionViewLayout.minimumLineSpacing = 10
         collectionViewLayout.minimumInteritemSpacing = 0
         collectionViewLayout.minimumInteritemSpacing = 0
-        collectionViewLayout.scrollDirection = .horizontal
         return collectionViewLayout
         return collectionViewLayout
     }()
     }()
+    
+    var productCommentModel : ProductCommentModel? {
+        didSet {
+            avatarImageView.kf.setImage(with: kURLImage(name: productCommentModel?.avatar ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            nickNameLabel.text = productCommentModel?.username
+            let attributeString = NSMutableAttributedString(string:productCommentModel?.content ?? "")
+            attributeString.changeAllLineSpacing(2)
+            evaluationLabel.attributedText = attributeString
+            
+            commentImages = productCommentModel?.imgs ?? []
+            if commentImages.count == 0 {
+                collectionView.snp.remakeConstraints { (make) in
+                    make.top.equalTo(evaluationLabel.snp_bottom)
+                    make.left.right.equalToSuperview()
+                    make.height.equalTo(0)
+                    make.bottom.equalToSuperview()
+                }
+            } else {
+                collectionView.reloadData()
+            }
+        }
+    }
+    
+    //加载数据
+    func reloadData() {
+        //collectionView重新加载数据
+        self.collectionView.reloadData()
+        //更新collectionView的高度约束
+        let contentSize = self.collectionView.collectionViewLayout.collectionViewContentSize
+        collectionView.snp.remakeConstraints { (make) in
+            make.top.equalTo(evaluationLabel.snp_bottom)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(contentSize.height)
+            make.bottom.equalToSuperview().offset(-14)
+        }
+        self.collectionView.collectionViewLayout.invalidateLayout()
+    }
 }
 }
 
 
 extension ProductDetailEvaluationTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
 extension ProductDetailEvaluationTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
     func numberOfSections(in collectionView: UICollectionView) -> Int {
     func numberOfSections(in collectionView: UICollectionView) -> Int {
-        return 0
+        return 1
     }
     }
     
     
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        return 0
+        return commentImages.count
     }
     }
     
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         let cell = ProductDetailEvaluationImageCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
         let cell = ProductDetailEvaluationImageCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
-
+        cell.imageUrl = commentImages[indexPath.row]
         return cell
         return cell
     }
     }
     
     
-    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
-//        let productSearchModel = productSearchListModel?.data?[indexPath.row]
-//        if let jumpToDetailClosure = self.jumpToDetailClosure {
-//            jumpToDetailClosure(productSearchModel?.id ?? 0, productSearchModel?.shopId ?? 0)
-//        }
-    }
-    
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
-        return CGSize(width:(kScreenWidth-30-(14*3))/4, height: (kScreenWidth-30-(14*3))/4)
+        return CGSize(width:(kScreenWidth-30-5*3)/4, height: (kScreenWidth-30-5*3)/4)
     }
     }
     
     
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
-        return UIEdgeInsets(top: 10, left: 14, bottom: 10, right: 14)
+        return UIEdgeInsets(top: 10, left: 15, bottom: 0, right: 15)
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        
     }
     }
     
     
 }
 }

+ 3 - 2
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailView.swift

@@ -351,8 +351,6 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
     }
     }
     
     
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
-        
-        
         switch indexPath.section {
         switch indexPath.section {
         case 0:
         case 0:
             let cell = ProductDetailProductInfoTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
             let cell = ProductDetailProductInfoTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
@@ -396,6 +394,9 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
         case 2:
         case 2:
             let cell = ProductDetailEvaluationTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
             let cell = ProductDetailEvaluationTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
             cell.productCommentModel = productCommentListModel?.data?[indexPath.row]
             cell.productCommentModel = productCommentListModel?.data?[indexPath.row]
+            cell.frame = tableView.bounds
+            cell.layoutIfNeeded()
+            cell.reloadData()
             return cell
             return cell
         case 3:
         case 3:
             let cell = ProductDetailShopTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
             let cell = ProductDetailShopTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)