//
|
// MinePublishSaleDetailMoreVC.swift
|
// OKProject
|
//
|
// Created by 无故事王国 on 2022/5/9.
|
// Copyright © 2022 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
|
class MinePublishSaleDetailMoreVC: YYViewController {
|
|
private let cellW:Double = (ScreenWidth - 30.0)/2.0
|
private let cellH:Double = 36
|
|
@IBOutlet weak var scrollView: UIScrollView!
|
@IBOutlet weak var stackView: UIStackView!
|
@IBOutlet weak var deployItemCollectionView: UICollectionView!
|
@IBOutlet weak var deployItemCollectionHeiCons: NSLayoutConstraint!
|
|
@IBOutlet weak var brandNameL: UILabel!
|
@IBOutlet weak var mileageL: UILabel!
|
@IBOutlet weak var displacementL: UILabel!
|
@IBOutlet weak var transmissionCaseL: UILabel!
|
@IBOutlet weak var locationOfLicensePlateL: UILabel!
|
@IBOutlet weak var transferTimesL: UILabel!
|
@IBOutlet weak var levelL: UILabel!
|
@IBOutlet weak var remainingOperationTimeView: UIView!
|
@IBOutlet weak var remainingOperationTimeL: UILabel!
|
@IBOutlet weak var operationUpdateTimeView: UIView!
|
@IBOutlet weak var operationUpdateTimeL: UILabel!
|
@IBOutlet weak var licensingTimeL: UILabel!
|
@IBOutlet weak var dueTimeOfCompulsoryInsuranceL: UILabel!
|
@IBOutlet weak var expirationTimeOfAnnualInspectionL: UILabel!
|
@IBOutlet weak var maturityTimeOfCommercialInsuranceL: UILabel!
|
@IBOutlet weak var havePledgeBtn: UIButton! //有抵押
|
@IBOutlet weak var notHavePledgeBtn: UIButton! //无抵押
|
|
var carSellModel:CarSellModel?
|
var sellCarReqModel:SellCarReqModel?
|
var config = ConfigModel.localConfig()
|
var containConfig = [String]()
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
navigationItem.title = "车辆档案信息"
|
|
|
if let m = carSellModel{
|
|
|
brandNameL.text = m.brandName
|
mileageL.text = String(format: "%.2lf万", m.mileage)
|
displacementL.text = m.displacement
|
transmissionCaseL.text = m.transmissionCase
|
locationOfLicensePlateL.text = m.locationOfLicensePlate
|
transferTimesL.text = String(format: "%@次", m.transferTimes)
|
levelL.text = m.level
|
remainingOperationTimeL.text = m.remainingOperationTime
|
operationUpdateTimeL.text = m.operationUpdateTime
|
licensingTimeL.text = m.licensingTime
|
dueTimeOfCompulsoryInsuranceL.text = m.dueTimeOfCompulsoryInsurance
|
expirationTimeOfAnnualInspectionL.text = m.expirationTimeOfAnnualInspection
|
maturityTimeOfCommercialInsuranceL.text = m.maturityTimeOfCommercialInsurance
|
containConfig = m.installationConfiguration.components(separatedBy: ",").filter({!$0.isEmpty})
|
|
if m.mortgage == 1{
|
havePledgeBtn.backgroundColor = UIColor(hexString: "#00BF30")
|
notHavePledgeBtn.backgroundColor = .white
|
havePledgeBtn.isSelected = true
|
notHavePledgeBtn.isSelected = false
|
}else{
|
notHavePledgeBtn.backgroundColor = UIColor(hexString: "#00BF30")
|
havePledgeBtn.backgroundColor = .white
|
havePledgeBtn.isSelected = false
|
notHavePledgeBtn.isSelected = true
|
}
|
//73507 【买车】列表-进入详情:数据显示不对
|
remainingOperationTimeView.isHidden = m.userType == .user ? true:false
|
operationUpdateTimeView.isHidden = m.userType == .user ? true:false
|
deployItemCollectionView.reloadData()
|
calHei()
|
}
|
|
if let m1 = sellCarReqModel{
|
brandNameL.text = m1.brandName
|
mileageL.text = String(format: "%.2lf", m1.mileage ?? 0)
|
displacementL.text = m1.displacement
|
transmissionCaseL.text = m1.transmissionCase
|
locationOfLicensePlateL.text = m1.locationOfLicensePlate
|
transferTimesL.text = String(format: "%ld", m1.transferTimes ?? 0)
|
levelL.text = m1.level
|
remainingOperationTimeL.text = m1.remainingOperationTime
|
operationUpdateTimeL.text = m1.operationUpdateTime
|
licensingTimeL.text = m1.licensingTime
|
dueTimeOfCompulsoryInsuranceL.text = m1.dueTimeOfCompulsoryInsurance
|
expirationTimeOfAnnualInspectionL.text = m1.expirationTimeOfAnnualInspection
|
maturityTimeOfCommercialInsuranceL.text = m1.maturityTimeOfCommercialInsurance
|
|
if m1.mortgage == 1{
|
havePledgeBtn.backgroundColor = UIColor(hexString: "#00BF30")
|
notHavePledgeBtn.backgroundColor = .white
|
havePledgeBtn.isSelected = true
|
notHavePledgeBtn.isSelected = false
|
}else{
|
notHavePledgeBtn.backgroundColor = UIColor(hexString: "#00BF30")
|
havePledgeBtn.backgroundColor = .white
|
havePledgeBtn.isSelected = false
|
notHavePledgeBtn.isSelected = true
|
}
|
|
deployItemCollectionView.reloadData()
|
calHei()
|
}
|
}
|
|
override func setupViews() {
|
super.setupViews()
|
view.backgroundColor = UIColor(hexString: "#F3F4F5")
|
scrollView.contentInset = UIEdgeInsets(top: 21, left: 0, bottom: 10, right: 0)
|
stackView.backgroundColor = .white
|
stackView.cornerRadius = 4
|
stackView.maskToBounds = true
|
|
deployItemCollectionView.delegate = self
|
deployItemCollectionView.dataSource = self
|
deployItemCollectionView.register(UINib(nibName: "CheckItemTCell", bundle: nil), forCellWithReuseIdentifier: "_CheckItemTCell")
|
deployItemCollectionView.isScrollEnabled = false
|
calHei()
|
|
notHavePledgeBtn.borderWidth = 1
|
havePledgeBtn.borderWidth = 1
|
notHavePledgeBtn.borderColor = UIColor(hexString: "#00BF30")!
|
havePledgeBtn.borderColor = UIColor(hexString: "#00BF30")!
|
}
|
|
private func calHei(){
|
if let m = carSellModel{
|
let h = ceil(Double(config.count) / 2.0) * cellH
|
deployItemCollectionHeiCons.constant = h
|
}
|
|
if let m1 = sellCarReqModel{
|
let items = m1.installationConfiguration!.components(separatedBy: ",")
|
let h = ceil(Double(items.count) / 2.0) * cellH
|
deployItemCollectionHeiCons.constant = h
|
}
|
}
|
}
|
|
extension MinePublishSaleDetailMoreVC:UICollectionViewDelegate{
|
|
}
|
|
extension MinePublishSaleDetailMoreVC:UICollectionViewDataSource{
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
if let _ = carSellModel{
|
return config.count
|
}
|
|
if let m1 = sellCarReqModel{
|
return m1.installationConfiguration!.components(separatedBy: ",").filter({$0.isEmpty == false}).count
|
}
|
return 0
|
}
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
|
var items = [String]()
|
if let _ = carSellModel{
|
items = config.map({$0.name})
|
}
|
|
if let m1 = sellCarReqModel{
|
items = m1.installationConfiguration!.components(separatedBy: ",").filter({$0.isEmpty == false})
|
}
|
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_CheckItemTCell", for: indexPath) as! CheckItemTCell
|
cell.checkBtn.isSelected = true
|
cell.itemL.text = items[indexPath.row]
|
|
if containConfig.count != 0{
|
if !containConfig.contains(items[indexPath.row]){
|
cell.checkBtn.isSelected = false
|
}
|
}
|
|
return cell
|
}
|
}
|
|
extension MinePublishSaleDetailMoreVC:UICollectionViewDelegateFlowLayout{
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
|
return 0.01
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
return 0.01
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
return CGSize(width: cellW, height: cellH)
|
}
|
}
|