无故事王国
2024-03-15 049c0b33c1f3936a6d32012c9e6234273feaec67
WanPai/Root/Search/VC/WorldCupRankVC.swift
@@ -26,13 +26,14 @@
class WorldCupRankVC: BaseVC {
            private var viewModel = WorldCupRankViewModel()
            private(set) var viewModel = WorldCupRankViewModel()
            var partModel:BehaviorRelay<ActivityDetailPartModel?>?
            private var worldCupRankModel:WorldCupRankModel?
            private let cityBtn = UIButton(type: .custom)
            var currentRankModel:BehaviorRelay<WorldCupMatchRankModel?>?
//            private var worldCupRankModel:WorldCupRankModel?
//            private let cityBtn = UIButton(type: .custom)
            private let yearBtn = QMUIButton(type: .custom)
            private let ratioRankBtn = QMUIButton(type: .custom)
            private let provinceBtn = UIButton(type: .custom)
//            private let provinceBtn = UIButton(type: .custom)
            private var tableView:UITableView!
            var superScrollView:UIScrollView?
@@ -50,6 +51,7 @@
                        tableView.showsHorizontalScrollIndicator = false
                        tableView.backgroundColor = .clear
                        tableView.separatorStyle = .none
                        tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: 100 - UIDevice.jq_safeEdges.bottom, right: 0)
                        if #available(iOS 15.0, *) {
                                    tableView.sectionHeaderTopPadding = 0
                        }
@@ -75,16 +77,25 @@
                                                self?.viewModel.isStudent.accept(m.isStudent)
                                                self?.viewModel.beginRefresh()
                                                Services.getEntrantRank(id: m.id, isStudent: m.isStudent).subscribe(onNext: {[weak self] data in
                                                            if let model = data.data{
                                                                        self?.worldCupRankModel = model
                                                                        self?.cityBtn.setTitle(model.cityName, for: .normal)
                                                                        self?.cityBtn.layoutIfNeeded()
                                                                        self?.cityBtn.layoutSubviews()
                                                            }
                                                }).disposed(by: weakSelf.disposeBag)
//                                                Services.getEntrantRank(id: m.id, isStudent: m.isStudent).subscribe(onNext: {[weak self] data in
//                                                            if let model = data.data{
//                                                                        self?.worldCupRankModel = model
//                                                                        self?.cityBtn.setTitle(model.cityName, for: .normal)
//                                                                        self?.cityBtn.layoutIfNeeded()
//                                                                        self?.cityBtn.layoutSubviews()
//                                                            }
//                                                }).disposed(by: weakSelf.disposeBag)
                                    }
                        }).disposed(by: disposeBag)
                        viewModel.dataSource.subscribe(onNext: {[weak self] data in
                                    guard let weakSelf = self else { return }
                                    data.forEach { model in
                                                if model.oneself == 1{
                                                            weakSelf.currentRankModel?.accept(model)
                                                }
                                    }
                        }).disposed(by: disposeBag)
//                        Observable.combineLatest(superScrollView!.rx.contentOffset, tableView.rx.contentOffset).subscribe { v1,v2 in
@@ -100,30 +111,30 @@
//                        }.disposed(by: disposeBag)
            }
            @objc func radiusAction(btn:UIButton){
                        if btn.tag == 10{
                                    provinceBtn.jq_borderWidth = 0
                                    provinceBtn.setTitleColor(.white, for: .normal)
                                    provinceBtn.backgroundColor = UIColor(hexString: "#FE7E03")
                                    cityBtn.setTitleColor(UIColor(hexString: "#FE7E03"), for: .normal)
                                    cityBtn.backgroundColor = .white
                                    cityBtn.jq_borderWidth = 1
                                    cityBtn.jq_borderColor = UIColor(hexString: "#FE7E03")
                                    viewModel.radius.accept(1)
                        }else{
                                    cityBtn.jq_borderWidth = 0
                                    cityBtn.setTitleColor(.white, for: .normal)
                                    cityBtn.backgroundColor = UIColor(hexString: "#FE7E03")
                                    provinceBtn.setTitleColor(UIColor(hexString: "#FE7E03"), for: .normal)
                                    provinceBtn.backgroundColor = .white
                                    provinceBtn.jq_borderWidth = 1
                                    viewModel.radius.accept(2)
                        }
                        viewModel.beginRefresh()
            }
//            @objc func radiusAction(btn:UIButton){
//                        if btn.tag == 10{
//                                    provinceBtn.jq_borderWidth = 0
//                                    provinceBtn.setTitleColor(.white, for: .normal)
//                                    provinceBtn.backgroundColor = UIColor(hexString: "#FE7E03")
//
//                                    cityBtn.setTitleColor(UIColor(hexString: "#FE7E03"), for: .normal)
//                                    cityBtn.backgroundColor = .white
//                                    cityBtn.jq_borderWidth = 1
//                                    cityBtn.jq_borderColor = UIColor(hexString: "#FE7E03")
//                                    viewModel.radius.accept(1)
//                        }else{
//                                    cityBtn.jq_borderWidth = 0
//                                    cityBtn.setTitleColor(.white, for: .normal)
//                                    cityBtn.backgroundColor = UIColor(hexString: "#FE7E03")
//
//                                    provinceBtn.setTitleColor(UIColor(hexString: "#FE7E03"), for: .normal)
//                                    provinceBtn.backgroundColor = .white
//                                    provinceBtn.jq_borderWidth = 1
//                                    viewModel.radius.accept(2)
//                        }
//                        viewModel.beginRefresh()
//
//            }
            @objc func filterAction(){
                        CommonYearsPickerView.show {[weak self] index in
@@ -235,8 +246,8 @@
                        cell.indexPath = indexPath
                        cell.model = viewModel.dataSource.value[indexPath.row]
                                    cell.addLine(UIColor(hexStr: "#E1E1E1"), false, true, false, true, 0.4)
                                    return cell
                        cell.addLine(UIColor(hexStr: "#E1E1E1"), false, true, false, true, 0.4)
                        return cell
            }
//            func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
@@ -319,68 +330,68 @@
                        return headerView
            }
            func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
