// // MyDelegateDetailViewController.swift // xingchuangke // // Created by Virgil on 2019/4/21. // Copyright © 2019 Virgil. All rights reserved. // import UIKit class MyShopDetailViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var tableView: UITableView! @IBOutlet weak var lblDate: UILabel! @IBOutlet weak var lblName: UILabel! @IBOutlet weak var imgIcon: UIImageView! var id = "" // var isKssSer: Bool = false var isHSF: Bool = false var isXW: Bool = false var arrTitle = [["商户编号", "商户姓名", "商户类型", "身份证号", "联系电话", "商户地址", "所属行业"], ["结算费率", "结算人姓名", "银行卡号", "银行名称", "所属地区", "所属支行", "预留手机号"], ["品牌名称", "产品类型", "设备SN号", "激活状态"]] var arrContent = [["", "", "", "", "", "", ""], ["", "", "", "", "", "", ""], ["", "", "", ""]] override func viewDidLoad() { super.viewDidLoad() self.title = "商户详情" initNavLeftBackButton() tableView.register(UINib(nibName: "TiXianDetailTableViewCell", bundle: nil), forCellReuseIdentifier: "TiXianDetailTableViewCell") tableView.delegate = self tableView.dataSource = self tableView.separatorStyle = .none tableView.showsVerticalScrollIndicator = false tableView.estimatedRowHeight = 100 if isKssSer { arrTitle = [["商户编号", "商户姓名", "身份证号", "联系电话"], ["结算费率"], ["品牌名称", "设备SN号"]] loadDataForKss() } else { if isHSF { arrTitle = [["商户编号", "商户姓名", "身份证号", "联系电话"], ["结算费率"], ["品牌名称", "设备SN号"]] } if isXW { arrTitle = [["商户编号", "商户姓名", "身份证号", "联系电话"], ["结算费率"], ["品牌名称", "设备SN号"]] } loadData() } } // MARK: =============加载数据=============== // 快益刷、快闪刷 func loadDataForKss() { let url = RequestURL.myMerchantDetailKys let params = NSMutableDictionary() params.setValue(id, forKey: "id") loadDataInfo(url: url, params: params, tag: 1002) } func loadData() { if isHSF == true { let url = RequestURL.myMerchantDetailXcx let params = NSMutableDictionary() params.setValue(id, forKey: "id") loadDataInfo(url: url, params: params, tag: 1003) }else if isXW == true { let url = RequestURL.myMerchantDetailXwsy let params = NSMutableDictionary() params.setValue(id, forKey: "id") loadDataInfo(url: url, params: params, tag: 1004) }else{ let url = RequestURL.myMerchantDetail let params = NSMutableDictionary() params.setValue(id, forKey: "id") loadDataInfo(url: url, params: params, tag: 1001) } } override func returnData(tag: Int) { if tag == 1001 { lblName.text = getString(key: "companyName") lblDate.text = "认证时间:\(getString(key: "createtime"))" arrContent[0][0] = getString(key: "mercNo") arrContent[0][1] = getString(key: "applicantName") let busType = getIntValue(key: "busType") arrContent[0][2] = busType == 1 ? "商户" : "个人" arrContent[0][3] = CommonValue.formatCardNum(str: getString(key: "applicantCard")) arrContent[0][4] = CommonValue.formatPhone(phone: getString(key: "busPhone")) arrContent[0][5] = "\( getString(key: "provinceCN"))\( getString(key: "cityCN"))\( getString(key: "areaCN"))\(getString(key: "shopAddress"))" arrContent[0][6] = getString(key: "categoryOneCN") //"结算费率","结算人姓名","银行卡号","银行名称","所属地区","所属支行","预留手机号" arrContent[1][0] = "\(getDoubleValue(key: "rate"))%" arrContent[1][1] = getString(key: "bankOpenName") arrContent[1][2] = CommonValue.formatCardNum(str: getString(key: "bankCardNumber")) arrContent[1][3] = getString(key: "bankAffiliatedBankCN") arrContent[1][4] = "\(getString(key: "bankProvinceCN"))\(getString(key: "bankCityCN"))\(getString(key: "bankAreaCN"))" arrContent[1][5] = getString(key: "bankAffiliatedBranchBankCN") arrContent[1][6] = CommonValue.formatPhone(phone: getString(key: "reservePhone")) arrContent[2][0] = getString(key: "machineTypeCN") arrContent[2][1] = getString(key: "productTypeCN") arrContent[2][2] = getString(key: "machineSnCode") let bindStatus = getIntValue(key: "bindStatus") if bindStatus == 0 { arrContent[2][3] = "未绑定" } else if bindStatus == 1 { arrContent[2][3] = "已绑定" } else if bindStatus == 2 { arrContent[2][3] = "已激活" } tableView.reloadData() } else { lblName.text = getString(key: "companyName") lblDate.text = "认证时间:\(getString(key: "createtime"))" arrContent[0][0] = getString(key: "mercNo") arrContent[0][1] = getString(key: "applicantName") // arrContent[0][2] = CommonValue.formatCardNum(str: getString(key: "applicantCard")) arrContent[0][2] = getString(key: "idCardNum") arrContent[0][3] = getString(key: "busPhone") if isHSF||isXW { arrContent[1][0] = "\(getDoubleValue(key: "rate")/10)%" }else{ arrContent[1][0] = "\(getDoubleValue(key: "rate"))%" } arrContent[2][0] = getString(key: "machineTypeCN") arrContent[2][1] = getString(key: "machineSnCode") tableView.reloadData() } } override func returnError(tag: Int, type: String) { } func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 55 } func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let view = CommonViewUntils.getViewForXIB(xibName: "OpenDetailTableViewHeaderView") as! OpenDetailTableViewHeaderView view.initView(section: section) view.lblRemark.isHidden = true if section == 0 { view.lblName.text = "基本信息" } else if section == 1 { view.lblName.text = "结算信息" } else if section == 2 { view.lblName.text = "绑定设备信息" } return view } // func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { // return 12; // } // func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { // let view = UIView(frame: CGRect(x: 0, y: 0, width: ScreenWidth, height: 12)) // view.backgroundColor = CommonUntils.getUIColorFromRGB(rgbValue: 0xf0f0f2, alpha: 1.0); // return view; // } // MARK: TABLEVLEW 实现 func numberOfSections(in tableView: UITableView) -> Int { return self.arrTitle.count } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.arrTitle[section].count } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 55 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "TiXianDetailTableViewCell", for: indexPath as IndexPath) as! TiXianDetailTableViewCell cell.lblTitle.text = arrTitle[indexPath.section][indexPath.row] cell.lblContent.text = arrContent[indexPath.section][indexPath.row] return cell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { // let view = UIViewController() // view.oneGoId = self.arrData[indexPath.row]["ItemId"] as! Int // self.navigationController?.pushViewController(view, animated: true) } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) } override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: "MyShopDetailViewController", bundle: nil) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } }