From 642175113bf6f2c90894e689dacda50278cad570 Mon Sep 17 00:00:00 2001 From: 杨锴 <841720330@qq.com> Date: 星期四, 19 九月 2024 15:50:11 +0800 Subject: [PATCH] complete most UI & Mock API --- XQMuse/Root/Me/VC/SpendingDetailContentVC.swift | 28 +++++++++++++++++++++------- 1 files changed, 21 insertions(+), 7 deletions(-) diff --git a/XQMuse/Root/Me/VC/SpendingDetailContentVC.swift b/XQMuse/Root/Me/VC/SpendingDetailContentVC.swift index bfa4d0c..971939e 100644 --- a/XQMuse/Root/Me/VC/SpendingDetailContentVC.swift +++ b/XQMuse/Root/Me/VC/SpendingDetailContentVC.swift @@ -7,15 +7,26 @@ import UIKit import JQTools +import RxSwift +import RxRelay + +class SpendingDetailViewModel:RefreshInnerModel<BalanceInfoModel>{ + + var state = BehaviorRelay<Int>(value: 1) + + override func api() -> (Observable<BaseResponse<BaseResponseList<BalanceInfoModel>>>)? { + return Services.balanceRecordList(page: page, pageSize: 20, state: state.value) + } +} class SpendingDetailContentVC: BaseVC { - private var page:Int! private var tableView:UITableView! + private var viewModel = SpendingDetailViewModel() - init(page:Int) { + init(state:Int) { super.init(nibName: nil, bundle: nil) - self.page = page + viewModel.state.accept(state) } required init?(coder: NSCoder) { @@ -25,7 +36,8 @@ override func viewDidLoad() { super.viewDidLoad() - // Do any additional setup after loading the view. + viewModel.configure(tableView) + viewModel.beginRefresh() } override func setUI() { @@ -45,18 +57,20 @@ extension SpendingDetailContentVC:UITableViewDelegate & UITableViewDataSource{ func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - let vc = SpendingDetailInfoVC() + let model = viewModel.dataSource.value!.list[indexPath.row] + let vc = SpendingDetailInfoVC(id: model.id) JQ_currentViewController().jq_push(vc: vc, animated: true) } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let model = viewModel.dataSource.value!.list[indexPath.row] let cell = tableView.dequeueReusableCell(withIdentifier: "_SpendingDetailContentTCell", for: indexPath) as! SpendingDetailContentTCell - + cell.setBalanceInfoModel(model) return cell } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - return 10 + return viewModel.dataSource.value?.list.count ?? 0 } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { -- Gitblit v1.7.1