Browse Source

Merge branch 'feature/nanxinlin' into develop

南鑫林 6 years ago
parent
commit
2193b01fc4
20 changed files with 666 additions and 90 deletions
  1. 17 1
      RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj
  2. 2 0
      RainbowPlanet/RainbowPlanet/Macro/ColorMacro.swift
  3. 1 1
      RainbowPlanet/RainbowPlanet/Modules/CommonModules/LocationModule/SelfRecommendation/View/SelfRecommendationView.swift
  4. 9 2
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailProductInfo/ProductDetailProductInfoTableViewCell.swift
  5. 7 0
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailProductSku/ProductDetailProductSkuTableViewCell.swift
  6. 54 0
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailSkuView/ProductDetailSkuSectionHeaerCollectionReusableView.swift
  7. 326 0
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailSkuView/ProductDetailSkuView.swift
  8. 53 3
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailView.swift
  9. 95 1
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/ViewController/ProductDetailViewController.swift
  10. 75 72
      RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductDetailModel.swift
  11. 1 1
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaServiceProductApi.swift
  12. 0 6
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/BG/Contents.json
  13. 23 0
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_sku_cancel.imageset/Contents.json
  14. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_sku_cancel.imageset/common_sku_cancel.png
  15. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_sku_cancel.imageset/common_sku_cancel@2x.png
  16. BIN
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/CommonIcon/common_sku_cancel.imageset/common_sku_cancel@3x.png
  17. 3 3
      RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/BG/bg0.imageset/Contents.json
  18. 0 0
      RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/my_bg.imageset/my_bg.png
  19. 0 0
      RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/my_bg.imageset/my_bg@2x.png
  20. 0 0
      RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/my_bg.imageset/my_bg@3x.png

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

@@ -38,6 +38,8 @@
 		A70B2C6722887B2B00B2449F /* ProductDetailEvaluationListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A70B2C6622887B2B00B2449F /* ProductDetailEvaluationListTableViewCell.swift */; };
 		A70B2C6B2288815300B2449F /* PickHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A70B2C6A2288815300B2449F /* PickHeaderView.swift */; };
 		A70B2C6D2288815E00B2449F /* PickViewOneComponentsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A70B2C6C2288815E00B2449F /* PickViewOneComponentsView.swift */; };
+		A70B2C732289019200B2449F /* ProductDetailSkuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A70B2C722289019200B2449F /* ProductDetailSkuView.swift */; };
+		A70B2C75228920BA00B2449F /* ProductDetailSkuSectionHeaerCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A70B2C74228920BA00B2449F /* ProductDetailSkuSectionHeaerCollectionReusableView.swift */; };
 		A70EBBC022561179000AD74F /* Extension+UITableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A70EBBBF22561179000AD74F /* Extension+UITableView.swift */; };
 		A7190167227543DB00104A50 /* baidu_cityid_rel.json in Resources */ = {isa = PBXBuildFile; fileRef = A7190166227543DB00104A50 /* baidu_cityid_rel.json */; };
 		A71901692275464000104A50 /* ProvinceCityAreaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A71901682275464000104A50 /* ProvinceCityAreaView.swift */; };
@@ -354,6 +356,8 @@
 		A70B2C6622887B2B00B2449F /* ProductDetailEvaluationListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductDetailEvaluationListTableViewCell.swift; sourceTree = "<group>"; };
 		A70B2C6A2288815300B2449F /* PickHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickHeaderView.swift; sourceTree = "<group>"; };
 		A70B2C6C2288815E00B2449F /* PickViewOneComponentsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PickViewOneComponentsView.swift; sourceTree = "<group>"; };
+		A70B2C722289019200B2449F /* ProductDetailSkuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductDetailSkuView.swift; sourceTree = "<group>"; };
+		A70B2C74228920BA00B2449F /* ProductDetailSkuSectionHeaerCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductDetailSkuSectionHeaerCollectionReusableView.swift; sourceTree = "<group>"; };
 		A70EBBBF22561179000AD74F /* Extension+UITableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Extension+UITableView.swift"; sourceTree = "<group>"; };
 		A7190166227543DB00104A50 /* baidu_cityid_rel.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = baidu_cityid_rel.json; sourceTree = "<group>"; };
 		A71901682275464000104A50 /* ProvinceCityAreaView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProvinceCityAreaView.swift; sourceTree = "<group>"; };
@@ -769,6 +773,7 @@
 		A70B2C192286B4ED00B2449F /* View */ = {
 			isa = PBXGroup;
 			children = (
+				A70B2C702289016600B2449F /* ProductDetailSkuView */,
 				A70B2C3B228819E900B2449F /* ProductDetailHeader */,
 				A70B2C39228819CA00B2449F /* Cell */,
 				A70B2C1F2286B54500B2449F /* ProductDetailView.swift */,
@@ -811,8 +816,8 @@
 				A70B2C442288408E00B2449F /* ProductDetailHotSell */,
 				A70B2C4122883B2F00B2449F /* ProductDetailShop */,
 				A70B2C3C2288259200B2449F /* ProductDetailEvaluation */,
-				A70B2C3A228819DC00B2449F /* ProductDetailProductInfo */,
 				A70B2C38228819B500B2449F /* ProductDetailProductSku */,
+				A70B2C3A228819DC00B2449F /* ProductDetailProductInfo */,
 			);
 			path = Cell;
 			sourceTree = "<group>";
@@ -945,6 +950,15 @@
 			path = PickView;
 			sourceTree = "<group>";
 		};
+		A70B2C702289016600B2449F /* ProductDetailSkuView */ = {
+			isa = PBXGroup;
+			children = (
+				A70B2C722289019200B2449F /* ProductDetailSkuView.swift */,
+				A70B2C74228920BA00B2449F /* ProductDetailSkuSectionHeaerCollectionReusableView.swift */,
+			);
+			path = ProductDetailSkuView;
+			sourceTree = "<group>";
+		};
 		A71901622275411C00104A50 /* ProvinceCityArea */ = {
 			isa = PBXGroup;
 			children = (
@@ -3000,6 +3014,7 @@
 				A7284401224DBB7700F82F30 /* SwiftMoyaNetWorkServiceUser.swift in Sources */,
 				A7B4E728228160BA0012914A /* ProductRightSideleftPictureCollectionViewCell.swift in Sources */,
 				BDEF7793228575A800ED0AC0 /* CommonPayCell.swift in Sources */,
+				A70B2C75228920BA00B2449F /* ProductDetailSkuSectionHeaerCollectionReusableView.swift in Sources */,
 				A72843FC224DB6B800F82F30 /* SwiftMoyaServiceUserApi.swift in Sources */,
 				A7CC750622714306003C4F38 /* MessageNoticeHeaderCollectionReusableView.swift in Sources */,
 				A7C3DD1A226422BF00FA262E /* SwiftMoyaServiceSMSApi.swift in Sources */,
@@ -3027,6 +3042,7 @@
 				BD20F1D32283D0ED00677D8E /* ShoppingCartPaySuccessCell.swift in Sources */,
 				A71AA52822732173008FF1A5 /* SwiftMoyaNetWorkServiceConfig.swift in Sources */,
 				A775CC0322377C6500EBDCF8 /* EmptyView.swift in Sources */,
+				A70B2C732289019200B2449F /* ProductDetailSkuView.swift in Sources */,
 				A70B2C4322883B4E00B2449F /* ProductDetailShopTableViewCell.swift in Sources */,
 				A70B2C102286A3BC00B2449F /* ProductDetailModel.swift in Sources */,
 				A72A72A922321DE000B21995 /* NumberKeyboard.swift in Sources */,

+ 2 - 0
RainbowPlanet/RainbowPlanet/Macro/ColorMacro.swift

@@ -24,6 +24,8 @@ let kEnabledTitleColor = UIColor(hexString: "#FFFFFF")
 
 let k333333Color = UIColor(hexString: "333333")
 
+let kE6E6E6Color = UIColor(hexString: "E6E6E6")
+
 let k404040Color = UIColor(hexString: "404040")
 
 let kFE352BColor = UIColor(hexString: "FE352B")

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/CommonModules/LocationModule/SelfRecommendation/View/SelfRecommendationView.swift

@@ -87,7 +87,7 @@ class SelfRecommendationView: BaseView {
     
     private lazy var locationBgImageView: UIImageView = {
         let locationBgImageView = UIImageView()
-        locationBgImageView.image = kImage(name: "bg0")
+        locationBgImageView.image = kImage(name: "my_bg")
         locationBgImageView.isUserInteractionEnabled = true
         return locationBgImageView
     }()

+ 9 - 2
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailProductInfo/ProductDetailProductInfoTableViewCell.swift

@@ -203,14 +203,21 @@ class ProductDetailProductInfoTableViewCell: UITableViewCell {
                         let attributeString = NSMutableAttributedString(string:"¥\( sku.originPrice ?? 0)")
                         attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle(rawValue: NSUnderlineStyle.single.rawValue), color: UIColor.white)
                         markPriceLabel.attributedText = attributeString
-                        soldNumberLabel.text = "已售\(sku.originPrice ?? 0)"
                         stockLabel.text = "仅剩\(sku.stock ?? 0)"
                     }
                 }
             }
             titleLabel.text = productDetailModel?.name
-            timeLabel.text = "  次日达  "
             detailTitleLabel.text = productDetailModel?.subtitle
+            soldNumberLabel.text = "已售\(productDetailModel?.totalCount ?? 0)"
+            
+            if productDetailModel?.receiveType == 0 {
+                 timeLabel.text = "  次日达  "
+            }else if productDetailModel?.receiveType == 1 {
+                timeLabel.text = "  \(productDetailModel?.receiveTime ?? "")  "
+            }else if productDetailModel?.receiveType == 2 {
+                timeLabel.text = "  \(productDetailModel?.receiveTime ?? "")  "
+            }
             
         }
     }

+ 7 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/Cell/ProductDetailProductSku/ProductDetailProductSkuTableViewCell.swift

@@ -10,6 +10,13 @@ import UIKit
 
 class ProductDetailProductSkuTableViewCell: UITableViewCell {
     
+    var productDetailModel : ProductDetailModel? {
+        didSet {
+            
+        }
+    }
+    
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ProductDetailProductSkuTableViewCell {
         let ID = "ProductDetailProductSkuTableViewCell"
         tableView.register(ProductDetailProductSkuTableViewCell.self, forCellReuseIdentifier: ID)

+ 54 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailSkuView/ProductDetailSkuSectionHeaerCollectionReusableView.swift

@@ -0,0 +1,54 @@
+//
+//  ProductDetailSkuSectionHeaerCollectionReusableView.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/5/13.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class ProductDetailSkuSectionHeaerCollectionReusableView: UICollectionReusableView {
+    class func headerWith(collectionView:UICollectionView,kind: String,indexPath: IndexPath) -> UICollectionReusableView {
+        let ID = "ProductDetailSkuSectionHeaerCollectionReusableView"
+        collectionView.register(ProductDetailSkuSectionHeaerCollectionReusableView.self, forSupplementaryViewOfKind: kind, withReuseIdentifier: ID)
+        let headerView : ProductDetailSkuSectionHeaerCollectionReusableView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: ID, for: indexPath) as! ProductDetailSkuSectionHeaerCollectionReusableView
+        headerView.indexPath = indexPath
+        return headerView
+    }
+    
+    var indexPath : IndexPath? {
+        didSet {
+            
+        }
+    }
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+        setupViews()
+        setupLayouts()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    //MARK: - 设置View
+    private func setupViews() {
+        addSubview(titleLabel)
+    }
+    
+    private func setupLayouts() {
+        titleLabel.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.left.equalTo(14)
+        }
+    }
+    
+    private lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.text = "颜色"
+        titleLabel.textColor = k333333Color
+        titleLabel.font = kRegularFont15
+        return titleLabel
+    }()
+}

+ 326 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailSkuView/ProductDetailSkuView.swift

