宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
//  HireCarTCell.swift
//  OKProject
//
//  Created by 无故事王国 on 2022/5/6.
//  Copyright © 2022 yangwang. All rights reserved.
//
 
import UIKit
 
class HireCarTCell: UITableViewCell {
 
    @IBOutlet weak var profileImg: UIImageView!
    @IBOutlet weak var saleStateL: UILabel!
    @IBOutlet weak var topTypeL: UILabel!
    @IBOutlet weak var titleL: UILabel!
    @IBOutlet weak var priceL: UILabel!
    @IBOutlet weak var infoL: UILabel!
    @IBOutlet weak var topTypeView: UIView!
    @IBOutlet weak var delBtn: UIButton!
 
    private var delClouse:(()->Void)?
 
    override func awakeFromNib() {
        super.awakeFromNib()
 
        selectionStyle = .none
    }
 
    override func layoutSubviews() {
        super.layoutSubviews()
        topTypeView.addRoundedCorners(corners: [.bottomRight], rect: CGRect(x: 0, y: 0, width: 55, height: 20), radius: CGSize(width: 8, height: 8))
    }
 
    @IBAction func delAction(_ sender: UIButton) {
        alert(popup: .double, title: "提示", text: "删除后数据不会恢复?", submitTitle: "确认", cancelTitle: "取消") { [weak self] () in
            guard let weakSelf = self else { return }
            weakSelf.delClouse?()
        } cancelClick: {
 
        }
    }
 
    func clouseDel(_ clouse:@escaping ()->Void){
        self.delClouse = clouse
    }
 
    func setCarSellModel(_ m:CarSellModel){
        profileImg.load(url:m.imgUrl.components(separatedBy: ",").first ?? "")
        saleStateL.text = m.status.rawStr
        titleL.text = m.title
 
        var temp = [String]()
        temp.append(String(format: "%.2lf万公里", m.mileage))
        temp.append(m.licensingTime)
        temp.append(m.cityName)
 
        infoL.text = temp.filter({!$0.isEmpty}).joined(separator:"/")
        priceL.text = String(format: "%.2lf万", Double(m.transferPrice) / 10000.0)
 
        if m.userType == .user{
            topTypeL.text = "个人车辆"
//            topTypeL.backgroundColor = UIColor(hexString: "#00BF30")?.withAlphaComponent(0.79)
        }else{
            topTypeL.text = "企业车辆"
//            topTypeL.backgroundColor = UIColor(hexString: "#FF8A3D")?.withAlphaComponent(0.79)
        }
 
        switch m.status {
            case .takeDown,.waitOnShelf:
                delBtn.isHidden = false
                saleStateL.textColor = .white
            case .reject:
                saleStateL.textColor = UIColor(hexString: "#FF4747")
                delBtn.isHidden = false
            default:
                delBtn.isHidden = true
                saleStateL.textColor = .white
        }
    }
}