r
昨天 8c309ff419690cc77c9b178096878e18d4849fc2
WanPai/Root/CardCenter/View/CardCenterSheetView.swift
@@ -187,6 +187,10 @@
    @IBAction func closeAction(_ sender: UIButton) {
        dimissAlert()
    }
    func dimissAlert(){
        NotificationCenter.default.removeObserver(self)
        self.cons_bottom.constant = -(JQ_ScreenW * 1.1)
@@ -225,64 +229,75 @@
        updatePrice()
        let studentIds = selectStudents.map({"\($0.stuId)"}).joined(separator: ",")
        if totalMoney == 0 {
            Services.payHuiminCard(id: m.id, payType: PayType.coin, studentIds: studentIds).subscribe(onNext: { data in
                if  data.code == 200 {
                    self.dimissAlert()
                    let vc = PaymentResultVC(result: .success, objType: .huimin)
                    JQ_currentViewController().jq_push(vc: vc)
                }
            }).disposed(by: self.disposeBag)
        }else {
            PaymentView.show(enumType: .huiminCard, money: (ali: totalMoney, wx: totalMoney, coin: nil, course: nil, integral: nil)) {[unowned self] type in
                Services.payHuiminCard(id: m.id, payType: type, studentIds: studentIds).subscribe(onNext: { data in
                    if let m = data.data{
        PaymentView.show(enumType: .huiminCard, money: (ali: totalMoney, wx: totalMoney, coin: nil, course: nil, integral: nil)) {[unowned self] type in
            Services.payHuiminCard(id: m.id, payType: type, studentIds: studentIds).subscribe(onNext: { data in
                if let m = data.data{
                    self.cons_bottom.constant = -(JQ_ScreenW * 1.1)
                    UIView.animate(withDuration: 0.4) {
                        self.alpha = 0
                        self.layoutIfNeeded()
                    } completion: { _ in
                        self.removeFromSuperview()
                        switch type {
                            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: .huimin)
                                            JQ_currentViewController().jq_push(vc: vc)
                                        case .cancel:
                                            let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .huimin) {[unowned self] in
                                                self.buyNowAction(self.btn_buyment)
                                            }
                                            JQ_currentViewController().jq_push(vc: vc)
                                        case .failure(_):
                                            let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .huimin){[unowned self] in
                                                self.buyNowAction(self.btn_buyment)
                                            }
                                            JQ_currentViewController().jq_push(vc: vc)
                        self.cons_bottom.constant = -(JQ_ScreenW * 1.1)
                        UIView.animate(withDuration: 0.4) {
                            self.alpha = 0
                            self.layoutIfNeeded()
                        } completion: { _ in
                            self.removeFromSuperview()
                            switch type {
                                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: .huimin)
                                                JQ_currentViewController().jq_push(vc: vc)
                                            case .cancel:
                                                let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .huimin) {[unowned self] in
                                                    self.buyNowAction(self.btn_buyment)
                                                }
                                                JQ_currentViewController().jq_push(vc: vc)
                                            case .failure(_):
                                                let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .huimin){[unowned self] in
                                                    self.buyNowAction(self.btn_buyment)
                                                }
                                                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: .huimin)
                                            JQ_currentViewController().jq_push(vc: vc)
                                        case .cancel:
                                            let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .huimin) {[unowned self] in
                                                self.buyNowAction(self.btn_buyment)
                                            }
                                            JQ_currentViewController().jq_push(vc: vc)
                                        case .failure(_):
                                            let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .huimin){[unowned self] in
                                                self.buyNowAction(self.btn_buyment)
                                            }
                                            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: .huimin)
                                                JQ_currentViewController().jq_push(vc: vc)
                                            case .cancel:
                                                let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .huimin) {[unowned self] in
                                                    self.buyNowAction(self.btn_buyment)
                                                }
                                                JQ_currentViewController().jq_push(vc: vc)
                                            case .failure(_):
                                                let vc = PaymentResultVC(result: .fail("支付失败",0), objType: .huimin){[unowned self] in
                                                    self.buyNowAction(self.btn_buyment)
                                                }
                                                JQ_currentViewController().jq_push(vc: vc)
                                        }
                                    }
                                }
                            default:
                                let vc = PaymentResultVC(result: .success, objType: .huimin)
                                JQ_currentViewController().jq_push(vc: vc)
                                default:
                                    let vc = PaymentResultVC(result: .success, objType: .huimin)
                                    JQ_currentViewController().jq_push(vc: vc)
                            }
                        }
                    }
                }
            }).disposed(by: self.disposeBag)
                }).disposed(by: self.disposeBag)
            }
        }
    }
    override func layoutSubviews() {