//
|
// JobDetailHeaderVC.swift
|
// OKProject
|
//
|
// Created by 无故事王国 on 2022/5/17.
|
// Copyright © 2022 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
|
class JobDetailHeaderVC: YYViewController {
|
|
private var jobListModel:JobListModel?
|
@IBOutlet weak var titleL: UILabel!
|
@IBOutlet weak var priceL: UILabel!
|
@IBOutlet weak var infoL: UILabel!
|
@IBOutlet weak var publishTimeL: UILabel!
|
@IBOutlet weak var itemCollectionView: UICollectionView!
|
@IBOutlet weak var collectionHeiCons: NSLayoutConstraint!
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
|
itemCollectionView.delegate = self
|
itemCollectionView.dataSource = self
|
itemCollectionView.register(UINib(nibName: "Common_SingleText_CCell", bundle: nil), forCellWithReuseIdentifier: "_Common_SingleText_CCell")
|
}
|
|
|
func setJobListModel(_ model:JobListModel?){
|
if let m = model{
|
jobListModel = m
|
titleL.text = m.title
|
|
if m.startSalary == 0 && m.endSalary == 0{
|
priceL.text = "薪资面议"
|
}else{
|
priceL.text = String(format: "%.2lf-%.2lf元/月", m.startSalary,m.endSalary)
|
}
|
|
let createTime = DateClass.timeStringToDate(m.createTime)
|
let diffday = DateClass.dateDifference(Date(), from: createTime)
|
|
if diffday > 1.0{
|
publishTimeL.text = String(format: "%@发布", DateClass.dateToDateString(createTime, dateFormat: "yyyy-MM-dd"))
|
}else{
|
let time = DateClass.timeStringToDate(m.createTime).timeIntervalSince1970 * 1000
|
publishTimeL.text = String(format: "%@发布", DateClass.compareCurrentTime(str: "\(time)"))
|
}
|
|
var array = Array<String>()
|
array.append(String(format: "招%ld人", m.recruitsNumber))
|
|
if m.experienceRequirements.isEmpty{
|
array.append("经验不限")
|
}else{
|
array.append(m.experienceRequirements)
|
}
|
|
if m.educationalRequirements.isEmpty{
|
array.append("学历不限")
|
}else{
|
array.append(m.educationalRequirements)
|
}
|
infoL.text = array.joined(separator: " | ")
|
itemCollectionView.reloadData()
|
}
|
}
|
|
override func viewDidLayoutSubviews() {
|
super.viewDidLayoutSubviews()
|
collectionHeiCons.constant = itemCollectionView.contentSize.height + 10
|
}
|
}
|
|
extension JobDetailHeaderVC:UICollectionViewDelegate{
|
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
|
}
|
}
|
|
extension JobDetailHeaderVC:UICollectionViewDataSource{
|
|
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
return jobListModel?.welfare.components(separatedBy: ",").filter({!$0.isEmpty}).count ?? 0
|
}
|
|
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
let text = jobListModel!.welfare.components(separatedBy: ",").filter({!$0.isEmpty})[indexPath.row]
|
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_Common_SingleText_CCell", for: indexPath) as! Common_SingleText_CCell
|
cell.titleL.text = text
|
cell.titleL.font = UIFont.systemFont(ofSize: 12)
|
cell.titleL.cornerRadius = 2
|
cell.titleL.borderWidth = 0.6
|
cell.titleL.maskToBounds = true
|
cell.titleL.borderColor = UIColor.color(hexString: "#00BF30")
|
cell.titleL.backgroundColor = .white
|
cell.titleL.textColor = UIColor.color(hexString: "#00BF30")
|
return cell
|
}
|
}
|
|
extension JobDetailHeaderVC:UICollectionViewDelegateFlowLayout{
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
|
return 5
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
|
return 5
|
}
|
|
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
|
let title = jobListModel!.welfare.components(separatedBy: ",").filter({!$0.isEmpty})[indexPath.row]
|
let calCellW = title.width(UIFont.systemFont(ofSize: 15), height: 15)
|
return CGSize(width: calCellW+6, height: 18)
|
}
|
}
|