Browse Source

Merge branch 'develop' into feature/nanxinlin

* develop:
  购物车 -- 热销商品fixed
南鑫林 6 years ago
parent
commit
45abba00f6

+ 12 - 0
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -275,6 +275,7 @@
 		A7D46092227619CD00A5A54E /* BaiduToCityFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7D46091227619CC00A5A54E /* BaiduToCityFactory.swift */; };
 		A7D460942276854500A5A54E /* BaiduToCity2Model.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7D460932276854500A5A54E /* BaiduToCity2Model.swift */; };
 		A7DC467F22783A47001F3EFC /* EditExpressAddressTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DC467E22783A47001F3EFC /* EditExpressAddressTableViewCell.swift */; };
+		BD15CCD122895E1800EDCE93 /* ProductCartHotSaleCollectionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD15CCD022895E1800EDCE93 /* ProductCartHotSaleCollectionCell.swift */; };
 		BD20F1CB2283C12000677D8E /* ShoppingCartListNoneItemCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD20F1CA2283C12000677D8E /* ShoppingCartListNoneItemCell.swift */; };
 		BD20F1CD2283C51300677D8E /* ShoppingCartFinishPayController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD20F1CC2283C51300677D8E /* ShoppingCartFinishPayController.swift */; };
 		BD20F1CF2283CE2300677D8E /* ShoppingCartFinishPayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD20F1CE2283CE2300677D8E /* ShoppingCartFinishPayView.swift */; };
@@ -606,6 +607,7 @@
 		A7D460932276854500A5A54E /* BaiduToCity2Model.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaiduToCity2Model.swift; sourceTree = "<group>"; };
 		A7DC467E22783A47001F3EFC /* EditExpressAddressTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditExpressAddressTableViewCell.swift; sourceTree = "<group>"; };
 		A7E03A30F40582782EC5DA89 /* Pods_RainbowPlanetTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RainbowPlanetTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+		BD15CCD022895E1800EDCE93 /* ProductCartHotSaleCollectionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCartHotSaleCollectionCell.swift; sourceTree = "<group>"; };
 		BD20F1CA2283C12000677D8E /* ShoppingCartListNoneItemCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartListNoneItemCell.swift; sourceTree = "<group>"; };
 		BD20F1CC2283C51300677D8E /* ShoppingCartFinishPayController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartFinishPayController.swift; sourceTree = "<group>"; };
 		BD20F1CE2283CE2300677D8E /* ShoppingCartFinishPayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartFinishPayView.swift; sourceTree = "<group>"; };
@@ -717,6 +719,7 @@
 		A70B2C132286B1C500B2449F /* CollectionViewCell */ = {
 			isa = PBXGroup;
 			children = (
+				BD15CCCF22895DBD00EDCE93 /* ProductCartHotSaleCollectionCell */,
 				A70B2C472288413E00B2449F /* ProductDetailHotSell */,
 				A70B2C172286B47B00B2449F /* ProductSlidingTopBottom */,
 				A70B2C162286B44600B2449F /* ProductMallBarChart */,
@@ -2482,6 +2485,14 @@
 			path = FMDB;
 			sourceTree = "<group>";
 		};
+		BD15CCCF22895DBD00EDCE93 /* ProductCartHotSaleCollectionCell */ = {
+			isa = PBXGroup;
+			children = (
+				BD15CCD022895E1800EDCE93 /* ProductCartHotSaleCollectionCell.swift */,
+			);
+			path = ProductCartHotSaleCollectionCell;
+			sourceTree = "<group>";
+		};
 		BD3474F722859788000908C5 /* ShoppingCartPayOrder */ = {
 			isa = PBXGroup;
 			children = (
@@ -2998,6 +3009,7 @@
 				A7CC7526227196A8003C4F38 /* AccountSecurityTableViewCell.swift in Sources */,
 				A7CC74F122706FE3003C4F38 /* MessageOneCollectionViewCell.swift in Sources */,
 				A72A72D622321E2700B21995 /* ThirdPartyMacro.swift in Sources */,
+				BD15CCD122895E1800EDCE93 /* ProductCartHotSaleCollectionCell.swift in Sources */,
 				BDF47D80228288F900941AB9 /* ShoppingCartAccountView.swift in Sources */,
 				A7284401224DBB7700F82F30 /* SwiftMoyaNetWorkServiceUser.swift in Sources */,
 				A7B4E728228160BA0012914A /* ProductRightSideleftPictureCollectionViewCell.swift in Sources */,

+ 3 - 3
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartHotSale/ShoppingCartHotSaleTableViewCell.swift

@@ -151,12 +151,12 @@ extension ShoppingCartHotSaleTableViewCell: UICollectionViewDelegateFlowLayout,U
     }
     
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-//        return hotSaleModelArr?.count ?? 0
-        return 3
+        return hotSaleModelArr?.count ?? 0
     }
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
-        let cell = ProductSlidingTopBottomCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        let cell = ProductCartHotSaleCollectionCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        cell.hotProductModel = hotSaleModelArr![indexPath.row]
         return cell
     }
     