@@ -0,0 +1,326 @@
+//
+//  ProductDetailSkuView.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/5/13.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import FWPopupView
+import RxSwift
+import RxCocoa
+
+class ProductDetailSkuView: FWPopupView {
+    
+    let disposeBag = DisposeBag()
+    
+    
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+        setupViews()
+        setupLayouts()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    private func setupViews() {
+       
+        
+        addSubview(topBgView)
+        topBgView.addSubview(productImageView)
+        topBgView.addSubview(priceLabel)
+        topBgView.addSubview(stockLabel)
+        topBgView.addSubview(oneLineLabel)
+        
+        addSubview(closeButton)
+        
+        addSubview(sureButton)
+        
+        addSubview(bottomBgView)
+        bottomBgView.addSubview(twoLineLabel)
+        bottomBgView.addSubview(buyNumberLabel)
+        bottomBgView.addSubview(limitLabel)
+        
+        bottomBgView.addSubview(buyNumberBgView)
+        buyNumberBgView.addSubview(plusButton)
+        buyNumberBgView.addSubview(oneVLine)
+        buyNumberBgView.addSubview(twoVLine)
+        buyNumberBgView.addSubview(numberLabel)
+        buyNumberBgView.addSubview(reduceButton)
+        
+        addSubview(collectionView)
+
+    }
+    
+    private func setupLayouts() {
+        
+        closeButton.snp.makeConstraints { (make) in
+            make.top.right.equalToSuperview()
+            make.size.equalTo(46)
+        }
+        
+        topBgView.snp.makeConstraints { (make) in
+            make.top.equalToSuperview()
+            make.left.equalTo(14)
+            make.right.equalTo(-15)
+            make.height.equalTo(115)
+        }
+        productImageView.snp.makeConstraints { (make
+            ) in
+            make.top.left.equalToSuperview()
+            make.size.equalTo(100)
+        }
+        stockLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(productImageView.snp.right).offset(22)
+            make.bottom.equalTo(productImageView)
+        }
+        priceLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(stockLabel)
+            make.bottom.equalTo(stockLabel.snp.top).offset(-7)
+        }
+        oneLineLabel.snp.makeConstraints { (make) in
+            make.bottom.left.right.equalToSuperview()
+            make.height.equalTo(1)
+        }
+        sureButton.snp.makeConstraints { (make) in
+            make.bottom.equalTo(-kSafeTabBarHeight)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(50)
+        }
+        bottomBgView.snp.makeConstraints { (make) in
+            make.bottom.equalTo(sureButton.snp.top).offset(-13)
+            make.left.equalTo(14)
+            make.right.equalTo(-14)
+            make.height.equalTo(50)
+        }
+        twoLineLabel.snp.makeConstraints { (make) in
+            make.top.left.right.equalToSuperview()
+            make.height.equalTo(1)
+        }
+        buyNumberLabel.snp.makeConstraints { (make) in
+            make.centerY.left.equalToSuperview()
+        }
+        limitLabel.snp.makeConstraints { (make) in
+            make.centerY.left.equalTo(buyNumberLabel)
+        }
+        
+        plusButton.snp.makeConstraints { (make) in
+            make.top.bottom.right.equalToSuperview()
+            make.width.equalTo(buyNumberBgView.height)
+        }
+        oneVLine.snp.makeConstraints { (make) in
+            make.top.bottom.equalToSuperview()
+            make.width.equalTo(1)
+            make.right.equalTo(plusButton.snp.left)
+        }
+        
+        numberLabel.snp.makeConstraints { (make) in
+            make.top.bottom.equalToSuperview()
+            make.width.greaterThanOrEqualTo(36)
+            make.right.equalTo(oneVLine.snp.left)
+        }
+        
+        twoVLine.snp.makeConstraints { (make) in
+            make.top.bottom.equalToSuperview()
+            make.width.equalTo(1)
+            make.right.equalTo(numberLabel.snp.left)
+        }
+        reduceButton.snp.makeConstraints { (make) in
+            make.top.bottom.equalToSuperview()
+            make.right.equalTo(twoVLine.snp.left)
+            make.width.equalTo(22)
+        }
+        
+        buyNumberBgView.snp.makeConstraints { (make) in
+            make.centerY.equalToSuperview()
+            make.height.equalTo(22)
+            make.right.equalTo(plusButton)
+            make.left.equalTo(reduceButton)
+        }
+        collectionView.snp.makeConstraints { (make) in
+            make.top.equalTo(topBgView.snp.bottom)
+            make.bottom.equalTo(bottomBgView.snp.top)
+            make.left.right.equalToSuperview()
+        }
+    }
+
+    private lazy var closeButton : UIButton = {
+        let closeButton = UIButton(type: UIButton.ButtonType.custom)
+        closeButton.setImage(kImage(name: "common_sku_cancel"), for: UIControl.State.normal)
+        closeButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            self?.hide()
+        }).disposed(by: disposeBag)
+        return closeButton
+    }()
+    
+    private lazy var topBgView: UIView = {
+        let topBgView = UIView()
+        return topBgView
+    }()
+    
+    private lazy var productImageView: UIImageView = {
+        let productImageView = UIImageView()
+        productImageView.image = kImage(name: "pic_preload")
+        return productImageView
+    }()
+    
+    private lazy var priceLabel: UILabel = {
+        let priceLabel = UILabel()
+        priceLabel.text = "¥16.8"
+        priceLabel.textColor = kfe352bColor
+        priceLabel.font = kMediumFont18
+        return priceLabel
+    }()
+    
+    private lazy var stockLabel: UILabel = {
+        let stockLabel = UILabel()
+        stockLabel.text = "库存2300件"
+        stockLabel.textColor = k333333Color
+        stockLabel.font = kMediumFont13
+        return stockLabel
+    }()
+    
+    lazy var oneLineLabel: UILabel = {
+        let oneLineLabel = UILabel()
+        oneLineLabel.backgroundColor = kf5f5f5Color
+        return oneLineLabel
+    }()
+    
+    private lazy var collectionView: UICollectionView = {
+        let collectionView = UICollectionView.init(frame: CGRect.zero, collectionViewLayout: collectionViewLayout)
+        collectionView.backgroundColor = UIColor.white
+        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
+        collectionViewLayout.estimatedItemSize = CGSize(width: 72, height: 25)
+        return collectionViewLayout
+    }()
+    
+    private lazy var bottomBgView: UIView = {
+        let bottomBgView = UIView()
+        return bottomBgView
+    }()
+    
+    private lazy var twoLineLabel: UILabel = {
+        let twoLineLabel = UILabel()
+        twoLineLabel.backgroundColor = kf5f5f5Color
+        return twoLineLabel
+    }()
+    
+    private lazy var buyNumberLabel: UILabel = {
+        let buyNumberLabel = UILabel()
+        buyNumberLabel.text = "购买数量"
+        buyNumberLabel.textColor = k333333Color
+        buyNumberLabel.font = kRegularFont15
+        return buyNumberLabel
+    }()
+    
+    private lazy var limitLabel: UILabel = {
+        let limitLabel = UILabel()
+        limitLabel.text = "(每人限购3件)"
+        limitLabel.textColor = k999999Color
+        limitLabel.font = kRegularFont13
+        return limitLabel
+    }()
+    
+    private lazy var buyNumberBgView: UIView = {
+        let buyNumberBgView = UIView()
+        buyNumberBgView.cornerRadius = 2
+        buyNumberBgView.masksToBounds = true
+        return buyNumberBgView
+    }()
+    
+    lazy var plusButton : UIButton = {
+        let plusButton = UIButton(type: UIButton.ButtonType.custom)
+        plusButton.setTitle("+", for: UIControl.State.normal)
+        plusButton.setTitleColor(k333333Color, for: UIControl.State.normal)
+        plusButton.titleLabel?.font = kMediumFont13
+        return plusButton
+    }()
+    
+    lazy var reduceButton : UIButton = {
+        let reduceButton = UIButton(type: UIButton.ButtonType.custom)
+        reduceButton.setTitle("-", for: UIControl.State.normal)
+        reduceButton.setTitleColor(k333333Color, for: UIControl.State.normal)
+        reduceButton.titleLabel?.font = kMediumFont13
+        return reduceButton
+    }()
+    
+    lazy var numberLabel : UILabel = {
+        let numberLabel = UILabel()
+        numberLabel.text = "  99  "
+        numberLabel.textColor = k333333Color
+        numberLabel.font = kMediumFont13
+        return numberLabel
+    }()
+    
+    lazy var oneVLine: UILabel = {
+        let oneVLine = UILabel()
+        oneVLine.backgroundColor = kE6E6E6Color
+        return oneVLine
+    }()
+    
+    lazy var twoVLine: UILabel = {
+        let twoVLine = UILabel()
+        twoVLine.backgroundColor = kE6E6E6Color
+        return twoVLine
+    }()
+    
+    lazy var sureButton: UIButton = {
+        let sureButton = UIButton(type: UIButton.ButtonType.custom)
+        sureButton.backgroundColor = kFFA42FColor
+        sureButton.setTitle("确  认", for: UIControl.State.normal)
+        sureButton.setTitleColor(UIColor.white, for: UIControl.State.normal)
+        sureButton.titleLabel?.font = kRegularFont16
+        return sureButton
+    }()
+    
+
+}
+
+extension ProductDetailSkuView: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
+    func numberOfSections(in collectionView: UICollectionView) -> Int {
+        return 3
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+        return 6
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        let cell = ProductDetailProductSkuLabelCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        return cell
+        
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
+        return UIEdgeInsets(top: 0, left: 14, bottom: 10, right: 14)
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
+        if kind == UICollectionView.elementKindSectionHeader {
+
+            let headerView = ProductDetailSkuSectionHeaerCollectionReusableView.headerWith(collectionView: collectionView, kind:  UICollectionView.elementKindSectionHeader, indexPath: indexPath)
+            return headerView
+        }
+        return UICollectionReusableView()
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
+         return CGSize(width:kScreenWidth, height:41)
+    }
+    
+}
+

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

@@ -8,9 +8,34 @@
 
 import UIKit
 import PPBadgeViewSwift
+import FWPopupView
 
 class ProductDetailView: BaseView {
     
+    
+    var index : Int? {
+        didSet {
+            if index == 0 {
+                tableView.scrollToTop()
+            }else {
+                let reloadSection = 2 * index!
+                let indexPtah = IndexPath(row: 0, section: reloadSection)
+                tableView.scrollToRow(at: indexPtah, at: UITableView.ScrollPosition.top, animated: true)
+//                UIEdgeInsets insets = self.collectionView.scrollIndicatorInsets;
+//
+//                CGRect rect = attr.frame;
+//                rect.size = self.collectionView.frame.size;
+//                rect.size.height -= insets.top + insets.bottom;
+//                CGFloat offset = (rect.origin.y + rect.size.height) - self.collectionView.contentSize.height;
+//                if ( offset > 0.0 ) rect = CGRectOffset(rect, 0, -offset);
+//
+//                [_collectionView scrollRectToVisible:rect animated:YES];
+
+            }
+           
+        }
+    }
+    
     var productDetailModel : ProductDetailModel? {
         didSet {
             tableView.ly_startLoading()
@@ -131,6 +156,10 @@ class ProductDetailView: BaseView {
         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
     }()
     
@@ -140,6 +169,20 @@ class ProductDetailView: BaseView {
         return topButton
     }()
     
+    func productDetailSkuView() {
+        let view = ProductDetailSkuView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 157+113+257*kScaleWidth))
+        
+        let vProperty = FWPopupViewProperty()
+        vProperty.popupCustomAlignment = .bottomCenter
+        vProperty.popupAnimationType = .frame
+        vProperty.maskViewColor = UIColor(white: 0, alpha: 0.5)
+        vProperty.touchWildToHide = "1"
+        vProperty.popupViewEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
+        vProperty.animationDuration = 0.2
+        view.vProperty = vProperty
+        view.show()
+    }
+    
 }
 
 extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
@@ -169,6 +212,7 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
             return cell
         case 1:
             let cell = ProductDetailProductSkuTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+            cell.productDetailModel = productDetailModel
             cell.frame = tableView.bounds
             cell.layoutIfNeeded()
             cell.reloadData()
@@ -237,7 +281,13 @@ extension ProductDetailView : UITableViewDelegate, UITableViewDataSource {
         return nil
     }
     
+    func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
+        
+    }
+    
+    func scrollViewDidScroll(_ scrollView: UIScrollView) {
+        let offset = scrollView.contentOffset
+        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ProductDetailView"), object: offset)
+    }
+    
 }
-
-
-

+ 95 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/ViewController/ProductDetailViewController.swift

@@ -7,11 +7,17 @@
 //
 
 import UIKit
+import JXSegmentedView
 
 class ProductDetailViewController: BaseViewController {
     
-    var productModel : ProductModel?
+    deinit {
+        NotificationCenter.default.removeObserver(observe!)
+    }
+    weak var observe : NSObjectProtocol?
     
+    var productModel : ProductModel?
+
     override func viewDidLoad() {
         super.viewDidLoad()
         setupViews()
@@ -23,18 +29,37 @@ class ProductDetailViewController: BaseViewController {
         navigationBar.wr_setBackgroundAlpha(alpha: 0)
         view.addSubview(productDetailView)
         view.insertSubview(navigationBar, aboveSubview: productDetailView)
+        navigationBar.addSubview(segmentedView)
     }
     
     override func setupLayouts() {
         productDetailView.snp.makeConstraints { (make) in
             make.edges.equalToSuperview()
         }
+        segmentedView.snp.makeConstraints { (make) in
+            make.top.equalTo(kSafeStatusBarHeight)
+            make.left.equalTo(50)
+            make.right.equalTo(-50)
+            make.bottom.equalToSuperview()
+        }
     }
     override func setupData() {
         productDetailView.tableView.addHeaderWithHeader(withBeginRefresh: true, animation: false) {
             [weak self] (page) in
             self?.productDetailApi()
         }
+        
+        observe = NotificationCenter.default.addObserver(forName: NSNotification.Name("ProductDetailView"), object: nil, queue: OperationQueue.main) {[weak self] (notification) in
+            let offset = notification.object as! CGPoint
+            if offset.y <= 0  {
+                self?.segmentedView.isHidden = true
+                self?.navigationBar.wr_setBackgroundAlpha(alpha: 0)
+            }else {
+                self?.segmentedView.isHidden = false
+                self?.navigationBar.wr_setBackgroundAlpha(alpha: 1)
+            }
+        }
+        
     }
     
     private func productDetailApi() {
@@ -48,5 +73,74 @@ class ProductDetailViewController: BaseViewController {
         let productDetailView = ProductDetailView()
         return productDetailView
     }()
+    
+    //1.初始化JXSegmentedView
+    private lazy var segmentedView: JXSegmentedView = {
+        let segmentedView = JXSegmentedView()
+        segmentedView.delegate = self
+        segmentedView.indicators = [indicator]
+        segmentedView.dataSource = segmentedDataSource
+        segmentedView.isHidden = true
+        return segmentedView
+    }()
+    
+    //2.初始化dataSource
+    private lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
+        let segmentedDataSource = JXSegmentedTitleDataSource()
+        segmentedDataSource.titles = ["商品","评价","热销","详情"]
+        segmentedDataSource.isTitleColorGradientEnabled = true
+        segmentedDataSource.isItemSpacingAverageEnabled = true
+        segmentedDataSource.titleNormalColor = k333333Color
+        segmentedDataSource.titleSelectedColor = k333333Color
+        segmentedDataSource.titleNormalFont = kMediumFont18!
+        segmentedDataSource.titleSelectedFont = kMediumFont18
+        
+        //reloadData(selectedIndex:)方法一定要调用,方法内部会刷新数据源数组
+        segmentedDataSource.reloadData(selectedIndex: 0)
+        return segmentedDataSource
+    }()
+    
+    //3.初始化指示器indicator
+    private lazy var indicator: JXSegmentedIndicatorLineView = {
+        let indicator = JXSegmentedIndicatorLineView()
+        indicator.indicatorColor = kFFA42FColor
+        indicator.indicatorHeight = 4
+        indicator.indicatorWidth = 34
+        return indicator
+    }()
 
 }
+
+extension ProductDetailViewController : JXSegmentedViewDelegate {
+    //点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,而不关心具体是点击还是滚动选中的情况。
+    func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
+        
+    }
+    
+    // 点击选中的情况才会调用该方法
+    func segmentedView(_ segmentedView: JXSegmentedView, didClickSelectedItemAt index: Int) {
+        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
+    }
+    
+    // 滚动选中的情况才会调用该方法
+    func segmentedView(_ segmentedView: JXSegmentedView, didScrollSelectedItemAt index: Int) {
+        
+    }
+    
+    // 正在滚动中的回调
+    func segmentedView(_ segmentedView: JXSegmentedView, scrollingFrom leftIndex: Int, to rightIndex: Int, percent: CGFloat) {
+    }
+    
+    /// 是否允许点击选中目标index的item
+    func segmentedView(_ segmentedView: JXSegmentedView, canClickItemAt index: Int) -> Bool {
+        return true
+    }
+}

