杨锴
2025-05-11 7453d2d0cef415b34323d1b91e6cfa4a6ba31178
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//
//  WorldCupRecordVC.swift
//  WanPai
//
//  Created by 无故事王国 on 2024/2/27.
//
 
import UIKit
import RxSwift
import RxCocoa
import SnapKit
 
class WorldCupRecordViewModel:RefreshInnerModel<WorldCupMatchRecordDataModel>{
 
                let studentId = BehaviorRelay<Int>(value:0)
                let isStudent = BehaviorRelay<Int>(value:0)
 
                override func api() -> (Observable<BaseResponse<BaseResponseList<WorldCupMatchRecordDataModel>>>)? {
                                return Services.getWorldCupMatchRecord(id: studentId.value, isStudent: isStudent.value, pageNo: page)
                }
 
}
 
class WorldCupRecordVC: BaseVC {
 
                private(set) var tableView:BaseScrollInnerTableView!
                private var viewModel = WorldCupRecordViewModel()
                var partModel:BehaviorRelay<ActivityDetailPartModel?>?
                var superScrollView:UIScrollView?
                override func viewDidLoad() {
                                super.viewDidLoad()
                                view.backgroundColor = .clear
                }
 
                override func setUI() {
                                superScrollView?.delegate = self
                                tableView = BaseScrollInnerTableView(frame: .zero, style: .grouped)
                                tableView.delegate = self
                                tableView.dataSource = self
                                tableView.separatorStyle = .none
                                tableView.backgroundColor = .clear
                                if #available(iOS 15.0, *) {
                                                tableView.sectionHeaderTopPadding = 0
                                }
                                tableView.register(UINib(nibName: "WorldCupRecordTCell", bundle: nil), forCellReuseIdentifier: "_WorldCupRecordTCell")
 
                                view.addSubview(tableView)
                                tableView.snp.makeConstraints { make in
                                                make.edges.equalToSuperview()
                                }
 
                                viewModel.configure(tableView)
                                viewModel.beginRefresh()
                }
 
                override func setRx() {
                                partModel?.subscribe(onNext: {[weak self]model in
                                                if let m = model{
                                                                self?.viewModel.studentId.accept(m.id)
                                                                self?.viewModel.isStudent.accept(m.isStudent)
                                                                self?.viewModel.beginRefresh()
                                                }
                                }).disposed(by: disposeBag)
                }
}
extension WorldCupRecordVC:UIScrollViewDelegate{
 
                func scrollViewDidScroll(_ scrollView: UIScrollView) {
                                var canScroll = true
                                if scrollView.tag == 2100{
 
                                                if scrollView.contentOffset.y < 350 && scrollView.contentOffset.y != 0{
                                                                canScroll = false
                                                }
                                                print("\(scrollView.contentOffset.y)----\(canScroll)")
                                                tableView.isScrollEnabled = canScroll
                                }
                }
}
 
extension WorldCupRecordVC:UITableViewDelegate,UITableViewDataSource{
                func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
                                return viewModel.dataSource.value?.list.count ?? 0
                }
 
                func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                                let cell = tableView.dequeueReusableCell(withIdentifier: "_WorldCupRecordTCell") as! WorldCupRecordTCell
                                cell.backgroundColor = .clear
                                cell.model = viewModel.dataSource.value!.list[indexPath.row]
                                return cell
                }
 
                func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
                                return 102
                }
 
                func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
                                var headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "header")
                                if headerView == nil{
                                                headerView = UITableViewHeaderFooterView(reuseIdentifier: "header")
                                                headerView?.backgroundColor = .clear
                                                headerView?.contentView.backgroundColor = .clear
                                            let label    = UILabel()
                                                label.tag = 100
                                                label.font = UIFont.systemFont(ofSize: 16, weight: .semibold)
                                                label.textColor = .black.withAlphaComponent(0.8)
                                                headerView?.contentView.addSubview(label)
                                                label.snp.makeConstraints { make in
                                                                make.left.equalTo(14)
                                                                make.height.equalTo(22)
                                                                make.bottom.equalToSuperview().offset(-6.5)
                                                }
                                }
 
                                if let label = headerView?.contentView.viewWithTag(100) as? UILabel{
                                                label.text = "总场次:\(viewModel.dataSource.value?.totalSession ?? 0)场"
                                }
 
                                return headerView
                }
 
                func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
                                return 54
                }
 
}