| | |
| | | @IBOutlet weak var tf_passengerPhone: UITextField! |
| | | @IBOutlet weak var view_addPassenger: UIView! |
| | | var passengers = [PassengerInfo]() |
| | | var reasonModels = [ReasonModel]() |
| | | |
| | | var selectIndex = 0 |
| | | |
| | |
| | | |
| | | 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() { |
| | |
| | | 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 |
| | |
| | | } |
| | | |
| | | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { |
| | | return 8 |
| | | return reasonModels.count |
| | | } |
| | | } |
| | | |