Robert
5 天以前 bfe324e547c704b79b98ce5785686bd83def1daf
WanPai/Root/Search/VC/WorldCupRankVC.swift
@@ -18,9 +18,10 @@
            var radius = BehaviorRelay<Int>(value: 2)
            var sort = BehaviorRelay<Int>(value: 2)
            var year = BehaviorRelay<Int?>(value: nil)
                var worldCupId = BehaviorRelay<Int?>(value: nil)
                var time = BehaviorRelay<String?>(value: nil)
            override func api() -> (Observable<BaseResponse<[WorldCupMatchRankModel]>>)? {
                        return Services.getWorldCupRank(id: id.value, isStudent: isStudent.value, radius: radius.value, sort: sort.value,year: year.value)
                    return Services.getWorldCupRank(id: id.value, isStudent: isStudent.value, radius: radius.value, sort: sort.value,year: year.value,worldCupId:worldCupId.value,time:time.value)
            }
}
@@ -38,6 +39,9 @@
            var superScrollView:UIScrollView?
            var flowCell:WorldCupRankTCell?
    var id : Int = 0
    var isStudent: Int = 0
            override func viewDidLoad() {
                        super.viewDidLoad()
                        view.backgroundColor = .clear
@@ -75,6 +79,8 @@
                        partModel?.subscribe(onNext: {[weak self] model in
                                    guard let weakSelf = self else { return }
                                    if let m = model{
                                                    self?.id = m.id
                                                    self?.isStudent = m.isStudent
                                                self?.viewModel.id.accept(m.id)
                                                self?.viewModel.isStudent.accept(m.isStudent)
                                                self?.viewModel.beginRefresh()
@@ -138,14 +144,35 @@
//
//            }
    @objc func opensAction(){
        Services.getWorldCupListFromRank(id: id, isStudent: isStudent).subscribe(onNext: { [weak self]data in
            if data.data?.count != 0 {
                WorldCupListRankView.show(arr: data.data ?? []) { id in
                    self?.viewModel.worldCupId.accept(id)
                    self?.viewModel.beginRefresh()
                }
            }
        }).disposed(by: disposeBag)
    }
            @objc func filterAction(){
                        CommonYearsPickerView.show {[weak self] index in
                        CommonYearsPickerView.show {[weak self] index,value in
//                                    if index == 0{
//                                                self?.viewModel.year.accept(nil)
//                                                self?.yearBtn.setTitle("  全部", for: .normal)
//                                    }else{
//                                                self?.viewModel.year.accept(index)
//                                                self?.yearBtn.setTitle("  \(index)年", for: .normal)
//                                    }
                                    if index == 0{
                                        self?.viewModel.year.accept(Int(value))
                                        self?.viewModel.time.accept(nil)
                                    }else if index == 1 {
                                                self?.viewModel.year.accept(nil)
                                                self?.yearBtn.setTitle("  全部", for: .normal)
                                    }else{
                                                self?.viewModel.year.accept(index)
                                                self?.yearBtn.setTitle("  \(index)年", for: .normal)
                                        self?.viewModel.time.accept(value)
                                    }else if index == 2 {
                                        self?.viewModel.year.accept(nil)
                                        self?.viewModel.time.accept(nil)
                                    }
                                    self?.viewModel.beginRefresh()
                        }
@@ -221,6 +248,20 @@
                                                }
                                                label1.addLine(UIColor(hexStr: "#E1E1E1"), true, true, true, false, 0.4)
                                                    let label4 = UILabel()
                                                    label4.text = "积分"
                                                    label4.textAlignment = .center
                                                    label4.font = UIFont.systemFont(ofSize: 12, weight: .medium)
                                                    label4.textColor = .black.withAlphaComponent(0.8)
                                                    cell?.contentView.addSubview(label4)
                                                    label4.snp.makeConstraints { make in
                                                                    make.top.bottom.equalToSuperview()
                                                                    make.width.equalTo(60)
                                                                    make.height.equalTo(32)
                                                                    make.left.equalTo(label1.snp.right)
                                                    }
                                                    label4.addLine(UIColor(hexStr: "#E1E1E1"), true, true, true, false, 0.4)
                                                let label2 = UILabel()
                                                label2.text = "总场次"
                                                label2.textAlignment = .center
@@ -229,9 +270,9 @@
                                                cell?.contentView.addSubview(label2)
                                                label2.snp.makeConstraints { make in
                                                            make.top.bottom.equalToSuperview()
                                                            make.width.equalTo((JQ_ScreenW - 28) * 0.3314)
                                                            make.width.equalTo((JQ_ScreenW - 28) * 0.2114)
                                                            make.height.equalTo(32)
                                                            make.left.equalTo(label1.snp.right)
                                                            make.left.equalTo(label4.snp.right)
                                                }
                                                label2.addLine(UIColor(hexStr: "#E1E1E1"), true, true, true, false, 0.4)
@@ -243,7 +284,7 @@
                                                cell?.contentView.addSubview(label3)
                                                label3.snp.makeConstraints { make in
                                                            make.top.bottom.equalToSuperview()
                                                            make.width.equalTo((JQ_ScreenW - 28) * 0.2016)
                                                            make.width.equalTo((JQ_ScreenW - 28) * 0.1516)
                                                            make.height.equalTo(32)
                                                            make.left.equalTo(label2.snp.right)
                                                }
@@ -285,22 +326,7 @@
                                    headerView = UITableViewHeaderFooterView(reuseIdentifier: "header")
                                    headerView?.backgroundColor = .clear
                                    headerView?.contentView.backgroundColor = .clear
                                    let label = UILabel(text: "参与年份: ")
                                    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.centerY.equalToSuperview()
                                    }
                                    if    viewModel.year.value == nil{
                                                yearBtn.setTitle("  全部", for: .normal)
                                    }else{
                                                yearBtn.setTitle("  \(viewModel.year.value!)年", for: .normal)
                                    }
                                                yearBtn.setTitle("总排名", for: .normal)
                                    yearBtn.setTitleColor(.black.withAlphaComponent(0.74), for: .normal)
                                    yearBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
                                    yearBtn.jq_borderColor = UIColor(hexString: "#D9D9D9")
@@ -312,27 +338,29 @@
                                    yearBtn.jq_cornerRadius = 5
                                    headerView?.contentView.addSubview(yearBtn)
                                    yearBtn.snp.makeConstraints { make in
                                                make.left.equalTo(label.snp.right).offset(2)
                                                make.left.equalTo(20)
                                                make.centerY.equalToSuperview()
                                                make.width.greaterThanOrEqualTo(68)
                                                make.width.greaterThanOrEqualTo(100)
                                                make.height.equalTo(35)
                                    }
                                    ratioRankBtn.setTitle("赛事排名", for: .normal)
                                    ratioRankBtn.setTitleColor(.black.withAlphaComponent(0.74), for: .normal)
                                    ratioRankBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
                                    ratioRankBtn.jq_borderColor = UIColor(hexString: "#D9D9D9")
                                    ratioRankBtn.jq_borderWidth = 1
                                    ratioRankBtn.setImage(UIImage(named: "icon_down_arrow"), for: .normal)
                                    ratioRankBtn.addTarget(self, action: #selector(opensAction), for: .touchUpInside)
                                    ratioRankBtn.spacingBetweenImageAndTitle = 5
                                    ratioRankBtn.imagePosition = .right
                                    ratioRankBtn.jq_cornerRadius = 5
                                    headerView?.contentView.addSubview(ratioRankBtn)
                                    ratioRankBtn.snp.makeConstraints { make in
                                        make.right.equalTo(-20)
                                                    make.centerY.equalToSuperview()
                                                    make.width.greaterThanOrEqualTo(100)
                                                make.height.equalTo(35)
                                    }
                                    ratioRankBtn.setTitle("按胜率排名", for: .normal)
                                    ratioRankBtn.setTitle(viewModel.sort.value == 1 ? "按场次排名":"按胜率排名", for: .normal)
                                    ratioRankBtn.setTitleColor(UIColor(hexString: "#3876F2"), for: .normal)
                                    ratioRankBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16,weight: .medium)
                                    ratioRankBtn.setImage(UIImage(named: "icon_reset"), for: .normal)
                                    ratioRankBtn.addTarget(self, action: #selector(rateAction), for: .touchUpInside)
                                    ratioRankBtn.spacingBetweenImageAndTitle = 5
                                    ratioRankBtn.isSelected = true
                                    ratioRankBtn.imagePosition = .right
                                    headerView?.contentView.addSubview(ratioRankBtn)
                                    ratioRankBtn.snp.makeConstraints { make in
                                                make.right.equalToSuperview().offset(-14)
                                                make.centerY.equalToSuperview()
                                                make.height.equalTo(22)
                                    }
                        }
                        return headerView
            }