Browse Source

no message

南鑫林 6 years ago
parent
commit
f2f0cbb409
40 changed files with 538 additions and 97 deletions
  1. 5 5
      RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj
  2. 0 1
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Category/ViewController/CategoryViewController.swift
  3. 16 7
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailDescription/ProductDetailDescriptionTableViewCell.swift
  4. 13 22
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailHotSell/ProductDetailHotSellTableViewCell.swift
  5. 19 6
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailParameter/ProductDetailParameterTableViewCell.swift
  6. 1 1
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailShop/ProductDetailShopTableViewCell.swift
  7. 50 9
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailView.swift
  8. 47 7
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/ViewController/ProductDetailViewController.swift
  9. 10 9
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductView/CollectionViewCell/ProductDetailHotSell/ProductDetailHotSellCollectionViewCell.swift
  10. 12 0
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductView/CollectionViewCell/ProductMallSlidingLeftRight/ProductSlidingLeftRightCollectionViewCell.swift
  11. 20 6
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductView/CollectionViewCell/ProductSlidingTopBottom/ProductSlidingTopBottomCollectionViewCell.swift
  12. 50 1
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopSectionHeaderView.swift
  13. 28 3
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopView.swift
  14. 86 6
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopViewShopInfoTableViewCell.swift
  15. 37 2
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopViewTableViewCell.swift
  16. 25 1
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/ViewController/ShopViewController.swift
  17. 4 0
      RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductDetailModel.swift
  18. 1 0
      RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductSearchModel.swift
  19. 3 2
      RainbowPlanet/RainbowPlanet/Service/Model/ShopModel/ShopModel.swift
  20. 49 6
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaNetWorkServiceProduct.swift
  21. 4 0
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaServiceProductApi.swift
  22. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_down.imageset/common_store_arrow_down.png
  23. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_down.imageset/common_store_arrow_down@2x.png
  24. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_down.imageset/common_store_arrow_down@3x.png
  25. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_top.imageset/common_store_arrow_top.png
  26. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_top.imageset/common_store_arrow_top@2x.png
  27. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_top.imageset/common_store_arrow_top@3x.png
  28. 3 3
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_top.imageset/Contents.json
  29. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_up.imageset/common_store_arrow_up.png
  30. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_up.imageset/common_store_arrow_up@2x.png
  31. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_up.imageset/common_store_arrow_up@3x.png
  32. 23 0
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_packup.imageset/Contents.json
  33. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_packup.imageset/common_word_packup.png
  34. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_packup.imageset/common_word_packup@2x.png
  35. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_packup.imageset/common_word_packup@3x.png
  36. 26 0
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_unfold.imageset/Contents.json
  37. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_unfold.imageset/common_word_unfold.png
  38. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_unfold.imageset/common_word_unfold@2x.png
  39. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_unfold.imageset/common_word_unfold@3x.png
  40. 6 0
      RainbowPlanet/RainbowPlanet/Tools/MJRefreshEX/UIScrollView+MJRefreshEX.h

+ 5 - 5
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -817,13 +817,13 @@
 			isa = PBXGroup;
 			children = (
 				A70B2C6522887B1600B2449F /* ProductDetailEvaluationList */,
-				A70B2C4F22884EF100B2449F /* ProductDetailDescription */,
-				A70B2C4A228845B200B2449F /* ProductDetailParameter */,
-				A70B2C442288408E00B2449F /* ProductDetailHotSell */,
 				A70B2C3A228819DC00B2449F /* ProductDetailProductInfo */,
 				A70B2C38228819B500B2449F /* ProductDetailProductSku */,
 				A70B2C3C2288259200B2449F /* ProductDetailEvaluation */,
 				A70B2C4122883B2F00B2449F /* ProductDetailShop */,
+				A70B2C442288408E00B2449F /* ProductDetailHotSell */,
+				A70B2C4A228845B200B2449F /* ProductDetailParameter */,
+				A70B2C4F22884EF100B2449F /* ProductDetailDescription */,
 			);
 			path = Cell;
 			sourceTree = "<group>";
