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