Quellcode durchsuchen

配送方式修改完成

南鑫林 vor 6 Jahren
Ursprung
Commit
6b7f082bb1
14 geänderte Dateien mit 190 neuen und 101 gelöschten Zeilen
  1. 8 9
      RainbowPlanet/RainbowPlanet/Modules/CommonModules/LocationModule/Location/ViewController/LocationViewController.swift
  2. 12 11
      RainbowPlanet/RainbowPlanet/Modules/CommonModules/LocationModule/SelfRecommendation/ViewController/SelfRecommendationViewController.swift
  3. 7 6
      RainbowPlanet/RainbowPlanet/Modules/MineModule/AddressManager/ViewController/AddressManagerViewController.swift
  4. 63 13
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/Floor/ShoppingMallFloorTableViewCell.swift
  5. 10 17
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallBarChart/ShoppingMallBarChartCollectionViewCell.swift
  6. 8 14
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallRightSideleftPicture/ShoppingMallRightSideleftPictureCollectionViewCell.swift
  7. 6 4
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallSlidingLeftRight/ShoppingMallSlidingLeftRightBgCollectionViewCell.swift
  8. 15 0
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallSlidingLeftRight/ShoppingMallSlidingLeftRightCollectionViewCell.swift
  9. 5 4
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallNavigationBarView.swift
  10. 11 5
      RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/ViewController/ShoppingMallListViewController.swift
  11. 1 2
      RainbowPlanet/RainbowPlanet/Service/Model/UserModel/DeliveryMethodTypeModel.swift
  12. 5 10
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaNetWorkServiceProduct.swift
  13. 23 2
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaNetWorkServiceUser.swift
  14. 16 4
      RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaServiceUserApi.swift

+ 8 - 9
RainbowPlanet/RainbowPlanet/Modules/CommonModules/LocationModule/Location/ViewController/LocationViewController.swift

