//
|
// 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
|
}
|
}
|
}
|