From bfe324e547c704b79b98ce5785686bd83def1daf Mon Sep 17 00:00:00 2001 From: Robert <Robert@qq.com> Date: 星期一, 18 八月 2025 00:30:10 +0800 Subject: [PATCH] 赛事 --- WanPai/Root/Other/View/CommonYearsPickerView.swift | 116 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 97 insertions(+), 19 deletions(-) diff --git a/WanPai/Root/Other/View/CommonYearsPickerView.swift b/WanPai/Root/Other/View/CommonYearsPickerView.swift index 7a0ff2b..1135f93 100644 --- a/WanPai/Root/Other/View/CommonYearsPickerView.swift +++ b/WanPai/Root/Other/View/CommonYearsPickerView.swift @@ -17,23 +17,59 @@ @IBOutlet weak var cons_bottom: NSLayoutConstraint! @IBOutlet weak var pickerView: UIPickerView! - private var clickClouse:((Int)->Void)! + @IBOutlet weak var pickviewTwo: UIPickerView! + private var clickClouse:(((Int,String))->Void)! private var disposeBag = DisposeBag() private var years = [Int]() + var dataSoure : [String :[Any]] = [:] + var selectIndex : Int = 0 + var titleArr = ["年度排名","季度排名","全部"] +// var selectData : (Int,String)? override func awakeFromNib() { super.awakeFromNib() years = (Date().jq_nowYear()-5...Date().jq_nowYear()).map{$0}.sorted(by: {$0 > $1}) - years.insert(0, at: 0) +// years.insert(0, at: 0) cons_bottom.constant = -(JQ_ScreenW * 1.1) pickerView.delegate = self pickerView.dataSource = self alpha = 0 layoutIfNeeded() setRx() + + + + for item in titleArr { + var array = Array<[String:String]>() + if item == "季度排名" { + for intem1 in years { + if intem1 != 0 { + for i in 0..<4 { + if i == 0 { + array.append(["\(intem1)第1季度":"\(intem1)-01-01-\(intem1)-03-30"]) + }else if i == 1 { + array.append(["\(intem1)第2季度":"\(intem1)-04-01-\(intem1)-06-30"]) + }else if i == 2 { + array.append(["\(intem1)第3季度":"\(intem1)-07-01-\(intem1)-09-30"]) + }else if i == 3 { + array.append(["\(intem1)第4季度":"\(intem1)-10-01-\(intem1)-12-30"]) + } + + } + } + } + dataSoure[item] = array + }else if item == "年度排名" { + dataSoure[item] = years + }else if item == "全部" { + dataSoure[item] = ["全部"] + } + + } + print(dataSoure); } - static func show(clickClouse:@escaping (Int)->Void){ + static func show(clickClouse:@escaping ((Int,String))->Void){ let studentChooseView = CommonYearsPickerView.jq_loadNibView() studentChooseView.frame = sceneDelegate?.window?.frame ?? .zero studentChooseView.clickClouse = clickClouse @@ -72,40 +108,82 @@ } @IBAction func completeAction(_ sender: UIButton) { - let index = pickerView.selectedRow(inComponent: 0) - clickClouse!(years[index]) - closeAction() + let index = pickerView.selectedRow(inComponent: 1) + var str = "" + if selectIndex == 1 { + if let dict = dataSoure[titleArr[selectIndex]]?[index] as? Dictionary<String, String> { + str = "\(dict.values.first ?? "")" + } + + }else{ + str = "\(dataSoure[titleArr[selectIndex]]?[index] ?? "")" + } + + clickClouse((selectIndex,str)) + closeAction() } } extension CommonYearsPickerView:UIPickerViewDelegate{ func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView { - let label = UILabel() + if component == 0 { + let label = UILabel() + label.text = "\(titleArr[row])" + label.textColor = UIColor(hexString: "3C3C3C") + label.textAlignment = .center + label.font = UIFont.systemFont(ofSize: 18, weight: .semibold) + label.bounds = CGRect(origin: .zero, size: CGSize(width: 100, height: 45)) + return label + }else{ + let label = UILabel() - if years[row] == 0{ - label.text = "全部" - }else{ - label.text = "\(years[row])年" - } - label.textColor = UIColor(hexString: "3C3C3C") - label.textAlignment = .center - label.font = UIFont.systemFont(ofSize: 18, weight: .semibold) - label.bounds = CGRect(origin: .zero, size: CGSize(width: 100, height: 45)) - return label + if selectIndex == 1 { + if let dict = dataSoure[titleArr[selectIndex]]?[row] as? Dictionary<String, String> { + label.text = "\(dict.keys.first ?? "")" + } + + }else{ + label.text = "\(dataSoure[titleArr[selectIndex]]?[row] ?? "")" + } + + + label.textColor = UIColor(hexString: "3C3C3C") + label.textAlignment = .center + label.font = UIFont.systemFont(ofSize: 18, weight: .semibold) + label.bounds = CGRect(origin: .zero, size: CGSize(width: 120, height: 45)) + return label + } + } func pickerView(_ pickerView: UIPickerView, rowHeightForComponent component: Int) -> CGFloat { return 50 } + func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int){ + if component == 0 { + selectIndex = row + pickerView.reloadComponent(1) + } + + } } extension CommonYearsPickerView:UIPickerViewDataSource{ func numberOfComponents(in pickerView: UIPickerView) -> Int { - return 1 + return 2 } func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { - return years.count + + if dataSoure.keys.count == 0 { + return 0 + } + + if component == 0 { + return dataSoure.count + }else{ + return dataSoure[titleArr[selectIndex]]!.count + } } } -- Gitblit v1.7.1