// // SelectBankViewController.swift // xingchuangke // // Created by Virgil on 2019/3/30. // Copyright © 2019 Virgil. All rights reserved. // import UIKit class CommonSelectViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate { var delegate: CommonDelegate! @IBOutlet weak var tableView: UITableView! @IBOutlet weak var textF: UITextField! @IBOutlet weak var viewMenu: UIView! /// 0:行业类别编码 1:MCC列表 2:选择结算银行 var type = 0 var height = 0 let arrTitle = ["选择行业类别", "选择经营范围", "选择结算银行"] override func viewDidLoad() { super.viewDidLoad() self.title = arrTitle[type] initNavLeftBackButton() if CommonUntils.isIphonex() { height = 88 } else { height = 64 } viewMenu.marginTop(top: 0) tableView.marginTop(top: 1, view: viewMenu) tableView.setSizeHeight(height: ScreenHeight - viewMenu.height() - CGFloat(height)) tableView.register(UINib(nibName: "SelectBankTableViewCell", bundle: nil), forCellReuseIdentifier: "SelectBankTableViewCell") tableView.delegate = self tableView.dataSource = self tableView.separatorStyle = .none tableView.showsVerticalScrollIndicator = false tableView.estimatedRowHeight = 100 tableView.keyboardDismissMode = .onDrag textF.delegate = self textF.returnKeyType = .search loadData() } func textFieldShouldReturn(_ textField: UITextField) -> Bool { self.currentPage = 1 loadData() return true } @IBAction func btnQuery(_ sender: Any) { self.currentPage = 1 loadData() } // MARK: =============加载数据=============== func loadData() //str:String { var url = RequestURL.customMccTypeList let params = NSMutableDictionary() if type == 1 { url = RequestURL.mccNameList params.setValue(textF.text, forKey: "mcc_name") } else if type == 2 { url = RequestURL.qybFindBankList } loadDataList(url: url, params: params, tableView: tableView, tag: 1001) } override func returnData(tag: Int) { if tag == 1001 { tableView.reloadData() } } override func returnError(tag: Int, type: String) { } // MARK: TABLEVLEW 实现 func numberOfSections(in tableView: UITableView) -> Int { return 1 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.arrData.count } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 53 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "SelectBankTableViewCell", for: indexPath as IndexPath) as! SelectBankTableViewCell if type == 0 { cell.lblTitle.text = getString(current: indexPath.row, key: "name") } else if type == 1 { cell.lblTitle.text = getString(current: indexPath.row, key: "mcc_name") } else if type == 2 { cell.lblTitle.text = getString(current: indexPath.row, key: "issuser_name") } return cell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { delegate.rebackFunction(dic: NSMutableDictionary(dictionary: self.arrData[indexPath.row] as! NSDictionary)) handleBack() } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "CommonSelectViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }