fix
无故事王国
2024-03-04 54c6ef0be42d9f2e49a344fd69f231cb6df43797
WanPai/Root/Search/VC/WorldCupHeaderVC.swift
@@ -6,24 +6,76 @@
//
import UIKit
import QMUIKit
import JQTools
class WorldCupHeaderVC: BaseVC {
    override func viewDidLoad() {
        super.viewDidLoad()
            @IBOutlet weak var btn_exchange: QMUIButton!
            @IBOutlet weak var label_name: UILabel!
            @IBOutlet weak var img_QR: UIImageView!
            @IBOutlet weak var label_provinceRank: UILabel!
            @IBOutlet weak var label_yearRank: UILabel!
            @IBOutlet weak var label_cityRank: UILabel!
            @IBOutlet weak var label_winNum: UILabel!
            @IBOutlet weak var label_loseNum: UILabel!
            @IBOutlet weak var label_winRate: UILabel!
            var currentPartModel:ActivityDetailPartModel?{
                        didSet{
                                    if let m = currentPartModel{
                                                label_name.text = m.name
                                                img_QR.image = UIImage.jq_GenerateQRCode(with: "\(m.id)", width: 76)
                                                getData(id: m.id, isStudent: m.isStudent)
                                    }
                        }
            }
            var partModels = [ActivityDetailPartModel](){
                        didSet{
                                    btn_exchange.isHidden = partModels.count <= 1
                        }
            }
            override func viewDidLoad() {
        super.viewDidLoad()
                        view.backgroundColor = .clear
    }
            override func setUI() {
                        btn_exchange.isHidden = true
                        label_name.text = "暂无参赛人员"
                        label_yearRank.text = "您的\(Date().jq_nowYear())年场次排名"
    /*
    // MARK: - Navigation
                        setProvince(rank: 0)
                        setCity(cityName: "", rank: 0)
            }
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */
            private func getData(id:Int,isStudent:Int){
                        Services.getEntrantRank(id: id, isStudent: isStudent).subscribe(onNext: {[weak self] data in
                                    if let model = data.data{
                                                self?.setProvince(rank: model.nationalRank)
                                                self?.setCity(cityName: model.cityName, rank: model.cityRank)
                                                self?.label_winNum.text = "\(model.win)"
                                                self?.label_loseNum.text = "\(model.lose)"
                                                self?.label_winRate.text = "\(model.winRate)%"
                                    }
                        }).disposed(by: disposeBag)
            }
            private func setProvince(rank:Int){
                        label_provinceRank.attributedText    = AttributedStringbuilder.build().add(string: "全国排名 ", withFont: .systemFont(ofSize: 14), withColor: .white).add(string: "\(rank)", withFont: .systemFont(ofSize: 28, weight: .semibold), withColor: .white).mutableAttributedString
            }
            private func setCity(cityName:String,rank:Int){
                        label_cityRank.attributedText   = AttributedStringbuilder.build().add(string: "\(cityName)排名 ", withFont: .systemFont(ofSize: 14), withColor: .white).add(string: "\(rank)", withFont: .systemFont(ofSize: 28, weight: .semibold), withColor: .white).mutableAttributedString
            }
            @IBAction func exchangeAction(_ sender: Any) {
                        StudentChoose2View.show { items in
                        }
            }
}