// // TiXianRecordListViewController.swift // xingchuangke // // Created by Virgil on 2019/4/21. // Copyright © 2019 Virgil. All rights reserved. // import UIKit class TiXianRecordListViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var viewMenu: UIView! @IBOutlet weak var tableView: UITableView! var machineTypeId: String = "" ///返回类型 0:返回上一个页面 1:返回我的钱包页 var backType = 0 var status = 999 override func viewDidLoad() { super.viewDidLoad() self.title = "提现记录" initNavLeftBackButton() let segment = Virgil_SegmentView(frame: CGRect(x: 0, y: 3, width: ScreenWidth, height: 45), titles: ["全部", "待审核", "待打款", "已打款", "未通过"], defaultColor: CommonUntils.getUIColorFromRGB(rgbValue: 0x333333, alpha: 1.0), currentColor: CommonUntils.getUIColorFromRGB(rgbValue: 0x2094f5, alpha: 1.0), lineHeight: 2, lineIsBottom: true) { [weak self](index) in if index == 0 { self!.status = 999 } else if index == 1 { self!.status = 0 } else if index == 2 { self!.status = 1 } else if index == 3 { self!.status = 2 } else if index == 4 { self!.status = 3 } else { self!.status = 999 } self!.currentPage = 1 self!.tableView.mj_header?.beginRefreshing() } self.viewMenu.addSubview(segment) tableView.register(UINib(nibName: "TiXianRecordListTableViewCell", bundle: nil), forCellReuseIdentifier: "TiXianRecordListTableViewCell") 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() }) tableView.mj_header?.beginRefreshing() } // MARK: =============加载数据=============== func loadData() { let url = RequestURL.cashApplicationList let params = NSMutableDictionary() params.setValue(status, forKey: "status") params.setValue(machineTypeId, forKey: "machineTypeId") loadDataList(url: url, params: params, tableView: self.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 71 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "TiXianRecordListTableViewCell", for: indexPath as IndexPath) as! TiXianRecordListTableViewCell if indexPath.row >= self.arrData.count { return cell } let type = getIntValue(current: indexPath.row, key: "type") if type == 0 { cell.lblTitle.text = "提现" } else { cell.lblTitle.text = "提现(发票)" } cell.lblMoney.text = "-\(getDoubleValue(current: indexPath.row, key: "amount_money", defaultValue: 0.00))" cell.lblDate.text = getString(current: indexPath.row, key: "createtime") let status = getIntValue(current: indexPath.row, key: "status") ///0:待审核 1待打款 2已打款 3拒绝 if status == 0 { cell.dzMoneyLable.isHidden = true cell.lblState.text = "待审核" cell.lblState.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x999999, alpha: 1.0) } else if status == 1 { cell.dzMoneyLable.isHidden = true cell.lblState.text = "待打款" cell.lblState.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xfc9005, alpha: 1.0) } else if status == 2 { cell.dzMoneyLable.isHidden = false cell.dzMoneyLable.text = "(到账¥\(getDoubleValue(current: indexPath.row, key: "realy_amount", defaultValue: 0.00)))" cell.lblState.text = "已打款" cell.lblState.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0x16b006, alpha: 1.0) } else if status == 3 { cell.dzMoneyLable.isHidden = true cell.lblState.text = "未通过" cell.lblState.textColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xff0000, alpha: 1.0) } //cell.lblTitle.text = getString(indexPath.row, key: "Name") return cell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { if indexPath.row >= arrData.count { return } let vc = TiXianDetailViewController() vc.id = getString(current: indexPath.row, key: "id") vc.dicData.setDic(dic: arrData[indexPath.row] as! NSDictionary) toViewController(viewController: vc) } override func handleBack() { if backType == 0 { super.handleBack() } else { if !CommonUntils.reBackView(controller: self, aclass: MyWalletViewController.classForCoder()) { self.navigationController?.popToRootViewController(animated: true) } } } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) appDelegate.setNavigationBarHidden(isHidden: false) } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "TiXianRecordListViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }