南鑫林 vor 6 Jahren
Ursprung
Commit
99966a5e81

+ 45 - 0
RainbowPlanet/RainbowPlanet/Modules/ShoppingMallModule/ShoppingMall/View/ShoppingMallFloor/FloorCell/ShoppingMallBarChart/ShoppingMallBarChartCollectionViewCell.swift

@@ -8,7 +8,12 @@
 
 import UIKit
 
+import RxSwift
+
 class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
+    
+    let disposeBag = DisposeBag()
+    
     class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ShoppingMallBarChartCollectionViewCell {
         let ID = "ShoppingMallBarChartCollectionViewCell"
         collectionView.register(ShoppingMallBarChartCollectionViewCell.self, forCellWithReuseIdentifier: ID)
@@ -176,6 +181,11 @@ class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
     private lazy var plusButton: UIButton = {
         let plusButton = UIButton(type: UIButton.ButtonType.custom)
         plusButton.setImage(kImage(name: "shopping_mall_plus"), for: UIControl.State.normal)
+        plusButton.isHidden = true
+        plusButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            self?.setProductAmount(type: 1)
+        }).disposed(by: disposeBag)
         return plusButton
     }()
     
@@ -185,12 +195,18 @@ class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
         numberLabel.textAlignment = .center
         numberLabel.font = kRegularFont14
         numberLabel.textColor = k333333Color
+        numberLabel.isHidden = true
         return numberLabel
     }()
     
     private lazy var reduceButton: UIButton = {
         let reduceButton = UIButton(type: UIButton.ButtonType.custom)
         reduceButton.setImage(kImage(name: "home_btn_buy_subtract"), for: UIControl.State.normal)
+        reduceButton.isHidden = true
+        reduceButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            self?.setProductAmount(type: 2)
+        }).disposed(by: disposeBag)
         return reduceButton
     }()
     
@@ -204,6 +220,10 @@ class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
         shopingCarButton.cornerRadius = 31/2
         shopingCarButton.masksToBounds = true
         shopingCarButton.isHidden = true
+        shopingCarButton.rx.tap.subscribe(onNext: {
+            [weak self] (data) in
+            self?.addCart()
+        }).disposed(by: disposeBag)
         return shopingCarButton
     }()
     
@@ -218,6 +238,31 @@ class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
             let attributeString = NSMutableAttributedString(string:"¥\(productModel?.originPrice ?? 0)")
             attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
             markPriceLabel.attributedText = attributeString
+            reduceButton.isHidden = true
+            numberLabel.isHidden = true
+            plusButton.isHidden = true
+            shopingCarButton.isHidden = false
         }
     }
+    
+    
+    /// 添加购物车
+    ///
+    /// - Returns:
+    func addCart() {
+        reduceButton.isHidden = false
+        numberLabel.isHidden = false
+        plusButton.isHidden = false
+        shopingCarButton.isHidden = true
+    }
+
+    
+    /// 添加数量
+    func setProductAmount(type:Int){
+        reduceButton.isHidden = true
+        numberLabel.isHidden = true
+        plusButton.isHidden = true
+        shopingCarButton.isHidden = false
+    }
+
 }