南鑫林 6 年 前
コミット
f66e3d9c64
共有11 個のファイルを変更した175 個の追加96 個の削除を含む
  1. 0 8
      RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj
  2. 12 33
      RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartHotSale/ProductSlidingTopBottomCollectionViewCell.swift
  3. 64 6
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/Floor/ShoppingMallFloorTableViewCell.swift
  4. 31 30
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallBarChart/ShoppingMallBarChartCollectionViewCell.swift
  5. 10 0
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallRightSideleftPicture/ShoppingMallRightSideleftPictureCollectionViewCell.swift
  6. 22 0
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallSlidingLeftRight/ShoppingMallSlidingLeftRightBgCollectionViewCell.swift
  7. 13 2
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallSlidingLeftRight/ShoppingMallSlidingLeftRightCollectionViewCell.swift
  8. 2 2
      RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductCartAmountModel.swift
  9. 3 0
      RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductModel.swift
  10. 14 13
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaNetWorkServiceProduct.swift
  11. 4 2
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceManger/SwiftMoyaNetWorkManager/SwiftMoyaNetWorkManager.swift

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

@@ -858,13 +858,6 @@
 			path = SwiftMoyaNetWorkManager;
 			sourceTree = "<group>";
 		};
-		A7284A672253BE35000BAEC4 /* Reactor */ = {
-			isa = PBXGroup;
-			children = (
-			);
-			path = Reactor;
-			sourceTree = "<group>";
-		};
 		A7284A6B2253BE57000BAEC4 /* Reactor */ = {
 			isa = PBXGroup;
 			children = (
@@ -1605,7 +1598,6 @@
 		A77F2CB02232010F001BD3F6 /* ShoppingCart */ = {
 			isa = PBXGroup;
 			children = (
-				A7284A672253BE35000BAEC4 /* Reactor */,
 				BDF47D782282645900941AB9 /* View */,
 				A77F2CB12232010F001BD3F6 /* ViewController */,
 			);

+ 12 - 33
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartHotSale/ProductSlidingTopBottomCollectionViewCell.swift

@@ -45,7 +45,6 @@ class ProductSlidingTopBottomCollectionViewCell: UICollectionViewCell {
         addSubview(sellPriceLabel)
         addSubview(markPriceLabel)
         addSubview(plusButton)
-        addSubview(shopingCarButton)
     }
     
     private func setupLayouts() {
@@ -80,13 +79,6 @@ class ProductSlidingTopBottomCollectionViewCell: UICollectionViewCell {
             make.size.equalTo(25)
         }
         
-        shopingCarButton.snp.makeConstraints { (make) in
-            make.right.equalTo(-10)
-            make.bottom.equalTo(-10)
-            make.width.equalTo(100)
-            make.height.equalTo(31)
-        }
-        
     }
     
     private lazy var iconImagView: UIImageView = {
@@ -139,30 +131,17 @@ class ProductSlidingTopBottomCollectionViewCell: UICollectionViewCell {
         return plusButton
     }()
     
-    private lazy var shopingCarButton: UIButton = {
-        let shopingCarButton = UIButton(type: UIButton.ButtonType.custom)
-        shopingCarButton.setTitle("加入购物车", for: UIControl.State.normal)
-        shopingCarButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
-        shopingCarButton.titleLabel?.font = kMediumFont14
-        shopingCarButton.backgroundColor = kFFAC33Color
-        shopingCarButton.cornerRadius = 31/2
-        shopingCarButton.masksToBounds = true
-        shopingCarButton.isHidden = true
-        return shopingCarButton
-    }()
-    
-    //    var productSearchModel: ProductSearchModel? {
-    //        didSet {
-    //            iconImagView.kf.setImage(with: kURLImage(name: productSearchModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
-    //            titleLabel.text = productSearchModel?.nameSkuName
-    //            detailTitleLabel.text = productSearchModel?.saleName
-    //            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
-    //
-    //        }
-    //    }
+    var productModel: ProductModel? {
+        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)")
+            attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
+            markPriceLabel.attributedText = attributeString
+
+        }
+    }
     
 }

+ 64 - 6
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/Floor/ShoppingMallFloorTableViewCell.swift

@@ -88,6 +88,47 @@ class ShoppingMallFloorTableViewCell: UITableViewCell {
         }
         self.collectionView.collectionViewLayout.invalidateLayout()
     }
+    
+    
+    /// 添加购物车
+    ///
+    /// - Returns:
+    func addCart(productModel:ProductModel,indexPath:IndexPath) {
+        productModel.isSelect = 1
+        productModel.amount = 1
+        SwiftMoyaNetWorkServiceProduct.shared().productCartAddApi(productMdl: productModel) {
+            [weak self] (cartAmountModel) -> (Void) in
+            let cartAmountModel = cartAmountModel as? CartAmountModel
+            let productModels = self?.productModelsArrays![indexPath.section]
+            let productModel = productModels![indexPath.row]
+            productModel.cartId = cartAmountModel?.id ?? 0
+            productModel.amount = 1
+            self!.collectionView.reloadItems(at: [indexPath])
+            SwiftProgressHUD.shared().showText("已加入购物车")
+
+        }
+    }
+    
+    /// 添加数量
+    func setProductAmount(type:Int,productModel:ProductModel,indexPath:IndexPath){
+        SwiftMoyaNetWorkServiceProduct.shared().productCartAmountApi(id: productModel.cartId ?? 0, type: type) {
+            [weak self] (cartAmountModel) -> (Void) in
+            let cartAmountModel = cartAmountModel as? CartAmountModel
+            let productModels = self?.productModelsArrays![indexPath.section]
+            let productModel = productModels![indexPath.row]
+            productModel.cartId = cartAmountModel?.id ?? 0
+            productModel.amount = cartAmountModel?.amount
+            self!.collectionView.reloadItems(at: [indexPath])
+            if type == 1{
+                SwiftProgressHUD.shared().showText("已加入购物车")
+            }else {
+                SwiftProgressHUD.shared().showText("已移出购物车")
+            }
+            
+        }
+        
+    }
+    
 }
 
 extension ShoppingMallFloorTableViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
@@ -139,6 +180,11 @@ extension ShoppingMallFloorTableViewCell: UICollectionViewDelegateFlowLayout,UIC
                     cell.layer.mask = shapeLayer
                 }
             }
+            cell.plusClosure = {
+                [weak self] (productModel,indexPath) in
+                self?.addCart(productModel: productModel!, indexPath: indexPath!)
+            }
+        
             
             return cell
         case 1: // 1:通栏大图
@@ -148,6 +194,18 @@ extension ShoppingMallFloorTableViewCell: UICollectionViewDelegateFlowLayout,UIC
                 let productModels = productModelsArrays![indexPath.section]
                 cell.productModel = productModels[indexPath.row]
             }
+            cell.shopingCarClosure = {
+                [weak self] (productModel,indexPath) in
+                self?.addCart(productModel: productModel!, indexPath: indexPath!)
+            }
+            cell.plusClosure = {
+                [weak self] (productModel,indexPath) in
+                self?.setProductAmount(type: 1, productModel: productModel!, indexPath: indexPath!)
+            }
+            cell.reduceClosure = {
+                [weak self] (productModel,indexPath) in
+                self?.setProductAmount(type: 2, productModel: productModel!, indexPath: indexPath!)
+            }
             return cell
         case 2: //  2:左右滑动
             let cell = ShoppingMallSlidingLeftRightBgCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
@@ -245,29 +303,29 @@ extension ShoppingMallFloorTableViewCell: UICollectionViewDelegateFlowLayout,UIC
             
             return CGSize(width:347 * kScaleWidth, height: 50 + kScaleWidth * 90)
         case 1: // 1:通栏大图
