// // MealEvaluateListVC.swift // ADHTuanCan // // Created by 敖德亨 on 2023/11/11. // import UIKit import RxCocoa import RxSwift class MealEvaluateListVC: ADHBaseVC { @IBOutlet weak var topCons: NSLayoutConstraint! @IBOutlet weak var tableView: UITableView! /// 菜品ID var mealId : NSNumber?{ didSet{ self.viewModel.getMealEvaluateListModel.mealId = mealId } } let viewModel : EvaluateViewModel = EvaluateViewModel.init() let diposableBag = DisposeBag() var dataSource : [NeedEvaluateListModel]? override func viewDidLoad() { super.viewDidLoad() self.topCons.constant = kNavAndStatuHeight + 1 let navStyle = MCNavBarStyle() navStyle.styleForBackImage = UIImage.init(named: "黑色返回")! navStyle.styleForTitleColor = UIColor.black self.navBar = MCNavBarView.init(title: LanguagesUtil.createTextBy(Ctext: "发表评价", Etext: "Comment"), subTitle: nil,style: navStyle) self.navBar?.backgroundColor = UIColor.white tableView.register(withType: MealEcaluateCell.self) self.tableView.mj_header = MJRefreshNormalHeader.init(refreshingBlock: {[unowned self] in self.getDataList(true) }); self.tableView.mj_footer = MJRefreshBackNormalFooter.init(refreshingBlock: {[unowned self] in self.getDataList(true) }); self.tableView.ly_emptyView = LYEmptyView.emptyActionView(with: UIImage.init(named: "暂无数据"), titleStr: "暂无数据", detailStr: "", btnTitleStr: "点击刷新", btnClick: {[unowned self] in self.getDataList(true) }) self.getDataList(true) } // MARK: - 获取列表 func getDataList(_ isFirstPage: Bool){ self.hud.showLoading() self.viewModel.signalGetMealEvaluateList(isFirstPage)?.on(success: { dd in self.dataSource = self.viewModel.needEvaluateList self.tableView.reloadData() self.hud.hidden() self.tableView.mj_header.endRefreshing() self.tableView.mj_footer.endRefreshing() }, error: { error in self.tableView.mj_header.endRefreshing() self.tableView.mj_footer.endRefreshing() self.hud.showFailure(error.msg ?? LanguagesUtil.createTextBy(Ctext: "网络错误", Etext: "network error")) }) } } extension MealEvaluateListVC : UITableViewDelegate,UITableViewDataSource{ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.dataSource?.count ?? 0 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "MealEcaluateCell") as! MealEcaluateCell; let model : NeedEvaluateListModel = self.dataSource![indexPath.row] cell.configModel(model: model) return cell } func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return 0.01 } func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat { return 0.01 } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { } }