ソースを参照

自提信息相关

Chris 6 年 前
コミット
9879c638b7

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

@@ -304,6 +304,7 @@
 		BDE3045F228554CA001D050F /* ProductCartAmountModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDE3045E228554CA001D050F /* ProductCartAmountModel.swift */; };
 		BDEF7791228571DC00ED0AC0 /* CommonPayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDEF7790228571DC00ED0AC0 /* CommonPayView.swift */; };
 		BDEF7793228575A800ED0AC0 /* CommonPayCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDEF7792228575A800ED0AC0 /* CommonPayCell.swift */; };
+		BDF45F0D228C00B8004E2682 /* DefaultContactInfoModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDF45F0C228C00B8004E2682 /* DefaultContactInfoModel.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 */; };
@@ -643,6 +644,7 @@
 		BDE3045E228554CA001D050F /* ProductCartAmountModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCartAmountModel.swift; sourceTree = "<group>"; };
 		BDEF7790228571DC00ED0AC0 /* CommonPayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonPayView.swift; sourceTree = "<group>"; };
 		BDEF7792228575A800ED0AC0 /* CommonPayCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonPayCell.swift; sourceTree = "<group>"; };
+		BDF45F0C228C00B8004E2682 /* DefaultContactInfoModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultContactInfoModel.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>"; };
@@ -1194,6 +1196,7 @@
 				A757C92D22744ACE00226355 /* AddressManagerListModel.swift */,
 				A79057012276C9770037F823 /* SetPasswordModel.swift */,
 				A79057072276FEB00037F823 /* SelfMentionContactsModel.swift */,
+				BDF45F0C228C00B8004E2682 /* DefaultContactInfoModel.swift */,
 			);
 			path = UserModel;
 			sourceTree = "<group>";
@@ -2948,6 +2951,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				A70B2C3322880BB700B2449F /* ProductDetailProductSkuTableViewCell.swift in Sources */,
+				BDF45F0D228C00B8004E2682 /* DefaultContactInfoModel.swift in Sources */,
 				A72A72BA22321DE000B21995 /* Extension+String.swift in Sources */,
 				A77F2CA02231FE45001BD3F6 /* BaseWebViewController.swift in Sources */,
 				BD20F1D52283D15500677D8E /* ShoppingCartPayFailureCell.swift in Sources */,

+ 8 - 2
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCartPayOrder/View/AdressCell/OrderPaySelfPickInfoCell.swift

