// // WalletRecordViewController.swift // xingchuangke // // Created by 李晓飞 on 2020/8/15. // Copyright © 2020 Virgil. All rights reserved. // import UIKit @objcMembers class WalletRecordViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource { var type: NSInteger? var machineTypeId: String = "" let tableView: UITableView = { let tab = UITableView.init(frame: UIScreen.main.bounds, style: .plain) return tab }() let dataList: Array = { return ["收益流水", "提现记录"] }() let headerView: CommonHeaderView = { let headerV = CommonHeaderView.init(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 180)) headerV.isCycle = false headerV.isMoney = true headerV.setupUI() headerV.dataView2.rewardControl.addTarget(self, action: #selector(rewardClick1), for: .touchUpInside) return headerV }() @objc func rewardClick1( ) { let vc = AllocatedListVC() vc.machineTypeId = machineTypeId appDelegate.navController.pushViewController(vc, animated: true) } let footer: UIView = { let w = UIScreen.main.bounds.width let view = UIView.init(frame: CGRect.init(x: 0, y: 0, width: w, height: 160)) view.backgroundColor = UIColor.init(white: 245/255.0, alpha: 1.0) return view }() let withdrawBtn: UIButton = { let w = UIScreen.main.bounds.width let btn = UIButton.init(type: .custom) btn.backgroundColor = UIColor.init(red: 42/255.0, green: 146/255.0, blue: 247/255.0, alpha: 1.0) btn.frame = CGRect.init(x: 0, y: 0, width: w - 60, height: 44) btn.setTitle("提现", for: .normal) btn.layer.cornerRadius = 22 return btn }() override func viewDidLoad() { super.viewDidLoad() initNavLeftBackButton() footer.addSubview(withdrawBtn) withdrawBtn.center = footer.center withdrawBtn.addTarget(self, action: #selector(withdrawBtnBlock), for: .touchUpInside) tableView.delegate = self tableView.dataSource = self tableView.backgroundColor = UIColor.init(white: 245/255.0, alpha: 1.0) tableView.tableHeaderView = headerView tableView.tableFooterView = footer self.view.addSubview(tableView) loadData() } @objc func withdrawBtnBlock() { let vc = TiXianViewController() if dicData["XUserWalletHfHkHkqg"] is NSNull { vc.withdraw = "0" } else { let dic: NSDictionary = dicData["XUserWalletHfHkHkqg"] as! NSDictionary NSLog("\(dic)") var all = 0.0 all = dic["profit_balance"] as! Double vc.withdraw = "\(String(format: "%.2f", all))" } vc.machineTypeId = machineTypeId self.navigationController?.pushViewController(vc, animated: true) } // MARK: - request func loadData() { let url = RequestURL.findwalletListByMachineTypeId let params = NSMutableDictionary() params.setValue(CommonValue.getUserId(), forKey: "userId") params.setValue(machineTypeId, forKey: "machineTypeId") loadDataInfo(url: url, params: params, tag: 1001) } override func returnData(tag: Int) { if dicData["XUserWalletHfHkHkqg"] is NSNull { headerView.dataView2.earnLbl.text = "¥0.0" headerView.dataView2.rewardLbl.text = "¥0.0" headerView.dataView2.dhMoney.text = "¥0.0" return } let dic: NSDictionary = dicData["XUserWalletHfHkHkqg"] as! NSDictionary var all = 0.0 all = dic["profit_balance"] as! Double var all1 = 0.0 all1 = dicData["UnallocatedBalance"] as! Double let all2 = all + all1 headerView.dataView2.earnLbl.text = "¥\(String(format: "%.2f", all2))" headerView.dataView2.rewardLbl.text = "¥\(String(format: "%.2f", all))" headerView.dataView2.dhMoney.text = "¥\(String(format: "%.2f", all1))" } override func returnError(tag: Int, type: String) { } // MARK: - delegate func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 2 } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 60 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cellId = "businessCellId" var cell = tableView.dequeueReusableCell(withIdentifier: cellId) if cell == nil { cell = UITableViewCell.init(style: .default, reuseIdentifier: cellId) let imgV = UIImageView.init(image: UIImage.init(named: "ion_arrow_right_gray")) cell?.accessoryView = imgV cell?.selectionStyle = .none cell?.textLabel?.font = UIFont.systemFont(ofSize: 15) } cell?.textLabel?.text = dataList[indexPath.row] return cell! } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let tit = dataList[indexPath.row] if tit == "提现记录" { let vc = TiXianRecordListViewController() vc.machineTypeId = machineTypeId self.navigationController?.pushViewController(vc, animated: true) } else if tit == "收益流水" { let vc = BillFlowViewController() vc.machineTypeId = machineTypeId self.navigationController?.pushViewController(vc, animated: true) } } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ }