MealEvaluateListVC.swift 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // MealEvaluateListVC.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/11/11.
  6. //
  7. import UIKit
  8. import RxCocoa
  9. import RxSwift
  10. class MealEvaluateListVC: ADHBaseVC {
  11. @IBOutlet weak var topCons: NSLayoutConstraint!
  12. @IBOutlet weak var tableView: UITableView!
  13. /// 菜品ID
  14. var mealId : NSNumber?{
  15. didSet{
  16. self.viewModel.getMealEvaluateListModel.mealId = mealId
  17. }
  18. }
  19. let viewModel : EvaluateViewModel = EvaluateViewModel.init()
  20. let diposableBag = DisposeBag()
  21. var dataSource : [NeedEvaluateListModel]?
  22. override func viewDidLoad() {
  23. super.viewDidLoad()
  24. self.topCons.constant = kNavAndStatuHeight + 1
  25. let navStyle = MCNavBarStyle()
  26. navStyle.styleForBackImage = UIImage.init(named: "黑色返回")!
  27. navStyle.styleForTitleColor = UIColor.black
  28. self.navBar = MCNavBarView.init(title: LanguagesUtil.createTextBy(Ctext: "发表评价", Etext: "Comment"), subTitle: nil,style: navStyle)
  29. self.navBar?.backgroundColor = UIColor.white
  30. tableView.register(withType: MealEcaluateCell.self)
  31. self.tableView.mj_header = MJRefreshNormalHeader.init(refreshingBlock: {[unowned self] in
  32. self.getDataList(true)
  33. });
  34. self.tableView.mj_footer = MJRefreshBackNormalFooter.init(refreshingBlock: {[unowned self] in
  35. self.getDataList(true)
  36. });
  37. self.tableView.ly_emptyView = LYEmptyView.emptyActionView(with: UIImage.init(named: "暂无数据"), titleStr: "暂无数据", detailStr: "", btnTitleStr: "点击刷新", btnClick: {[unowned self] in
  38. self.getDataList(true)
  39. })
  40. self.getDataList(true)
  41. }
  42. // MARK: - 获取列表
  43. func getDataList(_ isFirstPage: Bool){
  44. self.hud.showLoading()
  45. self.viewModel.signalGetMealEvaluateList(isFirstPage)?.on(success: { dd in
  46. self.dataSource = self.viewModel.needEvaluateList
  47. self.tableView.reloadData()
  48. self.hud.hidden()
  49. self.tableView.mj_header.endRefreshing()
  50. self.tableView.mj_footer.endRefreshing()
  51. }, error: { error in
  52. self.tableView.mj_header.endRefreshing()
  53. self.tableView.mj_footer.endRefreshing()
  54. self.hud.showFailure(error.msg ?? LanguagesUtil.createTextBy(Ctext: "网络错误", Etext: "network error"))
  55. })
  56. }
  57. }
  58. extension MealEvaluateListVC : UITableViewDelegate,UITableViewDataSource{
  59. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  60. return self.dataSource?.count ?? 0
  61. }
  62. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  63. let cell = tableView.dequeueReusableCell(withIdentifier: "MealEcaluateCell") as! MealEcaluateCell;
  64. let model : NeedEvaluateListModel = self.dataSource![indexPath.row]
  65. cell.configModel(model: model)
  66. return cell
  67. }
  68. func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
  69. return 0.01
  70. }
  71. func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
  72. return 0.01
  73. }
  74. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  75. }
  76. }