+ 75 - 72
RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductDetailModel.swift

@@ -6,79 +6,82 @@ import Foundation
 import ObjectMapper
 
 class ProductDetailModel : NSObject, Mappable{
+    
+    class func newInstance(map: Map) -> Mappable?{
+        return ProductDetailModel()
+    }
+    required init?(map: Map){}
+    private override init(){}
 
-	var attributeCategoryId : Int?
-	var bigImg : String?
-	var categoryId1 : Int?
-	var categoryId2 : Int?
-	var categoryId3 : Int?
-	var city : [Int]?
-	var deliverType : Int?
-	var desc : String?
-	var id : Int?
-	var img : String?
-	var imgs : [String]?
-	var isConfirmSale : Int?
-	var label : [ProductDetailLabelModel]?
-	var limitNumber : Int?
-	var limitType : String?
-	var name : String?
-	var otherCode : String?
-	var parameter : [ProductDetailParameterModel]?
-	var receiveTime : String?
-	var receiveType : Int?
-	var report : [String]?
-	var saleName : String?
-	var shopId : Int?
-	var shopName : String?
-	var sku : [ProductDetailSkuModel]?
-	var spec : [ProductDetailSpecNameModel]?
-	var spuCode : String?
-	var storeTypeIds : String?
-	var subtitle : String?
-	var video : String?
-
-
-	class func newInstance(map: Map) -> Mappable?{
-		return ProductDetailModel()
-	}
-	required init?(map: Map){}
-	private override init(){}
-
-	func mapping(map: Map)
-	{
-		attributeCategoryId <- map["attribute_category_id"]
-		bigImg <- map["big_img"]
-		categoryId1 <- map["category_id1"]
-		categoryId2 <- map["category_id2"]
-		categoryId3 <- map["category_id3"]
-		city <- map["city"]
-		deliverType <- map["deliver_type"]
-		desc <- map["desc"]
-		id <- map["id"]
-		img <- map["img"]
-		imgs <- map["imgs"]
-		isConfirmSale <- map["is_confirm_sale"]
-		label <- map["label"]
-		limitNumber <- map["limit_number"]
-		limitType <- map["limit_type"]
-		name <- map["name"]
-		otherCode <- map["other_code"]
-		parameter <- map["parameter"]
-		receiveTime <- map["receive_time"]
-		receiveType <- map["receive_type"]
-		report <- map["report"]
-		saleName <- map["sale_name"]
-		shopId <- map["shop_id"]
-		shopName <- map["shop_name"]
-		sku <- map["sku"]
-		spec <- map["spec"]
-		spuCode <- map["spu_code"]
-		storeTypeIds <- map["store_type_ids"]
-		subtitle <- map["subtitle"]
-		video <- map["video"]
-		
-	}
+    var attributeCategoryId : Int?
+    var bigImg : String?
+    var categoryId1 : Int?
+    var categoryId2 : Int?
+    var categoryId3 : Int?
+    var city : [Int]?
+    var deliverType : Int?
+    var desc : String?
+    var id : Int?
+    var img : String?
+    var imgs : [String]?
+    var isConfirmSale : Int?
+    var limitNumber : Int?
+    var limitType : String?
+    var name : String?
+    var otherCode : String?
+    var receiveTime : String?
+    var receiveType : Int?
+    var report : [String]?
+    var saleName : String?
+    var shopId : Int?
+    var shopName : String?
+    var spuCode : String?
+    var storeTypeIds : String?
+    var subtitle : String?
+    var totalCount : Int?
+    var totalStock : Int?
+    var video : String?
+    var label : [ProductDetailLabelModel]?
+    var parameter : [ProductDetailParameterModel]?
+    var sku : [ProductDetailSkuModel]?
+    var spec : [ProductDetailSpecNameModel]?
+    
+    func mapping(map: Map)
+    {
+        attributeCategoryId <- map["attribute_category_id"]
+        bigImg <- map["big_img"]
+        categoryId1 <- map["category_id1"]
+        categoryId2 <- map["category_id2"]
+        categoryId3 <- map["category_id3"]
+        city <- map["city"]
+        deliverType <- map["deliver_type"]
+        desc <- map["desc"]
+        id <- map["id"]
+        img <- map["img"]
+        imgs <- map["imgs"]
+        isConfirmSale <- map["is_confirm_sale"]
+        label <- map["label"]
+        limitNumber <- map["limit_number"]
+        limitType <- map["limit_type"]
+        name <- map["name"]
+        otherCode <- map["other_code"]
+        parameter <- map["parameter"]
+        receiveTime <- map["receive_time"]
+        receiveType <- map["receive_type"]
+        report <- map["report"]
+        saleName <- map["sale_name"]
+        shopId <- map["shop_id"]
+        shopName <- map["shop_name"]
+        sku <- map["sku"]
+        spec <- map["spec"]
+        spuCode <- map["spu_code"]
+        storeTypeIds <- map["store_type_ids"]
+        subtitle <- map["subtitle"]
+        totalCount <- map["total_count"]
+        totalStock <- map["total_stock"]
+        video <- map["video"]
+        
+    }
 }
 
 class ProductDetailLabelModel : NSObject, Mappable{

+ 1 - 1
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaServiceProductApi.swift

@@ -19,7 +19,7 @@ public let kProductCategoryApi = "/product/categoryList"
 
 // MARK: - 首页商品
 /// 首页商品
-public let kProductHomeProductApi = "/product/honmeProduct"
+public let kProductHomeProductApi = "/product/homeProduct"
 
 // MARK: - 商品详情
 /// 商品详情

+ 0 - 6
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/BG/Contents.json

@@ -1,6 +0,0 @@
-{
-  "info" : {
-    "version" : 1,
-    "author" : "xcode"
-  }
-}

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

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

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


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


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


+ 3 - 3
RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/BG/bg0.imageset/Contents.json

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

RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/BG/bg0.imageset/bg0.png → RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/my_bg.imageset/my_bg.png


RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/BG/bg0.imageset/bg0@2x.png → RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/my_bg.imageset/my_bg@2x.png


RainbowPlanet/RainbowPlanet/Supporting Files/Assets.xcassets/BG/bg0.imageset/bg0@3x.png → RainbowPlanet/RainbowPlanet/Supporting Files/MineModule.xcassets/my_bg.imageset/my_bg@3x.png