@@ -60,16 +60,15 @@ class LocationViewController: BaseViewController {
     }()
     
     private func setDeliveryMethodType() { //快递
-        let model = DeliveryMethodTypeModel.shared().getModel()
-        model!.deliveryMethodType = "0"
-        DeliveryMethodTypeModel.shared().setModel(model: model!)
-        if self.presentingViewController != nil {
-            self.dismiss(animated: false, completion: {
+        SwiftMoyaNetWorkServiceUser.shared().userSetDeliverTypeApi(deliveryMethodType: "2") { (data) -> (Void) in
+            if self.presentingViewController != nil {
+                self.dismiss(animated: false, completion: {
+                    kAppDelegate.setTabbarController()
+                })
+            } else {
                 kAppDelegate.setTabbarController()
-            })
-        } else {
-            kAppDelegate.setTabbarController()
-        }
+            }
+        }        
     }
     
     private func configCityManagementIndexApi()  {

+ 12 - 11
RainbowPlanet/RainbowPlanet/Modules/CommonModules/LocationModule/SelfRecommendation/ViewController/SelfRecommendationViewController.swift

@@ -58,9 +58,9 @@ class SelfRecommendationViewController: BaseViewController {
             [weak self] in
             let deliveryMethodTypeModel = DeliveryMethodTypeModel.shared().getModel()
             if deliveryMethodTypeModel?.deliveryMethodType?.isEmpty ?? true {
-                 self?.tabbarController(deliveryMethodType: "0")
+                 self?.tabbarController(deliveryMethodType: "2")
             }else {
-                self?.tabbarController(deliveryMethodType: deliveryMethodTypeModel?.deliveryMethodType ?? "0")
+                self?.tabbarController(deliveryMethodType: deliveryMethodTypeModel?.deliveryMethodType ?? "2")
             }
         }
         selfRecommendationView.didSelectGoShoppingBlock = { //去首页自提
@@ -87,16 +87,17 @@ class SelfRecommendationViewController: BaseViewController {
     }()
     
     private func tabbarController(deliveryMethodType:String) {
-        let model = DeliveryMethodTypeModel.shared().getModel()
-        model?.deliveryMethodType = deliveryMethodType
-        DeliveryMethodTypeModel.shared().setModel(model: model!)
-        if self.presentingViewController != nil {
-            self.dismiss(animated: false, completion: {
-                kAppDelegate.setTabbarController()
-            })
-        } else {
-            kAppDelegate.setTabbarController()
+        SwiftMoyaNetWorkServiceUser.shared().userSetDeliverTypeApi(deliveryMethodType: deliveryMethodType) { (data) -> (Void) in
+                if self.presentingViewController != nil {
+                    self.dismiss(animated: false, completion: {
+                        kAppDelegate.setTabbarController()
+                    })
+                } else {
+                    kAppDelegate.setTabbarController()
+                }
         }
+        
+        
     }
     
     

+ 7 - 6
RainbowPlanet/RainbowPlanet/Modules/MineModule/AddressManager/ViewController/AddressManagerViewController.swift

@@ -149,21 +149,22 @@ class AddressManagerViewController: BaseViewController {
     
     /// 获取已开通城市列表
     func configCityManagementIndexApi() {
-        let deliveryMethodType = Int(DeliveryMethodTypeModel.shared().getModel()?.deliveryMethodType ?? "0")
-        if deliveryMethodType == 0 { //快递
+        let deliveryMethodType = Int(DeliveryMethodTypeModel.shared().getModel()?.deliveryMethodType ?? "2")
+        if deliveryMethodType == 1 { //自提
+            self.isOpenCity = true
+            userSelfAndExpressAddressListApi(type:1)
+        }
+        if deliveryMethodType == 2 { //快递
             SwiftMoyaNetWorkServiceConfig.shared().configCityManagementIndexApi { [weak self] (openCityListModel) -> (Void) in
                 let openCityListModel = openCityListModel as! OpenCityListModel
                 if openCityListModel.data?.isEmpty ?? true { //自提没有开通
                     self?.isOpenCity = false
                     self?.userSelfAndExpressAddressListApi(type:1)
-                }else { //自提开通
+                }else { //自提开通/加快递
                     self?.isOpenCity = true
                     self?.userSelfAndExpressAddressListApi(type:0)
                 }
             }
-        }else if deliveryMethodType == 1 { //自提
-            self.isOpenCity = true
-            userSelfAndExpressAddressListApi(type:0)
         }
     }
     

+ 63 - 13
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/Floor/ShoppingMallFloorTableViewCell.swift

@@ -129,16 +129,17 @@ extension ShoppingMallFloorTableViewCell: UICollectionViewDelegateFlowLayout,UIC
             if !(productModelsArrays?.isEmpty ?? true) {
                 let productModels = productModelsArrays![indexPath.section]
                 cell.productModel = productModels[indexPath.row]
+                if indexPath.row == productModels.count - 1 {
+                    let shapeLayer = CAShapeLayer()
+                    cell.layer.mask = nil
+                    let bezierPath = UIBezierPath(roundedRect: cell.bounds,
+                                                  byRoundingCorners: [.bottomLeft,.bottomRight],
+                                                  cornerRadii: CGSize(width: 4,height: 4))
+                    shapeLayer.path = bezierPath.cgPath
+                    cell.layer.mask = shapeLayer
+                }
             }
-            if indexPath.row == (cmsRuleModel?.rule!.showNum)! - 1 {
-                let shapeLayer = CAShapeLayer()
-                cell.layer.mask = nil
-                let bezierPath = UIBezierPath(roundedRect: cell.bounds,
-                                              byRoundingCorners: [.bottomLeft,.bottomRight],
-                                              cornerRadii: CGSize(width: 4,height: 4))
-                shapeLayer.path = bezierPath.cgPath
-                cell.layer.mask = shapeLayer
-            }
+            
             return cell
         case 1: // 1:通栏大图
             let cell = ShoppingMallBarChartCollectionViewCell.cellWith(
@@ -150,7 +151,10 @@ extension ShoppingMallFloorTableViewCell: UICollectionViewDelegateFlowLayout,UIC
             return cell
         case 2: //  2:左右滑动
             let cell = ShoppingMallSlidingLeftRightBgCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
-//            cell.productModels = productModels
+            if !(productModelsArrays?.isEmpty ?? true) {
+                let productModels = productModelsArrays![indexPath.section]
+                cell.productModels = productModels
+            }
             return cell
         default:
             return UICollectionViewCell()
@@ -195,6 +199,17 @@ extension ShoppingMallFloorTableViewCell: UICollectionViewDelegateFlowLayout,UIC
             switch cmsRuleModel?.showType {
             case 0: // 0:左图右字;
                 let headerView = ProductFloorLeftHeaderCollectionReusableView.headerWith(collectionView: collectionView, kind:  UICollectionView.elementKindSectionHeader, indexPath: indexPath)
+                
+                if !(productModelsArrays?.isEmpty ?? true) {
+                    let productModels = productModelsArrays![indexPath.section]
+                    if productModels.isEmpty {
+                        let shapeLayer = CAShapeLayer()
+                        headerView.bgView.layer.mask = nil
+                        let bezierPath = UIBezierPath(roundedRect: headerView.bgView.bounds,byRoundingCorners: [.allCorners],cornerRadii: CGSize(width: 4,height: 4))
+                        shapeLayer.path = bezierPath.cgPath
+                        headerView.bgView.layer.mask = shapeLayer
+                    }
+                }
                 return headerView
             case 1: // 1:通栏大图
                 let headerView = ProductFloorCenterHeaderCollectionReusableView.headerWith(collectionView: collectionView, kind:  UICollectionView.elementKindSectionHeader, indexPath: indexPath)
@@ -209,17 +224,52 @@ extension ShoppingMallFloorTableViewCell: UICollectionViewDelegateFlowLayout,UIC
         return UICollectionReusableView()
     }
     
-    
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
         
         let cmsRuleModel = cmsRuleModels?[section]
         switch cmsRuleModel?.showType {
         case 0: // 0:左图右字;
-           return CGSize(width:347 * kScaleWidth, height: 50 + kScaleWidth * 90)
+            if cmsRuleModel?.rule?.title == "" {
+                return CGSize(width:347 * kScaleWidth, height:kScaleWidth * 90)
+            }
+            
+            if cmsRuleModel?.rule?.url == "" {
+                return CGSize(width:347 * kScaleWidth, height:50)
+            }
+            
+            if cmsRuleModel?.rule?.title == "" &&  cmsRuleModel?.rule?.url == "" {
+                return CGSize(width:0, height:0)
+            }
+            
+            return CGSize(width:347 * kScaleWidth, height: 50 + kScaleWidth * 90)
         case 1: // 1:通栏大图
+            if cmsRuleModel?.rule?.title?.isEmpty ?? true {
+                 return CGSize(width:347 * kScaleWidth, height: 73 + (kScaleWidth * 90))
+            }
+            
+            if cmsRuleModel?.rule?.url?.isEmpty ?? true {
+                return CGSize(width:347 * kScaleWidth, height: 10 + (kScaleWidth * 90))
+            }
+            
+            if cmsRuleModel?.rule?.title?.isEmpty ?? true &&  cmsRuleModel?.rule?.url?.isEmpty ?? true {
+                return CGSize(width:0, height:0)
+            }
+            
             return CGSize(width:347 * kScaleWidth, height: 73 + (kScaleWidth * 90))
         case 2: //  2:左右滑动
-            return CGSize(width:kScreenWidth, height: 50 + kScaleWidth * 90)
+            if cmsRuleModel?.rule?.title?.isEmpty ?? true {
+                return CGSize(width:347 * kScaleWidth, height:kScaleWidth * 90)
+            }
+            
+            if cmsRuleModel?.rule?.url?.isEmpty ?? true {
+                return CGSize(width:347 * kScaleWidth, height:50)
+            }
+            
+            if cmsRuleModel?.rule?.title?.isEmpty ?? true &&  cmsRuleModel?.rule?.url?.isEmpty ?? true {
+                return CGSize(width:0, height:0)
+            }
+            
+            return CGSize(width:347 * kScaleWidth, height: 50 + kScaleWidth * 90)
         default:
             return CGSize(width:0, height: 0)
         }

+ 10 - 17
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallBarChart/ShoppingMallBarChartCollectionViewCell.swift

@@ -80,7 +80,7 @@ class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
         }
         markPriceLabel.snp.remakeConstraints { (make) in
             make.left.equalTo(sellPriceLabel.snp.right).offset(5)
-            make.bottom.equalTo(-10)
+            make.centerY.equalTo(sellPriceLabel)
             make.height.equalTo(13)
         }
         plusButton.snp.makeConstraints { (make) in
@@ -207,24 +207,17 @@ class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
         return shopingCarButton
     }()
     
+    
     var productModel : ProductModel? {
         didSet {
-            
+            iconImagView.kf.setImage(with: kURLImage(name: productModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            titleLabel.text = productModel?.saleName
+            detailTitleLabel.text = productModel?.saleName
+            sellNumberLabel.text = "已售\(productModel?.totalCount ?? 0)件"
+            sellPriceLabel.text = "¥\(productModel?.price ?? 0)"
+            let attributeString = NSMutableAttributedString(string:"¥\(productModel?.originPrice ?? 0)")
+            attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
+            markPriceLabel.attributedText = attributeString
         }
     }
-    
-    //    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
-    //
-    //        }
-    //    }
-    
 }

+ 8 - 14
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallRightSideleftPicture/ShoppingMallRightSideleftPictureCollectionViewCell.swift

@@ -140,21 +140,15 @@ class ShoppingMallRightSideleftPictureCollectionViewCell: UICollectionViewCell {
     
     var productModel : ProductModel? {
         didSet {
-            
+            iconImagView.kf.setImage(with: kURLImage(name: productModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            titleLabel.text = productModel?.saleName
+            detailTitleLabel.text = productModel?.saleName
+            sellNumberLabel.text = "已售\(productModel?.totalCount ?? 0)件"
+            sellPriceLabel.text = "¥\(productModel?.price ?? 0)"
+            let attributeString = NSMutableAttributedString(string:"¥\(productModel?.originPrice ?? 0)")
+            attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
+            markPriceLabel.attributedText = attributeString
         }
     }
     
-//    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
-//            
-//        }
-//    }
 }

+ 6 - 4
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallSlidingLeftRight/ShoppingMallSlidingLeftRightBgCollectionViewCell.swift

@@ -12,7 +12,7 @@ class ShoppingMallSlidingLeftRightBgCollectionViewCell: UICollectionViewCell {
     
     var productModels : [ProductModel]? {
         didSet {
-            
+            collectionView.reloadData()
         }
     }
     
@@ -68,7 +68,7 @@ class ShoppingMallSlidingLeftRightBgCollectionViewCell: UICollectionViewCell {
     
     private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
         let collectionViewLayout = UICollectionViewFlowLayout.init()
-        collectionViewLayout.minimumLineSpacing = 0
+        collectionViewLayout.minimumLineSpacing = 10
         collectionViewLayout.minimumInteritemSpacing = 0
         collectionViewLayout.scrollDirection = .horizontal
         return collectionViewLayout
@@ -78,15 +78,17 @@ class ShoppingMallSlidingLeftRightBgCollectionViewCell: UICollectionViewCell {
 
 extension ShoppingMallSlidingLeftRightBgCollectionViewCell: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
     func numberOfSections(in collectionView: UICollectionView) -> Int {
-        return 1
+        
+        return productModels?.isEmpty ?? true ? 0 : 1 
     }
     
     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-        return 10
+        return productModels?.isEmpty ?? true ? 0 : productModels?.count ?? 0
     }
     
     func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         let cell = ShoppingMallSlidingLeftRightCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        cell.productModel = productModels?[indexPath.row]
         return cell
         
     }

+ 15 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallSlidingLeftRight/ShoppingMallSlidingLeftRightCollectionViewCell.swift

@@ -67,6 +67,7 @@ class ShoppingMallSlidingLeftRightCollectionViewCell: UICollectionViewCell {
         markPriceLabel.snp.remakeConstraints { (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)
@@ -115,9 +116,11 @@ class ShoppingMallSlidingLeftRightCollectionViewCell: UICollectionViewCell {
         markPriceLabel.text = "¥24.4"
         markPriceLabel.textColor = kbbbbbbColor
         markPriceLabel.font = kScaleRegularFont11
+        markPriceLabel.textAlignment = .left
         let attrString = NSMutableAttributedString(string: "¥24.4")
         attrString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
         markPriceLabel.attributedText = attrString
+        markPriceLabel.adjustsFontSizeToFitWidth = true
         return markPriceLabel
     }()
     
@@ -127,4 +130,16 @@ class ShoppingMallSlidingLeftRightCollectionViewCell: UICollectionViewCell {
         return plusButton
     }()
     
+    var productModel : ProductModel? {
+        didSet {
+            iconImagView.kf.setImage(with: kURLImage(name: productModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
+            titleLabel.text = productModel?.saleName
+            detailTitleLabel.text = productModel?.saleName
+            sellPriceLabel.text = "¥\(productModel?.price ?? 0)"
+            let attributeString = NSMutableAttributedString(string:"¥\(productModel?.originPrice ?? 0)")
+            attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
+            markPriceLabel.attributedText = attributeString
+        }
+    }
+    
 }

+ 5 - 4
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallNavigationBarView.swift

@@ -48,13 +48,14 @@ class ShoppingMallNavigationBarView: BaseView {
             make.height.equalTo(30)
             make.right.equalTo(categoryButton.snp.left).offset(-9)
             let model = DeliveryMethodTypeModel.shared().getModel()
-            if model?.deliveryMethodType == "0" { //快递
-                addressLabel.isHidden = false
-                 make.left.equalTo(addressLabel.snp.right).offset(9)
-            }else  if model?.deliveryMethodType == "1" { //自提
+            if model?.deliveryMethodType == "1" { //自提
                 addressLabel.isHidden = true
                 make.left.equalTo(addressImageView.snp.right).offset(9)
             }
+            if model?.deliveryMethodType == "2" { //快递
+                addressLabel.isHidden = false
+                 make.left.equalTo(addressLabel.snp.right).offset(9)
+            }
         }
     
         searchIconImageView.snp.remakeConstraints { (make) in

+ 11 - 5
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/ViewController/ShoppingMallListViewController.swift

@@ -80,17 +80,23 @@ class ShoppingMallListViewController: UIViewController {
 
                                     let sema = DispatchSemaphore(value: 0)
                                     SwiftMoyaNetWorkServiceProduct.shared().productHomeProductApi(ids: cmsRuleModel.productId ?? "", completion: {[weak self] (productModels) -> (Void) in
-                                        productModelsArray[index] = productModels as! [ProductModel]
-                                        self?.productModelsArrays = productModelsArray
-                                        NXLLog("signal\(index)")
-                                        sema.signal()
+                                        if productModels is String {
+                                            NXLLog("signal\(index)")
+                                            sema.signal()
+                                        }else {
+                                            productModelsArray[index] = productModels as! [ProductModel]
+                                            self?.productModelsArrays = productModelsArray
+                                            NXLLog("signal\(index)")
+                                            sema.signal()
+                                        }
+                                        
                                     })
                                     //异步调用返回前,就会一直阻塞在这
                                     sema.wait()
                                     NXLLog("wait\(index)")
                                     
                                 }
-                            DispatchQueue.main.sync {
+                            DispatchQueue.main.async {
                                 self.shoppingMallListView.productModelsArrays = self.productModelsArrays
                             }
 

+ 1 - 2
RainbowPlanet/RainbowPlanet/Service/Model/UserModel/DeliveryMethodTypeModel.swift

@@ -20,8 +20,7 @@ class DeliveryMethodTypeModel : NSObject, NSCoding, Mappable{
         return _sharedInstance
     }
     
-    var deliveryMethodType:String? //0快递,1自提
-    
+    var deliveryMethodType:String? //0全部,1自提,2快递
     
     class func newInstance(map: Map) -> Mappable?{
         return DeliveryMethodTypeModel()

+ 5 - 10
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaNetWorkServiceProduct.swift

@@ -72,16 +72,11 @@ class SwiftMoyaNetWorkServiceProduct: NSObject {
     func productHomeProductApi(ids:String = "",completion: @escaping apiCallBack) {
         var parameters = Dictionary<String,Any>()
         parameters.updateValue(ids, forKey: "ids")
-        SwiftMoyaNetWorkManager.shared().request(target: MultiTarget(SwiftMoyaServiceProductApi.productHomeProduct(parameters: parameters))) { (rootModel) in
-            let rootModel = rootModel as! RootModel
-            SwiftProgressHUD.shared().hide()
-            if rootModel.code == 0 {
-                let productModels = Mapper<ProductModel>().mapArray(JSONString: rootModel.data!)
-                completion(productModels as Any)
-
-            }else if rootModel.code == 1 {
-                completion("")
-            }
+        SwiftMoyaNetWorkManager.shared().requestArray(ProductModel.self, target: MultiTarget(SwiftMoyaServiceProductApi.productHomeProduct(parameters: parameters))) { (productModels) in
+            completion(productModels)
+        }
+        SwiftMoyaNetWorkManager.shared().falseCallback = {
+            completion("")
         }
     }
 }

+ 23 - 2
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaNetWorkServiceUser.swift

@@ -278,7 +278,7 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
     /// 用户自提点,快递地址列表
     ///
     /// - Parameters:
-    ///   - type: 手机号 0所有列表 1快递列表
+    ///   - type: 0所有列表,1自提列表,2快递
     ///   - city_id: 城市id
     ///   - completion: 回调
     func userSelfAndExpressAddressListApi(type:Int,completion: @escaping apiCallBack) {
@@ -460,7 +460,7 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
         var parameters = Dictionary<String,Any>()
         let deliveryMethodTypeModel = DeliveryMethodTypeModel.shared().getModel()
         
-        parameters.updateValue(deliveryMethodTypeModel?.deliveryMethodType ?? "0", forKey: "address_type")
+        parameters.updateValue(deliveryMethodTypeModel?.deliveryMethodType ?? "1", forKey: "address_type")
         parameters.updateValue(cityId, forKey: "city_id")
         parameters.updateValue(cityName, forKey: "city_name")
         parameters.updateValue(pickupNodeId, forKey: "pickup_node_id")
@@ -473,5 +473,26 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
             completion("")
         }
     }
+    
+    // MARK: - 设置用户配送方式
+    /// 设置用户配送方式
+    ///
+    /// - Parameters:
+    ///   - deliveryMethodType: 0所有列表,1自提列表,2快递
+    ///   - completion: 返回
+    func userSetDeliverTypeApi(deliveryMethodType:String = "2",completion: @escaping apiCallBack) {
+        var parameters = Dictionary<String,Any>()
+        let model = DeliveryMethodTypeModel.shared().getModel()
+        model?.deliveryMethodType = deliveryMethodType
+        DeliveryMethodTypeModel.shared().setModel(model: model!)
+        parameters.updateValue(model?.deliveryMethodType ?? "2", forKey: "deliver_type")
+        SwiftProgressHUD.shared().showWait()
+        SwiftMoyaNetWorkManager.shared().request(target: MultiTarget(SwiftMoyaServiceUserApi.userSetDeliverType(parameters: parameters))) {
+            (rootModel) in
+            let rootModel = rootModel as! RootModel
+            SwiftProgressHUD.shared().showText(rootModel.msg!)
+            completion("")
+        }
+    }
 
 }

+ 16 - 4
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaServiceUserApi.swift

@@ -85,6 +85,10 @@ public let kUserSetExpreesContactsDefaultApi = "/user/setExpreesContactsDefault"
 /// 新增自提地址
 public let kUserAddSelfAddressApi = "/user/addSelfAddress"
 
+// MARK: - 设置用户配送方式
+/// 设置用户配送方式
+public let kUserSetDeliverTypeApi = "/user/setDeliverType"
+
 /// 用户
 ///
 /// - userLogout: 登出
@@ -106,6 +110,7 @@ public let kUserAddSelfAddressApi = "/user/addSelfAddress"
 /// - userDelExpreesContacts: 删除自提点收货人信息
 /// - userSetExpreesContactsDefault: 自提点收货人信息,设置默认
 /// - userSetExpreesContactsDefault: 新增自提地址
+/// - userSetDeliverType: 设置用户配送方式
 public enum SwiftMoyaServiceUserApi {
     case userLogout(parameters:Dictionary<String, Any>)
     case userRefresh(parameters:Dictionary<String, Any>)
@@ -126,6 +131,7 @@ public enum SwiftMoyaServiceUserApi {
     case userDelExpreesContacts(parameters:Dictionary<String, Any>)
     case userSetExpreesContactsDefault(parameters:Dictionary<String, Any>)
     case userAddSelfAddress(parameters:Dictionary<String, Any>)
+    case userSetDeliverType(parameters:Dictionary<String, Any>)
     
 }
 
@@ -151,7 +157,8 @@ extension SwiftMoyaServiceUserApi: TargetType {
              .userSaveExpreesContacts,
              .userDelExpreesContacts,
              .userSetExpreesContactsDefault,
-             .userAddSelfAddress
+             .userAddSelfAddress,
+             .userSetDeliverType
             :
             return URL(string: kApiDataPrefix())!
         }
@@ -197,6 +204,8 @@ extension SwiftMoyaServiceUserApi: TargetType {
             return kUserSetExpreesContactsDefaultApi
         case .userAddSelfAddress:
             return kUserAddSelfAddressApi
+        case.userSetDeliverType:
+             return kUserSetDeliverTypeApi
         }
     }
 
@@ -220,7 +229,8 @@ extension SwiftMoyaServiceUserApi: TargetType {
              .userSaveExpreesContacts,
              .userDelExpreesContacts,
              .userSetExpreesContactsDefault,
-             .userAddSelfAddress
+             .userAddSelfAddress,
+             .userSetDeliverType
             :
             return .post
         }
@@ -249,7 +259,8 @@ extension SwiftMoyaServiceUserApi: TargetType {
              .userSaveExpreesContacts(var parameters),
              .userDelExpreesContacts(var parameters),
              .userSetExpreesContactsDefault(var parameters),
-             .userAddSelfAddress(var parameters)
+             .userAddSelfAddress(var parameters),
+             .userSetDeliverType(var parameters)
             :
             let sign = SwiftSign.shared().sign(signType:.AccessToken, parameters: parameters)
             parameters.updateValue(sign, forKey: "sign")
@@ -290,7 +301,8 @@ extension SwiftMoyaServiceUserApi: TargetType {
              .userSaveExpreesContacts,
              .userDelExpreesContacts,
              .userSetExpreesContactsDefault,
-             .userAddSelfAddress
+             .userAddSelfAddress,
+             .userSetDeliverType
             :
             return (headerParameters(headerType: .tokenHeader) as! [String : String])
         case .userLogout,