| | |
| | | import UIKit |
| | | import JQTools |
| | | import QMUIKit |
| | | import RxSwift |
| | | import RxRelay |
| | | |
| | | class RechargeRecordViewModel:RefreshModel<BillingModel>{ |
| | | var coin = BehaviorRelay<Int>(value: 0) |
| | | var type = BehaviorRelay<Int?>(value: nil) |
| | | var yearMonth = BehaviorRelay<String>(value: "") |
| | | override func api() -> (Observable<BaseResponse<[BillingModel]>>)? { |
| | | return Services.voucherDetail(recordType: type.value, yearMonth: yearMonth.value) |
| | | } |
| | | } |
| | | |
| | | class RechargeRecordVC: BaseVC { |
| | | |
| | |
| | | @IBOutlet weak var view_cion: JQ_RollNumberLabel! |
| | | @IBOutlet weak var btn_rechange: UIButton! |
| | | @IBOutlet weak var view_container: UIView! |
| | | @IBOutlet weak var tableView: UITableView! |
| | | @IBOutlet weak var tableView: BaseTableView! |
| | | @IBOutlet weak var btn_filter: QMUIButton! |
| | | @IBOutlet weak var btn_date: UIButton! |
| | | |
| | | |
| | | private let viewModel = RechargeRecordViewModel() |
| | | |
| | | required init(coin:Int) { |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.viewModel.coin.accept(coin) |
| | | } |
| | | |
| | | required init?(coder: NSCoder) { |
| | | fatalError("init(coder:) has not been implemented") |
| | | } |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "充值明细" |
| | | view_cion.font = UIFont.init(name: "Impact", size: 36)! |
| | | view_cion.textColor = .white |
| | | DispatchQueue.main.asyncAfter(deadline: .now()+2) { |
| | | self.view_cion.valueNumber = NSNumber(value: 22199) |
| | | } |
| | | } |
| | | |
| | | override func viewDidAppear(_ animated: Bool) { |
| | | super.viewDidAppear(animated) |
| | | self.view_cion.valueNumber = NSNumber(value: self.viewModel.coin.value) |
| | | } |
| | | |
| | | |
| | |
| | | tableView.dataSource = self |
| | | tableView.separatorStyle = .none |
| | | tableView.register(UINib(nibName: "BillInfoTCell", bundle: nil), forCellReuseIdentifier:"_BillInfoTCell") |
| | | |
| | | viewModel.yearMonth.accept(Date().jq_format("yyyy-MM")) |
| | | btn_date.setTitle("\(Date().jq_format("yyyy年MM月"))>", for: .normal) |
| | | viewModel.configure(tableView,needMore: false) |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | @IBAction func datetimeAction(_ sender: UIButton) { |
| | | CommonDatePickerView.show { year, month, day in |
| | | |
| | | CommonDatePickerView.show(before: 3, after: 0, type: .YM) {[weak self] year, month, day in |
| | | self?.btn_date.setTitle(String(format: "%ld年%02ld月>", year,month), for: .normal) |
| | | self?.viewModel.yearMonth.accept(String(format: "%ld-02ld", year,month)) |
| | | self?.viewModel.beginRefresh() |
| | | } |
| | | } |
| | | |
| | | |
| | | @IBAction func filterAction(_ sender: QMUIButton) { |
| | | JQ_MenuView().show(self, tapView: sender, items: ["充值","扣除"], tableHei: 150) { index, str in |
| | | |
| | | JQ_MenuView().show(self, tapView: sender, items: ["全部记录","充值","扣除"], tableHei: 150) {[weak self] index, str in |
| | | if index == 0{ |
| | | self?.viewModel.type.accept(nil) |
| | | }else{ |
| | | self?.viewModel.type.accept(index) |
| | | } |
| | | self?.viewModel.beginRefresh() |
| | | } |
| | | } |
| | | |
| | | @IBAction func rechargeAction(_ sender: UIButton) { |
| | | let vc = RechargeCenterVC() |
| | | vc.viewModel = viewModel |
| | | push(vc: vc) |
| | | } |
| | | } |
| | |
| | | |
| | | extension RechargeRecordVC:UITableViewDataSource{ |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let model = viewModel.dataSource.value[indexPath.row] |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_BillInfoTCell") as! BillInfoTCell |
| | | cell.billingModel = model |
| | | return cell |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return 50 |
| | | return viewModel.dataSource.value.count |
| | | } |
| | | } |