|
@@ -0,0 +1,212 @@
|
|
|
+//
|
|
|
+// ShoppingMallBarChartCollectionViewCell.swift
|
|
|
+// RainbowPlanet
|
|
|
+//
|
|
|
+// Created by 南鑫林 on 2019/5/7.
|
|
|
+// Copyright © 2019 南鑫林. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+import UIKit
|
|
|
+
|
|
|
+class ShoppingMallBarChartCollectionViewCell: UICollectionViewCell {
|
|
|
+ class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> ShoppingMallBarChartCollectionViewCell {
|
|
|
+ let ID = "ShoppingMallBarChartCollectionViewCell"
|
|
|
+ collectionView.register(ShoppingMallBarChartCollectionViewCell.self, forCellWithReuseIdentifier: ID)
|
|
|
+ let cell : ShoppingMallBarChartCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: ID, for: indexPath) as! ShoppingMallBarChartCollectionViewCell
|
|
|
+ cell.indexPath = indexPath
|
|
|
+ return cell
|
|
|
+ }
|
|
|
+ //MARK: - indexPath
|
|
|
+ var indexPath: IndexPath?{
|
|
|
+ didSet {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //MARK: - 初始化
|
|
|
+ override init(frame: CGRect) {
|
|
|
+ super.init(frame: frame)
|
|
|
+ backgroundColor = UIColor.white
|
|
|
+ cornerRadius = 4
|
|
|
+ masksToBounds = true
|
|
|
+ setupViews()
|
|
|
+ setupLayouts()
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ required init?(coder aDecoder: NSCoder) {
|
|
|
+ fatalError("init(coder:) has not been implemented")
|
|
|
+ }
|
|
|
+
|
|
|
+ //MRAK: - 设置View
|
|
|
+ private func setupViews() {
|
|
|
+ addSubview(iconImagView)
|
|
|
+ addSubview(titleLabel)
|
|
|
+ addSubview(detailTitleLabel)
|
|
|
+ addSubview(sellNumberLabel)
|
|
|
+ addSubview(sellPriceLabel)
|
|
|
+ addSubview(markPriceLabel)
|
|
|
+ addSubview(plusButton)
|
|
|
+ addSubview(numberLabel)
|
|
|
+ addSubview(reduceButton)
|
|
|
+ addSubview(shopingCarButton)
|
|
|
+ }
|
|
|
+
|
|
|
+ private func setupLayouts() {
|
|
|
+ iconImagView.snp.makeConstraints { (make) in
|
|
|
+ make.top.left.right.equalToSuperview()
|
|
|
+ make.height.equalTo(150 * kScaleWidth)
|
|
|
+ }
|
|
|
+ titleLabel.snp.makeConstraints { (make) in
|
|
|
+ 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(4)
|
|
|
+ make.right.left.equalTo(titleLabel)
|
|
|
+ make.height.equalTo(13)
|
|
|
+ }
|
|
|
+ sellNumberLabel.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(detailTitleLabel.snp.bottom).offset(15)
|
|
|
+ make.left.right.equalTo(detailTitleLabel)
|
|
|
+ make.height.equalTo(13)
|
|
|
+ }
|
|
|
+ sellPriceLabel.snp.remakeConstraints { (make) in
|
|
|
+ make.left.equalTo(titleLabel)
|
|
|
+ make.bottom.equalTo(-10)
|
|
|
+ make.height.equalTo(19)
|
|
|
+ }
|
|
|
+ markPriceLabel.snp.remakeConstraints { (make) in
|
|
|
+ make.left.equalTo(sellPriceLabel.snp.right).offset(5)
|
|
|
+ make.bottom.equalTo(-10)
|
|
|
+ make.height.equalTo(13)
|
|
|
+ }
|
|
|
+ plusButton.snp.makeConstraints { (make) in
|
|
|
+ make.right.equalTo(-10)
|
|
|
+ make.bottom.equalTo(-10)
|
|
|
+ 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 = {
|
|
|
+ let iconImagView = UIImageView()
|
|
|
+ iconImagView.image = kImage(name: "pic_preload")
|
|
|
+ return iconImagView
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var titleLabel: UILabel = {
|
|
|
+ let titleLabel = UILabel()
|
|
|
+ titleLabel.text = "海南冰糖心木瓜 1个装"
|
|
|
+ titleLabel.textColor = k333333Color
|
|
|
+ titleLabel.font = kScaleMediumFont15
|
|
|
+ titleLabel.textAlignment = .left
|
|
|
+ titleLabel.numberOfLines = 1
|
|
|
+ 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 = k333333Color
|
|
|
+ sellNumberLabel.font = kScaleRegularFont11
|
|
|
+ return sellNumberLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var sellPriceLabel: UILabel = {
|
|
|
+ let sellPriceLabel = UILabel()
|
|
|
+ sellPriceLabel.text = "¥11.8"
|
|
|
+ sellPriceLabel.textColor = kfe352bColor
|
|
|
+ sellPriceLabel.font = kScaleBoldFont15
|
|
|
+ sellPriceLabel.textAlignment = .left
|
|
|
+ return sellPriceLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var markPriceLabel: UILabel = {
|
|
|
+ let markPriceLabel = UILabel()
|
|
|
+ markPriceLabel.text = "¥24.4"
|
|
|
+ markPriceLabel.textColor = kbbbbbbColor
|
|
|
+ markPriceLabel.font = kScaleRegularFont13
|
|
|
+ let attrString = NSMutableAttributedString(string: "¥24.4")
|
|
|
+ attrString.changeStrikethrough(atAllStyle: NSUnderlineStyle.single, color: kbbbbbbColor)
|
|
|
+ markPriceLabel.attributedText = attrString
|
|
|
+ return markPriceLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var plusButton: UIButton = {
|
|
|
+ let plusButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ plusButton.setImage(kImage(name: "home_btn_buy"), for: UIControl.State.normal)
|
|
|
+ return plusButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var numberLabel: UILabel = {
|
|
|
+ let numberLabel = UILabel()
|
|
|
+ numberLabel.text = "1"
|
|
|
+ numberLabel.textAlignment = .center
|
|
|
+ numberLabel.font = kRegularFont14
|
|
|
+ numberLabel.textColor = k333333Color
|
|
|
+ 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)
|
|
|
+ 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
|
|
|
+ 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
|
|
|
+ //
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+}
|