// // TotalTradeViewController.swift // xingchuangke // // Created by 李晓飞 on 2020/8/29. // Copyright © 2020 Virgil. All rights reserved. // import UIKit class TotalTradeViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var timeLabel: UILabel! @IBOutlet weak var totalLabel: UILabel! @IBOutlet weak var tableView: UITableView! var userId: String! var timeStr: String = "" var isTeam: String = "0" var dictData: NSDictionary = [:] var endTime: String = "" var startTime: String = "" var dataList: NSArray = [] override func viewDidLoad() { super.viewDidLoad() self.title = "交易总额" initNavLeftBackButton() analysisData() tableView.delegate = self tableView.dataSource = self tableView.tableFooterView = UIView.init() } func analysisData() { let dic: NSDictionary = dictData let arr: NSArray = dic["XMachineTypeListBy"] as! NSArray dataList = arr totalLabel.text = "\(dictData["transactionTotal"] ?? "0")" timeLabel.text = timeStr } // MARK: - delegate func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return dataList.count } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 60 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell = tableView.dequeueReusableCell(withIdentifier: "totalTradeCell") if cell == nil { cell = UITableViewCell.init(style: .value1, reuseIdentifier: "totalTradeCell") cell?.textLabel?.font = UIFont.systemFont(ofSize: 15) cell?.accessoryType = .disclosureIndicator cell?.detailTextLabel?.textColor = UIColor.black cell?.detailTextLabel?.font = UIFont.systemFont(ofSize: 14) cell?.selectionStyle = .none } let dic: NSDictionary = dataList[indexPath.row] as! NSDictionary cell?.textLabel?.text = dic["name"] as? String cell?.detailTextLabel?.text = "\(dic["total"] ?? "0")元" return cell! } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let vc = TotalDetailViewController() vc.userId = userId vc.isTeam = isTeam vc.timeStr = timeStr vc.startTime = self.startTime vc.endTime = self.endTime let dic: NSDictionary = dataList[indexPath.row] as! NSDictionary vc.type = brandList.firstIndex(of: dic["name"] as! String) ?? 0 vc.machineType = (dic["id"] as! String) vc.name = (dic["name"] as! String) 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. } */ }