无故事王国
2024-03-15 7ab2d732db69aed82fa019a5ee6f4b5888cd399a
WanPai/Root/Activity/VC/ActivitySignupListSubVC.swift
@@ -11,75 +11,75 @@
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)
    }
            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()
    lazy private var tableView:BaseTableView = {
        let tableView = BaseTableView(frame: .zero, style: .plain)
        tableView.delegate = self
        tableView.dataSource = self
      tableView.separatorStyle = .none
        tableView.register(UINib(nibName: "ActivityInfoTCell", bundle: nil), forCellReuseIdentifier: "_ActivityInfoTCell")
        return tableView
    }()
    init(type:SignupType) {
        super.init(nibName: nil, bundle: nil)
        viewModel.type.accept(type)
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
            var viewModel = ActivitySignupViewModel()
//        tableView.jq_setEmptyView()
        viewModel.configure(tableView)
        viewModel.beginRefresh()
    }
    override func setUI() {
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
            lazy private var tableView:BaseTableView = {
                        let tableView = BaseTableView(frame: .zero, style: .plain)
                        tableView.delegate = self
                        tableView.dataSource = self
                        tableView.separatorStyle = .none
                        tableView.register(UINib(nibName: "ActivityInfoTCell", bundle: nil), forCellReuseIdentifier: "_ActivityInfoTCell")
                        return tableView
            }()
    override func setRx() {
        NotificationCenter.default.rx.notification(CancelActivitySingup_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self]noti in
            self?.viewModel.beginRefresh()
        }).disposed(by: disposeBag)
    }
            init(type:SignupType) {
                        super.init(nibName: nil, bundle: nil)
                        viewModel.type.accept(type)
            }
            required init?(coder: NSCoder) {
                        fatalError("init(coder:) has not been implemented")
            }
            override func viewDidLoad() {
                        super.viewDidLoad()
                        view.backgroundColor = .white
                        //        tableView.jq_setEmptyView()
                        viewModel.configure(tableView)
                        viewModel.beginRefresh()
            }
            override func setUI() {
                        view.addSubview(tableView)
                        tableView.snp.makeConstraints { make in
                                    make.edges.equalToSuperview()
                        }
            }
            override func setRx() {
                        NotificationCenter.default.rx.notification(CancelActivitySingup_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self]noti in
                                    self?.viewModel.beginRefresh()
                        }).disposed(by: disposeBag)
            }
}
extension ActivitySignupListSubVC:UITableViewDelegate{
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let model = viewModel.dataSource.value[indexPath.row]
        let vc = ActivitySignupDetailVC(id: model.id)
        push(vc: vc)
    }
            func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
                        let model = viewModel.dataSource.value[indexPath.row]
                        let vc = ActivitySignupDetailVC(id: model.id)
                        push(vc: vc)
            }
}
extension ActivitySignupListSubVC:UITableViewDataSource{
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let model = viewModel.dataSource.value[indexPath.row]
        let cell = tableView.dequeueReusableCell(withIdentifier: "_ActivityInfoTCell") as! ActivityInfoTCell
        cell.activityListModel = model
      cell.label_ageScope.isHidden = true
        return cell
    }
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return viewModel.dataSource.value.count
    }
            func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
                        let model = viewModel.dataSource.value[indexPath.row]
                        let cell = tableView.dequeueReusableCell(withIdentifier: "_ActivityInfoTCell") as! ActivityInfoTCell
                        cell.activityListModel = model
                        cell.label_ageScope.isHidden = true
                        return cell
            }
            func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
                        return viewModel.dataSource.value.count
            }
}