@@ -10,6 +10,14 @@ import UIKit
 
 class OrderPaySelfPickInfoCell: UITableViewCell {
     
+    // 默认联系人Mdl
+    var contactMdl: DefaultContactInfoModel? {
+        didSet {
+            nameLabel.text = contactMdl?.name
+            phoneLabel.text = contactMdl?.mobile
+        }
+    }
+    
     override var frame: CGRect {
         get {
             return super.frame
@@ -76,7 +84,6 @@ class OrderPaySelfPickInfoCell: UITableViewCell {
     
     private lazy var nameLabel: UILabel = {
         let nameLabel = UILabel()
-        nameLabel.text = "范德彪"
         nameLabel.textColor = k333333Color
         nameLabel.font = kRegularFont14
         return nameLabel
@@ -84,7 +91,6 @@ class OrderPaySelfPickInfoCell: UITableViewCell {
     
     private lazy var phoneLabel: UILabel = {
         let phoneLabel = UILabel()
-        phoneLabel.text = "158xxxx5481"
         phoneLabel.textColor = k333333Color
         phoneLabel.font = kRegularFont14
         return phoneLabel

+ 4 - 3
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCartPayOrder/View/ShoppingCartOrderPayView.swift

@@ -45,7 +45,7 @@ class ShoppingCartOrderPayView: BaseView {
     }
     
     // 自提地址信息Mdl
-    var selfAddressArrMdl: Array<SelfAddresModel>? {
+    var selfAddressInfoMdl: DefaultContactInfoModel? {
         didSet {
             self.tableView.reloadSections([0], with: UITableView.RowAnimation.none)
         }
@@ -126,7 +126,7 @@ extension ShoppingCartOrderPayView : UITableViewDelegate, UITableViewDataSource
             switch deliverType {
             case "1":
                 // 自提
-                if selfAddressArrMdl?.isEmpty ?? true  {
+                if selfAddressInfoMdl == nil  {
                     if indexPath.row == 0 {
                         // 自提添加收货人信息
                         let cell = OrderPaySelfPickAddInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
@@ -140,6 +140,7 @@ extension ShoppingCartOrderPayView : UITableViewDelegate, UITableViewDataSource
                     if indexPath.row == 0 {
                         // 自提个人信息
                         let cell = OrderPaySelfPickInfoCell.cellWith(tableView: tableView, indexPath: indexPath)
+                        cell.contactMdl = selfAddressInfoMdl
                         return cell
                     } else {
                         // 自提地址信息
@@ -231,7 +232,7 @@ extension ShoppingCartOrderPayView : UITableViewDelegate, UITableViewDataSource
         switch deliverType {
         case "1":
             // 自提
-            if selfAddressArrMdl?.isEmpty ?? true {
+            if selfAddressInfoMdl == nil {
                 if indexPath.row == 0 {
                     if let jumpNavBlock = self.jumpNavBlock {
                         jumpNavBlock(WillJumpType.selfAddInfo)

+ 8 - 18
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCartPayOrder/ViewController/ShoppingCartPayOrderController.swift

@@ -50,7 +50,7 @@ class ShoppingCartPayOrderController: BaseViewController {
         
         switch deliverType {
         case "1":
-            self.userSelfAddressListApi()
+            self.userDefaultContactApi()
         case "2":
             // 获取默认快递信息
             self.userDefaultExpressApi()
@@ -89,18 +89,12 @@ class ShoppingCartPayOrderController: BaseViewController {
                 let vc = ExpressAddressListViewController()
                 self?.navigationController?.pushViewController(vc, animated: true)
             case WillJumpType.selfAddInfo:
-                print("------自提添加")
                 let vc = EditSelfMentionContactsViewController()
-//                vc.saveClosure = {
-//                    [weak self] in
-//                    self?.userExpreesContactsListApi()
-//                }
-//                if let selfMentionContactsModel = selfMentionContactsModel   {
-//                    vc.selfMentionContactsModel = selfMentionContactsModel
-//                }
                 self?.navigationController?.pushViewController(vc, animated: true)
             case WillJumpType.selfPersonalInfo:
                 print("------自提个人信息")
+                let vc = SelfMentionContactsListViewController()
+                self?.navigationController?.pushViewController(vc, animated: true)
             case WillJumpType.selfAddressInfo:                
                 let vc = SelfRecommendationViewController()
                 self?.navigationController?.pushViewController(vc, animated: true)
@@ -117,15 +111,11 @@ class ShoppingCartPayOrderController: BaseViewController {
         }
     }
     
-    // 获取用户自提点
-    func userSelfAddressListApi() {
-        SwiftMoyaNetWorkServiceUser.shared().userSelfAndExpressAddressListApi(type: 1) {
-            
-            [weak self] (addressManagerListModel) -> (Void) in
-            let addrListMdl = addressManagerListModel as? AddressManagerListModel            
-            // 自提点数组只返回1条数据
-            self?.orderPayView.selfAddressArrMdl = addrListMdl?.selfAddress
-        }
+    // 获取默认用户自提信息
+    func userDefaultContactApi() {
+        SwiftMoyaNetWorkServiceUser.shared().userDefaultContactApi { [weak self] (contactModel) -> (Void) in
+            self?.orderPayView.selfAddressInfoMdl = contactModel as? DefaultContactInfoModel
+        }        
     }
     
 }

+ 44 - 0
RainbowPlanet/RainbowPlanet/Service/Model/UserModel/DefaultContactInfoModel.swift

@@ -0,0 +1,44 @@
+//
+//  DefaultContactInfoModel.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/5/15.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import Foundation
+import ObjectMapper
+
+
+class DefaultContactInfoModel : NSObject, Mappable{
+    
+    var createdAt : AnyObject?
+    var deletedAt : AnyObject?
+    var id : Int?
+    var isDefault : Int?
+    var mobile : String?
+    var name : String?
+    var uid : Int?
+    var updatedAt : AnyObject?
+    
+    
+    class func newInstance(map: Map) -> Mappable?{
+        return DefaultContactInfoModel()
+    }
+    required init?(map: Map){}
+    private override init(){}
+    
+    func mapping(map: Map)
+    {
+        createdAt <- map["created_at"]
+        deletedAt <- map["deleted_at"]
+        id <- map["id"]
+        isDefault <- map["is_default"]
+        mobile <- map["mobile"]
+        name <- map["name"]
+        uid <- map["uid"]
+        updatedAt <- map["updated_at"]
+        
+    }
+    
+}

+ 16 - 1
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaNetWorkServiceUser.swift

@@ -390,14 +390,29 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
         let parameters = Dictionary<String,Any>()
         SwiftProgressHUD.shared().showWait()
         SwiftMoyaNetWorkManager.shared().request(target: MultiTarget(SwiftMoyaServiceUserApi.userDefaultExpress(parameters: parameters))) {(rootModel) in
-            let rootModel = rootModel as! RootModel
             SwiftProgressHUD.shared().hide()
+            let rootModel = rootModel as! RootModel
             
             let expressAddrModel = ExpressAddresModel(JSONString: rootModel.data ?? "")
             completion(expressAddrModel as Any)
         }
     }
     
+    // MARK: - 获取默认快递信息
+    /// 获取默认快递信息
+    ///
+    /// - Parameter completion: 成功回调
+    func userDefaultContactApi(completion: @escaping apiCallBack) {
+        let parameters = Dictionary<String,Any>()
+        SwiftProgressHUD.shared().showWait()
+        SwiftMoyaNetWorkManager.shared().request(target: MultiTarget(SwiftMoyaServiceUserApi.userDefaultContact(parameters: parameters))) {(rootModel) in
+            SwiftProgressHUD.shared().hide()
+            let rootModel = rootModel as! RootModel
+            
+            let contactMdl = DefaultContactInfoModel(JSONString: rootModel.data ?? "")
+            completion(contactMdl as Any)
+        }
+    }
     
     // MARK: - 新增、编辑 自提地址收货人信息
     /// 新增、编辑 自提地址收货人信息

+ 14 - 2
RainbowPlanet/RainbowPlanet/Service/SwiftMoyaService/SwiftMoyaServiceApi/SwiftMoyaServiceUser/SwiftMoyaServiceUserApi.swift

@@ -73,6 +73,10 @@ public let kUserExpreesContactsListApi = "/user/expreesContactsList"
 /// 获取默认快递信息
 public let kUserDefaultExpressApi = "/user/getDefault"
 
+// MARK: - 获取默认自提收货人
+/// 获取默认自提收货人
+public let kUserDefaultContactApi = "/user/getContactsDefault"
+
 // MARK: - 新增、编辑 自提地址收货人信息
 /// 新增、编辑 自提地址收货人信息
 public let kUserSaveExpreesContactsApi = "/user/saveExpreesContacts"
@@ -111,6 +115,7 @@ public let kUserSetDeliverTypeApi = "/user/setDeliverType"
 /// - userAddressDelete: 删除(自提/快递)地址
 /// - userExpreesContactsList: 自提点收货人列表
 /// - userDefaultExpress: 获取默认快递信息
+/// - userDefaultContact: 获取默认自提收货人
 /// - userSaveExpreesContacts: 新增、编辑 自提地址收货人信息
 /// - userDelExpreesContacts: 删除自提点收货人信息
 /// - userSetExpreesContactsDefault: 自提点收货人信息,设置默认
@@ -133,6 +138,7 @@ public enum SwiftMoyaServiceUserApi {
     case userAddressDelete(parameters:Dictionary<String, Any>)
     case userExpreesContactsList(parameters:Dictionary<String, Any>)
     case userDefaultExpress(parameters:Dictionary<String, Any>)
+    case userDefaultContact(parameters:Dictionary<String, Any>)
     case userSaveExpreesContacts(parameters:Dictionary<String, Any>)
     case userDelExpreesContacts(parameters:Dictionary<String, Any>)
     case userSetExpreesContactsDefault(parameters:Dictionary<String, Any>)
@@ -161,6 +167,7 @@ extension SwiftMoyaServiceUserApi: TargetType {
              .userAddressDelete,
              .userExpreesContactsList,
              .userDefaultExpress,
+             .userDefaultContact,
              .userSaveExpreesContacts,
              .userDelExpreesContacts,
              .userSetExpreesContactsDefault,
@@ -205,6 +212,8 @@ extension SwiftMoyaServiceUserApi: TargetType {
             return kUserExpreesContactsListApi
         case .userDefaultExpress:
             return kUserDefaultExpressApi
+        case .userDefaultContact:
+            return kUserDefaultContactApi
         case .userSaveExpreesContacts:
             return kUserSaveExpreesContactsApi
         case .userDelExpreesContacts:
@@ -237,12 +246,13 @@ extension SwiftMoyaServiceUserApi: TargetType {
             :
             return .post
         case .userAddressIsDefault,
-             .userExpreesContactsList,
              .userSetDeliverType
             :
             return .put
         case .userSelfAddressList,
-             .userDefaultExpress
+             .userExpreesContactsList,
+             .userDefaultExpress,
+             .userDefaultContact
             :
             return .get
         case .userAddressDelete,
@@ -273,6 +283,7 @@ extension SwiftMoyaServiceUserApi: TargetType {
              .userAddressDelete(var parameters),
              .userExpreesContactsList(var parameters),
              .userDefaultExpress(var parameters),
+             .userDefaultContact(var parameters),
              .userSaveExpreesContacts(var parameters),
              .userDelExpreesContacts(var parameters),
              .userSetExpreesContactsDefault(var parameters),
@@ -316,6 +327,7 @@ extension SwiftMoyaServiceUserApi: TargetType {
              .userAddressDelete,
              .userExpreesContactsList,
              .userDefaultExpress,
+             .userDefaultContact,
              .userSaveExpreesContacts,
              .userDelExpreesContacts,
              .userSetExpreesContactsDefault,