杨锴
2025-05-11 7453d2d0cef415b34323d1b91e6cfa4a6ba31178
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//
//  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!
                                var medalType:MedalType = .club
                                var isTopLevel:Int!
                }
 
                lazy private var tableView:UITableView = {
                                let table = UITableView(frame: .zero, style: .plain)
                                table.separatorStyle = .none
                                table.delegate = self
                                table.dataSource = self
                                table.contentInset = UIEdgeInsets(top: -21, left: 0, bottom: 0, right: 0)
                                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: String(format: "再上课打卡%@次可升级LV%ld", model.upgradeConditions,model.nextLevel), btnName: "去预约",medalType: model.medalType,isTopLevel: model.isTopLevel))
                                                                                                case .communtiy:
                                                                                                                self?.items.append(MentalInfo(icon: UIImage(named: "icon_coupon_3"), l1: "KING", l2: model.medalName, level: model.levelNum, info: String(format: "再预约场地%@次可升级LV%ld", model.upgradeConditions,model.nextLevel), btnName: "去预约",medalType: model.medalType,isTopLevel: model.isTopLevel))
                                                                                                case .deepPlayer:
                                                                                                                self?.items.append(MentalInfo(icon: UIImage(named: "icon_coupon_4"), l1: "APPOINTMENT", l2: model.medalName, level: model.levelNum, info: String(format: "再完成课后练习%@次可升级LV%ld", model.upgradeConditions,model.nextLevel), btnName: "去完成",medalType: model.medalType,isTopLevel: model.isTopLevel))
                                                                                                case .sport:
                                                                                                                self?.items.append(MentalInfo(icon: UIImage(named: "icon_coupon_2"), l1: "EVENTS", l2: model.medalName, level: model.levelNum, info: String(format: "再参与活动%@次可升级LV%ld", model.upgradeConditions,model.nextLevel), btnName: "去报名",medalType: model.medalType,isTopLevel: model.isTopLevel))
                                                                                                case .winner:
                                                                                                                self?.items.append(MentalInfo(icon: UIImage(named: "icon_coupon_8"), l1: "TRIUMPH", l2: model.medalName, level: model.levelNum, info: String(format: "社区世界杯再胜利%@次可升级LV%ld", model.upgradeConditions,model.nextLevel), btnName: "去查看",medalType: model.medalType,isTopLevel: model.isTopLevel))
                                                                                                case .counter:
                                                                                                                self?.items.append(MentalInfo(icon: UIImage(named: "icon_coupon_7"), l1: "FIGHTING", l2: model.medalName, level: model.levelNum, info: String(format: "社区世界杯再参与%@次可升级LV%ld", model.upgradeConditions,model.nextLevel), btnName: "去查看",medalType: model.medalType,isTopLevel: model.isTopLevel))
 
                                                                                                default:break
                                                                                }
                                                                }
                                                                self?.tableView.reloadData()
                                                }
                                }).disposed(by: disposeBag)
                }
}
 
extension StudentMentalListVC:UITableViewDelegate{
                func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
                                let model = items[indexPath.row]
                                switch model.medalType {
                                                case .club:
                                                                navigationController?.popToRootViewController(animated: true)
                                                case .communtiy:
                                                                let vc    = YardListVC()
                                                                push(vc: vc)
                                                case .sport:
                                                                var storeModel:HomeStoreModel?
                                                                if let storeStr = UserDefaults.standard.object(forKey: "CurrentStore") as? String{
                                                                                if let deserModel = HomeStoreModel.deserialize(from: storeStr){
                                                                                                storeModel = deserModel
                                                                                }
                                                                }
                                                                let vc = ActivityListVC(cityModel: storeModel)
                                                                push(vc: vc)
                                                case .deepPlayer:
                                                                let vc = CourseExerciseSubListVC()
                                                                push(vc: vc)
                                                case .counter,.winner:
                                                                let vc = WorldCupVC()
                                                                push(vc: vc)
                                                default:break
                                }
                }
}
 
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
                }
}