| | |
| | | // |
| | | |
| | | import UIKit |
| | | import RxSwift |
| | | |
| | | let AddressManage_Refresh_Noti = Notification.Name.init("AddressManage_Refresh_Noti") |
| | | |
| | | class AddressManageViewModel:RefreshModel<AddressModel>{ |
| | | override func api() -> (Observable<BaseResponse<[AddressModel]>>)? { |
| | | Services.addressList() |
| | | } |
| | | } |
| | | |
| | | class AddressManageVC: BaseVC { |
| | | |
| | |
| | | |
| | | private var tableView:UITableView! |
| | | private var addressManageType:AddressManageType! |
| | | private var viewModel = AddressManageViewModel() |
| | | |
| | | required init(type:AddressManageType) { |
| | | super.init(nibName: nil, bundle: nil) |
| | |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | |
| | | viewModel.configure(tableView) |
| | | viewModel.beginRefresh() |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | override func setRx() { |
| | | NotificationCenter.default.rx.notification(AddressManage_Refresh_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] _ in |
| | | self?.viewModel.beginRefresh() |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | @objc func handleAction(){ |
| | | let vc = AddressManageHandleVC() |
| | | vc.title = "地址管理" |
| | |
| | | |
| | | extension AddressManageVC:UITableViewDataSource{ |
| | | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
| | | let model = viewModel.dataSource.value[indexPath.row] |
| | | let cell = tableView.dequeueReusableCell(withIdentifier: "_AddressManageTCell") as! AddressManageTCell |
| | | cell.addressModel = model |
| | | cell.isFist = indexPath.row == 0 |
| | | cell.isLast = indexPath.row == 9 |
| | | cell.isDefault(indexPath.row == 0) |
| | | cell.isLast = indexPath.row == viewModel.dataSource.value.count - 1 |
| | | |
| | | cell.btn_edit.isHidden = addressManageType == .choose |
| | | cell.btn_delete.isHidden = addressManageType == .choose |
| | |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
| | | return 10 |
| | | return viewModel.dataSource.value.count |
| | | } |
| | | |
| | | func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |