// // PayViewController.swift // HDFwear // // Created by yangbin on 2022/3/7. // import UIKit class PayViewController: UIViewController { @IBOutlet weak var tableView: UITableView! private var payArray: [String] = ["微信", "支付宝", "PayPal"] private let payDic: [String: String] = ["微信": "push_wechat", "支付宝": "Alipay", "QQ": "push_qq", "PayPal": "PayPal"] lazy var footerView: UIView = { let view = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 45)) let label = UILabel(frame: CGRect(x: 12.5, y: 2.5, width: SCREEN_WIDTH-30, height: 40)) label.font = RegularFont(11) label.textColor = UIColor.rgbColorFromHex(0x808080) label.numberOfLines = 0 label.text = LocString("将收款二维码绑定至您的手表里,随时随地发起收款") view.addSubview(label) return view }() lazy var headerView: UIView = { let view = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 30)) let label = UILabel(frame: CGRect(x: 12.5, y: 0, width: SCREEN_WIDTH-30, height: 30)) label.font = RegularFont(11) label.textColor = UIColor.rgbColorFromHex(0x808080) label.numberOfLines = 0 label.text = LocString("收款") view.addSubview(label) return view }() let device = CurDevice override func viewDidLoad() { super.viewDidLoad() title = LocString("钱包") if device.name.contains("S7 NO.1") { payArray = ["微信", "支付宝"] } tableView.register(UINib.init(nibName: "SettingCell3", bundle: Bundle.main), forCellReuseIdentifier: "SettingCell3") tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0) tableView.tableFooterView = footerView tableView.tableHeaderView = headerView // Do any additional setup after loading the view. } /* // 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. } */ } extension PayViewController: UITableViewDelegate, UITableViewDataSource { func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 50 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return payArray.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "SettingCell3", for: indexPath) as! SettingCell3 let payText = payArray[indexPath.row] cell.titleLabel.text = LocString(payText) // cell.setImageView.image = UIImage(named: payDic[payText]!) return cell } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let cell = tableView.cellForRow(at: indexPath) as! SettingCell3 cell.isSelected = false let vc = UIStoryboard.loadViewControllerIdentifier(storyboardName: "Setting", identifier: "PayDetailVC") as! PayDetailVC if payArray[indexPath.row] == "微信" { vc.app = "微信" } else { vc.app = payArray[indexPath.row] } navigationController?.pushViewController(vc, animated: true) } }