123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- //
- // OrderApplyRefundProductCell.swift
- // RainbowPlanet
- //
- // Created by Christopher on 2019/5/17.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- // 申请退款--商品详情Cell
- import UIKit
- import RxSwift
- import RxCocoa
- import Kingfisher
- class OrderApplyRefundProductCell: UITableViewCell {
-
- let disposeBag = DisposeBag()
-
- // 选中商品
- typealias ProductSelBlock = (_ isProductSelected: Int) -> Void
- var productSelBlock : ProductSelBlock?
-
- class func cellWith(tableView:UITableView,indexPath:IndexPath) -> OrderApplyRefundProductCell {
- let ID = "OrderApplyRefundProductCell"
- tableView.register(OrderApplyRefundProductCell.self, forCellReuseIdentifier: ID)
- let cell : OrderApplyRefundProductCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! OrderApplyRefundProductCell
- 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
- addSubview(productImageView)
- addSubview(selectBtn)
- addSubview(priceLabel)
- addSubview(titleLabel)
- addSubview(timeLabel)
- addSubview(skuLabel)
- addSubview(numberLabel)
- addSubview(lineLabel)
- }
-
- private func setupLayouts() {
- productImageView.snp.makeConstraints { (make) in
- make.left.equalToSuperview().offset(34)
- make.top.equalToSuperview().offset(14)
- make.bottom.equalToSuperview().offset(-14)
- make.size.equalTo(80)
- }
- selectBtn.snp.makeConstraints { (make) in
- make.left.equalToSuperview().offset(14)
- make.size.equalTo(18)
- make.centerY.equalTo(productImageView)
- }
- priceLabel.snp.remakeConstraints { (make) in
- make.top.equalToSuperview().offset(21)
- make.right.equalTo(-14)
- make.width.lessThanOrEqualTo(60)
- make.height.equalTo(20)
- }
- titleLabel.snp.remakeConstraints { (make) in
- make.left.equalTo(productImageView.snp.right).offset(12)
- make.top.equalTo(20)
- make.right.equalTo(priceLabel.snp.left).offset(-11)
- make.height.equalTo(20)
- }
- timeLabel.snp.makeConstraints { (make) in
- make.top.equalTo(titleLabel.snp.bottom).offset(8)
- make.left.equalTo(titleLabel)
- make.height.equalTo(17)
- }
- skuLabel.snp.makeConstraints { (make) in
- make.top.equalTo(timeLabel.snp.bottom).offset(8)
- make.left.equalTo(titleLabel)
- make.height.equalTo(17)
- }
- numberLabel.snp.makeConstraints { (make) in
- make.centerY.equalTo(timeLabel)
- make.right.equalTo(-14)
- }
- lineLabel.snp.makeConstraints { (make) in
- make.bottom.equalToSuperview()
- make.height.equalTo(1)
- make.left.equalTo(14)
- make.right.equalTo(-14)
- }
- }
-
- private lazy var selectBtn: UIButton = {
- let selectBtn = UIButton(type: UIButton.ButtonType.custom)
- selectBtn.setImage(kImage(name: "common_uncheck_icon"), for: UIControl.State.normal)
- selectBtn.setImage(kImage(name: "common_check_icon"), for: UIControl.State.selected)
- selectBtn.rx.tap.subscribe(onNext: { [weak self] (data) in
- self?.selectBtn.isSelected = !(self?.selectBtn.isSelected)!
- if let productSelBlock = self?.productSelBlock {
- let isSel: Int = self?.selectBtn.isSelected == true ? 1 : 0
- productSelBlock(isSel)
- }
- }).disposed(by: disposeBag)
- return selectBtn
- }()
-
- private lazy var productImageView: UIImageView = {
- let productImageView = UIImageView()
- productImageView.image = kImage(name: "default_pic")
- productImageView.contentMode = .scaleAspectFill
- productImageView.masksToBounds = true
- return productImageView
- }()
-
- private lazy var titleLabel: UILabel = {
- let titleLabel = UILabel()
- titleLabel.textColor = k333333Color
- titleLabel.font = kBoldFont14
- return titleLabel
- }()
-
- private lazy var timeLabel: UILabel = {
- let timeLabel = UILabel()
- timeLabel.textColor = k666666Color
- timeLabel.font = kRegularFont12
- return timeLabel
- }()
-
- private lazy var skuLabel: UILabel = {
- let skuLabel = UILabel()
- skuLabel.textColor = k999999Color
- skuLabel.font = kRegularFont12
- return skuLabel
- }()
-
- private lazy var priceLabel: UILabel = {
- let priceLabel = UILabel()
- priceLabel.textColor = k333333Color
- priceLabel.font = kRegularFont14
- priceLabel.textAlignment = .right
- return priceLabel
- }()
-
- private lazy var numberLabel: UILabel = {
- let numberLabel = UILabel()
- numberLabel.textColor = k999999Color
- numberLabel.font = kRegularFont13
- return numberLabel
- }()
-
- private lazy var lineLabel: UILabel = {
- let lineLabel = UILabel()
- lineLabel.backgroundColor = kf5f5f5Color
- return lineLabel
- }()
-
- var orderModelDetailModel: OrderModelDetailModel? {
- didSet {
- // 选中状态
- let selStatus = orderModelDetailModel?.isSelect == 1 ? true : false
- selectBtn.isSelected = selStatus
-
- productImageView.kf.setImage(with: kURLImage(name: orderModelDetailModel?.productImg ?? "default_pic"), placeholder: kImage(name: "default_pic"))
- KingfisherManager.shared.cache.clearMemoryCache()
- titleLabel.text = orderModelDetailModel?.productName
- timeLabel.text = "预计配送时间:\(orderModelDetailModel?.receiveTime ?? "")"
- skuLabel.text = "规格:\(orderModelDetailModel?.skuName ?? "")"
- priceLabel.text = "\(priceConversion(price: orderModelDetailModel?.productPrice ?? 0))"
- numberLabel.text = "x\(orderModelDetailModel?.amount ?? 0)"
- }
- }
- }
|