-            if cmsRuleModel?.rule?.title?.isEmpty ?? true {
+            if cmsRuleModel?.rule?.title == "" {
                  return CGSize(width:347 * kScaleWidth, height: 73 + (kScaleWidth * 90))
             }
             
-            if cmsRuleModel?.rule?.url?.isEmpty ?? true {
+            if cmsRuleModel?.rule?.url == "" {
                 return CGSize(width:347 * kScaleWidth, height: 10 + (kScaleWidth * 90))
             }
             
-            if cmsRuleModel?.rule?.title?.isEmpty ?? true &&  cmsRuleModel?.rule?.url?.isEmpty ?? true {
+            if cmsRuleModel?.rule?.title == "" &&  cmsRuleModel?.rule?.url == "" {
                 return CGSize(width:0, height:0)
             }
             
             return CGSize(width:347 * kScaleWidth, height: 73 + (kScaleWidth * 90))
         case 2: //  2:左右滑动
-            if cmsRuleModel?.rule?.title?.isEmpty ?? true {
+            if cmsRuleModel?.rule?.title == "" {
                 return CGSize(width:347 * kScaleWidth, height:kScaleWidth * 90)
             }
             
-            if cmsRuleModel?.rule?.url?.isEmpty ?? true {
+            if cmsRuleModel?.rule?.url == ""{
                 return CGSize(width:347 * kScaleWidth, height:50)
             }
             
-            if cmsRuleModel?.rule?.title?.isEmpty ?? true &&  cmsRuleModel?.rule?.url?.isEmpty ?? true {
+            if cmsRuleModel?.rule?.title == "" && cmsRuleModel?.rule?.url == "" {
                 return CGSize(width:0, height:0)
             }
             

+ 31 - 30
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallBarChart/ShoppingMallBarChartCollectionViewCell.swift

@@ -7,13 +7,21 @@
 //
 
 import UIKit
-
 import RxSwift
 
 class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
     
     let disposeBag = DisposeBag()
     
+    typealias ShopingCarClosure = (_ productModel: ProductModel?,_ indexPath:IndexPath?) -> Void
+    var shopingCarClosure : ShopingCarClosure?
+    
+    typealias PlusClosure = (_ productModel: ProductModel?,_ indexPath:IndexPath?) -> Void
+    var plusClosure : PlusClosure?
+    
+    typealias ReduceClosure = (_ productModel: ProductModel?,_ indexPath:IndexPath?) -> Void
+    var reduceClosure : ReduceClosure?
+    
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ShoppingMallBarChartCollectionViewCell {
         let ID = "ShoppingMallBarChartCollectionViewCell"
         collectionView.register(ShoppingMallBarChartCollectionViewCell.self, forCellWithReuseIdentifier: ID)
@@ -184,14 +192,15 @@ class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
         plusButton.isHidden = true
         plusButton.rx.tap.subscribe(onNext: {
             [weak self] (data) in
-            self?.setProductAmount(type: 1)
+            if let plusClosure = self?.plusClosure {
+                plusClosure(self?.productModel, self?.indexPath)
+            }
         }).disposed(by: disposeBag)
         return plusButton
     }()
     
     private lazy var numberLabel: UILabel = {
         let numberLabel = UILabel()
-        numberLabel.text = "1"
         numberLabel.textAlignment = .center
         numberLabel.font = kRegularFont14
         numberLabel.textColor = k333333Color
@@ -205,7 +214,9 @@ class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
         reduceButton.isHidden = true
         reduceButton.rx.tap.subscribe(onNext: {
             [weak self] (data) in
-            self?.setProductAmount(type: 2)
+            if let reduceClosure = self?.reduceClosure {
+                reduceClosure(self?.productModel, self?.indexPath)
+            }
         }).disposed(by: disposeBag)
         return reduceButton
     }()
@@ -222,7 +233,9 @@ class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
         shopingCarButton.isHidden = true
         shopingCarButton.rx.tap.subscribe(onNext: {
             [weak self] (data) in
-            self?.addCart()
+            if let shopingCarClosure = self?.shopingCarClosure {
+                shopingCarClosure(self?.productModel, self?.indexPath)
+            }
         }).disposed(by: disposeBag)
         return shopingCarButton
     }()
@@ -237,32 +250,20 @@ class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
             sellPriceLabel.text = "¥\(productModel?.price ?? 0)"
             let attributeString = NSMutableAttributedString(string:"¥\(productModel?.originPrice ?? 0)")
             attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
-            markPriceLabel.attributedText = attributeString
-            reduceButton.isHidden = true
-            numberLabel.isHidden = true
-            plusButton.isHidden = true
-            shopingCarButton.isHidden = false
-        }
-    }
-    
-    
-    /// 添加购物车
-    ///
-    /// - Returns:
-    func addCart() {
-        reduceButton.isHidden = false
-        numberLabel.isHidden = false
-        plusButton.isHidden = false
-        shopingCarButton.isHidden = true
-    }
+            if productModel?.amount == 0 || productModel?.amount == nil  {
+                reduceButton.isHidden = true
+                numberLabel.isHidden = true
+                plusButton.isHidden = true
+                shopingCarButton.isHidden = false
+            }else {
+                reduceButton.isHidden = false
+                numberLabel.isHidden = false
+                plusButton.isHidden = false
+                shopingCarButton.isHidden = true
+                numberLabel.text =  "\(productModel?.amount ?? 1)"
+            }
 
-    
-    /// 添加数量
-    func setProductAmount(type:Int){
-        reduceButton.isHidden = true
-        numberLabel.isHidden = true
-        plusButton.isHidden = true
-        shopingCarButton.isHidden = false
+        }
     }
 
 }

+ 10 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallRightSideleftPicture/ShoppingMallRightSideleftPictureCollectionViewCell.swift

@@ -7,8 +7,12 @@
 //
 
 import UIKit
+import RxSwift
 
 class ShoppingMallRightSideleftPictureCollectionViewCell: UICollectionViewCell {
+    let disposeBag = DisposeBag()
+    typealias PlusClosure = (_ productModel: ProductModel?,_ indexPath:IndexPath?) -> Void
+    var plusClosure : PlusClosure?
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ShoppingMallRightSideleftPictureCollectionViewCell {
         let ID = "ShoppingMallRightSideleftPictureCollectionViewCell"
         collectionView.register(ShoppingMallRightSideleftPictureCollectionViewCell.self, forCellWithReuseIdentifier: ID)
@@ -135,6 +139,12 @@ class ShoppingMallRightSideleftPictureCollectionViewCell: 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?.productModel, self?.indexPath)
+            }
+        }).disposed(by: disposeBag)
         return plusButton
     }()
     

