123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- //
- // OrderShopAndStatusTableViewCell.swift
- // RainbowPlanet
- //
- // Created by 南鑫林 on 2019/5/15.
- // Copyright © 2019 RainbowPlanet. All rights reserved.
- //
- import UIKit
- import RxSwift
- class OrderShopAndStatusTableViewCell: UITableViewCell {
-
- let disposeBag = DisposeBag()
-
- typealias ShopClosure = (_ orderModel: OrderModel) -> Void
- var shopClosure : ShopClosure?
- class func cellWith(tableView:UITableView,indexPath:IndexPath) -> OrderShopAndStatusTableViewCell {
- let ID = "OrderShopAndStatusTableViewCell"
- tableView.register(OrderShopAndStatusTableViewCell.self, forCellReuseIdentifier: ID)
- let cell : OrderShopAndStatusTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! OrderShopAndStatusTableViewCell
- 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(shopButton)
- addSubview(statusLabel)
- addSubview(lineLabel)
- }
-
- private func setupLayouts() {
- shopButton.snp.makeConstraints { (make) in
- make.centerY.equalToSuperview()
- make.left.equalTo(14)
- }
- shopButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.right, imageTitleSpace: 5)
- statusLabel.snp.makeConstraints { (make) in
- make.centerY.equalToSuperview()
- 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 shopButton: UIButton = {
- let shopButton = UIButton(type: UIButton.ButtonType.custom)
- shopButton.setTitleColor(k333333Color, for: UIControl.State.normal)
- shopButton.titleLabel?.font = kRegularFont14
- shopButton.setImage(kImage(name: "my_arrows_unfold"), for: UIControl.State.normal)
- shopButton.rx.tap.subscribe(onNext: {
- [weak self] (data) in
- if self?.orderModel != nil {
- if let shopClosure = self?.shopClosure {
- shopClosure((self?.orderModel)!)
- }
- }
-
- if self?.orderDetailModel != nil {
- if let shopClosure = self?.shopClosure {
- shopClosure((self?.orderDetailModel)!)
- }
- }
-
- }).disposed(by: disposeBag)
- return shopButton
- }()
-
- private lazy var statusLabel: UILabel = {
- let statusLabel = UILabel()
- statusLabel.font = kRegularFont14
- return statusLabel
- }()
-
- private lazy var lineLabel: UILabel = {
- let lineLabel = UILabel()
- lineLabel.backgroundColor = kf5f5f5Color
- return lineLabel
- }()
-
- var orderModel: OrderModel? {
- didSet {
- shopButton.setTitle(orderModel?.shopName ?? "", for: UIControl.State.normal)
- shopButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.right, imageTitleSpace: 5)
-
- if orderModel?.feedbackStatus == 0 { //未维权
- switch orderModel?.status {
- case 0: //待付款
- statusLabel.text = "待付款"
- statusLabel.textColor = kFFA42FColor
- break
- case 1: //待发货
- statusLabel.text = "待发货"
- statusLabel.textColor = kFFA42FColor
- case 2: //已发货/待收货
- statusLabel.text = "待收货"
- statusLabel.textColor = k333333Color
- case 3: //配送中
- statusLabel.text = "配送中"
- statusLabel.textColor = kFFA42FColor
- case 4: //待自提
- statusLabel.text = "待自提"
- statusLabel.textColor = kFFA42FColor
- case 5: //已自提
- statusLabel.text = "已自提"
- statusLabel.textColor = k333333Color
-
- case 6: //已完成
- statusLabel.text = "已完成"
- statusLabel.textColor = k333333Color
- case 7: //已关闭
- statusLabel.text = "已关闭"
- statusLabel.textColor = k333333Color
-
- default:
- break
- }
- }else {
- switch orderModel?.feedbackStatus {
- case 1: //1-退款处理中
- statusLabel.text = "退款中"
- statusLabel.textColor = kFFA42FColor
- case 2: //2-退款完成
- statusLabel.text = "退款完成"
- statusLabel.textColor = k333333Color
- case 3: //3-拒绝退款
- statusLabel.text = "退款失败"
- statusLabel.textColor = k333333Color
- default:
- break
- }
- }
- }
- }
-
- var orderDetailModel: OrderModel? {
- didSet {
- shopButton.setTitle(orderDetailModel?.shopName ?? "", for: UIControl.State.normal)
- shopButton.layoutButton(edgeInsetsStyle: ButtonEdgeInsetsStyle.right, imageTitleSpace: 5)
- }
- }
- }
|