瀏覽代碼

Merge branch 'feature/liuxuqing' into develop

Chris 6 年之前
父節點
當前提交
e9804293ea

+ 1 - 1
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderPayOrder/View/ShoppingCartOrderPayView.swift

@@ -43,7 +43,7 @@ class ShoppingCartOrderPayView: BaseView {
     // 快递地址信息Mdl
     var expressAddressMdl: ExpressAddresModel? {
         didSet {
-            if expressAddressMdl != nil {
+            if expressAddressMdl != nil && expressAddressMdl?.id != nil {
                 tableView.reloadData()
             }
         }

+ 31 - 3
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartList/ShoppingCartListTableViewCell.swift

@@ -24,6 +24,15 @@ class ShoppingCartListTableViewCell: UITableViewCell {
     
     var productMdl : ProductModel? {
         didSet {
+            // 已下架
+            if productMdl?.upStatus == 0 {
+                self.resetButtonWithTitle("已下架")
+            }
+            // 已售罄
+            if productMdl?.stock == 0 {
+                self.resetButtonWithTitle("已售罄")
+            }
+            
             // 选中状态
             let selStatus = productMdl?.isSelect == 1 ? true : false
             selectedButton.isSelected = selStatus
@@ -43,6 +52,7 @@ class ShoppingCartListTableViewCell: UITableViewCell {
             numberLabel.text = "\(productMdl?.amount ?? 1)"
         }
     }
+    
     class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ShoppingCartListTableViewCell {
         let ID = "ShoppingCartListTableViewCell"
         tableView.register(ShoppingCartListTableViewCell.self, forCellReuseIdentifier: ID)
@@ -89,11 +99,13 @@ class ShoppingCartListTableViewCell: UITableViewCell {
             make.top.bottom.equalToSuperview()
             make.left.equalTo(14 * kScaleWidth)
             make.right.equalTo(-14 * kScaleWidth)
+            make.height.equalTo(148)
         }
         selectedButton.snp.makeConstraints { (make) in
-            make.left.top.bottom.equalToSuperview()
-            make.width.equalTo(40)
-            make.height.equalTo(148)
+            make.left.equalToSuperview()
+            make.top.equalTo(50)
+            make.width.equalTo(36)
+            make.height.equalTo(20)
         }
         iconImageView.snp.makeConstraints { (make) in
             make.left.equalToSuperview().offset(40)
@@ -146,6 +158,22 @@ class ShoppingCartListTableViewCell: UITableViewCell {
         
     }
     
+    private func resetButtonWithTitle(_ title: String) {
+        deliveryTime.isHidden = true
+        plusButton.isHidden = true
+        numberLabel.isHidden = true
+        reduceButton.isHidden = true
+        
+        selectedButton.setImage(kImage(name: ""), for: UIControl.State.normal)
+        selectedButton.setTitle(title, for: .normal)
+        selectedButton.setTitleColor(k333333Color, for: .normal)
+        selectedButton.titleLabel?.font = kRegularFont10
+        selectedButton.backgroundColor = kf5f5f5Color
+        selectedButton.cornerRadius = 10
+        selectedButton.masksToBounds = true
+        selectedButton.isUserInteractionEnabled = false
+    }
+    
     private lazy var selectedButton: UIButton = {
         let selectedButton = UIButton(type: UIButton.ButtonType.custom)
         selectedButton.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)

+ 19 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/ViewController/ShoppingCartViewController.swift

@@ -91,7 +91,8 @@ class ShoppingCartViewController: BaseViewController {
     func productCartListApi() {
         SwiftMoyaNetWorkServiceProduct.shared().productCartListApi { [weak self] (cartListData) -> (Void) in
             let cartListData = cartListData as? ProductCartListData
-            self?.shoppingCartView.cartListModelArr = cartListData?.data
+            let listMdlArr = self?.fixSelectStatusWithModel(modelArr: cartListData?.data ?? [])
+            self?.shoppingCartView.cartListModelArr = listMdlArr
         }
     }
     
@@ -113,4 +114,21 @@ class ShoppingCartViewController: BaseViewController {
         }
     }
     
+    // 已下架/售罄商品,数据源选中状态置0
+    func fixSelectStatusWithModel(modelArr: [CartProductListModel]) -> [CartProductListModel] {
+        for cartProListMdl in modelArr {
+            for productMdl in cartProListMdl.productList! {
+                // 已下架
+                if productMdl.upStatus == 0 {
+                    productMdl.isSelect = 0
+                }
+                // 已售罄
+                if productMdl.stock == 0 {
+                    productMdl.isSelect = 0
+                }
+            }
+        }
+        return modelArr
+    }
+    
 }

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

@@ -411,11 +411,8 @@ public class SwiftMoyaNetWorkServiceUser: NSObject {
     func userDefaultExpressApi(completion: @escaping apiCallBack) {
         let parameters = Dictionary<String,Any>()
         SwiftProgressHUD.shared().showWait()
-        SwiftMoyaNetWorkManager.shared().request(target: MultiTarget(SwiftMoyaServiceUserApi.userDefaultExpress(parameters: parameters))) {(rootModel) in
+        SwiftMoyaNetWorkManager.shared().request(ExpressAddresModel.self, target: MultiTarget(SwiftMoyaServiceUserApi.userDefaultExpress(parameters: parameters))) { (expressAddrModel) in
             SwiftProgressHUD.shared().hide()
-            let rootModel = rootModel as! RootModel
-            
-            let expressAddrModel = ExpressAddresModel(JSONString: rootModel.data ?? "")
             completion(expressAddrModel as Any)
         }
     }