+ 22 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallSlidingLeftRight/ShoppingMallSlidingLeftRightBgCollectionViewCell.swift

@@ -74,6 +74,24 @@ class ShoppingMallSlidingLeftRightBgCollectionViewCell: UICollectionViewCell {
         return collectionViewLayout
     }()
     
+    /// 添加购物车
+    ///
+    /// - Returns:
+    func addCart(productModel:ProductModel,indexPath:IndexPath) {
+        productModel.isSelect = 1
+        productModel.amount = 1
+        SwiftMoyaNetWorkServiceProduct.shared().productCartAddApi(productMdl: productModel) {
+            [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 ShoppingMallSlidingLeftRightBgCollectionViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
@@ -89,6 +107,10 @@ extension ShoppingMallSlidingLeftRightBgCollectionViewCell: UICollectionViewDele
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         let cell = ShoppingMallSlidingLeftRightCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
         cell.productModel = productModels?[indexPath.row]
+        cell.plusClosure = {
+            [weak self] (productModel,indexPath) in
+            self?.addCart(productModel: productModel!, indexPath: indexPath!)
+        }
         return cell
         
     }

+ 13 - 2
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallSlidingLeftRight/ShoppingMallSlidingLeftRightCollectionViewCell.swift

@@ -7,8 +7,14 @@
 //
 
 import UIKit
+import RxSwift
 
 class ShoppingMallSlidingLeftRightCollectionViewCell: UICollectionViewCell {
+    let disposeBag = DisposeBag()
+    
+    typealias PlusClosure = (_ productModel: ProductModel?,_ indexPath:IndexPath?) -> Void
+    var plusClosure : PlusClosure?
+    
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ShoppingMallSlidingLeftRightCollectionViewCell {
         let ID = "ShoppingMallSlidingLeftRightCollectionViewCell"
         collectionView.register(ShoppingMallSlidingLeftRightCollectionViewCell.self, forCellWithReuseIdentifier: ID)
@@ -64,10 +70,9 @@ class ShoppingMallSlidingLeftRightCollectionViewCell: UICollectionViewCell {
             make.left.equalTo(titleLabel)
             make.bottom.equalTo(5)
         }
-        markPriceLabel.snp.remakeConstraints { (make) in
+        markPriceLabel.snp.makeConstraints { (make) in
             make.left.equalTo(sellPriceLabel.snp.right).offset(3)
             make.bottom.equalTo(5)
-            make.right.equalTo(-30)
         }
         plusButton.snp.makeConstraints { (make) in
             make.bottom.equalTo(5)
@@ -127,6 +132,12 @@ class ShoppingMallSlidingLeftRightCollectionViewCell: 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?.productModel, self?.indexPath)
+            }
+        }).disposed(by: disposeBag)
         return plusButton
     }()
     

+ 2 - 2
RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductCartAmountModel.swift

@@ -13,7 +13,7 @@ import ObjectMapper
 class CartAmountModel : NSObject, Mappable{
     
     var amount : Int?
-    
+    var id : Int?
     
     class func newInstance(map: Map) -> Mappable?{
         return CartAmountModel()
@@ -24,6 +24,6 @@ class CartAmountModel : NSObject, Mappable{
     func mapping(map: Map)
     {
         amount <- map["amount"]
+        id <- map["id"]
     }
-    
 }

+ 3 - 0
RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductModel.swift

@@ -64,6 +64,9 @@ class ProductModel : NSObject, Mappable{
     var productPrice : Int?
     var skuPrice : Int?
     var uid : Int?
+    
+    // 购物车Id
+    var cartId : Int?
 
 
 	class func newInstance(map: Map) -> Mappable?{

+ 14 - 13
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaNetWorkServiceProduct.swift

@@ -10,6 +10,7 @@ import Foundation
 import Moya
 import SwiftyJSON
 import ObjectMapper
+
 class SwiftMoyaNetWorkServiceProduct: NSObject {
     private static let _sharedInstance = SwiftMoyaNetWorkServiceProduct()
     
@@ -114,16 +115,17 @@ class SwiftMoyaNetWorkServiceProduct: NSObject {
     ///   - completion: 回调
     func productCartAddApi(productMdl:ProductModel, completion: @escaping apiCallBack) {
         var parameters = Dictionary<String,Any>()
-        parameters.updateValue(productMdl.shopId       ?? 0, forKey: "shop_id")
-        parameters.updateValue(productMdl.productId    ?? 0, forKey: "product_id")
-        parameters.updateValue(productMdl.productPrice ?? 0, forKey: "product_price")
-        parameters.updateValue(productMdl.skuId        ?? 0, forKey: "sku_id")
-        parameters.updateValue(productMdl.amount       ?? 0, forKey: "amount")
+        
+        parameters.updateValue(productMdl.shopId ?? 0, forKey: "shop_id")
+        parameters.updateValue(productMdl.shopName ?? "", forKey: "shop_name")
+        parameters.updateValue(productMdl.id    ?? 0, forKey: "product_id")
+        parameters.updateValue(productMdl.price ?? 0, forKey: "product_price")
+        parameters.updateValue(productMdl.skuId ?? 0, forKey: "sku_id")
+        parameters.updateValue(productMdl.totalCount       ?? 0, forKey: "amount")
         parameters.updateValue(productMdl.isSelect     ?? 0, forKey: "is_select")
-        parameters.updateValue(productMdl.shopName    ?? "", forKey: "shop_name")
-        parameters.updateValue(productMdl.productName ?? "", forKey: "product_name")
-        parameters.updateValue(productMdl.productImg  ?? "", forKey: "product_img")
-        parameters.updateValue(productMdl.skuName     ?? "", forKey: "sku_name")
+        parameters.updateValue(productMdl.name ?? "", forKey: "product_name")
+        parameters.updateValue(productMdl.img  ?? "", forKey: "product_img")
+        parameters.updateValue(productMdl.skuName  ?? "", forKey: "sku_name")
         
         // 本地获取city_id/city_name
         let loacationModel = LocationModel.shared().getLocationModel()
@@ -136,10 +138,9 @@ class SwiftMoyaNetWorkServiceProduct: NSObject {
         parameters.updateValue(deliver_type ?? 0, forKey: "deliver_type")
         
         SwiftProgressHUD.shared().showWait()
-        SwiftMoyaNetWorkManager.shared().request(target: MultiTarget(SwiftMoyaServiceProductApi.productCartAdd(parameters: parameters))) { (rootModel) in
-            let rootModel = rootModel as! RootModel
-            SwiftProgressHUD.shared().showText(rootModel.msg!)
-            completion("")
+        SwiftMoyaNetWorkManager.shared().request(CartAmountModel.self,target: MultiTarget(SwiftMoyaServiceProductApi.productCartAdd(parameters: parameters))) { (cartAmountModel) in
+            SwiftProgressHUD.shared().hide()
+            completion(cartAmountModel)
         }
     }
     

+ 4 - 2
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceManger/SwiftMoyaNetWorkManager/SwiftMoyaNetWorkManager.swift

@@ -47,9 +47,11 @@ private let requestClosure = { (endpoint: Endpoint, done: MoyaProvider.RequestRe
         request.timeoutInterval = requestTimeOut
         // 打印请求参数
         if let requestData = request.httpBody {
-            NXLLog("\n"+"请求地址:"+"\(request.url!)"+"\n"+"请求方式:"+"\(request.httpMethod ?? "")"+"\n"+"请求头部:"+"\(String(describing: request.allHTTPHeaderFields!))"+"\n"+"发送参数:"+"\(String(data: request.httpBody!, encoding: String.Encoding.utf8) ?? "")")
+            let parameter = "\(String(data: request.httpBody!, encoding: String.Encoding.utf8) ?? "")"
+            NXLLog("\n"+"请求地址:"+"\(request.url!)"+"\n"+"请求方式:"+"\(request.httpMethod ?? "")"+"\n"+"请求头部:"+"\(String(describing: request.allHTTPHeaderFields!))"+"\n"+"发送参数:" + String(describing: parameter.removingPercentEncoding!))
         }else{
-            NXLLog("\n"+"请求地址:"+"\(request.url!)"+"\n"+"请求方式:"+"=\(String(describing: request.httpMethod!))"+"请求头部:"+"\(String(describing: request.allHTTPHeaderFields!))")
+            let urlStr = "\(request.url!)"
+            NXLLog("\n"+"请求地址:"+String(describing: urlStr.removingPercentEncoding!)+"\n"+"请求方式:"+"=\(String(describing: request.httpMethod!))"+"\n"+"请求头部:"+"\(String(describing: request.allHTTPHeaderFields!))")
         }
         done(.success(request))
     } catch {