// // ApplyCardBillViewController.swift // xingchuangke // // Created by Virgil on 2019/7/16. // Copyright © 2019 Virgil. All rights reserved. // import UIKit class ApplyCardBillViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var lblCount1: UILabel! @IBOutlet weak var lblCount2: UILabel! @IBOutlet weak var lblCount3: UILabel! @IBOutlet weak var lblCount4: UILabel! @IBOutlet weak var tableView: UITableView! ///类型 1:新建订单,2:待激活, 3: 申请成功 4: 关闭 var type = 1 override func viewDidLoad() { super.viewDidLoad() tableView.register(UINib(nibName: "ApplyCardBillTableViewCell", bundle: nil), forCellReuseIdentifier: "ApplyCardBillTableViewCell") tableView.delegate = self tableView.dataSource = self tableView.separatorStyle = .none tableView.showsVerticalScrollIndicator = false tableView.estimatedRowHeight = 100 tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in self!.currentPage = 1 self!.loadData() }) tableView.mj_header?.lastUpdatedTimeKey = "ShowTableViewCell" tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in self!.currentPage += 1 self!.loadData() }) self.loadCount() } //btnAddTarget(view: self.view, selector: #selector(self.btnMenuClick)) @IBAction func btnMenuClick(_ sender: AnyObject) { switch (sender as! UIButton).tag { case 1001: // 待确认 type = 1 lblCount1.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xFF680B, alpha: 1.0) lblCount2.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount3.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount4.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) self.currentPage = 1 loadData() break case 1002: // 待审核 type = 2 lblCount1.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount2.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xFF680B, alpha: 1.0) lblCount3.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount4.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) self.currentPage = 1 loadData() break case 1003: // 申请成功 type = 3 lblCount1.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount2.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount3.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xFF680B, alpha: 1.0) lblCount4.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) self.currentPage = 1 loadData() break case 1004: // 关闭 type = 4 lblCount1.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount2.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount3.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x545454, alpha: 1.0) lblCount4.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xFF680B, alpha: 1.0) self.currentPage = 1 loadData() break case 1005: // break case 1006: // break default: break } } // MARK: =============加载数据=============== func loadData() { let url = RequestURL.creditCardPageList let params = NSMutableDictionary() params.setValue(type, forKey: "type") loadDataList(url: url, params: params, tableView: self.tableView, tag: 1001) } func loadCount() { let url = RequestURL.creditNum let params = NSMutableDictionary() params.setValue(type, forKey: "type") loadDataInfo(url: url, params: params, tag: 1002) } override func returnData(tag: Int) { if tag == 1001 { tableView.reloadData() } else if tag == 1002 { self.loadData() lblCount1.text = "(\(getIntValue(key: "status1")))" lblCount2.text = "(\(getIntValue(key: "status2")))" lblCount3.text = "(\(getIntValue(key: "status3")))" lblCount4.text = "(\(getIntValue(key: "status4")))" } } override func returnError(tag: Int, type: String) { if tag == 1002 { self.loadData() } } // 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 100 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "ApplyCardBillTableViewCell", for: indexPath as IndexPath) as! ApplyCardBillTableViewCell cell.lblCard.text = CommonValue.formatCardNum(str: getString(current: indexPath.row, key: "identity_id")) cell.lblDate.text = getString(current: indexPath.row, key: "createtime") cell.lblPhone.text = CommonValue.formatPhone(phone: getString(current: indexPath.row, key: "phone")) cell.lblCardName.text = getString(current: indexPath.row, key: "bank_name") cell.lblApplyName.text = "申请人:\(getString(current: indexPath.row, key: "name"))" cell.btnQuery.tag = indexPath.row cell.btnQuery.addTarget(self, action: #selector(btnQueryClick), for: .touchUpInside) return cell } @objc func btnQueryClick(btn: UIButton) { UIApplication.shared.openURL(URL(string: "http://card-dev.qdrsd.top/#/progress")!) } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { // let view = UIViewController() // view.oneGoId = self.arrData[indexPath.row]["ItemId"] as! Int // self.navigationController?.pushViewController(view, animated: true) } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) self.tabBarController?.title = self.title } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "ApplyCardBillViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }