宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-04-06 a1ae6802080a22e6e6ce6d0935e95facb1daca5c
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//
//  MineWalletVC.swift
//  OKProject
//
//  Created by alvin_y on 2020/6/16.
//  Copyright © 2020 yangwang. All rights reserved.
//
 
import UIKit
 
/// 我的钱包
class MineWalletVC: YYViewController {
    
    /// 充值
    @IBOutlet weak var button_topUp: YYButton!
    
    /// UITableView
    @IBOutlet weak var tableView: UITableView!
    
    /// 余额
    @IBOutlet weak var label_balance: UILabel!
    
    /// 余额描述
    @IBOutlet weak var label_balanceDesc: UILabel!
    
    /// 数据源
    private let dataSource = ["消费记录","打车红包"]
    
    override func viewDidLoad() {
        super.viewDidLoad()
 
        // Do any additional setup after loading the view.
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        label_balance.text = "\(app.userInfo.balance.remain2Digits())"
//        yy_nav_back_img = UIImage.init(named: "icon_back_white")!
        self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.color(light: UIColor.color(hexString: "#000000"), dark: UIColor.color(hexString: "#FFFFFF")),NSAttributedString.Key.font: UIFont.init(name: Medium, size: 18) ?? UIFont.systemFont(ofSize: 18)]
        self.navigationController?.navigationBar.barTintColor = UIColor.color(light: UIColor.color(hexString: "#FFFFFF"), dark: UIColor.color(hexString: "#191919"))
        self.navigationController?.navigationBar.barTintColor = ThemeColor
    }
 
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.color(light: UIColor.color(hexString: "#000000"), dark: UIColor.color(hexString: "#FFFFFF")),NSAttributedString.Key.font: UIFont.init(name: Medium, size: 18) ?? UIFont.systemFont(ofSize: 18)]
        self.navigationController?.navigationBar.barTintColor = UIColor.color(light: UIColor.color(hexString: "#FFFFFF"), dark: UIColor.color(hexString: "#191919"))
    }
    //MARK: - UI
    override func setupViews() {
        super.setupViews()
        navigationItem.title = "钱包"
        navigationItem.rightBarButtonItem = UIBarButtonItem.yy_creat(title: "提现", UIFont.systemFont(ofSize: 14), .black, target: self, action: #selector(withdrawal)).item
        label_balanceDesc.attributedText = AttributedStringbuilder.build()
            .add(string: "余额", withFont: UIFont.systemFont(ofSize: 14), withColor: .white)
            .add(string: "(元)", withFont: UIFont.systemFont(ofSize: 12), withColor: .white).mutableAttributedString
        tableView.delegate = self
        tableView.dataSource = self
        tableView.tableFooterView = UIView()
        tableView.register(UITableViewCell.self, forCellReuseIdentifier: "item")
        tableView.separatorColor = UIColor.color(light: UIColor.color(hexString: "#F6F6F6"), dark: UIColor.color(hexString: "#F6F6F6"))
    }
   
    //MARK: - Rx
    override func bindRx() {
        super.bindRx()
        button_topUp.rx.tap.subscribe(onNext: {[unowned self] (_) in
            let vc = MineTopUpVC()
            self.yy_push(vc: vc)
        }).disposed(by: disposeBag)
    }
    
    /// 提现
    @objc func withdrawal()
    {
        let vc = MineWithdrawalVC()
        self.yy_push(vc: vc)
    }
}
 
// MARK: - UITableViewDelegate
extension MineWalletVC:UITableViewDelegate{
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 50
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        switch dataSource[indexPath.row] {
        case "消费记录":
            let vc = MineExpenseRecordVC()
            self.yy_push(vc: vc)
            break
        case "打车红包":
            let vc = MineTripRedEnvelopeVC()
            self.yy_push(vc: vc)
            break
        default:
            break
        }
    }
}
 
// MARK: - UITableViewDelegate
extension MineWalletVC:UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataSource.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "item", for: indexPath)
        cell.textLabel?.text = dataSource[indexPath.row]
        cell.textLabel?.font = Medium(font: 14)
        cell.textLabel?.textColor = UIColor.color(light: UIColor.color(hexString: "#333333"), dark: UIColor.color(hexString: "#333333"))
        cell.separatorInset = UIEdgeInsets(top: 0, left: 14, bottom: 0, right: 14)
        cell.accessoryType = .disclosureIndicator
        return cell
    }
}