+ 12 - 10
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartView.swift

@@ -104,11 +104,12 @@ extension ShoppingCartView : UITableViewDelegate, UITableViewDataSource {
                 return cell
             case 1:
                 // 超值热卖
-                let cell = ShoppingCartHotSaleTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
-                cell.frame = tableView.bounds
-                cell.layoutIfNeeded()
-                cell.reloadData()
-                return cell
+                let hotSaleCell = ShoppingCartHotSaleTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+                hotSaleCell.frame = tableView.bounds
+                hotSaleCell.hotSaleModelArr = hotSaleModelArr
+                hotSaleCell.layoutIfNeeded()
+                hotSaleCell.reloadData()
+                return hotSaleCell
             default:
                 return UITableViewCell()
             }
@@ -134,11 +135,12 @@ extension ShoppingCartView : UITableViewDelegate, UITableViewDataSource {
                 
             } else {
                 // 超值热卖
-                let cell = ShoppingCartHotSaleTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
-                cell.frame = tableView.bounds
-                cell.layoutIfNeeded()
-                cell.reloadData()
-                return cell
+                let hotSaleCell = ShoppingCartHotSaleTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
+                hotSaleCell.frame = tableView.bounds
+                hotSaleCell.hotSaleModelArr = hotSaleModelArr
+                hotSaleCell.layoutIfNeeded()
+                hotSaleCell.reloadData()
+                return hotSaleCell
             }
         }
     }

+ 148 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ProductView/CollectionViewCell/ProductCartHotSaleCollectionCell/ProductCartHotSaleCollectionCell.swift

