younger_times
2023-07-14 ca2a4ce89064be715e90ae60dc305c26e7dd5719
WanPai/Root/Activity/VC/ActivitySignupListSubVC.swift
@@ -7,28 +7,31 @@
import UIKit
import JQTools
import RxSwift
import RxCocoa
class ActivitySignupViewModel:RefreshModel<ActivityListModel>{
    var type = BehaviorRelay<SignupType>(value: .all)
    override func api() -> (Observable<BaseResponse<[ActivityListModel]>>)? {
        return Services.queryMyCompetitionList(page: page,pageSize: 20, type: type.value)
    }
}
class ActivitySignupListSubVC: BaseVC {
    var viewModel = ActivitySignupViewModel()
    
    enum SignupType:Int {
        case all = 0
        case ongoing
        case over
        case prepare
        case cancel
    }
    var signupType:SignupType!
    lazy private var tableView:UITableView = {
        let tableView = UITableView(frame: .zero, style: .plain)
    lazy private var tableView:BaseTableView = {
        let tableView = BaseTableView(frame: .zero, style: .plain)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.register(UINib(nibName: "ActivityInfoTCell", bundle: nil), forCellReuseIdentifier: "_ActivityInfoTCell")
        return tableView
    }()
    
    init(type:SignupType) {
        super.init(nibName: nil, bundle: nil)
        self.signupType = type
        viewModel.type.accept(type)
    }
    
    required init?(coder: NSCoder) {
@@ -37,14 +40,15 @@
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .jq_randomColor
        view.backgroundColor = .white
        tableView.jq_setEmptyView()
        viewModel.configure(tableView)
        viewModel.beginRefresh()
    }
    
    override func setUI() {
        view.addSubview(tableView)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.register(UINib(nibName: "ActivityInfoTCell", bundle: nil), forCellReuseIdentifier: "_ActivityInfoTCell")
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
@@ -53,6 +57,7 @@
extension ActivitySignupListSubVC:UITableViewDelegate{
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let model = viewModel.dataSource.value[indexPath.row]
        let vc = ActivitySignupDetailVC()
        push(vc: vc)
    }
@@ -65,6 +70,6 @@
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 5
        return viewModel.dataSource.value.count
    }
}