// // MachineDetailViewController.swift // xingchuangke // // Created by Virgil on 2019/5/16. // Copyright © 2019 Virgil. All rights reserved. // import UIKit class MachineDetailViewController: BaseViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var tableView: UITableView! var id = "" let arrTitle = ["机具品牌", "SN码", "所属商户", "商户编号", "绑定时间", "商户手机号", "激活状态"] var arrContent = ["", "", "", "", "", "", ""] override func viewDidLoad() { super.viewDidLoad() initNavLeftBackButton() self.title = "终端信息" tableView.register(UINib(nibName: "MachineDetailTableViewCell", bundle: nil), forCellReuseIdentifier: "MachineDetailTableViewCell") tableView.delegate = self tableView.dataSource = self tableView.separatorStyle = .none tableView.showsVerticalScrollIndicator = false tableView.estimatedRowHeight = 100 loadData() } // MARK: =============加载数据=============== func loadData() { let url = RequestURL.machineDetail let params = NSMutableDictionary() params.setValue(id, forKey: "id") loadDataInfo(url: url, params: params, tag: 1001) } override func returnData(tag: Int) { if tag == 1001 { arrContent[0] = getString(key: "machineTypeCN") arrContent[1] = getString(key: "sn_code") arrContent[2] = getString(key: "bind_merchant_name") arrContent[3] = getString(key: "mercNo") arrContent[4] = getString(key: "bind_time") arrContent[5] = CommonValue.formatPhone(phone: getString(key: "busPhone")) let state = getIntValue(key: "status") if state == 0 { arrContent[6] = "未绑定" } else if state == 1 { arrContent[6] = "已绑定" } else if state == 2 { arrContent[6] = "已激活" } 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.arrTitle.count } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 54 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "MachineDetailTableViewCell", for: indexPath as IndexPath) as! MachineDetailTableViewCell cell.lblTitle.text = arrTitle[indexPath.row] cell.lblContent.text = arrContent[indexPath.row] return cell } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "MachineDetailViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }