南鑫林 il y a 6 ans
Parent
commit
9993736100

+ 16 - 0
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 */; };
@@ -353,6 +355,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>"; };
@@ -766,6 +770,7 @@
 		A70B2C192286B4ED00B2449F /* View */ = {
 			isa = PBXGroup;
 			children = (
+				A70B2C702289016600B2449F /* ProductDetailSkuView */,
 				A70B2C3B228819E900B2449F /* ProductDetailHeader */,
 				A70B2C39228819CA00B2449F /* Cell */,
 				A70B2C1F2286B54500B2449F /* ProductDetailView.swift */,
@@ -942,6 +947,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 = (
@@ -2988,6 +3002,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 */,
@@ -3015,6 +3030,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
     }()

+ 42 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailSkuView/ProductDetailSkuSectionHeaerCollectionReusableView.swift

@@ -9,5 +9,46 @@
 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
+    }()
 }

+ 314 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailSkuView/ProductDetailSkuView.swift

@@ -7,7 +7,320 @@
 //
 
 import UIKit
+import FWPopupView
+import RxSwift
+import RxCocoa
 
-class ProductDetailSkuView: baseView {
+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)
+    }
+    
 }
+

+ 28 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductDetail/View/ProductDetailView.swift

@@ -8,9 +8,19 @@
 
 import UIKit
 import PPBadgeViewSwift
+import FWPopupView
 
 class ProductDetailView: BaseView {
     
+    
+    var index : Int? {
+        didSet {
+            let reloadSection = 2 * index!
+            let indexPtah = IndexPath(row: 0, section: reloadSection)
+            tableView.scrollToRow(at: indexPtah, at: UITableView.ScrollPosition.top, animated: true)
+        }
+    }
+    
     var productDetailModel : ProductDetailModel? {
         didSet {
             tableView.ly_startLoading()
@@ -131,6 +141,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 +154,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 {

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

@@ -7,6 +7,7 @@
 //
 
 import UIKit
+import JXSegmentedView
 
 class ProductDetailViewController: BaseViewController {
     
@@ -20,15 +21,22 @@ class ProductDetailViewController: BaseViewController {
     }
     
     override func setupViews() {
-        navigationBar.wr_setBackgroundAlpha(alpha: 0)
+        navigationBar.wr_setBackgroundAlpha(alpha: 1)
         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) {
@@ -48,5 +56,69 @@ 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
+        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) {
+        //传递didClickSelectedItemAt事件给listContainerView,必须调用!!!
+//        listContainerView.didClickSelectedItem(at: index)
+        productDetailView.index = index
+    }
+    
+    // 滚动选中的情况才会调用该方法
+    func segmentedView(_ segmentedView: JXSegmentedView, didScrollSelectedItemAt index: Int) {
+        
+    }
+    
+    // 正在滚动中的回调
+    func segmentedView(_ segmentedView: JXSegmentedView, scrollingFrom leftIndex: Int, to rightIndex: Int, percent: CGFloat) {
+        //传递scrolling事件给listContainerView,必须调用!!!
+//        listContainerView.segmentedViewScrolling(from: leftIndex, to: rightIndex, percent: percent, selectedIndex: segmentedView.selectedIndex)
+    }
+    
+    /// 是否允许点击选中目标index的item
+    func segmentedView(_ segmentedView: JXSegmentedView, canClickItemAt index: Int) -> Bool {
+        return true
+    }
 }

+ 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: - 商品详情
 /// 商品详情