无故事王国
2023-10-17 77041c81c325c0bc88c94dc28d732f656cc4c885
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
//
//  StudentMentalListVC.swift
//  WanPai
//
//  Created by 无故事王国 on 2023/6/27.
//
 
import UIKit
 
class StudentMentalListVC: BaseVC {
 
    struct MentalInfo {
        var icon:UIImage!
        var l1:String!
        var l2:String!
        var level:Int!
        var info:String!
        var btnName:String!
    }
 
    lazy private var tableView:UITableView = {
        let table = UITableView(frame: .zero, style: .plain)
        table.separatorStyle = .none
        table.delegate = self
        table.dataSource = self
        table.register(UINib(nibName: "StudentMentalTCell", bundle: nil), forCellReuseIdentifier: "_StudentMentalTCell")
        return table
    }()
 
    private var items = [MentalInfo]()
    private var stuId:Int!
 
    required init(stuId:Int) {
        super.init(nibName: nil, bundle: nil)
        self.stuId = stuId
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "运动营成员勋章"
 
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
 
        Services.courseStuMedal(stuId: stuId).subscribe(onNext: { [weak self] data in
            if let models = data.data{
                for model in models{
                    switch model.medalType{
                        case .club:
                            self?.items.append(MentalInfo(icon: UIImage(named: "icon_coupon_1"), l1: "COURSE", l2: model.medalName, level: model.levelNum, info: model.upgradeConditions, btnName: "去预约"))
                        case .communtiy:
                            self?.items.append(MentalInfo(icon: UIImage(named: "icon_coupon_3"), l1: "ON_LINE", l2: model.medalName, level: model.levelNum, info: model.upgradeConditions, btnName: "去预约"))
                        case .deepPlayer:
                            self?.items.append(MentalInfo(icon: UIImage(named: "icon_coupon_4"), l1: "APPOINTMENT", l2: model.medalName, level: model.levelNum, info: model.upgradeConditions, btnName: "去完成"))
                        case .sport:
                            self?.items.append(MentalInfo(icon: UIImage(named: "icon_coupon_2"), l1: "EVENTS", l2: model.medalName, level: model.levelNum, info: model.upgradeConditions, btnName: "去报名"))
                    }
                }
                self?.tableView.reloadData()
            }
        }).disposed(by: disposeBag)
    }
}
 
extension StudentMentalListVC:UITableViewDelegate{}
 
extension StudentMentalListVC:UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return items.count
    }
 
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "_StudentMentalTCell") as! StudentMentalTCell
        cell.mentalInfo = items[indexPath.row]
        return cell
    }
}