| | |
| | | @IBOutlet weak var img_action_2: UIImageView! |
| | | @IBOutlet weak var img_action_3: UIImageView! |
| | | |
| | | private var price:Double = 0 |
| | | private var price:Double? |
| | | |
| | | private var tapType:TapType = .none{ |
| | | didSet{ |
| | |
| | | init(pendingModel:PendingItemModel,type:PaymentOrderType){ |
| | | super.init(nibName: nil, bundle: nil) |
| | | self.pendingModel = pendingModel |
| | | self.businessId = pendingModel.orderId |
| | | self.type = type |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | if let m = pendingModel{ |
| | | |
| | | if self.businessId != nil{ |
| | | self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: btn) |
| | | } |
| | | |
| | | price = m.amount |
| | | image_cover.sd_setImage(with: URL(string: m.coverUrl.components(separatedBy: ",").first?.jq_urlEncoded())) |
| | | label_courseName.text = m.title |
| | |
| | | weakSelf.img_action_1.image = balanceData > 0 ? UIImage(named: "icon_choose_small_s") : UIImage(named: "icon_choose_small_1") |
| | | weakSelf.label_walletBalance.text = "当前可用 ¥\(formattedBalance)" |
| | | |
| | | if balanceData > weakSelf.price { |
| | | if balanceData > weakSelf.price ?? 0 { |
| | | weakSelf.tapType = .t1 |
| | | } |
| | | } else { |
| | |
| | | weakSelf.label_walletBalance.text = "当前可用 0疗愈币" |
| | | weakSelf.tapType = .t1 |
| | | } |
| | | |
| | | if weakSelf.price == 0{ |
| | | weakSelf.tapType = .t1 |
| | | weakSelf.btn_tap0.isUserInteractionEnabled = false |
| | | weakSelf.btn_tap1.isUserInteractionEnabled = false |
| | | weakSelf.btn_tap2.isUserInteractionEnabled = false |
| | | } |
| | | |
| | | }).disposed(by: disposeBag) |
| | | } |
| | | |
| | | |
| | | @IBAction func discountByCoinAction(_ sender: TapBtn) { |
| | | |
| | | guard balance > 0 else {return} |
| | | guard balance >= 0 else {return} |
| | | guard let p = price else{return} |
| | | //是否能全部抵扣 |
| | | let allDiscount = balance > price |
| | | let allDiscount = balance > p |
| | | |
| | | if allDiscount{ |
| | | tapType = .t1 |
| | |
| | | } |
| | | |
| | | @IBAction func chooseAction(_ sender: TapBtn) { |
| | | guard let p = price else{return} |
| | | |
| | | //是否能全部抵扣 |
| | | let allDiscount = balance > price |
| | | let allDiscount = balance > p |
| | | |
| | | switch sender.tag { |
| | | case 2001: |
| | |
| | | } |
| | | |
| | | @IBAction func completeAction(_ sender: UIButton) { |
| | | guard let p = price else{return} |
| | | |
| | | var id:Int = 0 |
| | | var orderId:Int? |
| | |
| | | } |
| | | } |
| | | |
| | | if balance < price && tapType == .t1{ |
| | | alertError(msg: "抵扣余额不足");return |
| | | if tapType == .t1{ |
| | | paymentByCoin(id: id);return |
| | | } |
| | | |
| | | //进行抵扣 |
| | |
| | | discountByCoin = 1 |
| | | } |
| | | |
| | | var payType = 1 |
| | | if tapType == .t1t2 || tapType == .t2{ |
| | | payType = 2 |
| | | } |
| | | |
| | | if tapType == .t1{ |
| | | paymentByCoin(id: id);return |
| | | } |
| | | let payType = (tapType == .t1t2 || tapType == .t2) ?2:1 |
| | | |
| | | Services.placeOrder(orderForm: type, payType: payType, amount: nil, balanceFlag: discountByCoin, orderId: orderId, receiverId: giftUserId, targetId: targetId, vipType: nil).subscribe(onNext: { [weak self] data in |
| | | guard let weakSelf = self else { return } |
| | |
| | | } |
| | | |
| | | private func paymentByCoin(id:Int){ |
| | | guard let p = price else{return} |
| | | |
| | | |
| | | guard balance > price else{ |
| | | CommonAlertView.show(title: "提示", content: "当前余额不足,请先充值", cancelStr: "暂不充值", completeStr: "去充值", isSingle: false) {[weak self] state in |
| | | if state{ |
| | | let vc = WalletRechargeVC() |
| | | self?.push(vc: vc) |
| | | } |
| | | //需要支付 |
| | | if p > 0 { |
| | | if balance < p{ |
| | | alertError(msg: "抵扣余额不足");return |
| | | } |
| | | return |
| | | |
| | | guard balance > p else{ |
| | | CommonAlertView.show(title: "提示", content: "当前余额不足,请先充值", cancelStr: "暂不充值", completeStr: "去充值", isSingle: false) {[weak self] state in |
| | | if state{ |
| | | let vc = WalletRechargeVC() |
| | | self?.push(vc: vc) |
| | | } |
| | | } |
| | | return |
| | | } |
| | | |
| | | } |
| | | |
| | | if businessId != nil{ |
| | |
| | | self?.courseItemModel?.isBuy = .yes |
| | | self?.museModel?.isBuy = .yes |
| | | self?.courseModel?.isBuy = .yes |
| | | let vc = PaymentOrderResultVC(type: weakSelf.type, id: id, price: weakSelf.price) |
| | | let vc = PaymentOrderResultVC(type: weakSelf.type, id: id, price: p) |
| | | self?.push(vc: vc) |
| | | }).disposed(by: disposeBag) |
| | | return |
| | |
| | | self?.courseItemModel?.isBuy = .yes |
| | | self?.museModel?.isBuy = .yes |
| | | self?.courseModel?.isBuy = .yes |
| | | let vc = PaymentOrderResultVC(type: weakSelf.type, id: id, price: weakSelf.price) |
| | | let vc = PaymentOrderResultVC(type: weakSelf.type, id: id, price: p) |
| | | self?.push(vc: vc) |
| | | }).disposed(by: disposeBag) |
| | | } |