Selaa lähdekoodia

购物车列表 -- request

Chris 6 vuotta sitten
vanhempi
commit
a2e3617165

+ 4 - 4
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -184,7 +184,6 @@
 		A7A98E41228046C5005306E9 /* ShoppingMallSepcialTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7A98E40228046C4005306E9 /* ShoppingMallSepcialTableViewCell.swift */; };
 		A7A98E4322804851005306E9 /* ShoppingMallSepcialFlowLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7A98E4222804851005306E9 /* ShoppingMallSepcialFlowLayout.swift */; };
 		A7A98E4522804C63005306E9 /* ShoppingMallSepcialCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7A98E4422804C63005306E9 /* ShoppingMallSepcialCollectionViewCell.swift */; };
-		A7B4E71D22812DD70012914A /* ShoppingMallSlidingLeftRightTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7B4E71C22812DD70012914A /* ShoppingMallSlidingLeftRightTableViewCell.swift */; };
 		A7B4E71F228131720012914A /* ShoppingMallSlidingLeftRightCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7B4E71E228131720012914A /* ShoppingMallSlidingLeftRightCollectionViewCell.swift */; };
 		A7B4E721228151F40012914A /* ProductFloorTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7B4E720228151F40012914A /* ProductFloorTitleView.swift */; };
 		A7B4E723228154750012914A /* ProductFloorBannerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7B4E722228154750012914A /* ProductFloorBannerView.swift */; };
@@ -263,6 +262,7 @@
 		BDD4FB1222840597006FE833 /* ShoppingCartPayOrderController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDD4FB1122840597006FE833 /* ShoppingCartPayOrderController.swift */; };
 		BDD4FB1422840954006FE833 /* ShoppingCartOrderPayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDD4FB1322840954006FE833 /* ShoppingCartOrderPayView.swift */; };
 		BDD4FB1722840DD3006FE833 /* OrderPayAcountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDD4FB1622840DD3006FE833 /* OrderPayAcountView.swift */; };
+		BDE3045D22851E4F001D050F /* ProductCartListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDE3045C22851E4F001D050F /* ProductCartListModel.swift */; };
 		BDF47D7A228271F600941AB9 /* ShoppingCartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF47D79228271F600941AB9 /* ShoppingCartView.swift */; };
 		BDF47D7E22827C3F00941AB9 /* ProductSlidingTopBottomCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF47D7D22827C3F00941AB9 /* ProductSlidingTopBottomCollectionViewCell.swift */; };
 		BDF47D80228288F900941AB9 /* ShoppingCartAccountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF47D7F228288F900941AB9 /* ShoppingCartAccountView.swift */; };
@@ -480,8 +480,6 @@
 		A7A98E40228046C4005306E9 /* ShoppingMallSepcialTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingMallSepcialTableViewCell.swift; sourceTree = "<group>"; };
 		A7A98E4222804851005306E9 /* ShoppingMallSepcialFlowLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingMallSepcialFlowLayout.swift; sourceTree = "<group>"; };
 		A7A98E4422804C63005306E9 /* ShoppingMallSepcialCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingMallSepcialCollectionViewCell.swift; sourceTree = "<group>"; };
-		A7B4E71C22812DD70012914A /* ShoppingMallSlidingLeftRightTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingMallSlidingLeftRightTableViewCell.swift; sourceTree = "<group>"; };
-		A7B4E71922811F770012914A /* ShoppingCarModoule.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = ShoppingCarModoule.xcassets; sourceTree = "<group>"; };
 		A7B4E71E228131720012914A /* ShoppingMallSlidingLeftRightCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingMallSlidingLeftRightCollectionViewCell.swift; sourceTree = "<group>"; };
 		A7B4E720228151F40012914A /* ProductFloorTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductFloorTitleView.swift; sourceTree = "<group>"; };
 		A7B4E722228154750012914A /* ProductFloorBannerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductFloorBannerView.swift; sourceTree = "<group>"; };
@@ -562,6 +560,7 @@
 		BDD4FB1122840597006FE833 /* ShoppingCartPayOrderController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartPayOrderController.swift; sourceTree = "<group>"; };
 		BDD4FB1322840954006FE833 /* ShoppingCartOrderPayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartOrderPayView.swift; sourceTree = "<group>"; };
 		BDD4FB1622840DD3006FE833 /* OrderPayAcountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderPayAcountView.swift; sourceTree = "<group>"; };
+		BDE3045C22851E4F001D050F /* ProductCartListModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCartListModel.swift; sourceTree = "<group>"; };
 		BDF47D79228271F600941AB9 /* ShoppingCartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartView.swift; sourceTree = "<group>"; };
 		BDF47D7D22827C3F00941AB9 /* ProductSlidingTopBottomCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductSlidingTopBottomCollectionViewCell.swift; sourceTree = "<group>"; };
 		BDF47D7F228288F900941AB9 /* ShoppingCartAccountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartAccountView.swift; sourceTree = "<group>"; };
@@ -1730,6 +1729,7 @@
 				A7A98E01227E8900005306E9 /* ProductSearchListModel.swift */,
 				A7A98E11227ECA11005306E9 /* ProductSearchModel.swift */,
 				A70B2C062284305400B2449F /* ProductModel.swift */,
+				BDE3045C22851E4F001D050F /* ProductCartListModel.swift */,
 			);
 			path = ProductModel;
 			sourceTree = "<group>";
@@ -2572,6 +2572,7 @@
 				A7BB6857226965C100AB07A2 /* SelfRecommendationHeaderCollectionReusableView.swift in Sources */,
 				A7BB68672269B1DD00AB07A2 /* AddressPOIViewController.swift in Sources */,
 				A7284A7322546460000BAEC4 /* SwiftMoyaServicePayApi.swift in Sources */,
+				BDE3045D22851E4F001D050F /* ProductCartListModel.swift in Sources */,
 				A7A98DFF227E8501005306E9 /* SwiftMoyaNetWorkServiceProduct.swift in Sources */,
 				A7CC74DC2270352F003C4F38 /* MineOrderCollectionViewCell.swift in Sources */,
 				BDD4FB1222840597006FE833 /* ShoppingCartPayOrderController.swift in Sources */,
@@ -2594,7 +2595,6 @@
 				A77F2CCA223209F2001BD3F6 /* BaseTabbarViewController.swift in Sources */,
 				A7CC75332271ABB0003C4F38 /* AddressManagerViewController.swift in Sources */,
 				A7CC750D227157DA003C4F38 /* MessageDetailesView.swift in Sources */,
-				A7B4E72B2281752B0012914A /* ShoppingMallBarChartTableViewCell.swift in Sources */,
 				BD7AB83622841A8B0030646A /* ShoppingCartPayOrderItemCell.swift in Sources */,
 				A71AA519227219D7008FF1A5 /* EditExpressAddressViewController.swift in Sources */,
 				BD20F1CD2283C51300677D8E /* ShoppingCartFinishPayController.swift in Sources */,

+ 1 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/ViewController/ShoppingMallListViewController.swift

@@ -66,6 +66,7 @@ class ShoppingMallListViewController: UIViewController {
     
     var productModelsArrays = Array<[ProductModel]>()
     
+    /// 获取商品列表
     func productHomeProductApi(cmsModel:CMSModel?) {
 
         if let model = cmsModel {

+ 104 - 0
RainbowPlanet/RainbowPlanet/Service/Model/ProductModel/ProductCartListModel.swift

@@ -0,0 +1,104 @@
+//
+//  ProductCartListModel.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/5/10.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import Foundation
+import ObjectMapper
+
+
+class ProductCartListData : NSObject, Mappable{
+    
+    var data : [CartProductListModel]?
+    
+    
+    class func newInstance(map: Map) -> Mappable?{
+        return ProductCartListData()
+    }
+    required init?(map: Map){}
+    private override init(){}
+    
+    func mapping(map: Map)
+    {
+        data <- map["data"]
+    }
+    
+}
+
+class CartProductListModel : NSObject, Mappable{
+    
+    var productList : [CartProductModel]?
+    var shopId : Int?
+    var shopName : String?
+    
+    
+    class func newInstance(map: Map) -> Mappable?{
+        return CartProductListModel()
+    }
+    required init?(map: Map){}
+    private override init(){}
+    
+    func mapping(map: Map)
+    {
+        productList <- map["product_list"]
+        shopId <- map["shop_id"]
+        shopName <- map["shop_name"]
+    }
+    
+}
+
+
+class CartProductModel : NSObject, Mappable{
+    
+    var amount : Int?
+    var cityId : Int?
+    var cityName : String?
+    var createdAt : String?
+    var deliverType : Int?
+    var id : Int?
+    var isSelect : Int?
+    var productId : Int?
+    var productImg : String?
+    var productName : String?
+    var productPrice : Int?
+    var shopId : Int?
+    var shopName : String?
+    var skuId : Int?
+    var skuName : String?
+    var skuPrice : Int?
+    var uid : Int?
+    var updatedAt : String?
+    
+    
+    class func newInstance(map: Map) -> Mappable?{
+        return CartProductModel()
+    }
+    required init?(map: Map){}
+    private override init(){}
+    
+    func mapping(map: Map)
+    {
+        amount <- map["amount"]
+        cityId <- map["city_id"]
+        cityName <- map["city_name"]
+        createdAt <- map["created_at"]
+        deliverType <- map["deliver_type"]
+        id <- map["id"]
+        isSelect <- map["is_select"]
+        productId <- map["product_id"]
+        productImg <- map["product_img"]
+        productName <- map["product_name"]
+        productPrice <- map["product_price"]
+        shopId <- map["shop_id"]
+        shopName <- map["shop_name"]
+        skuId <- map["sku_id"]
+        skuName <- map["sku_name"]
+        skuPrice <- map["sku_price"]
+        uid <- map["uid"]
+        updatedAt <- map["updated_at"]
+    }
+    
+}

+ 25 - 0
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaNetWorkServiceProduct.swift

@@ -84,4 +84,29 @@ class SwiftMoyaNetWorkServiceProduct: NSObject {
             }
         }
     }
+    
+    /// 购物车列表
+    ///
+    /// - Parameters:
+    ///   - uid: 用户id
+    ///   - city_id: 城市id
+    ///   - deliver_type: 配送方式
+    ///   - completion: 回调
+    func productCartListApi(completion: @escaping apiCallBack) {
+        var parameters = Dictionary<String,Any>()
+        // 本地获取city_id
+        let loacationModel = LocationModel.shared().getLocationModel()
+        let baiduToCityModel = BaiduToCityFactory.shared.query(bjcityId: loacationModel!.cityCode)
+        parameters.updateValue(baiduToCityModel.areaCode, forKey: "city_id")
+        
+        // 本地获取deliver_type
+        let deliver_type = DeliveryMethodTypeModel.shared().getModel()?.deliveryMethodType
+        parameters.updateValue(deliver_type ?? "0", forKey: "deliver_type")
+        
+        SwiftProgressHUD.shared().showWait()
+        SwiftMoyaNetWorkManager.shared().request(ProductCartListData.self, target: MultiTarget(SwiftMoyaServiceProductApi.productCartList(parameters: parameters))) { (productCartListData) in
+            SwiftProgressHUD.shared().hide()
+            completion(productCartListData)
+        }
+    }
 }

