//
|
// ExchangeRecordHistoryVC.swift
|
// DolphinEnglishLearnManager
|
//
|
// Created by 无故事王国 on 2024/5/20.
|
//
|
|
import UIKit
|
import RxSwift
|
|
let Refresh_MarketExchange_Noti = Notification.Name.init("Refresh_MarketExchange_Noti")
|
|
class ExchangeRecordViewModel:RefreshModel<ExchangeRecordModel>{
|
override func api() -> (Observable<BaseResponse<[ExchangeRecordModel]>>)? {
|
return Services.exchangeRecord()
|
}
|
}
|
|
class ExchangeRecordHistoryVC: BaseVC {
|
|
|
private let viewModel = ExchangeRecordViewModel()
|
private var tableView:UITableView!
|
|
override func viewDidLoad() {
|
super.viewDidLoad()
|
|
viewModel.configure(tableView,needMore: false)
|
viewModel.beginRefresh()
|
}
|
|
override func setUI() {
|
super.setUI()
|
tableView = UITableView(frame: .zero, style: .plain)
|
tableView.delegate = self
|
tableView.dataSource = self
|
tableView.backgroundColor = .clear
|
tableView.showsVerticalScrollIndicator = false
|
tableView.showsLargeContentViewer = false
|
tableView.separatorStyle = .none
|
tableView.register(UINib(nibName: "GoodsItemTCell", bundle: nil), forCellReuseIdentifier: "_GoodsItemTCell")
|
view.addSubview(tableView)
|
tableView.snp.makeConstraints { make in
|
make.left.equalTo(159 * Config.RatioW)
|
make.right.equalTo(-159 * Config.RatioW)
|
make.top.equalTo(self.view.safeAreaLayoutGuide.snp.top).offset(27 * Config.RatioW)
|
make.bottom.equalTo(self.view.safeAreaLayoutGuide.snp.bottom).offset(-5)
|
}
|
}
|
|
override func setRx() {
|
NotificationCenter.default.rx.notification(Refresh_MarketExchange_Noti).take(until: self.rx.deallocated).subscribe(onNext: {_ in
|
self.viewModel.beginRefresh()
|
}).disposed(by: disposeBag)
|
}
|
}
|
|
|
extension ExchangeRecordHistoryVC:UITableViewDelegate{
|
|
}
|
|
extension ExchangeRecordHistoryVC:UITableViewDataSource{
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
let cell = tableView.dequeueReusableCell(withIdentifier: "_GoodsItemTCell") as! GoodsItemTCell
|
cell.setModel(viewModel.dataSource.value[indexPath.row])
|
return cell
|
}
|
|
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
return viewModel.dataSource.value.count
|
}
|
|
// func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
//// return 215
|
// }
|
|
|
}
|