| | |
| | | // |
| | | |
| | | import UIKit |
| | | import RxSwift |
| | | import RxDataSources |
| | | |
| | | class NoticeCenterViewModel:RefreshInnerModel<NoticeModel>{ |
| | | override func api() -> (Observable<BaseResponse<BaseResponseList<NoticeModel>>>)? { |
| | | return Services.noticeList(page: page, pageSize: 20) |
| | | } |
| | | } |
| | | |
| | | class NoticeCenterVC: BaseVC { |
| | | |
| | | private var tableView:UITableView! |
| | | private var viewModel = NoticeCenterViewModel() |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "消息通知" |
| | | |
| | | viewModel.configure(tableView) |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | override func setUI() { |
| | |
| | | extension NoticeCenterVC:UITableViewDelegate & UITableViewDataSource{ |
| | | |
| | | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
| | | if indexPath.row == 0{ |
| | | let vc = NoticeCenterSysDetailVC() |
| | | push(vc: vc) |
| | | } |
| | | let model = viewModel.dataSource.value!.list[indexPath.row] |
| | | model.readStatus = 2 |
| | | tableView.reloadRows(at: [indexPath], with: .none) |
| | | |
| | | if indexPath.row == 1{ |
| | | let vc = NoticeCenterUserRepeaceDetailVC() |
| | | push(vc: vc) |
| | | } |
| | | Services.noticeDetailId(model.id).subscribe(onNext: {data in |
| | | if let m = data.data{ |
| | | if model.noticeType == 1{ |
| | | let vc = NoticeCenterSysDetailVC(m) |
| | | self.push(vc: vc) |
| | | } |
| | | |
| | | if model.noticeType == 2{ |
| | | let vc = NoticeCenterUserRepeaceDetailVC(m) |
| | | self.push(vc: vc) |
| | | } |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | |
| | | |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let model = viewModel.dataSource.value!.list[indexPath.row] |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_MessageTCell", for: indexPath) as! MessageTCell |
| | | cell.backgroundColor = .clear |
| | | cell.setNoticeModel(model) |
| | | return cell |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return 10 |
| | | return viewModel.dataSource.value?.list.count ?? 0 |
| | | } |
| | | |
| | | |