|
@@ -18,9 +18,7 @@ class ProductMallBarChartCollectionViewCell: UICollectionViewCell {
|
|
|
|
|
|
typealias PlusClosure = (_ productModel: ProductModel?,_ indexPath:IndexPath?) -> Void
|
|
|
var plusClosure : PlusClosure?
|
|
|
-
|
|
|
- typealias ReduceClosure = (_ productModel: ProductModel?,_ indexPath:IndexPath?) -> Void
|
|
|
- var reduceClosure : ReduceClosure?
|
|
|
+
|
|
|
|
|
|
class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ProductMallBarChartCollectionViewCell {
|
|
|
let ID = "ProductMallBarChartCollectionViewCell"
|
|
@@ -60,9 +58,6 @@ class ProductMallBarChartCollectionViewCell: UICollectionViewCell {
|
|
|
addSubview(sellPriceLabel)
|
|
|
addSubview(markPriceLabel)
|
|
|
addSubview(plusButton)
|
|
|
- addSubview(numberLabel)
|
|
|
- addSubview(reduceButton)
|
|
|
- addSubview(shopingCarButton)
|
|
|
}
|
|
|
|
|
|
private func setupLayouts() {
|
|
@@ -102,24 +97,6 @@ class ProductMallBarChartCollectionViewCell: UICollectionViewCell {
|
|
|
make.size.equalTo(25)
|
|
|
}
|
|
|
|
|
|
- numberLabel.snp.makeConstraints { (make) in
|
|
|
- make.top.bottom.equalTo(plusButton)
|
|
|
- make.right.equalTo(plusButton.snp.left)
|
|
|
- make.width.greaterThanOrEqualTo(50)
|
|
|
- }
|
|
|
-
|
|
|
- reduceButton.snp.makeConstraints { (make) in
|
|
|
- make.right.equalTo(numberLabel.snp.left)
|
|
|
- make.top.width.bottom.equalTo(plusButton)
|
|
|
- }
|
|
|
-
|
|
|
- shopingCarButton.snp.makeConstraints { (make) in
|
|
|
- make.right.equalTo(-10)
|
|
|
- make.bottom.equalTo(-10)
|
|
|
- make.width.equalTo(100)
|
|
|
- make.height.equalTo(31)
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private lazy var iconImagView: UIImageView = {
|
|
@@ -199,48 +176,6 @@ class ProductMallBarChartCollectionViewCell: UICollectionViewCell {
|
|
|
return plusButton
|
|
|
}()
|
|
|
|
|
|
- private lazy var numberLabel: UILabel = {
|
|
|
- let numberLabel = UILabel()
|
|
|
- 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
|
|
|
- if let reduceClosure = self?.reduceClosure {
|
|
|
- reduceClosure(self?.productModel, self?.indexPath)
|
|
|
- }
|
|
|
- }).disposed(by: disposeBag)
|
|
|
- return reduceButton
|
|
|
- }()
|
|
|
-
|
|
|
-
|
|
|
- private lazy var shopingCarButton: UIButton = {
|
|
|
- let shopingCarButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
- shopingCarButton.setTitle("加入购物车", for: UIControl.State.normal)
|
|
|
- shopingCarButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
|
|
|
- shopingCarButton.titleLabel?.font = kMediumFont14
|
|
|
- shopingCarButton.backgroundColor = kFFAC33Color
|
|
|
- shopingCarButton.cornerRadius = 31/2
|
|
|
- shopingCarButton.masksToBounds = true
|
|
|
- shopingCarButton.isHidden = true
|
|
|
- shopingCarButton.rx.tap.subscribe(onNext: {
|
|
|
- [weak self] (data) in
|
|
|
- if let shopingCarClosure = self?.shopingCarClosure {
|
|
|
- shopingCarClosure(self?.productModel, self?.indexPath)
|
|
|
- }
|
|
|
- }).disposed(by: disposeBag)
|
|
|
- return shopingCarButton
|
|
|
- }()
|
|
|
-
|
|
|
-
|
|
|
var productModel : ProductModel? {
|
|
|
didSet {
|
|
|
iconImagView.kf.setImage(with: kURLImage(name: productModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
|
|
@@ -252,23 +187,9 @@ class ProductMallBarChartCollectionViewCell: UICollectionViewCell {
|
|
|
attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
|
|
|
|
|
|
if productModel?.totalStock == 0 {
|
|
|
- reduceButton.isHidden = true
|
|
|
- numberLabel.isHidden = true
|
|
|
plusButton.isHidden = true
|
|
|
- shopingCarButton.isHidden = true
|
|
|
}else {
|
|
|
- if productModel?.amount == 0 || productModel?.amount == nil {
|
|
|
- reduceButton.isHidden = true
|
|
|
- numberLabel.isHidden = true
|
|
|
- plusButton.isHidden = true
|
|
|
- shopingCarButton.isHidden = false
|
|
|
- }else {
|
|
|
- reduceButton.isHidden = false
|
|
|
- numberLabel.isHidden = false
|
|
|
- plusButton.isHidden = false
|
|
|
- shopingCarButton.isHidden = true
|
|
|
- numberLabel.text = "\(productModel?.amount ?? 1)"
|
|
|
- }
|
|
|
+ plusButton.isHidden = false
|
|
|
}
|
|
|
|
|
|
}
|