| | |
| | | |
| | | 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: "ON_LINE", 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)) |
| | | default:break |
| | | } |
| | | 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! |
| | | } |
| | | self?.tableView.reloadData() |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | 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: "ON_LINE", 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 |
| | | } |
| | | 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 |
| | | } |
| | | } |
| | | let vc = ActivityListVC(cityModel: storeModel) |
| | | push(vc: vc) |
| | | case .deepPlayer: |
| | | let vc = CourseExerciseSubListVC() |
| | | push(vc: vc) |
| | | default:break |
| | | } |
| | | } |
| | | } |
| | | |
| | | extension StudentMentalListVC:UITableViewDataSource{ |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return items.count |
| | | } |
| | | 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 |
| | | } |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_StudentMentalTCell") as! StudentMentalTCell |
| | | cell.mentalInfo = items[indexPath.row] |
| | | return cell |
| | | } |
| | | } |
| | | |