宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-04-06 a1ae6802080a22e6e6ce6d0935e95facb1daca5c
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
//
//  SaleCarTCell.swift
//  OKProject
//
//  Created by 无故事王国 on 2022/5/6.
//  Copyright © 2022 yangwang. All rights reserved.
//
 
import UIKit
 
class SaleCarTCell: UITableViewCell {
 
    @IBOutlet weak var profileImg: UIImageView!
    @IBOutlet weak var saleStateL: UILabel!
    @IBOutlet weak var topTypeView: UIView!
    @IBOutlet weak var topTypeL: UILabel!
    @IBOutlet weak var titleL: UILabel!
    @IBOutlet weak var priceL: UILabel!
    @IBOutlet weak var positionL: UILabel!
    @IBOutlet weak var callBtn: UIButton!
    @IBOutlet weak var delBtn: UIButton!
 
    private var rentalModel:RentalModel?
    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 callAction(_ sender: UIButton) {
        if let m = rentalModel{
            UIApplication.shared.open(URL(string: "telprompt://\(m.contactsPhone)")!, options: [:], completionHandler: nil)
        }
    }
 
    @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 setRentalModel(_ m:RentalModel){
        rentalModel = m
        profileImg.load(url: m.imgUrl.components(separatedBy: ",").first ?? "")
        saleStateL.text = m.status.rawStr
        if m.status == .reject{
            saleStateL.textColor = UIColor(hexString: "#FF4747")
        }else{
            saleStateL.textColor = .white
        }
        if m.userType == .user{
            topTypeL.text = "个人车辆"
        }else{
            topTypeL.text = "企业车辆"
        }
 
        titleL.text = m.title
        priceL.text = String(format: "%.2lf元/天", m.rentMoney)
        positionL.text = String(format: "%@%@%@", m.provinceName,m.cityName,m.addres)
        callBtn.isHidden = m.contactsPhone.isEmpty
        delBtn.isHidden = m.status == .onShelf || m.status == .review
    }
}