| | |
| | | let StartGame_Noti = Notification.Name.init("StartGame_Noti") |
| | | |
| | | struct QRCodeModel:HandyJSON { |
| | | // var scan_type:ScanType? //扫码类型:1000:游戏,10001:课程 |
| | | var space_id:String? //场地ID |
| | | var sutu_id:String? //设备ID |
| | | var course_id:Int? //课程ID |
| | | var scan_type:ScanType? //扫码类型 |
| | | var space_id:Int? //场地ID |
| | | var sutu_id:Int? //设备ID |
| | | var id:Int? //课程/场地/游戏 |
| | | } |
| | | |
| | | class GamesVC: BaseVC { |
| | | |
| | | private var codeModel:QRCodeModel! |
| | | |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | title = "智慧球场" |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | override func setRx() { |
| | | NotificationCenter.default.rx.notification(StartGame_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] noti in |
| | | guard let weakSelf = self else { return } |
| | | if let gameId = noti.object as? Int{ |
| | | Services.userDetails().subscribe(onNext: {[weak self] data in |
| | | guard let weakSelf = self else { return } |
| | | if let model = data.data{ |
| | | Services.game_gameStart(gameId: gameId, spaceId: weakSelf.codeModel.space_id!, sutuId: weakSelf.codeModel.sutu_id!, userID: model.userId).subscribe(onNext: { _ in |
| | | alertSuccess(msg: "启动成功") |
| | | }) { error in |
| | | |
| | | }.disposed(by: weakSelf.disposeBag) |
| | | } |
| | | }).disposed(by: weakSelf.disposeBag) |
| | | } |
| | | }).disposed(by: disposeBag) |
| | | // NotificationCenter.default.rx.notification(StartGame_Noti).take(until: self.rx.deallocated).subscribe(onNext: {[weak self] noti in |
| | | // guard let weakSelf = self else { return } |
| | | // if let gameId = noti.object as? Int{ |
| | | // Services.userDetails().subscribe(onNext: {[weak self] data in |
| | | // guard let weakSelf = self else { return } |
| | | // if let model = data.data{ |
| | | // Services.game_gameStart(gameId: gameId, spaceId: weakSelf.codeModel.space_id!, sutuId: weakSelf.codeModel.sutu_id!, userID: model.userId).subscribe(onNext: { _ in |
| | | // alertSuccess(msg: "启动成功") |
| | | // }) { error in |
| | | // |
| | | // }.disposed(by: weakSelf.disposeBag) |
| | | // } |
| | | // }).disposed(by: weakSelf.disposeBag) |
| | | // } |
| | | // }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | @IBAction func scanAction(_ sender: UIButton) { |