// // NewlyAddedMercViewController.swift // xingchuangke // // Created by 李晓飞 on 2020/8/29. // Copyright © 2020 Virgil. All rights reserved. // import UIKit class NewlyAddedMercViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var timeLabel: UILabel! @IBOutlet weak var tableView: UITableView! var timeStr: String = "" var dictData: NSDictionary = [:] var dataList: NSArray = [] override func viewDidLoad() { super.viewDidLoad() self.title = "新增商户" initNavLeftBackButton() self.view.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xF1F1F1, alpha: 1.0) analysisData() tableView.frame = CGRect.init(x: 0, y: timeLabel.bottom() + 5, width: self.view.bounds.width, height: self.view.bounds.height - 5 - timeLabel.bottom()) tableView.delegate = self tableView.dataSource = self tableView.tableFooterView = UIView.init() tableView.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xF1F1F1, alpha: 1.0) } func analysisData() { // let dic: NSDictionary = dictData["lstr"] as! NSDictionary // let arr: NSArray = dic["XMachineTypeList"] as! NSArray let arr: NSArray = dictData["XMachineTypeListBy"] as! NSArray dataList = arr timeLabel.text = timeStr } // MARK: UITableViewDelegate/UITableViewDataSource 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: "newlyAddedMercCell") if cell == nil { cell = UITableViewCell.init(style: .value1, reuseIdentifier: "newlyAddedMercCell") cell?.selectionStyle = .none cell?.textLabel?.font = UIFont.systemFont(ofSize: 15) cell?.detailTextLabel?.font = UIFont.systemFont(ofSize: 14) } let dic: NSDictionary = dataList[indexPath.row] as? NSDictionary ?? NSDictionary() cell?.textLabel?.text = dic["name"] as? String cell?.detailTextLabel?.text = "\(dic["total"] ?? "0")个" return cell! } /* // 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. } */ }