r
15 小时以前 8c309ff419690cc77c9b178096878e18d4849fc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//
//  GamesTCell.swift
//  WanPai
//
//  Created by 无故事王国 on 2023/9/15.
//
 
import UIKit
import RxSwift
import RxRelay
import JQTools
 
class GamesTCell: UITableViewCell {
 
                var disposeBag = DisposeBag()
 
                @IBOutlet weak var img_icon: UIImageView!
                var QRCodeModel:QRCodeModel!
                var spaceId = 0
                var sutuId = 0
                var storeId = 0
 
                var gameListModel:GameListModel!{
                                didSet{
                                                img_icon.sd_setImage(with: URL(string: gameListModel.img))
                                }
                }
 
                override func awakeFromNib() {
                                super.awakeFromNib()
                                selectionStyle = .none
                                contentView.layer.masksToBounds = false
                }
 
                @IBAction func intruduceAction(_ sender: UIButton) {
                                GamesIntruduceView.show(url: gameListModel.video, content: gameListModel.intro)
                }
 
                @IBAction func launchGameAction(_ sender: UIButton) {
                                GamesPayView.show(price: gameListModel.cash, coin: gameListModel.playCoin,integral: gameListModel.integral) {[weak self] () in
                                                guard let weakSelf = self else { return }
                                                PaymentView.show(enumType:.game,money: (ali: weakSelf.gameListModel.cash, wx: weakSelf.gameListModel.cash, coin: weakSelf.gameListModel.playCoin, course: nil,integral:weakSelf.gameListModel.integral)) { [weak self] payType in
                                                                guard let weakSelf = self else { return }
                Services.payGame(configId: weakSelf.gameListModel.id, gameId: weakSelf.gameListModel.gameId, spaceId: weakSelf.spaceId, sutuId: weakSelf.sutuId, type: payType,gameType: weakSelf.gameListModel.gameType).subscribe(onNext: {data in
                                                                                if let m = data.data{
 
                                                                                                if m.isStaff{
                                                                                                                let vc = PaymentResultVC(result: .success, objType: .games)
                                                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                                                                return
                                                                                                }
 
                                                                                                switch payType {
                                                                                                                case .wechat:
                                                                                                                                YYPaymentManager.shared.sendPaymentRequest(YYWeChatPayRequest(partnerId: m.partnerid, prepayId: m.prepayid, package: m.package, nonceStr: m.noncestr, timeStamp: m.timestamp, sign: m.sign)) { result in
                                                                                                                                                switch result {
                                                                                                                                                                case .success:
                                                                                                                                                                                let vc = PaymentResultVC(result: .success, objType: .games)
                                                                                                                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                                                                                                                case .cancel:alert(msg: "支付已取消")
                                                                                                                                                                case .failure(_):
                                                                                                                                                                                let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .games)
                                                                                                                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                                                                                                }
                                                                                                                                }
 
                                                                                                                case .aliPay:
                                                                                                                                YYPaymentManager.shared.sendPaymentRequest(YYAlipayRequest(orderString: data.data?.orderString ?? "")) { result in
                                                                                                                                                switch result {
                                                                                                                                                                case .success:
                                                                                                                                                                                let vc = PaymentResultVC(result: .success, objType: .games)
                                                                                                                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                                                                                                                case .cancel:alert(msg: "支付已取消")
                                                                                                                                                                case .failure(_):
                                                                                                                                                                                let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .games)
                                                                                                                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                                                                                                }
                                                                                                                                }
                                                                                                                default:
                                                                                                                                let vc = PaymentResultVC(result: .success, objType: .games)
                                                                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                                                }
                                                                                }
                                                                }) { error in
                                                                                if let er = error as? NetworkRequest.NetRequestError{
                                                                                                switch er {
                                                                                                                case .Other(let code,let string):
                                                                                                                                let vc = PaymentResultVC(result: .fail(string,code), objType: .games)
                                                                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                                                                default:
                                                                                                                                let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .games)
                                                                                                                                JQ_currentViewController().jq_push(vc: vc)
                                                                                                }
                                                                                }
                                                                }.disposed(by: weakSelf.disposeBag)
                                                }
                                }
 
                                //        Services.userDetails().subscribe(onNext: {[weak self] data in
                                //            guard let weakSelf = self else { return }
                                //            if let model = data.data{
                                //                Services.game_gameStart(gameId: weakSelf.gameListModel.id, spaceId: weakSelf.QRCodeModel.space_id!, sutuId: weakSelf.QRCodeModel.sutu_id!, userID: model.userId).subscribe(onNext: { _ in
                                //                    alertSuccess(msg: "启动成功")
                                //                }) { error in
                                //
                                //                }.disposed(by: weakSelf.disposeBag)
                                //            }
                                //        }).disposed(by: disposeBag)
 
                }
}