Browse Source

快递 - 订单支付展示运费

Chris 5 years ago
parent
commit
ef45e8f457

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

@@ -322,6 +322,7 @@
 		A7FF1598228D092A00A85748 /* OrderListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF1597228D092A00A85748 /* OrderListModel.swift */; };
 		A7FF159C228D9E3D00A85748 /* OrderRefundDetailModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF159B228D9E3C00A85748 /* OrderRefundDetailModel.swift */; };
 		BD09C84122955B480080D5A4 /* PopTopTriangleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD09C84022955B480080D5A4 /* PopTopTriangleView.swift */; };
+		BD0E678522A4C23B00B980BA /* ShoppingCartOrderPayFreightCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD0E678422A4C23B00B980BA /* ShoppingCartOrderPayFreightCell.swift */; };
 		BD1DC6C5228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C3228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift */; };
 		BD1DC6C6228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C4228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift */; };
 		BD1DC6C9228D005000B89C57 /* OrderCreateParameterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD1DC6C8228D005000B89C57 /* OrderCreateParameterModel.swift */; };
@@ -725,6 +726,7 @@
 		A7FF1597228D092A00A85748 /* OrderListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderListModel.swift; sourceTree = "<group>"; };
 		A7FF159B228D9E3C00A85748 /* OrderRefundDetailModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderRefundDetailModel.swift; sourceTree = "<group>"; };
 		BD09C84022955B480080D5A4 /* PopTopTriangleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PopTopTriangleView.swift; sourceTree = "<group>"; };
+		BD0E678422A4C23B00B980BA /* ShoppingCartOrderPayFreightCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShoppingCartOrderPayFreightCell.swift; sourceTree = "<group>"; };
 		BD1DC6C3228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftMoyaNetWorkServiceOrder.swift; sourceTree = "<group>"; };
 		BD1DC6C4228CFD0B00B89C57 /* SwiftMoyaServiceOrderApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftMoyaServiceOrderApi.swift; sourceTree = "<group>"; };
 		BD1DC6C8228D005000B89C57 /* OrderCreateParameterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrderCreateParameterModel.swift; sourceTree = "<group>"; };
@@ -2912,6 +2914,7 @@
 				BD7AB837228420310030646A /* ShoppingCartPayOrderHeader.swift */,
 				BD7AB8392284288D0030646A /* ShoppingCartPayOrderFooter.swift */,
 				BD7AB83522841A8B0030646A /* ShoppingCartPayOrderItemCell.swift */,
+				BD0E678422A4C23B00B980BA /* ShoppingCartOrderPayFreightCell.swift */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -3551,6 +3554,7 @@
 				A7FF1585228C847300A85748 /* OrderDetailContactAddressTableViewCell.swift in Sources */,
 				A72A72AA22321DE000B21995 /* Log.swift in Sources */,
 				A72A72B622321DE000B21995 /* Extension+NSRange.swift in Sources */,
+				BD0E678522A4C23B00B980BA /* ShoppingCartOrderPayFreightCell.swift in Sources */,
 				A75414FD224B5F28002480B5 /* MobileLoginViewController.swift in Sources */,
 				A771F07C226D4E1C007999DB /* AddressPOITableViewCell.swift in Sources */,
 				A70B842E228F97EC00882BC5 /* ProcuctDetailSelectSkuTableViewCell.swift in Sources */,

+ 94 - 0
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderPayOrder/View/ShoppingCartOrderPayFreightCell.swift

@@ -0,0 +1,94 @@
+//
+//  ShoppingCartOrderPayFreightCell.swift
+//  RainbowPlanet
+//
+//  Created by Christopher on 2019/6/3.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//  订单支付--运费Cell
+
+import UIKit
+
+class ShoppingCartOrderPayFreightCell: UITableViewCell {
+    
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ShoppingCartOrderPayFreightCell {
+        let ID = "ShoppingCartOrderPayFreightCell"
+        tableView.register(ShoppingCartOrderPayFreightCell.self, forCellReuseIdentifier: ID)
+        let cell : ShoppingCartOrderPayFreightCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! ShoppingCartOrderPayFreightCell
+        cell.indexPath = indexPath
+        return cell
+    }
+    
+    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+        super.init(style: style, reuseIdentifier: reuseIdentifier)
+        setupViews()
+        setupLayouts()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    var indexPath: IndexPath? {
+        didSet {
+            
+        }
+    }
+    override var frame: CGRect {
+        get {
+            return super.frame
+        }
+        set {
+            var frame = newValue
+            frame.origin.x += 14 * kScaleWidth
+            frame.size.width -= 14 * kScaleWidth * 2
+            super.frame = frame
+        }
+    }
+    
+    //MRAK: - 设置View
+    private func setupViews() {
+        self.selectionStyle = .none
+        addSubview(titleLabel)
+        addSubview(freightLabel)
+        addSubview(lineLabel)
+    }
+    
+    private func setupLayouts() {
+        titleLabel.snp.makeConstraints { (make) in
+            make.left.equalTo(14)
+            make.top.bottom.equalToSuperview()
+        }
+        freightLabel.snp.makeConstraints { (make) in
+            make.right.equalTo(-14)
+            make.top.bottom.equalToSuperview()
+        }
+        lineLabel.snp.makeConstraints { (make) in
+            make.bottom.equalToSuperview()
+            make.left.equalTo(titleLabel)
+            make.right.equalTo(freightLabel)
+            make.height.equalTo(1)
+        }
+    }
+    
+    private lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.text = "运费"
+        titleLabel.textColor = k333333Color
+        titleLabel.font = kRegularFont14
+        return titleLabel
+    }()
+    
+    private lazy var freightLabel: UILabel = {
+        let freightLabel = UILabel()
+        freightLabel.textColor = k333333Color
+        freightLabel.font = kRegularFont14
+        freightLabel.text = priceConversion(price: 0)
+        return freightLabel
+    }()
+    private lazy var lineLabel: UILabel = {
+        let lineLabel = UILabel()
+        lineLabel.backgroundColor = kf5f5f5Color
+        return lineLabel
+    }()
+    
+}

+ 34 - 5
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderPayOrder/View/ShoppingCartOrderPayView.swift

@@ -202,7 +202,17 @@ extension ShoppingCartOrderPayView : UITableViewDelegate, UITableViewDataSource
                 return 1
             }
         } else {
-            return proListModelArr![section-1].productList?.isEmpty ?? true ? 0 : proListModelArr![section-1].productList?.count ?? 0
+            let productItems: Int = proListModelArr![section-1].productList?.isEmpty ?? true ? 0 : proListModelArr![section-1].productList?.count ?? 0
+            switch deliverType {
+            case "1":
+                // 自提
+                return productItems
+            case "2":
+                // 快递(商品Cells + 运费Cell)
+                return productItems + 1
+            default:
+                return productItems
+            }
         }
     }
     
@@ -252,10 +262,29 @@ extension ShoppingCartOrderPayView : UITableViewDelegate, UITableViewDataSource
             }
             
         } else {
-            // 购物车列表Item
-            let cell = ShoppingCartPayOrderItemCell.cellWith(tableView: tableView, indexPath: indexPath)
-            cell.productMdl = proListModelArr![indexPath.section-1].productList![indexPath.row]
-            return cell
+            let productItems: Int = proListModelArr![indexPath.section-1].productList?.isEmpty ?? true ? 0 : proListModelArr![indexPath.section-1].productList?.count ?? 0
+            switch deliverType {
+            case "1":
+                // 自提
+                // 购物车列表Item
+                let cell = ShoppingCartPayOrderItemCell.cellWith(tableView: tableView, indexPath: indexPath)
+                cell.productMdl = proListModelArr![indexPath.section-1].productList![indexPath.row]
+                return cell
+            case "2":
+                // 快递(商品Cells + 运费Cell)
+                if indexPath.row < productItems {
+                    // 购物车列表Item
+                    let cell = ShoppingCartPayOrderItemCell.cellWith(tableView: tableView, indexPath: indexPath)
+                    cell.productMdl = proListModelArr![indexPath.section-1].productList![indexPath.row]
+                    return cell
+                } else {
+                    // 运费Cell
+                    let cell = ShoppingCartOrderPayFreightCell.cellWith(tableView: tableView, indexPath: indexPath)
+                    return cell
+                }
+            default:
+                return UITableViewCell()
+            }
         }
     }
     

+ 6 - 2
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderPayOrder/ViewController/ShoppingCartPayOrderController.swift

@@ -106,6 +106,10 @@ class ShoppingCartPayOrderController: BaseViewController {
         return orderPayView
     }()
     
+}
+
+// MARK: - 网络请求相关
+extension ShoppingCartPayOrderController {
     /// 获取默认快递信息
     func userDefaultExpressApi() {
         SwiftMoyaNetWorkServiceUser.shared().userDefaultExpressApi { [weak self] (expressAddrModel) -> (Void) in
@@ -117,7 +121,7 @@ class ShoppingCartPayOrderController: BaseViewController {
     func userDefaultContactApi() {
         SwiftMoyaNetWorkServiceUser.shared().userDefaultContactApi { [weak self] (contactModel) -> (Void) in
             self?.orderPayView.selfAddressInfoMdl = contactModel as? SelfMentionContactsModel
-        }        
+        }
     }
     
     // 获取自提地址列表(始终只有1条)
@@ -145,7 +149,7 @@ class ShoppingCartPayOrderController: BaseViewController {
             }else  if self?.shoppingCartPayOrderVCType == .productDetail {
                 PayManagerPay.shared.payAlertView(orderPayModel: orderBackModel as! OrderCreateBackModel, orderFinishPayVCType: .productDetail, vc: self!)
             }
-           
+            
         }
     }
 }