瀏覽代碼

Merge branch 'develop' into feature/nanxinlin

南鑫林 6 年之前
父節點
當前提交
71721ac491

+ 15 - 1
RainbowPlanet/RainbowPlanet/Modules/OrderModule/OrderApplyRefund/ViewController/OrderApplyRefundController.swift

@@ -254,6 +254,19 @@ extension OrderApplyRefundController {
         tableView.reloadSections([0], with: UITableView.RowAnimation.none)
     }
     
+    // 校验商品是否全未选
+    func judgeAllUnselected() -> Bool {
+        var isAllUnsel: Bool = true
+        for productMdl in productArr ?? [] {
+            if productMdl.isSelect == 1 {
+                isAllUnsel = false
+                break
+            }
+        }
+        return isAllUnsel
+    }
+    
+    
     // 计算退款金额
     func calculateRefundAmount() -> Int {
         var totalPrice: Int = 0
@@ -276,7 +289,8 @@ extension OrderApplyRefundController {
     // 申请退款
     func applyOrderRefund() {
         
-        if productArr?.isEmpty ?? true {
+        let isAllUnselected: Bool = judgeAllUnselected()
+        if isAllUnselected {
             SwiftProgressHUD.shared().showText("请选择退款商品")
             return
         }

+ 14 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartList/ShoppingCartListTableViewCell.swift

@@ -35,6 +35,9 @@ class ShoppingCartListTableViewCell: UITableViewCell {
             if productMdl?.stock == 0 {
                 self.resetDisableWithTitle("已售罄")
             }
+            if productMdl?.upStatus != 0 && productMdl?.stock != 0 {
+                self.resetEnabledCell()
+            }                        
             
             // 选中状态
             let selStatus = productMdl?.isSelect == 1 ? true : false
@@ -176,6 +179,16 @@ class ShoppingCartListTableViewCell: UITableViewCell {
         selectedButton.isHidden = true
     }
     
+    private func resetEnabledCell() {
+        deliveryTime.isHidden = false
+        plusButton.isHidden = false
+        numberLabel.isHidden = false
+        reduceButton.isHidden = false
+        
+        disableLabel.isHidden = true
+        selectedButton.isHidden = false
+    }
+    
     private lazy var selectedButton: UIButton = {
         let selectedButton = UIButton(type: UIButton.ButtonType.custom)
         selectedButton.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
@@ -196,6 +209,7 @@ class ShoppingCartListTableViewCell: UITableViewCell {
         disableLabel.textColor = k333333Color
         disableLabel.font = kRegularFont10
         disableLabel.backgroundColor = kf5f5f5Color
+        disableLabel.textAlignment = .center
         disableLabel.cornerRadius = 10
         disableLabel.masksToBounds = true
         return disableLabel

+ 8 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartList/ShoppingCartListTableViewHeader.swift

@@ -33,6 +33,14 @@ class ShoppingCartListTableViewHeader: BaseView {
         }
     }
     
+    var isShopDisabled: Bool? {
+        didSet {
+            if self.isShopDisabled ?? false {
+                selectedButton.isHidden = true
+            }
+        }
+    }
+    
     override var frame: CGRect {
         get {
             return super.frame

+ 20 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingCartModule/ShoppingCart/View/ShoppingCartView.swift

@@ -362,6 +362,7 @@ extension ShoppingCartView : UITableViewDelegate, UITableViewDataSource {
         if cartListModelArr?.count ?? 0 > 0 && section < cartListModelArr!.count {
             let headerView = ShoppingCartListTableViewHeader(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: 58))
             headerView.shopName = cartListModelArr![section].shopName
+            headerView.isShopDisabled = judgeSectionAllDisabled(section)
             headerView.isSectionSelected = self.judgeSectionSelectedStatus(section)
             headerView.secSelectBlock = { [weak self]
                 (isSectionSel) in
@@ -459,6 +460,14 @@ extension ShoppingCartView {
     func judgeSectionSelectedStatus(_ section: Int) -> Int {
         let cartProListMdl: CartProductListModel = cartListModelArr![section]
         for productMdl in cartProListMdl.productList! {
+            // 忽略已售罄/下架商品选中状态
+            if productMdl.upStatus == 0 {
+                continue
+            }
+            if productMdl.stock == 0 {
+                continue
+            }
+            
             if productMdl.isSelect == 0 {
                 return 0
             }
@@ -539,4 +548,15 @@ extension ShoppingCartView {
         }
     }
     
+    // 校验Section内商品是否全不可用(售罄/下架)
+    func judgeSectionAllDisabled(_ section: Int) -> Bool {
+        let cartProListMdl: CartProductListModel = cartListModelArr![section]
+        for productMdl in cartProListMdl.productList! {
+            if productMdl.stock != 0 && productMdl.upStatus != 0 {
+                return false
+            }
+        }
+        return true
+    }
+    
 }

+ 4 - 4
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/MainView/ShoppingMallView.swift

@@ -17,7 +17,8 @@ class ShoppingMallView: UIView {
     override init(frame: CGRect) {
         super.init(frame: frame)
         DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) {
-            self.addressPopView()
+            let addrMdl = SelfMentionAddressModel.getModel()
+            self.addressPopView(address: addrMdl?.address ?? "")
         }
         self.cmsTemplateSetTemplateNameApi()
     }
@@ -103,8 +104,6 @@ class ShoppingMallView: UIView {
     //初始化自提地址提示View
     lazy var selfAddressPopView: PopTopTriangleView = {
         let selfAddressPopView = PopTopTriangleView()
-        let addrMdl = SelfMentionAddressModel.getModel()
-        selfAddressPopView.address = addrMdl?.address
         return selfAddressPopView
     }()
     
@@ -169,11 +168,12 @@ class ShoppingMallView: UIView {
     }()
     
     /// 8.自提地址
-    func addressPopView() {
+    func addressPopView(address: String) {
         let deliverType = DeliveryMethodTypeModel.shared().getModel()?.deliveryMethodType
         if deliverType == "1" {
             // 自提
             addSubview(selfAddressPopView)
+            selfAddressPopView.address = address
             selfAddressPopView.snp.remakeConstraints { (make) in
                 make.top.equalToSuperview()
                 make.left.equalToSuperview().offset(14)

+ 2 - 1
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/ViewController/ShoppingMallViewController.swift

@@ -110,7 +110,8 @@ class ShoppingMallViewController: BaseViewController {
             [weak self] in
             let model = DeliveryMethodTypeModel.shared().getModel()
             if model?.deliveryMethodType == "1" { //自提
-                self?.shoppingMallView.addressPopView()
+                let addrMdl = SelfMentionAddressModel.getModel()
+                self?.shoppingMallView.addressPopView(address: addrMdl?.address ?? "")
             }            
         }
         return navigationBarView