宽窄优行-由【嘉易行】项目成品而来
无故事王国
2023-05-24 b57da2ad2fa51029fb47f10b9e96ac8e87d7c983
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
//
//  MineCreditApplyVC.swift
//  OKProject
//
//  Created by 无故事王国 on 2023/4/11.
//  Copyright © 2023 yangwang. All rights reserved.
//
 
import UIKit
import QMUIKit
import RxSwift
 
class MineCreditApplyVC: YYViewController {
 
    @IBOutlet weak var tf_apply_amount: UITextField!
    @IBOutlet weak var textview_reason: QMUITextView!
    @IBOutlet weak var btn_submit: UIButton!
 
    private let viewModel = EnterpriseViewModel()
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "申请"
    }
 
    override func bindRx() {
       let sequeue = Observable.combineLatest(tf_apply_amount.rx.text.orEmpty, textview_reason.rx.text.orEmpty)
        sequeue.subscribe {[weak self] t1,t2 in
            let status = !(t1.isEmpty || t2.isEmpty)
            self?.btn_submit.isEnabled = status
            if status{
                self?.btn_submit.backgroundColor = UIColor(hexString: "#45B494")
            }else{
                self?.btn_submit.backgroundColor = UIColor(hexString: "#818287")
            }
        }.disposed(by: disposeBag)
    }
 
    @IBAction func submitAction(_ sender: UIButton) {
        guard let v = Int(tf_apply_amount.text!) else { alert(text: "请输入申请额度");return }
        guard !textview_reason.text.isEmpty else {
            alert(text: "请输入申请理由");return
            }
 
        viewModel.saveCompanyLimit(applyQuota: tf_apply_amount.text!, applyReason: textview_reason.text!) { status in
            switch status {
                case .success(_):
                    alert(popup: .single, title: "提示!", text: "申请提交成功", submitTitle: "确定", cancelTitle: "取消") {
                        NotificationCenter.default.post(name: Refresh_MineBusinessCredit_Noti, object: nil)
                        self.yy_pop()
                    } cancelClick: {
 
                    }
                case .error(let e):
                    alert(text: e.localizedDescription)
                    break
            }
 
        }
    }
}