fix
无故事王国
2024-02-28 4468d9f9b3b8c70597f04e5f1ecb61118c404d2c
WanPai/Root/Games/VC/GamesSubListVC.swift
@@ -10,93 +10,93 @@
import RxSwift
enum GamesSubType:Int{
   case offline = 0
   case crossMatch = 1
   case accuracyMatch = 2
            case offline = 0
            case crossMatch = 1
            case accuracyMatch = 2
}
class GamesOffLineViewModel:RefreshModel<GameListModel>{
   let spaceId = BehaviorRelay<Int>(value: 0)
   let sutuId = BehaviorRelay<Int>(value: 0)
   let storeId = BehaviorRelay<Int>(value: 0)
            let spaceId = BehaviorRelay<Int>(value: 0)
            let sutuId = BehaviorRelay<Int>(value: 0)
            let storeId = BehaviorRelay<Int>(value: 0)
   override func api() -> (Observable<BaseResponse<[GameListModel]>>)? {
      return Services.game_gameList(spaceId: spaceId.value, storeId: storeId.value)
   }
            override func api() -> (Observable<BaseResponse<[GameListModel]>>)? {
                        return Services.game_gameList(spaceId: spaceId.value, storeId: storeId.value)
            }
}
class GamesSubListVC: BaseVC {
   private var type:GamesSubType!
   private var model:QRCodeModel!
            private var type:GamesSubType!
            private var model:QRCodeModel!
   private let offLineViewModel = GamesOffLineViewModel()
   private var homeStoreModel:HomeStoreModel!
   private var tableView:BaseTableView!
            private let offLineViewModel = GamesOffLineViewModel()
            private var homeStoreModel:HomeStoreModel!
            private var tableView:BaseTableView!
   init(type:GamesSubType,model:QRCodeModel) {
      super.init(nibName: nil, bundle: nil)
      self.type = type
      self.model = model
   }
   required init?(coder: NSCoder) {
      fatalError("init(coder:) has not been implemented")
   }
    override func viewDidLoad() {
        super.viewDidLoad()
      if let storeStr = UserDefaults.standard.object(forKey: "CurrentStore") as? String{
         if let deserModel = HomeStoreModel.deserialize(from: storeStr){
            offLineViewModel.storeId.accept(deserModel.storeId)
            if type == .offline{
               offLineViewModel.spaceId.accept(model.space_id!)
               offLineViewModel.sutuId.accept(model.sutu_id!)
               offLineViewModel.configure(tableView, needMore: false)
               offLineViewModel.beginRefresh()
            init(type:GamesSubType,model:QRCodeModel) {
                        super.init(nibName: nil, bundle: nil)
                        self.type = type
                        self.model = model
            }
         }
      }
    }
   override func setUI() {
      tableView = BaseTableView(frame: .zero, style: .plain)
      tableView.delegate = self
      tableView.dataSource = self
      tableView.register(UINib(nibName: "GamesTCell", bundle: nil), forCellReuseIdentifier: "_GamesTCell")
      view.addSubview(tableView)
      tableView.snp.makeConstraints { make in
         make.edges.equalToSuperview()
      }
            required init?(coder: NSCoder) {
                        fatalError("init(coder:) has not been implemented")
            }
//      tableView.jq_setEmptyView()
   }
            override func viewDidLoad() {
                        super.viewDidLoad()
                        if let storeStr = UserDefaults.standard.object(forKey: "CurrentStore") as? String{
                                    if let deserModel = HomeStoreModel.deserialize(from: storeStr){
                                                offLineViewModel.storeId.accept(deserModel.storeId)
                                                if type == .offline{
                                                            offLineViewModel.spaceId.accept(model.space_id!)
                                                            offLineViewModel.sutuId.accept(model.sutu_id!)
                                                            offLineViewModel.configure(tableView, needMore: false)
                                                            offLineViewModel.beginRefresh()
                                                }
                                    }
                        }
            }
            override func setUI() {
                        tableView = BaseTableView(frame: .zero, style: .plain)
                        tableView.delegate = self
                        tableView.dataSource = self
                        tableView.register(UINib(nibName: "GamesTCell", bundle: nil), forCellReuseIdentifier: "_GamesTCell")
                        view.addSubview(tableView)
                        tableView.snp.makeConstraints { make in
                                    make.edges.equalToSuperview()
                        }
                        //      tableView.jq_setEmptyView()
            }
}
extension GamesSubListVC:UITableViewDelegate{
}
extension GamesSubListVC:UITableViewDataSource{
   func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: "_GamesTCell") as! GamesTCell
      if type == .offline{
         cell.gameListModel = offLineViewModel.dataSource.value[indexPath.row]
         cell.QRCodeModel = model
         cell.spaceId = offLineViewModel.spaceId.value
         cell.storeId = offLineViewModel.storeId.value
         cell.sutuId = offLineViewModel.sutuId.value
      }
      return cell
   }
                        let cell = tableView.dequeueReusableCell(withIdentifier: "_GamesTCell") as! GamesTCell
                        if type == .offline{
                                    cell.gameListModel = offLineViewModel.dataSource.value[indexPath.row]
                                    cell.QRCodeModel = model
                                    cell.spaceId = offLineViewModel.spaceId.value
                                    cell.storeId = offLineViewModel.storeId.value
                                    cell.sutuId = offLineViewModel.sutuId.value
                        }
                        return cell
            }
   func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
      return 212
   }
            func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
                        return 212
            }
   func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
      return offLineViewModel.dataSource.value.count
   }
            func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
                        return offLineViewModel.dataSource.value.count
            }
}