|
@@ -25,8 +25,12 @@ class ProductSlidingTopBottomCollectionViewCell: UICollectionViewCell {
|
|
|
//MARK: - 初始化
|
|
|
override init(frame: CGRect) {
|
|
|
super.init(frame: frame)
|
|
|
+ backgroundColor = UIColor.white
|
|
|
+ cornerRadius = 4
|
|
|
+ masksToBounds = true
|
|
|
setupViews()
|
|
|
setupLayouts()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
@@ -37,40 +41,50 @@ class ProductSlidingTopBottomCollectionViewCell: UICollectionViewCell {
|
|
|
private func setupViews() {
|
|
|
addSubview(iconImagView)
|
|
|
addSubview(titleLabel)
|
|
|
- addSubview(detailTitleLabel)
|
|
|
+ addSubview(sellNumberLabel)
|
|
|
addSubview(sellPriceLabel)
|
|
|
addSubview(markPriceLabel)
|
|
|
addSubview(plusButton)
|
|
|
+ addSubview(shopingCarButton)
|
|
|
}
|
|
|
|
|
|
private func setupLayouts() {
|
|
|
iconImagView.snp.makeConstraints { (make) in
|
|
|
make.top.left.right.equalToSuperview()
|
|
|
- make.height.equalTo(120)
|
|
|
+ make.height.equalTo(150 * kScaleWidth)
|
|
|
}
|
|
|
titleLabel.snp.makeConstraints { (make) in
|
|
|
- make.top.equalTo(iconImagView.snp.bottom).offset(4)
|
|
|
- make.left.equalTo(5)
|
|
|
- make.right.equalTo(-5)
|
|
|
- make.height.equalTo(15)
|
|
|
+ make.left.equalTo(10)
|
|
|
+ make.top.equalTo(iconImagView.snp.bottom).offset(10)
|
|
|
+ make.right.equalTo(-10)
|
|
|
+ make.height.equalTo(23)
|
|
|
}
|
|
|
- detailTitleLabel.snp.makeConstraints { (make) in
|
|
|
- make.top.equalTo(titleLabel.snp.bottom).offset(5)
|
|
|
- make.right.left.equalTo(titleLabel)
|
|
|
- make.height.equalTo(12)
|
|
|
+ sellNumberLabel.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(titleLabel.snp.bottom).offset(15)
|
|
|
+ make.left.right.equalTo(titleLabel)
|
|
|
+ make.height.equalTo(13)
|
|
|
}
|
|
|
sellPriceLabel.snp.remakeConstraints { (make) in
|
|
|
make.left.equalTo(titleLabel)
|
|
|
- make.bottom.equalTo(5)
|
|
|
+ make.bottom.equalTo(-10)
|
|
|
+ make.height.equalTo(19)
|
|
|
}
|
|
|
markPriceLabel.snp.remakeConstraints { (make) in
|
|
|
- make.left.equalTo(sellPriceLabel.snp.right).offset(3)
|
|
|
- make.bottom.equalTo(5)
|
|
|
+ make.left.equalTo(sellPriceLabel.snp.right).offset(5)
|
|
|
+ make.bottom.equalTo(-10)
|
|
|
+ make.height.equalTo(13)
|
|
|
}
|
|
|
plusButton.snp.makeConstraints { (make) in
|
|
|
- make.bottom.equalTo(5)
|
|
|
- make.right.equalTo(-5)
|
|
|
- make.size.equalTo(22)
|
|
|
+ make.right.equalTo(-10)
|
|
|
+ make.bottom.equalTo(-10)
|
|
|
+ make.size.equalTo(25)
|
|
|
+ }
|
|
|
+
|
|
|
+ shopingCarButton.snp.makeConstraints { (make) in
|
|
|
+ make.right.equalTo(-10)
|
|
|
+ make.bottom.equalTo(-10)
|
|
|
+ make.width.equalTo(100)
|
|
|
+ make.height.equalTo(31)
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -91,20 +105,19 @@ class ProductSlidingTopBottomCollectionViewCell: UICollectionViewCell {
|
|
|
return titleLabel
|
|
|
}()
|
|
|
|
|
|
- private lazy var detailTitleLabel: UILabel = {
|
|
|
- let detailTitleLabel = UILabel()
|
|
|
- detailTitleLabel.text = "酸甜可口营养无限"
|
|
|
- detailTitleLabel.textColor = k999999Color
|
|
|
- detailTitleLabel.font = kScaleRegularFont12
|
|
|
- detailTitleLabel.textAlignment = .left
|
|
|
- return detailTitleLabel
|
|
|
+ private lazy var sellNumberLabel: UILabel = {
|
|
|
+ let sellNumberLabel = UILabel()
|
|
|
+ sellNumberLabel.text = "已售2400件"
|
|
|
+ sellNumberLabel.textColor = k999999Color
|
|
|
+ sellNumberLabel.font = kScaleRegularFont12
|
|
|
+ return sellNumberLabel
|
|
|
}()
|
|
|
|
|
|
private lazy var sellPriceLabel: UILabel = {
|
|
|
let sellPriceLabel = UILabel()
|
|
|
sellPriceLabel.text = "¥11.8"
|
|
|
sellPriceLabel.textColor = kfe352bColor
|
|
|
- sellPriceLabel.font = kScaleBoldFont14
|
|
|
+ sellPriceLabel.font = kScaleBoldFont15
|
|
|
sellPriceLabel.textAlignment = .left
|
|
|
return sellPriceLabel
|
|
|
}()
|
|
@@ -113,7 +126,7 @@ class ProductSlidingTopBottomCollectionViewCell: UICollectionViewCell {
|
|
|
let markPriceLabel = UILabel()
|
|
|
markPriceLabel.text = "¥24.4"
|
|
|
markPriceLabel.textColor = kbbbbbbColor
|
|
|
- markPriceLabel.font = kScaleRegularFont11
|
|
|
+ markPriceLabel.font = kScaleRegularFont13
|
|
|
let attrString = NSMutableAttributedString(string: "¥24.4")
|
|
|
attrString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
|
|
|
markPriceLabel.attributedText = attrString
|
|
@@ -126,4 +139,30 @@ class ProductSlidingTopBottomCollectionViewCell: UICollectionViewCell {
|
|
|
return plusButton
|
|
|
}()
|
|
|
|
|
|
+ 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
|
|
|
+ return shopingCarButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ // var productSearchModel: ProductSearchModel? {
|
|
|
+ // didSet {
|
|
|
+ // iconImagView.kf.setImage(with: kURLImage(name: productSearchModel?.img ?? "pic_preload"), placeholder: kImage(name: "pic_preload"))
|
|
|
+ // titleLabel.text = productSearchModel?.nameSkuName
|
|
|
+ // detailTitleLabel.text = productSearchModel?.saleName
|
|
|
+ // sellNumberLabel.text = "已售\(productSearchModel?.totalCount ?? 0)件"
|
|
|
+ // sellPriceLabel.text = "¥\(productSearchModel?.price ?? 0)"
|
|
|
+ // let attributeString = NSMutableAttributedString(string:"¥\(productSearchModel?.originPrice ?? 0)")
|
|
|
+ // attributeString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
|
|
|
+ // markPriceLabel.attributedText = attributeString
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
}
|