宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
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
//
//  MineBusinessCreditVC.swift
//  OKProject
//
//  Created by 无故事王国 on 2023/4/11.
//  Copyright © 2023 yangwang. All rights reserved.
//
 
import UIKit
 
class MineBusinessCreditViewModel:YYRefreshViewModel<LinesModel>{
    override func api() -> API! {
        return .mineLimitList(pageNum: currentPage)
    }
}
 
let Refresh_MineBusinessCredit_Noti = Notification.Name.init("Refresh_MineBusinessCredit_Noti")
 
class MineBusinessCreditVC: YYViewController {
 
    @IBOutlet weak var label_quotaAccount: UILabel!
    @IBOutlet weak var label_account: UILabel!
    @IBOutlet weak var tableview: UITableView!
 
    private var viewModel:MineBusinessCreditViewModel!
 
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        yy_nav_back_img = UIImage.init(named: "icon_back_white")!
 
        let attributes = [NSAttributedString.Key.foregroundColor:UIColor.white,NSAttributedString.Key.font: UIFont.init(name: Medium, size: 18) ?? UIFont.systemFont(ofSize: 18)]
 
        if #available(iOS 15.0, *) {
            let bar = UINavigationBarAppearance()
            bar.configureWithOpaqueBackground() //消除15的黑框
            bar.backgroundEffect = nil
            bar.shadowColor = nil
            bar.titleTextAttributes = attributes
            bar.backgroundColor = ThemeColor
            navigationController?.navigationBar.scrollEdgeAppearance = bar //顶部透明
            navigationController?.navigationBar.standardAppearance = bar
        }else {
            navigationController?.navigationBar.titleTextAttributes  = attributes
            navigationController?.navigationBar.barTintColor = UIColor.white
        }
    }
 
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        yy_nav_back_img = UIImage.init(named: "icon_back_right")!
        let attributes = [NSAttributedString.Key.foregroundColor:UIColor.black,NSAttributedString.Key.font: UIFont.init(name: Medium, size: 18) ?? UIFont.systemFont(ofSize: 18)]
 
        if #available(iOS 15.0, *) {
            let bar = UINavigationBarAppearance()
            bar.configureWithOpaqueBackground() //消除15的黑框
            bar.backgroundEffect = nil
            bar.shadowColor = nil
            bar.titleTextAttributes = attributes
            bar.backgroundColor = UIColor.white
            navigationController?.navigationBar.scrollEdgeAppearance = bar //顶部透明
            navigationController?.navigationBar.standardAppearance = bar
        }else {
            navigationController?.navigationBar.titleTextAttributes  = attributes
            navigationController?.navigationBar.barTintColor = UIColor.black
        }
    }
 
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "企业额度"
        viewModel = MineBusinessCreditViewModel()
        tableview.register(UINib(nibName: "MineApplyRecordTCell", bundle: nil), forCellReuseIdentifier:"_MineApplyRecordTCell")
        tableview.delegate = self
        tableview.dataSource = self
        viewModel.configure(tableView: tableview)
        tableview.beginRefreshing()
 
        label_quotaAccount.text = "\(app.userInfo.balance.remain2Digits())"
        label_account.text = "\(app.userInfo.balanceQuota.remain2Digits())"
    }
 
    override func bindRx() {
        NotificationCenter.default.rx.notification(Refresh_MineBusinessCredit_Noti).takeUntil(self.rx.deallocated).subscribe(onNext: {[weak self] noti in
            self?.tableview.beginRefreshing()
        }).disposed(by: disposeBag)
    }
 
    @IBAction func applyAction(_ sender: UIButton) {
        let vc = MineCreditApplyVC()
        yy_push(vc: vc)
    }
 
 
    override var preferredStatusBarStyle: UIStatusBarStyle{
        return .lightContent
    }
}
 
extension MineBusinessCreditVC:UITableViewDelegate{
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let model = viewModel.dataSource.value[indexPath.row]
        let vc = MineBusinessCreditDetailVC(model: model)
        yy_push(vc: vc)
    }
}
 
extension MineBusinessCreditVC:UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return viewModel.dataSource.value.count
    }
 
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "_MineApplyRecordTCell") as! MineApplyRecordTCell
        cell.model = viewModel.dataSource.value[indexPath.row]
        return cell
    }
}