//
|
// 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
|
}
|
}
|