|
@@ -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)
|