PayViewController.swift
3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// 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)
}
}