//            func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
//
//                        if section == 0{return nil}
//                        var footView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "footer")
//                        if footView == nil{
//                                    footView = UITableViewHeaderFooterView(reuseIdentifier: "footer")
//                                    let stackView = UIStackView()
//                                    stackView.axis = .horizontal
//                                    stackView.distribution = .fillEqually
//                                    stackView.spacing = 10
//
//                                    provinceBtn.setTitle("全国", for: .normal)
//                                    provinceBtn.tag = 10
//                                    provinceBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .medium)
//                                    provinceBtn.setTitleColor(UIColor(hexString: "#FE7E03"), for: .normal)
//                                    provinceBtn.borderColor = UIColor(hexString: "#FE7E03")
//                                    provinceBtn.borderWidth = 1
//                                    provinceBtn.cornerRadius = 20
//                                    provinceBtn.addTarget(self, action: #selector(radiusAction), for: .touchUpInside)
//
//                                    cityBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .medium)
//                                    cityBtn.tag = 11
//                                    cityBtn.setTitleColor(.white, for: .normal)
//                                    cityBtn.backgroundColor = UIColor(hexString: "#FE7E03")
//                                    cityBtn.cornerRadius = 20
//                                    cityBtn.addTarget(self, action: #selector(radiusAction), for: .touchUpInside)
//
//                                    stackView.addArrangedSubview(provinceBtn)
//                                    stackView.addArrangedSubview(cityBtn)
//
//                                    footView?.contentView.addSubview(stackView)
//                                    footView?.contentView.backgroundColor = .white
//                                    stackView.snp.makeConstraints { make in
//                                                make.left.right.equalToSuperview().inset(UIEdgeInsets(top: 0, left: 27, bottom: 0, right: 27))
//                                                make.bottom.equalToSuperview()
//                                                make.height.equalTo(40)
//                                    }
//
//                                    let cell = WorldCupRankTCell(style: .default, reuseIdentifier: nil)
//                                    cell.tag = 1100
//                                    cell.borderColor = UIColor(hexString: "#FC743A")
//                                    cell.jq_borderWidth = 1
//                                    footView?.addSubview(cell)
//                                    cell.snp.makeConstraints { make in
//                                                make.left.top.right.equalToSuperview()
//                                                make.height.equalTo(45)
//                                    }
//                        }
//                        if let cell = footView?.viewWithTag(1100) as? WorldCupRankTCell{
//                                    if let model  = viewModel.dataSource.value.filter({$0.oneself == 1}).first{
//                                                cell.model = model
//                                    }
//                        }
//                        return footView
//            }
                        if section == 0{return nil}
                        var footView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "footer")
                        if footView == nil{
                                    footView = UITableViewHeaderFooterView(reuseIdentifier: "footer")
                                    let stackView = UIStackView()
                                    stackView.axis = .horizontal
                                    stackView.distribution = .fillEqually
                                    stackView.spacing = 10
                                    provinceBtn.setTitle("全国", for: .normal)
                                    provinceBtn.tag = 10
                                    provinceBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .medium)
                                    provinceBtn.setTitleColor(UIColor(hexString: "#FE7E03"), for: .normal)
                                    provinceBtn.borderColor = UIColor(hexString: "#FE7E03")
                                    provinceBtn.borderWidth = 1
                                    provinceBtn.cornerRadius = 20
                                    provinceBtn.addTarget(self, action: #selector(radiusAction), for: .touchUpInside)
                                    cityBtn.titleLabel?.font = UIFont.systemFont(ofSize: 15, weight: .medium)
                                    cityBtn.tag = 11
                                    cityBtn.setTitleColor(.white, for: .normal)
                                    cityBtn.backgroundColor = UIColor(hexString: "#FE7E03")
                                    cityBtn.cornerRadius = 20
                                    cityBtn.addTarget(self, action: #selector(radiusAction), for: .touchUpInside)
                                    stackView.addArrangedSubview(provinceBtn)
                                    stackView.addArrangedSubview(cityBtn)
                                    footView?.contentView.addSubview(stackView)
                                    footView?.contentView.backgroundColor = .white
                                    stackView.snp.makeConstraints { make in
                                                make.left.right.equalToSuperview().inset(UIEdgeInsets(top: 0, left: 27, bottom: 0, right: 27))
                                                make.bottom.equalToSuperview()
                                                make.height.equalTo(40)
                                    }
                                    let cell = WorldCupRankTCell(style: .default, reuseIdentifier: nil)
                                    cell.tag = 1100
                                    cell.borderColor = UIColor(hexString: "#FC743A")
                                    cell.jq_borderWidth = 1
                                    footView?.addSubview(cell)
                                    cell.snp.makeConstraints { make in
                                                make.left.top.right.equalToSuperview()
                                                make.height.equalTo(45)
                                    }
                        }
                        if let cell = footView?.viewWithTag(1100) as? WorldCupRankTCell{
                                    if let model  = viewModel.dataSource.value.filter({$0.oneself == 1}).first{
                                                cell.model = model
                                    }
                        }
                        return footView
            }
            func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
                        if section == 0{
                                    return 0.001
                        }
                        return 100
            }
//            func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
//                        if section == 0{
//                                    return 0.001
//                        }
//                        return 100
//            }
            func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {