|
@@ -0,0 +1,204 @@
|
|
|
+//
|
|
|
+// ShoppingCartListTableViewCell.swift
|
|
|
+// RainbowPlanet
|
|
|
+//
|
|
|
+// Created by Christopher on 2019/5/8.
|
|
|
+// Copyright © 2019 RainbowPlanet. All rights reserved.
|
|
|
+//
|
|
|
+
|
|
|
+import UIKit
|
|
|
+
|
|
|
+class ShoppingCartListTableViewCell: UITableViewCell {
|
|
|
+
|
|
|
+ override var frame: CGRect {
|
|
|
+ get {
|
|
|
+ return super.frame
|
|
|
+ }
|
|
|
+ set {
|
|
|
+ var frame = newValue
|
|
|
+ frame.origin.x += 14 * kScaleWidth
|
|
|
+ frame.size.width -= 14 * kScaleWidth * 2
|
|
|
+ super.frame = frame
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ class func cellWith(tableView:UITableView,indexPath:IndexPath) -> ShoppingCartListTableViewCell {
|
|
|
+ let ID = "ShoppingCartListTableViewCell"
|
|
|
+ tableView.register(ShoppingCartListTableViewCell.self, forCellReuseIdentifier: ID)
|
|
|
+ let cell : ShoppingCartListTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! ShoppingCartListTableViewCell
|
|
|
+ cell.indexPath = indexPath
|
|
|
+ return cell
|
|
|
+ }
|
|
|
+
|
|
|
+ override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
|
|
|
+ super.init(style: style, reuseIdentifier: reuseIdentifier)
|
|
|
+ setupViews()
|
|
|
+ setupLayouts()
|
|
|
+ }
|
|
|
+
|
|
|
+ required init?(coder aDecoder: NSCoder) {
|
|
|
+ fatalError("init(coder:) has not been implemented")
|
|
|
+ }
|
|
|
+
|
|
|
+ var indexPath: IndexPath? {
|
|
|
+ didSet {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //MRAK: - 设置View
|
|
|
+ private func setupViews() {
|
|
|
+ self.selectionStyle = .none
|
|
|
+// cornerRadius = 4
|
|
|
+// masksToBounds = true
|
|
|
+
|
|
|
+ addSubview(selectedButton)
|
|
|
+ addSubview(iconImagView)
|
|
|
+ addSubview(titleLabel)
|
|
|
+ addSubview(deliveryTime)
|
|
|
+ addSubview(sellScaleLabel)
|
|
|
+ addSubview(sellNumberLabel)
|
|
|
+ addSubview(sellPriceLabel)
|
|
|
+ addSubview(plusButton)
|
|
|
+ addSubview(numberLabel)
|
|
|
+ addSubview(reduceButton)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private func setupLayouts() {
|
|
|
+ selectedButton.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalTo(10)
|
|
|
+ make.top.equalTo(50)
|
|
|
+ make.bottom.equalTo(-80)
|
|
|
+ make.size.equalTo(18)
|
|
|
+ }
|
|
|
+ iconImagView.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalToSuperview().offset(40)
|
|
|
+ make.centerY.equalToSuperview()
|
|
|
+ make.width.height.equalTo(92 * kScaleWidth)
|
|
|
+ }
|
|
|
+ titleLabel.snp.makeConstraints { (make) in
|
|
|
+ make.left.equalTo(iconImagView.snp_right).offset(10)
|
|
|
+ make.top.equalTo(14)
|
|
|
+ make.right.equalTo(-26)
|
|
|
+ make.height.equalTo(20)
|
|
|
+ }
|
|
|
+ deliveryTime.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(titleLabel.snp.bottom).offset(8)
|
|
|
+ make.right.left.equalTo(titleLabel)
|
|
|
+ make.height.equalTo(17)
|
|
|
+ }
|
|
|
+ sellScaleLabel.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(deliveryTime.snp.bottom).offset(8)
|
|
|
+ make.left.right.equalTo(deliveryTime)
|
|
|
+ make.height.equalTo(17)
|
|
|
+ }
|
|
|
+ sellNumberLabel.snp.makeConstraints { (make) in
|
|
|
+ make.top.equalTo(sellScaleLabel.snp.bottom).offset(4)
|
|
|
+ make.left.right.equalTo(sellScaleLabel)
|
|
|
+ make.height.equalTo(17)
|
|
|
+ }
|
|
|
+ sellPriceLabel.snp.remakeConstraints { (make) in
|
|
|
+ make.top.equalTo(sellNumberLabel.snp.bottom).offset(8)
|
|
|
+ make.left.equalTo(sellNumberLabel.snp_left).offset(-4)
|
|
|
+ make.height.equalTo(23)
|
|
|
+ }
|
|
|
+
|
|
|
+ plusButton.snp.makeConstraints { (make) in
|
|
|
+ make.centerY.equalTo(sellPriceLabel)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ make.size.equalTo(20)
|
|
|
+ }
|
|
|
+
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private lazy var selectedButton: UIButton = {
|
|
|
+ let selectedButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ selectedButton.setImage(kImage(name: "my_address_uncheck"), for: UIControl.State.normal)
|
|
|
+ selectedButton.setImage(kImage(name: "my_address_check"), for: UIControl.State.selected)
|
|
|
+ return selectedButton
|
|
|
+ }()
|
|
|
+
|
|
|
+ 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 = "妈妈冬装外套棉袄短款"
|
|
|
+ titleLabel.textColor = k333333Color
|
|
|
+ titleLabel.font = kScaleBoldFont14
|
|
|
+ titleLabel.textAlignment = .left
|
|
|
+ titleLabel.numberOfLines = 1
|
|
|
+ return titleLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var deliveryTime: UILabel = {
|
|
|
+ let deliveryTime = UILabel()
|
|
|
+ deliveryTime.text = "预计配送时间:次日达"
|
|
|
+ deliveryTime.textColor = k666666Color
|
|
|
+ deliveryTime.font = kScaleRegularFont12
|
|
|
+ deliveryTime.textAlignment = .left
|
|
|
+ return deliveryTime
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var sellScaleLabel: UILabel = {
|
|
|
+ let sellScaleLabel = UILabel()
|
|
|
+ sellScaleLabel.text = "规格:3个装"
|
|
|
+ sellScaleLabel.textColor = k999999Color
|
|
|
+ sellScaleLabel.font = kScaleRegularFont12
|
|
|
+ return sellScaleLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var sellNumberLabel: UILabel = {
|
|
|
+ let sellNumberLabel = UILabel()
|
|
|
+ sellNumberLabel.text = "x1"
|
|
|
+ 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 = kScaleBoldFont15
|
|
|
+ sellPriceLabel.textAlignment = .left
|
|
|
+ return sellPriceLabel
|
|
|
+ }()
|
|
|
+
|
|
|
+ private lazy var plusButton: UIButton = {
|
|
|
+ let plusButton = UIButton(type: UIButton.ButtonType.custom)
|
|
|
+ plusButton.setImage(kImage(name: "shopping_mall_plus"), 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
|
|
|
+ }()
|
|
|
+
|
|
|
+}
|