//
|
// MineWithdrawalVC.swift
|
// OKProject
|
//
|
// Created by alvin_y on 2020/6/17.
|
// Copyright © 2020 yangwang. All rights reserved.
|
//
|
|
import UIKit
|
|
/// 提现
|
class MineWithdrawalVC: YYViewController {
|
|
/// 提交
|
@IBOutlet weak var button_submit: YYButton!
|
|
/// 持卡人姓名
|
@IBOutlet weak var textField_name: YYTextField!
|
|
/// 卡号
|
@IBOutlet weak var textField_cardNum: YYTextField!
|
|
/// 金额
|
@IBOutlet weak var textFied_money: YYTextField!
|
|
/// 余额
|
private var money: Double = app.userInfo.balance
|
|
let viewModel = MineWithdrawalViewModel()
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
|
// Do any additional setup after loading the view.
|
}
|
|
//MARK: - UI
|
override func setupViews() {
|
super.setupViews()
|
navigationItem.title = "提现"
|
textFied_money.placeholder = "\(money)元可提现"
|
navigationItem.rightBarButtonItem = UIBarButtonItem.yy_creat(title: "提现记录", UIFont.systemFont(ofSize: 14), UIColor.color(light: UIColor.color(hexString: "#666666"), dark: UIColor.color(hexString: "#666666")), target: self, action: #selector(withdrawalRecord)).item
|
}
|
|
//MARK: - Rx
|
override func bindRx() {
|
super.bindRx()
|
|
textFied_money.rx.text.orEmpty.map{ value in
|
return value.wy_toDouble()
|
}.bind(to: viewModel.money).disposed(by: disposeBag)
|
|
textField_cardNum.rx.text.orEmpty.bind(to: viewModel.code).disposed(by: disposeBag)
|
|
textField_name.rx.text.orEmpty.bind(to: viewModel.name).disposed(by: disposeBag)
|
|
button_submit.rx.tap.subscribe(onNext: {[unowned self] (_) in
|
if self.textFied_money.isEmpty(empty: "请输入提交金额"){
|
return
|
}
|
if self.textField_cardNum.isEmpty(empty: "请输入卡号"){
|
return
|
}
|
if self.textField_name.isEmpty(empty: "请输入持卡人姓名"){
|
return
|
}
|
self.viewModel.withdrawal()
|
}).disposed(by: disposeBag)
|
|
viewModel.queryUserInfoSubject
|
.subscribe(onNext: {[unowned self] (status) in
|
switch status{
|
case .loading:
|
// self.show()
|
break
|
case .success(_):
|
// self.hide()
|
self.yy_pop()
|
break
|
case .error(let error):
|
// self.hide()
|
alert(text: error.localizedDescription)
|
break
|
}
|
}).disposed(by: rx.disposeBag)
|
/// 提现
|
viewModel.requestSubject
|
.subscribe(onNext: {[unowned self] (status) in
|
switch status{
|
case .loading:
|
self.show()
|
break
|
case .success(_):
|
self.hide()
|
alert(text: "提交成功!我们将尽快处理,请您注意查看到账情况")
|
self.viewModel.queryUserInfo()
|
// alert(popup: .single, title: "提示", text: , submitTitle: "确定", cancelTitle: nil, submitClick: {
|
//
|
// }) {}
|
break
|
case .error(let error):
|
self.hide()
|
alert(text: error.localizedDescription)
|
break
|
}
|
}).disposed(by: rx.disposeBag)
|
}
|
|
|
/// 提现记录
|
@objc func withdrawalRecord(){
|
let vc = MineWithdrawalRecordVC()
|
self.yy_push(vc: vc)
|
}
|
}
|