fix
无故事王国
2024-06-20 0c89e362069e2f97d18a01a3a82835ef37a34d18
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
//  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
//                }
 
 
}