@@ -0,0 +1,148 @@
+//
+//  ProductCartHotSaleCollectionCell.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/5/13.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import RxSwift
+import RxCocoa
+
+class ProductCartHotSaleCollectionCell: UICollectionViewCell {
+    
+    let disposeBag = DisposeBag()
+    
+    var hotProductModel: ProductSearchModel? {
+        didSet {
+            iconImagView.kf.setImage(with: kURLImage(name: hotProductModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            titleLabel.text = hotProductModel?.saleName
+            sellNumberLabel.text = "已售\(hotProductModel?.totalCount ?? 0)件"
+            sellPriceLabel.text = "¥\(hotProductModel?.price ?? 0)"
+            let attrString = NSMutableAttributedString(string:"¥\(hotProductModel?.originPrice ?? 0)")
+            attrString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
+            markPriceLabel.attributedText = attrString
+        }
+    }
+    
+    class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ProductCartHotSaleCollectionCell {
+        let ID = "ProductCartHotSaleCollectionCell"
+        collectionView.register(ProductCartHotSaleCollectionCell.self, forCellWithReuseIdentifier: ID)
+        let cell : ProductCartHotSaleCollectionCell = collectionView.dequeueReusableCell(withReuseIdentifier: ID, for: indexPath) as! ProductCartHotSaleCollectionCell
+        cell.indexPath = indexPath
+        return cell
+    }
+    //MARK: - indexPath
+    var indexPath: IndexPath?{
+        didSet {
+            
+        }
+    }
+    //MARK: - 初始化
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+        backgroundColor = UIColor.white
+        cornerRadius = 4
+        masksToBounds = true
+        setupViews()
+        setupLayouts()
+        
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    //MRAK: - 设置View
+    private func setupViews() {
+        addSubview(iconImagView)
+        addSubview(titleLabel)
+        addSubview(sellNumberLabel)
+        addSubview(sellPriceLabel)
+        addSubview(markPriceLabel)
+        addSubview(plusButton)
+    }
+    
+    private func setupLayouts() {
+        iconImagView.snp.makeConstraints { (make) in
+            make.top.left.right.equalToSuperview()
+            make.height.equalTo(150 * kScaleWidth)
+        }
+        titleLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(10)
+            make.top.equalTo(iconImagView.snp.bottom).offset(10)
+            make.right.equalTo(-10)
+            make.height.equalTo(23)
+        }
+        sellNumberLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(titleLabel.snp.bottom).offset(15)
+            make.left.right.equalTo(titleLabel)
+            make.height.equalTo(13)
+        }
+        sellPriceLabel.snp.remakeConstraints { (make) in
+            make.left.equalTo(titleLabel)
+            make.bottom.equalTo(-10)
+            make.height.equalTo(19)
+        }
+        markPriceLabel.snp.remakeConstraints { (make) in
+            make.left.equalTo(sellPriceLabel.snp.right).offset(5)
+            make.centerY.equalTo(sellPriceLabel)
+            make.height.equalTo(13)
+        }
+        plusButton.snp.makeConstraints { (make) in
+            make.right.equalTo(-10)
+            make.bottom.equalTo(-10)
+            make.size.equalTo(25)
+        }
+        
+    }
+    
+    private lazy var iconImagView: UIImageView = {
+        let iconImagView = UIImageView()
+        iconImagView.image = kImage(name: "pic_preload")
+        return iconImagView
+    }()
+    
+    private lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.textColor = k333333Color
+        titleLabel.font = kScaleMediumFont15
+        titleLabel.textAlignment = .left
+        titleLabel.numberOfLines = 1
+        return titleLabel
+    }()
+    
+    private lazy var sellNumberLabel: UILabel = {
+        let sellNumberLabel = UILabel()
+        sellNumberLabel.textColor = k999999Color
+        sellNumberLabel.font = kScaleRegularFont12
+        return sellNumberLabel
+    }()
+    
+    private lazy var sellPriceLabel: UILabel = {
+        let sellPriceLabel = UILabel()
+        sellPriceLabel.textColor = kfe352bColor
+        sellPriceLabel.font = kScaleBoldFont15
+        sellPriceLabel.textAlignment = .left
+        return sellPriceLabel
+    }()
+    
+    private lazy var markPriceLabel: UILabel = {
+        let markPriceLabel = UILabel()
+        markPriceLabel.textColor = kbbbbbbColor
+        markPriceLabel.font = kScaleRegularFont13
+        return markPriceLabel
+    }()
+    
+    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
+            print("添加购物车")
+        }).disposed(by: disposeBag)
+        
+        return plusButton
+    }()
+    
+}

+ 2 - 2
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaNetWorkServiceProduct.swift

@@ -118,9 +118,9 @@ class SwiftMoyaNetWorkServiceProduct: NSObject {
         parameters.updateValue(deliver_type ?? "0", forKey: "deliver_type")
         
         SwiftProgressHUD.shared().showWait()
-        SwiftMoyaNetWorkManager.shared().request(ProductCartListData.self, target: MultiTarget(SwiftMoyaServiceProductApi.productHotSale(parameters: parameters))) { (productCartListData) in
+        SwiftMoyaNetWorkManager.shared().request(ProductSearchListModel.self, target: MultiTarget(SwiftMoyaServiceProductApi.productHotSale(parameters: parameters))) { (productSearchListModel) in
             SwiftProgressHUD.shared().hide()
-            completion(productCartListData)
+            completion(productSearchListModel)
         }
     }