杨锴
2025-04-16 09a372bc45fde16fd42257ab6f78b8deeecf720b
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
//
//  BlackListVC.swift
//  XQMuse
//
//  Created by 无故事王国 on 2024/12/18.
//
 
import UIKit
import RxRelay
import RxSwift
 
let Refresh_Black_Noti = Notification.Name.init("Refresh_Black_Noti")
 
 
class BalckListViewModel:RefreshInnerModel<SimpleUserInfoModel>{
    override func api() -> (Observable<BaseResponse<BaseResponseList<SimpleUserInfoModel>>>)? {
        return Services.blackUserList(pageCurr: page)
    }
}
 
class BlackListVC: BaseVC {
 
    private var tableView:UITableView!
    private var viewModel = BalckListViewModel()
 
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "黑名单"
 
        viewModel.beginRefresh()
    }
 
    override func setUI() {
        tableView = UITableView(frame: .zero,style: .plain)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.separatorStyle = .none
        tableView.register(UINib(nibName: "BlackUserTCell", bundle: nil), forCellReuseIdentifier: "_BlackUserTCell")
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
 
        viewModel.configure(tableView)
 
    }
 
    override func setRx() {
        NotificationCenter.default.rx.notification(Refresh_Black_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in
            self?.viewModel.beginRefresh()
        }).disposed(by: disposeBag)
    }
}
 
extension BlackListVC:UITableViewDelegate{
 
}
 
extension BlackListVC:UITableViewDataSource{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return viewModel.dataSource.value?.list.count ?? 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "_BlackUserTCell", for: indexPath) as! BlackUserTCell
        cell.setModel(viewModel.dataSource.value!.list[indexPath.row])
        return cell
    }
 
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 60
    }
}