宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-05-29 a26039cd1a9437d2232ccaea7f5a66f59a46ee69
OKProject/Class/Home/Controller/ReasonforTravelVC.swift
@@ -35,6 +35,7 @@
    @IBOutlet weak var tf_passengerPhone: UITextField!
    @IBOutlet weak var view_addPassenger: UIView!
    var passengers = [PassengerInfo]()
    var reasonModels = [ReasonModel]()
    var selectIndex = 0
@@ -56,6 +57,21 @@
        passengers.append(PassengerInfo(name: "杨锴", phone: "18111223301"))
        tableViewHeiCons.constant = 40 * Double(passengers.count)
        APIManager.shared.provider.rx.request(.getBusinessReason).mapThenValidate([ReasonModel].self).subscribe { result in
            switch result{
            case .success(let m):
                self.reasonModels = m ?? []
                let h = ceil(Double(self.reasonModels.count) / 4.0) * 30.0 + floor(Double(self.reasonModels.count) / 4.0) * 10.0
                self.collectViewHeiCons.constant = h
                self.collectionView.reloadData()
            case .failure(let error):
                alert(text: error.localizedDescription)
            }
        } onError: { error in
            alert(text: error.localizedDescription)
        }.disposed(by: disposeBag)
    }
    override func bindRx() {
@@ -139,7 +155,8 @@
extension ReasonforTravelVC:UICollectionViewDataSource{
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "_Common_SingleText_CCell", for: indexPath) as! Common_SingleText_CCell
        cell.titleL.text = "测试"
        let model = reasonModels[indexPath.row]
        cell.titleL.text = model.name
        cell.titleL.borderWidth = 1
        cell.titleL.cornerRadius = 2
        cell.titleL.backgroundColor = .white
@@ -155,7 +172,7 @@
    }
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 8
        return reasonModels.count
    }
}