+ 16 - 4
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceProduct/SwiftMoyaServiceProductApi.swift

@@ -21,16 +21,22 @@ public let kProductCategoryApi = "/product/categoryList"
 /// 首页商品
 public let kProductHomeProductApi = "/product/honmeProduct"
 
+// MARK: - 购物车列表
+/// 购物车列表
+public let kProductCartListApi = "/product/cartList"
+
 
 /// 商品
 ///
 /// - productSearch: 搜索、列表、热销
 /// - productCategory: 商品分类
 /// - productHomeProduct: 首页商品
+/// - productCartList: 购物车列表
 public enum SwiftMoyaServiceProductApi {
     case productSearch(parameters:Dictionary<String, Any>)
     case productCategory(parameters:Dictionary<String, Any>)
     case productHomeProduct(parameters:Dictionary<String, Any>)
+    case productCartList(parameters:Dictionary<String, Any>)
 }
 
 extension SwiftMoyaServiceProductApi: TargetType {
@@ -39,7 +45,8 @@ extension SwiftMoyaServiceProductApi: TargetType {
         switch self {
         case .productSearch,
              .productCategory,
-             .productHomeProduct
+             .productHomeProduct,
+             .productCartList
             :
             return URL(string: kApiDataPrefix())!
         }
@@ -53,6 +60,8 @@ extension SwiftMoyaServiceProductApi: TargetType {
             return kProductCategoryApi
         case .productHomeProduct:
             return kProductHomeProductApi
+        case .productCartList:
+            return kProductCartListApi
         }
     }
     
@@ -60,7 +69,8 @@ extension SwiftMoyaServiceProductApi: TargetType {
         switch self {
         case .productSearch,
              .productCategory,
-             .productHomeProduct
+             .productHomeProduct,
+             .productCartList
             :
             return .post
         }
@@ -71,7 +81,8 @@ extension SwiftMoyaServiceProductApi: TargetType {
         switch self {
         case .productSearch(var parameters),
              .productCategory(var parameters),
-             .productHomeProduct(var parameters)
+             .productHomeProduct(var parameters),
+             .productCartList(var parameters)
             :
             let sign = SwiftSign.shared().sign(signType:.AccessToken, parameters: parameters)
             parameters.updateValue(sign, forKey: "sign")
@@ -96,7 +107,8 @@ extension SwiftMoyaServiceProductApi: TargetType {
         switch self {
         case .productSearch,
              .productCategory,
-             .productHomeProduct
+             .productHomeProduct,
+             .productCartList
             :
             return (headerParameters(headerType: .tokenHeader) as! [String : String])
         }