@@ -1871,10 +1871,10 @@
 		A77F2CA32232010F001BD3F6 /* ShoppingMallModule */ = {
 			isa = PBXGroup;
 			children = (
-				A70B2C5622886AAA00B2449F /* Shop */,
 				A70B2C122286B14C00B2449F /* ProductView */,
-				A70B2C112286B10000B2449F /* ProductDetail */,
 				A77F2CA42232010F001BD3F6 /* ShoppingMall */,
+				A70B2C112286B10000B2449F /* ProductDetail */,
+				A70B2C5622886AAA00B2449F /* Shop */,
 				A7A98E03227EB7FD005306E9 /* Category */,
 				A7A98E15227EECEA005306E9 /* Special */,
 			);

+ 0 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Category/ViewController/CategoryViewController.swift

@@ -63,7 +63,6 @@ class CategoryViewController: BaseViewController {
             self?.leftIndexPath = indexPath
             self?.productSearchApi(page: 1)
         }
-        
         categoryView.rightTableView.addHeaderWithHeader(withBeginRefresh: false, animation: false) {
             [weak self] (page) in
             self?.productSearchApi(page: page)

+ 16 - 7
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailDescription/ProductDetailDescriptionTableViewCell.swift

@@ -10,7 +10,7 @@ import UIKit
 
 class ProductDetailDescriptionTableViewCell: UITableViewCell {
     
-    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> UITableViewCell {
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailDescriptionTableViewCell {
         let ID = "ProductDetailDescriptionTableViewCell"
         tableView.register(ProductDetailDescriptionTableViewCell.self, forCellReuseIdentifier: ID)
         let cell : ProductDetailDescriptionTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! ProductDetailDescriptionTableViewCell
@@ -50,14 +50,23 @@ class ProductDetailDescriptionTableViewCell: UITableViewCell {
     
     private lazy var descriptionLabel: UILabel = {
         let descriptionLabel = UILabel()
-        let str = "<p>你好</p ><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;这是一个例子,请显示</p ><p>外加一个table</p ><table><tbody><tr class=\"firstRow\"><td valign=\"top\" width=\"261\">aaaa</td><td valign=\"top\" width=\"261\">bbbb</td><td valign=\"top\" width=\"261\">cccc</td></tr></tbody></table><p></p >"
-        let htmlData = NSString(string: str).data(using: String.Encoding.unicode.rawValue)
-        let options = [NSAttributedString.DocumentReadingOptionKey.documentType:
-            NSAttributedString.DocumentType.html]
-        let attributedString = try? NSMutableAttributedString(data: htmlData ?? Data(),options: options,documentAttributes: nil)
-        descriptionLabel.attributedText = attributedString
+
         descriptionLabel.numberOfLines = 0
         return descriptionLabel
     }()
+    
+    var productDetailModel : ProductDetailModel? {
+        didSet {
+            var str = productDetailModel?.desc ?? ""
+            if str == "" {
+                str = "暂无数据"
+            }
+            let htmlData = NSString(string: str).data(using: String.Encoding.unicode.rawValue)
+            let options = [NSAttributedString.DocumentReadingOptionKey.documentType:
+                NSAttributedString.DocumentType.html]
+            let attributedString = try? NSMutableAttributedString(data: htmlData ?? Data(),options: options,documentAttributes: nil)
+            descriptionLabel.attributedText = attributedString
+        }
+    }
 
 }

+ 13 - 22
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailHotSell/ProductDetailHotSellTableViewCell.swift

@@ -10,7 +10,8 @@ import UIKit
 
 class ProductDetailHotSellTableViewCell: UITableViewCell {
 
-    var productModels : [ProductModel]? {
+    
+    var productSearchListModel: ProductSearchListModel? {
         didSet {
             collectionView.reloadData()
         }
@@ -77,43 +78,33 @@ class ProductDetailHotSellTableViewCell: UITableViewCell {
     /// 添加购物车
     ///
     /// - Returns:
-    func addCart(productModel:ProductModel,indexPath:IndexPath) {
-        productModel.isSelect = 1
-        productModel.amount = 1
-        SwiftMoyaNetWorkServiceProduct.shared().productCartAddApi(productMdl: productModel) {
+    func addCart(productSearchModel:ProductSearchModel,indexPath:IndexPath) {
+        productSearchModel.isSelect = 1
+        SwiftMoyaNetWorkServiceProduct.shared().productCartListAddApi(productSearchModel: productSearchModel, completion: {
             [weak self] (cartAmountModel) -> (Void) in
-            let cartAmountModel = cartAmountModel as? CartAmountModel
-            let productModel = self?.productModels![indexPath.row]
-            productModel!.cartId = cartAmountModel?.id ?? 0
-            productModel!.amount = 1
             self!.collectionView.reloadItems(at: [indexPath])
             SwiftProgressHUD.shared().showText("已加入购物车")
-            
-        }
+        })
     }
     
 }
 
 extension ProductDetailHotSellTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
     func numberOfSections(in collectionView: UICollectionView) -> Int {
-        
-//        return productModels?.isEmpty ?? true ? 0 : 1
-        return 1
-
+        return productSearchListModel?.data?.isEmpty ?? true ? 0 : 1
     }
     
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-//        return productModels?.isEmpty ?? true ? 0 : productModels?.count ?? 0
-        return 10
+        return productSearchListModel?.data?.isEmpty ?? true ? 0 : productSearchListModel?.data?.count ?? 0
     }
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         let cell = ProductDetailHotSellCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
-//        cell.productModel = productModels?[indexPath.row]
-//        cell.plusClosure = {
-//            [weak self] (productModel,indexPath) in
-//            self?.addCart(productModel: productModel!, indexPath: indexPath!)
-//        }
+        cell.productSearchModel = productSearchListModel?.data?[indexPath.row]
+        cell.plusClosure = {
+            [weak self] (productSearchModel,indexPath) in
+            self?.addCart(productSearchModel: productSearchModel!, indexPath: indexPath!)
+        }
         return cell
         
     }

+ 19 - 6
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailParameter/ProductDetailParameterTableViewCell.swift

@@ -10,7 +10,7 @@ import UIKit
 
 class ProductDetailParameterTableViewCell: UITableViewCell {
 
-    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> UITableViewCell {
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailParameterTableViewCell {
         let ID = "ProductDetailParameterTableViewCell"
         tableView.register(ProductDetailParameterTableViewCell.self, forCellReuseIdentifier: ID)
         let cell : ProductDetailParameterTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! ProductDetailParameterTableViewCell
@@ -30,11 +30,7 @@ class ProductDetailParameterTableViewCell: UITableViewCell {
     
     var indexPath: IndexPath? {
         didSet {
-            if indexPath?.row == 4 {
-                lookTestReportButton.isHidden = false
-            }else {
-                lookTestReportButton.isHidden = true
-            }
+
         }
     }
     //MRAK: - 设置View
@@ -87,5 +83,22 @@ class ProductDetailParameterTableViewCell: UITableViewCell {
         lookTestReportButton.isHidden = true
         return lookTestReportButton
     }()
+    
+    var productDetailModel : ProductDetailModel? {
+        didSet {
+            let productDetailParameterModel = productDetailModel?.parameter?[(indexPath?.row)!]
+            titleLabel.text = productDetailParameterModel?.name
+            contentLabel.text = productDetailParameterModel?.value
+            if productDetailModel?.report?.isEmpty ?? true {
+                lookTestReportButton.isHidden = true
+            }else {
+                if indexPath?.row == productDetailModel?.parameter?.count ?? 1 - 1 {
+                    lookTestReportButton.isHidden = false
+                }else {
+                    lookTestReportButton.isHidden = true
+                }
+            }
+        }
+    }
 
 }

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailShop/ProductDetailShopTableViewCell.swift

@@ -103,7 +103,7 @@ class ProductDetailShopTableViewCell: UITableViewCell {
     
     var productDetailModel : ProductDetailModel? {
         didSet {
-            shopImageView.kf.setImage(with: kURLImage(name: productDetailModel?.shopName ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            shopImageView.kf.setImage(with: kURLImage(name: productDetailModel?.logoImg ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
             shopNameLabel.text = productDetailModel?.shopName
             
         }

+ 50 - 9
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailView.swift

@@ -12,6 +12,7 @@ import FWPopupView
 
 class ProductDetailView: BaseView {
     
+    var section : Int = 0
     
     var index : Int? {
         didSet {
@@ -31,14 +32,26 @@ class ProductDetailView: BaseView {
         didSet {
             tableView.ly_startLoading()
             tableView.reloadData()
-            if productDetailModel?.imgs?.isEmpty ?? true {
-                tableView.tableHeaderView = nil
-            }else {
-                tableView.ly_hideEmpty()
-                tableView.tableHeaderView = productDetailTableViewHeaderView
-                productDetailTableViewHeaderView.productDetailModel = productDetailModel
+            if productDetailModel != nil {
+                
+                if productDetailModel?.commentNumber != 0 && productDetailModel?.commentNumber != nil {
+                    titles[2] = "商品评价" + "(" + "\(productDetailModel?.commentNumber ?? 0)" + ")"
+
+                }
+                if productDetailModel?.imgs?.isEmpty ?? true {
+                    tableView.tableHeaderView = nil
+                }else {
+                    tableView.ly_hideEmpty()
+                    tableView.tableHeaderView = productDetailTableViewHeaderView
+                    productDetailTableViewHeaderView.productDetailModel = productDetailModel
+                }
             }
-           
+        }
+    }
+    
+    var productSearchListModel: ProductSearchListModel? {
+        didSet {
+            tableView.reloadSections([4], with: UITableView.RowAnimation.none)
         }
     }
 
@@ -155,6 +168,9 @@ class ProductDetailView: BaseView {
     private lazy var topButton : UIButton = {
         let topButton = UIButton(type: UIButton.ButtonType.custom)
         topButton.setImage(kImage(name: "product_detail_top"), for: UIControl.State.normal)
+        topButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            self?.tableView.scrollToTop()
+        }).disposed(by: disposeBag)
         return topButton
     }()
     
@@ -185,7 +201,7 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
     func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
         switch section {
         case 5:
-            return 5
+            return productDetailModel?.parameter?.isEmpty ?? true ? 0 :  productDetailModel?.parameter?.count ?? 0
         default:
             return 1
         }
@@ -215,12 +231,15 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
             return cell
         case 4:
             let cell = ProductDetailHotSellTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.productSearchListModel = productSearchListModel
             return cell
         case 5:
             let cell = ProductDetailParameterTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.productDetailModel = productDetailModel
             return cell
         case 6:
             let cell = ProductDetailDescriptionTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.productDetailModel = productDetailModel
             return cell
             
         default:
@@ -276,8 +295,30 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
     }
     
     func scrollViewDidScroll(_ scrollView: UIScrollView) {
-        let offset = scrollView.contentOffset
+        var offset = scrollView.contentOffset
         NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ProductDetailView"), object: offset)
+
+        if (!(scrollView.isTracking || scrollView.isDecelerating)) {
+            //不是用户滚动的,比如setContentOffset等方法,引起的滚动不需要处理。
+            return;
+        }
+        offset.y =  offset.y + kNavBarTotalHeight
+       
+        if  offset.y > 251 + kSafeTabBarHeight {
+            
+            let indexPath = tableView.indexPathForRow(at: offset)
+            if indexPath != nil {
+                var rect = tableView.rect(forSection: (indexPath?.section)!)
+                if rect.size.height + kNavBarTotalHeight - tableView.frame.size.height < 0 {
+                    rect.size.height = tableView.frame.size.height - kNavBarTotalHeight - rect.size.height
+                    tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: rect.size.height, right: 0)
+                }
+                if indexPath!.section % 2 == 0  {
+                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ProductDetailViewSection"), object: indexPath!.section)
+
+                }
+            }
+        }
     }
     
 }

+ 47 - 7
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/ViewController/ProductDetailViewController.swift

@@ -17,6 +17,8 @@ class ProductDetailViewController: BaseViewController {
     weak var observe : NSObjectProtocol?
     
     var productModel : ProductModel?
+    
+    var productSearchModel : ProductSearchModel?
 
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -47,6 +49,7 @@ class ProductDetailViewController: BaseViewController {
         productDetailView.tableView.addHeaderWithHeader(withBeginRefresh: true, animation: false) {
             [weak self] (page) in
             self?.productDetailApi()
+            self?.productListApi()
         }
         
         observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ProductDetailView"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
@@ -59,16 +62,56 @@ class ProductDetailViewController: BaseViewController {
                 self?.navigationBar.wr_setBackgroundAlpha(alpha: 1)
             }
         }
-        
+        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ProductDetailViewSection"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
+            let item = notification.object as! Int
+            if item == 0 {
+                self?.segmentedView.selectItemAt(index: item)
+            }else {
+                self?.segmentedView.selectItemAt(index: item/2)
+            }
+        }
     }
     
     private func productDetailApi() {
-        SwiftMoyaNetWorkServiceProduct.shared().productDetailApi(id: self.productModel?.id ?? 0) {
-            [weak self] (productDetailModel) -> (Void) in
-            self?.productDetailView.productDetailModel = productDetailModel as? ProductDetailModel
+        if self.productModel != nil {
+            SwiftMoyaNetWorkServiceProduct.shared().productDetailApi(id: self.productModel?.id ?? 0) {
+                [weak self] (productDetailModel) -> (Void) in
+                self?.productDetailView.productDetailModel = productDetailModel as? ProductDetailModel
+            }
+        }
+        
+        if self.productSearchModel != nil {
+            SwiftMoyaNetWorkServiceProduct.shared().productDetailApi(id: self.productSearchModel?.id ?? 0) {
+                [weak self] (productDetailModel) -> (Void) in
+                self?.productDetailView.productDetailModel = productDetailModel as? ProductDetailModel
+            }
+        }
+        
+    }
+    
+    /// 获取商家商品列表
+    private func productListApi() {
+        
+        if self.productModel != nil {
+            SwiftMoyaNetWorkServiceProduct.shared().productListApi(page: 1, shopId: productSearchModel?.shopId ?? 0,desc: 2, fieldOrder: 1) {
+                [weak self] (productListModel) -> (Void) in
+                let productSearchListModel = productListModel as? ProductSearchListModel
+                self?.productDetailView.productSearchListModel = productSearchListModel
+            }
         }
+        
+        if self.productSearchModel != nil {
+            SwiftMoyaNetWorkServiceProduct.shared().productListApi(page: 1, shopId: productSearchModel?.shopId ?? 0,desc: 2, fieldOrder: 1) {
+                [weak self] (productListModel) -> (Void) in
+                let productSearchListModel = productListModel as? ProductSearchListModel
+                self?.productDetailView.productSearchListModel = productSearchListModel
+            }
+        }
+        
+       
     }
     
+    
     lazy var productDetailView: ProductDetailView = {
         let productDetailView = ProductDetailView()
         return productDetailView
@@ -122,9 +165,6 @@ extension ProductDetailViewController : JXSegmentedViewDelegate {
         if index == 0 {
             self.segmentedView.isHidden = true
             navigationBar.wr_setBackgroundAlpha(alpha: 0)
-        }else {
-            self.segmentedView.isHidden = false
-            navigationBar.wr_setBackgroundAlpha(alpha: 1)
         }
 
         productDetailView.index = index

+ 10 - 9
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductView/CollectionViewCell/ProductDetailHotSell/ProductDetailHotSellCollectionViewCell.swift

@@ -13,9 +13,10 @@ import RxSwift
 class ProductDetailHotSellCollectionViewCell: UICollectionViewCell {
     let disposeBag = DisposeBag()
     
-    typealias PlusClosure = (_ productModel: ProductModel?,_ indexPath:IndexPath?) -> Void
+    typealias PlusClosure = (_ productSearchModel: ProductSearchModel?,_ indexPath:IndexPath?) -> Void
     var plusClosure : PlusClosure?
     
+    
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ProductDetailHotSellCollectionViewCell {
         let ID = "ProductDetailHotSellCollectionViewCell"
         collectionView.register(ProductDetailHotSellCollectionViewCell.self, forCellWithReuseIdentifier: ID)
@@ -55,7 +56,7 @@ class ProductDetailHotSellCollectionViewCell: UICollectionViewCell {
         iconImagView.snp.makeConstraints { (make) in
             make.top.equalTo(5)
             make.centerX.equalToSuperview()
-            make.height.equalTo(80)
+            make.size.equalTo(80)
         }
         titleLabel.snp.makeConstraints { (make) in
             make.top.equalTo(iconImagView.snp.bottom).offset(5)
@@ -140,19 +141,19 @@ class ProductDetailHotSellCollectionViewCell: UICollectionViewCell {
         plusButton.rx.tap.subscribe(onNext: {
             [weak self] (data) in
             if let plusClosure = self?.plusClosure {
-                plusClosure(self?.productModel, self?.indexPath)
+                plusClosure(self?.productSearchModel, self?.indexPath)
             }
         }).disposed(by: disposeBag)
         return plusButton
     }()
     
-    var productModel : ProductModel? {
+    var productSearchModel : ProductSearchModel? {
         didSet {
-            iconImagView.kf.setImage(with: kURLImage(name: productModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
-            titleLabel.text = productModel?.saleName
-            detailTitleLabel.text = productModel?.saleName
-            sellPriceLabel.text = "¥\(productModel?.price ?? 0)"
-            let attributeString = NSMutableAttributedString(string:"¥\(productModel?.originPrice ?? 0)")
+            iconImagView.kf.setImage(with: kURLImage(name: productSearchModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            titleLabel.text = productSearchModel?.saleName
+            detailTitleLabel.text = productSearchModel?.saleName
+            sellPriceLabel.text = "¥\(productSearchModel?.price ?? 0)"
+            let attributeString = NSMutableAttributedString(string:"¥\(productSearchModel?.originPrice ?? 0)")
             attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
             markPriceLabel.attributedText = attributeString
         }

+ 12 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductView/CollectionViewCell/ProductMallSlidingLeftRight/ProductSlidingLeftRightCollectionViewCell.swift

@@ -153,4 +153,16 @@ class ProductSlidingLeftRightCollectionViewCell: UICollectionViewCell {
         }
     }
     
+    var productSearchModel : ProductSearchModel? {
+        didSet {
+            iconImagView.kf.setImage(with: kURLImage(name: productSearchModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            titleLabel.text = productSearchModel?.saleName
+            detailTitleLabel.text = productSearchModel?.saleName
+            sellPriceLabel.text = "¥\(productSearchModel?.price ?? 0)"
+            let attributeString = NSMutableAttributedString(string:"¥\(productSearchModel?.originPrice ?? 0)")
+            attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
+            markPriceLabel.attributedText = attributeString
+        }
+    }
+    
 }

+ 20 - 6
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductView/CollectionViewCell/ProductSlidingTopBottom/ProductSlidingTopBottomCollectionViewCell.swift

@@ -7,8 +7,15 @@
 //
 
 import UIKit
+import RxSwift
 
 class ProductSlidingTopBottomCollectionViewCell: UICollectionViewCell {
+    
+    let disposeBag = DisposeBag()
+    
+    typealias PlusClosure = (_ productSearchModel: ProductSearchModel?,_ indexPath:IndexPath?) -> Void
+     var plusClosure : PlusClosure?
+    
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ProductSlidingTopBottomCollectionViewCell {
         let ID = "ProductSlidingTopBottomCollectionViewCell"
         collectionView.register(ProductSlidingTopBottomCollectionViewCell.self, forCellWithReuseIdentifier: ID)
@@ -128,16 +135,23 @@ class ProductSlidingTopBottomCollectionViewCell: UICollectionViewCell {
     private lazy var plusButton: UIButton = {
         let plusButton = UIButton(type: UIButton.ButtonType.custom)
         plusButton.setImage(kImage(name: "shopping_mall_plus"), for: UIControl.State.normal)
+        plusButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            if let plusClosure = self?.plusClosure {
+                plusClosure(self?.productSearchModel,self?.indexPath)
+            }
+
+        }).disposed(by: disposeBag)
         return plusButton
     }()
     
-    var productModel: ProductModel? {
+    var productSearchModel: ProductSearchModel? {
         didSet {
-            iconImagView.kf.setImage(with: kURLImage(name: productModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
-            titleLabel.text = productModel?.productName
-            sellNumberLabel.text = "已售\(productModel?.amount ?? 0)件"
-            sellPriceLabel.text = "¥\(productModel?.skuPrice ?? 0)"
-            let attributeString = NSMutableAttributedString(string:"¥\(productModel?.productPrice ?? 0)")
+            iconImagView.kf.setImage(with: kURLImage(name: productSearchModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            titleLabel.text = productSearchModel?.name
+            sellNumberLabel.text = "已售\(productSearchModel?.totalCount ?? 0)件"
+            sellPriceLabel.text = "¥\(productSearchModel?.price ?? 0)"
+            let attributeString = NSMutableAttributedString(string:"¥\(productSearchModel?.originPrice ?? 0)")
             attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
             markPriceLabel.attributedText = attributeString
 

+ 50 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopSectionHeaderView.swift

@@ -10,6 +10,9 @@ import UIKit
 
 class ShopSectionHeaderView: BaseView {
     
+    var priceState = 0 // 0默认,1down,2up
+    var salesState = 0 // 0默认,1down,2up
+    
     override func setupViews() {
         backgroundColor = UIColor.white
         addSubview(priceButton)
@@ -35,7 +38,30 @@ class ShopSectionHeaderView: BaseView {
         priceButton.setTitle("价格", for: UIControl.State.normal)
         priceButton.setTitleColor(k333333Color, for: UIControl.State.normal)
         priceButton.titleLabel?.font = kRegularFont14
-        priceButton.setImage(kImage(name: "common_store_arrow_top"), for: UIControl.State.normal)
+        priceButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
+        priceButton.isSelected = true
+        priceState = 2
+        priceButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            self?.salesVolumeButton.isSelected = false
+            self?.salesState = 0
+            if priceButton.isSelected && self?.priceState == 2 {
+                self?.priceState = 1
+                priceButton.setImage(kImage(name: "common_store_arrow_down"), for: UIControl.State.normal)
+            }else if priceButton.isSelected && self?.priceState == 1 {
+                self?.priceState = 2
+                priceButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
+            }else {
+                priceButton.isSelected = true
+                self?.priceState = 2
+                
+                priceButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
+                
+                self?.salesVolumeButton.setImage(kImage(name: "common_store_arrow_normal"), for: UIControl.State.normal)
+            }
+            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ShopVCDesc"), object: nil, userInfo: ["desc":self?.priceState as Any,"field_order":2])
+
+        }).disposed(by: disposeBag)
         return priceButton
     }()
     
@@ -45,6 +71,29 @@ class ShopSectionHeaderView: BaseView {
         salesVolumeButton.setTitleColor(k333333Color, for: UIControl.State.normal)
         salesVolumeButton.titleLabel?.font = kRegularFont14
         salesVolumeButton.setImage(kImage(name: "common_store_arrow_normal"), for: UIControl.State.normal)
+        salesState = 0
+        salesVolumeButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            self?.priceButton.isSelected = false
+            self?.priceState = 0
+            if salesVolumeButton.isSelected && self?.salesState == 2 {
+                self?.salesState = 1
+                salesVolumeButton.setImage(kImage(name: "common_store_arrow_down"), for: UIControl.State.normal)
+
+            }else if salesVolumeButton.isSelected && self?.salesState == 1 {
+                self?.salesState = 2
+                salesVolumeButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
+
+            }else {
+                salesVolumeButton.isSelected = true
+                self?.salesState = 2
+                self?.priceButton.setImage(kImage(name: "common_store_arrow_normal"), for: UIControl.State.normal)
+
+                salesVolumeButton.setImage(kImage(name: "common_store_arrow_up"), for: UIControl.State.normal)
+
+            }
+            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ShopVCDesc"), object: nil, userInfo: ["desc":self?.salesState as Any,"field_order":1])
+        }).disposed(by: disposeBag)
         return salesVolumeButton
     }()
 

+ 28 - 3
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopView.swift

@@ -10,11 +10,21 @@ import UIKit
 
 class ShopView: BaseView {
     
+    typealias DidSelectItemBlock = (_ indexPath: IndexPath) -> Void
+    var didSelectItemBlock : DidSelectItemBlock?
+    
     var shopModel : ShopModel? {
         didSet {
             tableView.reloadSections([0], with: UITableView.RowAnimation.none)
         }
     }
+    
+    var paginationModel: PaginationModel? {
+        didSet {
+            tableView.reloadSections([0], with: UITableView.RowAnimation.none)
+        }
+    }
+    
     var productSearchModelArray : Array<ProductSearchModel>? {
         didSet {
             if productSearchModelArray?.isEmpty ?? true {
@@ -22,10 +32,12 @@ class ShopView: BaseView {
             }else {
                 tableView.isHiddenFooter(false)
             }
-           tableView.reloadSections([1], with: UITableView.RowAnimation.none)
+            tableView.reloadRows(at: [IndexPath(row: 0, section: 1)], with: UITableView.RowAnimation.none)
         }
     }
     
+    
+    
     override func setupViews() {
         addSubview(tableView)
     }
@@ -42,7 +54,7 @@ class ShopView: BaseView {
         tableView.backgroundColor = kf7f8faColor
         tableView.dataSource = self
         tableView.delegate = self
-        tableView.estimatedRowHeight = 0.000001
+        tableView.estimatedRowHeight = 82
         tableView.estimatedSectionFooterHeight = 0.000001
         tableView.estimatedSectionHeaderHeight = 0.000001
         return tableView
@@ -63,13 +75,26 @@ extension ShopView : UITableViewDelegate, UITableViewDataSource {
         switch indexPath.section {
         case 0:
             let cell = ShopViewShopInfoTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
-
+            cell.shopModel = shopModel
+            cell.paginationModel = paginationModel
+            cell.lookButtonClosure = {
+                [weak self] isSelected in
+                self?.shopModel?.isOpen = isSelected
+                tableView.reloadRows(at: [indexPath], with: UITableView.RowAnimation.none)
+            }
             return cell
         case 1:
             let cell = ShopViewTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.productSearchModelArray = productSearchModelArray
             cell.frame = tableView.bounds
             cell.layoutIfNeeded()
             cell.reloadData()
+            cell.didSelectItemBlock = {
+                [weak self] indexPath in
+                if let didSelectItemBlock = self?.didSelectItemBlock {
+                    didSelectItemBlock(indexPath)
+                }
+            }
             return cell
         default:
             return UITableViewCell()

+ 86 - 6
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopViewShopInfoTableViewCell.swift

@@ -7,10 +7,15 @@
 //
 
 import UIKit
+import RxSwift
 
 class ShopViewShopInfoTableViewCell: UITableViewCell {
     
-    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> UITableViewCell {
+    let disposeBag = DisposeBag()
+    
+    typealias LookButtonClosure = (_ isSelected: Bool) -> Void
+    var lookButtonClosure : LookButtonClosure?
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ShopViewShopInfoTableViewCell {
         let ID = "ShopViewShopInfoTableViewCell"
         tableView.register(ShopViewShopInfoTableViewCell.self, forCellReuseIdentifier: ID)
         let cell : ShopViewShopInfoTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! ShopViewShopInfoTableViewCell
@@ -41,6 +46,7 @@ class ShopViewShopInfoTableViewCell: UITableViewCell {
         addSubview(shopNameLabel)
         addSubview(productNumberLabel)
         addSubview(descriptionLabel)
+        addSubview(lookButton)
     }
     
     func setupLayouts() {
@@ -61,11 +67,16 @@ class ShopViewShopInfoTableViewCell: UITableViewCell {
             make.height.equalTo(14)
             make.bottom.equalTo(shopIconImageView).offset(-11)
         }
-        descriptionLabel.snp.makeConstraints { (make) in
+        descriptionLabel.snp.remakeConstraints { (make) in
             make.top.equalTo(shopIconImageView.snp.bottom).offset(10)
             make.left.equalTo(14)
             make.right.equalTo(-14)
-            make.bottom.equalTo(-20)
+            make.bottom.equalTo(-35)
+        }
+        lookButton.snp.makeConstraints { (make) in
+            make.top.equalTo(descriptionLabel.snp.bottom).offset(10)
+            make.right.equalTo(-18)
+            make.bottom.equalTo(-10)
         }
     }
     
@@ -96,6 +107,7 @@ class ShopViewShopInfoTableViewCell: UITableViewCell {
         descriptionLabel.textColor = UIColor.white
         descriptionLabel.font = kRegularFont14
         descriptionLabel.numberOfLines = 0
+        descriptionLabel.sizeToFit()
         let str = "彩虹星球专营店主营生鲜蔬菜肉类生禽彩虹星球专营店主营生鲜蔬菜、肉类生禽彩虹彩虹星球专营店主营生鲜蔬菜肉类生禽彩虹星球专营店主营生鲜蔬菜、肉类生禽彩虹彩虹星球专营店主营生鲜蔬菜肉类生禽彩虹星球专营店主营生鲜蔬菜、肉类生禽彩虹…"
         let attributeString = NSMutableAttributedString(string:str)
         attributeString.changeAllLineSpacing(2)
@@ -103,15 +115,83 @@ class ShopViewShopInfoTableViewCell: UITableViewCell {
         return descriptionLabel
     }()
     
+    lazy var lookButton: UIButton = {
+        let lookButton = UIButton(type: UIButton.ButtonType.custom)
+        lookButton.setTitleColor(UIColor.white, for: UIControl.State.normal)
+        lookButton.titleLabel?.font = kRegularFont14
+        lookButton.isHidden = true
+        lookButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+            lookButton.isSelected = !lookButton.isSelected
+            if let lookButtonClosure = self?.lookButtonClosure {
+                lookButtonClosure(lookButton.isSelected)
+            }
+        }).disposed(by: disposeBag)
+        return lookButton
+    }()
+    
     var shopModel : ShopModel? {
         didSet {
-            shopIconImageView.kf.setImage(with: kURLImage(name: shopModel?.logoImg ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
-             shopNameLabel.text = shopModel?.shopName
+            
             let str = shopModel?.shopDesc
             let attributeString = NSMutableAttributedString(string:str ?? "")
             attributeString.changeAllLineSpacing(2)
             descriptionLabel.attributedText = attributeString
-            productNumberLabel.text = "全部商品:200"
+            
+            
+            let dict = [
+                NSAttributedString.Key.font: UIFont.systemFont(ofSize: 14),
+            ]
+            let height: CGFloat = str?.boundingRect(with: CGSize(width: kScreenWidth-60-28-10, height:CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: dict, context: nil).size.height ?? 0
+            let labelHeight = height
+            
+            let count = Int((labelHeight) / descriptionLabel.font.lineHeight)
+
+            
+            if (shopModel?.isOpen ?? false) {
+                descriptionLabel.numberOfLines = 0
+                descriptionLabel.lineBreakMode = .byCharWrapping
+                lookButton.isSelected = true
+                lookButton.setImage(UIImage.init(named: "common_word_packup"), for: UIControl.State.selected)
+                lookButton.setTitle("收起", for: UIControl.State.normal)
+            } else {
+                descriptionLabel.numberOfLines = 2
+                descriptionLabel.lineBreakMode = .byTruncatingTail
+                lookButton.isSelected = false
+                lookButton.setImage(kImage(name: "common_word_unfold"), for: UIControl.State.normal)
+                lookButton.setTitle("查看更多", for: UIControl.State.normal)
+            }
+            lookButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.right, imageTitleSpace: 4)
+
+            
+            shopIconImageView.kf.setImage(with: kURLImage(name: shopModel?.logoImg ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+             shopNameLabel.text = shopModel?.shopName
+
+            
+            if count > 2 {
+                descriptionLabel.snp.remakeConstraints { (make) in
+                    make.top.equalTo(shopIconImageView.snp.bottom).offset(10)
+                    make.left.equalTo(14)
+                    make.right.equalTo(-14)
+                    make.bottom.equalTo(-35)
+                }
+                lookButton.isHidden = false
+            }else {
+                descriptionLabel.snp.remakeConstraints { (make) in
+                    make.top.equalTo(shopIconImageView.snp.bottom).offset(10)
+                    make.left.equalTo(14)
+                    make.right.equalTo(-14)
+                    make.bottom.equalTo(-10)
+                }
+                lookButton.isHidden = true
+            }
+            
+        }
+    }
+    
+    var paginationModel: PaginationModel? {
+        didSet{
+            productNumberLabel.text = "全部商品:\(paginationModel?.total ?? 0)"
+
         }
     }
 }

+ 37 - 2
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/View/ShopViewTableViewCell.swift

@@ -10,6 +10,15 @@ import UIKit
 
 class ShopViewTableViewCell: UITableViewCell {
 
+    var productSearchModelArray : Array<ProductSearchModel>? {
+        didSet {
+            collectionView.reloadData()
+        }
+    }
+    
+    typealias DidSelectItemBlock = (_ indexPath: IndexPath) -> Void
+    var didSelectItemBlock : DidSelectItemBlock?
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ShopViewTableViewCell {
         let ID = "ShopViewTableViewCell"
         tableView.register(ShopViewTableViewCell.self, forCellReuseIdentifier: ID)
@@ -74,23 +83,47 @@ class ShopViewTableViewCell: UITableViewCell {
         }
         self.collectionView.collectionViewLayout.invalidateLayout()
     }
+    
+    /// 添加购物车
+    ///
+    /// - Returns:
+    func addCart(productSearchModel:ProductSearchModel,indexPath:IndexPath) {
+            productSearchModel.isSelect = 1
+        SwiftMoyaNetWorkServiceProduct.shared().productCartListAddApi(productSearchModel: productSearchModel, completion: {
+            [weak self] (cartAmountModel) -> (Void) in
+            self!.collectionView.reloadItems(at: [indexPath])
+            SwiftProgressHUD.shared().showText("已加入购物车")
+        })
+    }
+    
 
 }
 
 extension ShopViewTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
     func numberOfSections(in collectionView: UICollectionView) -> Int {
-        return 1
+        return productSearchModelArray?.isEmpty ?? true ? 0 : 1
     }
     
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        return 5
+        return productSearchModelArray?.isEmpty ?? true ? 0 :  productSearchModelArray?.count ?? 0
     }
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         let cell = ProductSlidingTopBottomCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        cell.productSearchModel = productSearchModelArray![indexPath.row]
+        cell.plusClosure = {
+            [weak self] (productSearchModel,indexPath) in
+            self?.addCart(productSearchModel: productSearchModel!, indexPath: indexPath!)
+        }
         return cell
     }
     
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        if let didSelectItemBlock = didSelectItemBlock {
+            didSelectItemBlock(indexPath)
+        }
+    }
+    
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
         return CGSize(width:170 * kScaleWidth, height: 170 * kScaleWidth + 80)
     }
@@ -99,5 +132,7 @@ extension ShopViewTableViewCell: UICollectionViewDelegateFlowLayout,UICollection
         return UIEdgeInsets(top: 10, left: 14 * kScaleWidth, bottom: 10, right: 14 * kScaleWidth)
     }
     
+    
+    
 }
 

+ 25 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/Shop/ViewController/ShopViewController.swift

@@ -13,6 +13,9 @@ class ShopViewController: BaseViewController {
     var productDetailModel : ProductDetailModel?
     var productSearchModelArray = Array<ProductSearchModel>()
     
+    var fieldOrder : Int = 2
+    var desc : Int = 2
+    
     override func viewDidLoad() {
         super.viewDidLoad()
         setupViews()
@@ -48,6 +51,23 @@ class ShopViewController: BaseViewController {
         shopView.tableView.addFooterWithWithHeader(withAutomaticallyRefresh: true) { [weak self] (page) in
             self?.productListApi(page: page)
         }
+        
+        _ = NotificationCenter.default.rx
+            .notification(NSNotification.Name("ShopVCDesc"))
+            .takeUntil(self.rx.deallocated) //页面销毁自动移除通知监听
+            .subscribe(onNext: {
+                [weak self] notification in
+                self?.desc = notification.userInfo!["desc"] as! Int
+                self?.fieldOrder = notification.userInfo!["field_order"] as! Int
+                self?.productListApi(page: 1)
+            })
+        shopView.didSelectItemBlock = {
+            [weak self] indexPath in
+            let vc = ProductDetailViewController()
+            let productSearch = self?.productSearchModelArray[indexPath.row]
+            vc.productSearchModel = productSearch
+            self?.navigationController?.pushViewController(vc, animated: true)
+        }
        
     }
     
@@ -67,11 +87,15 @@ class ShopViewController: BaseViewController {
     
     /// 获取商家商品列表
     private func productListApi(page:Int) {
-        SwiftMoyaNetWorkServiceProduct.shared().productListApi(page: 1, shopId: productDetailModel?.shopId ?? 0) {  [weak self] (productListModel) -> (Void) in
+        
+        SwiftMoyaNetWorkServiceProduct.shared().productListApi(page: page, shopId: productDetailModel?.shopId ?? 0,desc: desc, fieldOrder: fieldOrder) {
+            [weak self] (productListModel) -> (Void) in
             let productSearchListModel = productListModel as? ProductSearchListModel
             if productSearchListModel?.pagination?.currentPage ?? 1  <= productSearchListModel?.pagination?.totalPages ?? 1 {
                 if productSearchListModel?.pagination?.currentPage == 1{
                     self?.productSearchModelArray.removeAll()
+                    self?.shopView.paginationModel = productSearchListModel?.pagination
+                    self?.shopView.tableView.resetNoMoreData()
                 }
                 self?.productSearchModelArray = (self?.productSearchModelArray)! + (productSearchListModel?.data!)!
                 self?.shopView.productSearchModelArray = self?.productSearchModelArray

+ 4 - 0
RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductDetailModel.swift

@@ -24,6 +24,7 @@ class ProductDetailModel : NSObject, Mappable{
     var id : Int?
     var img : String?
     var imgs : [String]?
+    var logoImg : String?
     var isConfirmSale : Int?
     var limitNumber : Int?
     var limitType : String?
@@ -41,6 +42,7 @@ class ProductDetailModel : NSObject, Mappable{
     var totalCount : Int?
     var totalStock : Int?
     var video : String?
+    var commentNumber : Int?
     var label : [ProductDetailLabelModel]?
     var parameter : [ProductDetailParameterModel]?
     var sku : [ProductDetailSkuModel]?
@@ -59,6 +61,7 @@ class ProductDetailModel : NSObject, Mappable{
         id <- map["id"]
         img <- map["img"]
         imgs <- map["imgs"]
+        logoImg <- map["logo_img"]
         isConfirmSale <- map["is_confirm_sale"]
         label <- map["label"]
         limitNumber <- map["limit_number"]
@@ -80,6 +83,7 @@ class ProductDetailModel : NSObject, Mappable{
         totalCount <- map["total_count"]
         totalStock <- map["total_stock"]
         video <- map["video"]
+        commentNumber <- map["comment_number"]
         
     }
 }

+ 1 - 0
RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductSearchModel.swift

@@ -36,6 +36,7 @@ class ProductSearchModel : NSObject, Mappable{
     var totalCount : Int?
     var totalStock : Int?
     var upStatus : Int?
+    var isSelect : Int?
     
     
     class func newInstance(map: Map) -> Mappable?{

+ 3 - 2
RainbowPlanet/RainbowPlanet/Service/Model/ShopModel/ShopModel.swift

@@ -23,7 +23,7 @@ class ShopModel : NSObject, Mappable{
 	var proportion : Int?
 	var provinceId : Int?
 	var provinceName : String?
-	var shopDesc : String?
+    var shopDesc : String?
 	var shopId : Int?
 	var shopName : String?
 	var shopShortName : String?
@@ -31,7 +31,8 @@ class ShopModel : NSObject, Mappable{
 	var status : Int?
 	var updatedAt : String?
 	var verifyType : Int?
-
+    
+    var isOpen : Bool?
 
 	class func newInstance(map: Map) -> Mappable?{
 		return ShopModel()

+ 49 - 6
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaNetWorkServiceProduct.swift

@@ -28,10 +28,10 @@ class SwiftMoyaNetWorkServiceProduct: NSObject {
     /// - Parameters:
     ///   - keyword: 关键字:商品名称、子标题、规格
     ///   - category_id: 一级分类id
-    ///   - order: 排序字段:商品分类排序、商品排序、价格、销量、好评率
-    ///   - desc: 排序方式:desc、asc
+    ///   - field_order: 1销量 2价格
+    ///   - desc: 排序方式:1 desc倒序2 asc正序
     ///   - completion: 回调
-    func productListApi(page:Int = 1,shopId:Int  = 0, keyword:String = "",categoryId:Int = 0, order:String = "",desc:String = "",fieldOrder:Int = 0,completion: @escaping apiCallBack) {
+    func productListApi(page:Int = 1,shopId:Int  = 0, keyword:String = "",categoryId:Int = 0,desc:Int = 0,fieldOrder:Int = 0,completion: @escaping apiCallBack) {
         var parameters = Dictionary<String,Any>()
         // 本地获取city_id
         let loacationModel = LocationModel.shared().getLocationModel()
@@ -43,15 +43,19 @@ class SwiftMoyaNetWorkServiceProduct: NSObject {
         parameters.updateValue(deliver_type ?? "2", forKey: "deliver_type")
         parameters.updateValue(page, forKey: "page")
         parameters.updateValue(keyword, forKey: "keyword")
-        parameters.updateValue(order, forKey: "order")
-        parameters.updateValue(desc, forKey: "desc")
         
-        if shopId != 0 {
+        if shopId == 0 {
             parameters.updateValue("", forKey: "shop_id")
         }else {
             parameters.updateValue(shopId, forKey: "shop_id")
         }
         
+        if desc == 0 {
+            parameters.updateValue("", forKey: "desc")
+        }else {
+            parameters.updateValue(desc, forKey: "desc")
+        }
+        
         if fieldOrder == 0 {
             parameters.updateValue("", forKey: "field_order")
         }else {
@@ -208,6 +212,45 @@ class SwiftMoyaNetWorkServiceProduct: NSObject {
         }
     }
     
+    // MARK: - 购物车-添加
+    /// 购物车店铺-添加
+    ///
+    /// - Parameters:
+    ///   - productMdl: 商品Model
+    ///   - completion: 回调
+    func productCartListAddApi(productSearchModel:ProductSearchModel, completion: @escaping apiCallBack) {
+        var parameters = Dictionary<String,Any>()
+        
+        
+        parameters.updateValue(productSearchModel.shopId ?? "", forKey: "shop_id")
+        parameters.updateValue(productSearchModel.shopName ?? "", forKey: "shop_name")
+        parameters.updateValue(productSearchModel.id ?? "", forKey: "product_id")
+        parameters.updateValue(productSearchModel.price ?? "", forKey: "product_price")
+        parameters.updateValue(productSearchModel.skuId ?? "", forKey: "sku_id")
+        parameters.updateValue(productSearchModel.totalCount ?? "", forKey: "amount")
+        parameters.updateValue(productSearchModel.isSelect ?? 1, forKey: "is_select")
+        parameters.updateValue(productSearchModel.name ?? "", forKey: "product_name")
+        parameters.updateValue(productSearchModel.img  ?? "", forKey: "product_img")
+        parameters.updateValue(productSearchModel.skuName  ?? "", forKey: "sku_name")
+        
+        // 本地获取city_id/city_name
+        let loacationModel = LocationModel.shared().getLocationModel()
+        let baiduToCityModel = BaiduToCityFactory.shared.query(bjcityId: loacationModel!.cityCode)
+        parameters.updateValue(baiduToCityModel.areaCode, forKey: "city_id")
+        parameters.updateValue(baiduToCityModel.areaName, forKey: "city_name")
+        
+        // 本地获取deliver_type
+        let deliver_type = DeliveryMethodTypeModel.shared().getModel()?.deliveryMethodType
+        parameters.updateValue(deliver_type ?? 0, forKey: "deliver_type")
+        
+        SwiftProgressHUD.shared().showWait()
+        SwiftMoyaNetWorkManager.shared().request(CartAmountModel.self,target: MultiTarget(SwiftMoyaServiceProductApi.productCartAdd(parameters: parameters))) { (cartAmountModel) in
+            SwiftProgressHUD.shared().hide()
+            completion(cartAmountModel)
+        }
+    }
+    
+    
     // MARK: - 购物车-删除
     /// 购物车-删除
     ///

+ 4 - 0
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaServiceProductApi.swift

@@ -29,6 +29,10 @@ public let kProductDetailApi = "/product/detail"
 /// 热销商品
 public let kProductHotSaleApi = "/product/hotSales"
 
+// MARK: - 商品评价列表
+/// 商品评价列表
+public let kProductCommentListApi = "/product/commentList"
+
 // MARK: - 购物车列表
 /// 购物车列表
 public let kProductCartListApi = "/product/cartList"

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_down.imageset/common_store_arrow_down.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_down.imageset/common_store_arrow_down@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_down.imageset/common_store_arrow_down@3x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_top.imageset/common_store_arrow_top.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_top.imageset/common_store_arrow_top@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_top.imageset/common_store_arrow_top@3x.png


+ 3 - 3
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_top.imageset/Contents.json

@@ -2,17 +2,17 @@
   "images" : [
     {
       "idiom" : "universal",
-      "filename" : "common_store_arrow_top.png",
+      "filename" : "common_store_arrow_up.png",
       "scale" : "1x"
     },
     {
       "idiom" : "universal",
-      "filename" : "common_store_arrow_top@2x.png",
+      "filename" : "common_store_arrow_up@2x.png",
       "scale" : "2x"
     },
     {
       "idiom" : "universal",
-      "filename" : "common_store_arrow_top@3x.png",
+      "filename" : "common_store_arrow_up@3x.png",
       "scale" : "3x"
     }
   ],

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_up.imageset/common_store_arrow_up.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_up.imageset/common_store_arrow_up@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_store_arrow_up.imageset/common_store_arrow_up@3x.png


+ 23 - 0
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_packup.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "common_word_packup.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "common_word_packup@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "common_word_packup@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_packup.imageset/common_word_packup.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_packup.imageset/common_word_packup@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_packup.imageset/common_word_packup@3x.png


+ 26 - 0
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_unfold.imageset/Contents.json

@@ -0,0 +1,26 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "common_word_unfold.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "common_word_unfold@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "common_word_unfold@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  },
+  "properties" : {
+    "template-rendering-intent" : "original"
+  }
+}

BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_unfold.imageset/common_word_unfold.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_unfold.imageset/common_word_unfold@2x.png


BIN
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_word_unfold.imageset/common_word_unfold@3x.png


+ 6 - 0
RainbowPlanet/RainbowPlanet/Tools/MJRefreshEX/UIScrollView+MJRefreshEX.h

@@ -38,6 +38,12 @@
  没有数据结束刷新
  */
 - (void)endFooterNoMoreData;
+
+
+/**
+ 回复数据结束刷新
+ */
+- (void)resetNoMoreData;
  
 /**
  是否隐藏Footer