|
|
@@ -32,6 +32,8 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
|
|
|
var time: Long = 0
|
|
|
private var id: String = ""
|
|
|
private var doctorBean: DoctorBean? = null
|
|
|
+ private var orderNo = ""
|
|
|
+ private var paymentQrCodeDialog: PaymentQrCodeDialog? = null
|
|
|
private var purchaseConsultationBean: PurchaseConsultationBean? = null
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
@@ -62,25 +64,7 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
|
|
|
}
|
|
|
|
|
|
override fun initData() {
|
|
|
- val m: Long = 1000
|
|
|
- rxTimer.interval(m) {
|
|
|
- time = 60 * 15 - it - 1
|
|
|
- val minutes = time / 60
|
|
|
- val seconds = time % 60
|
|
|
- binding.tvTime.text = if (minutes > 0) {
|
|
|
- if (seconds > 0) {
|
|
|
- "请在 $minutes 分钟 $seconds 秒内完成支付,超时将取消"
|
|
|
- } else {
|
|
|
- "请在 $minutes 分钟 内完成支付,超时将取消"
|
|
|
- }
|
|
|
- } else {
|
|
|
- "请在 $seconds 秒内完成支付,超时将取消"
|
|
|
- }
|
|
|
- if (it == time - 1) {
|
|
|
- rxTimer.cancel()
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
@@ -146,17 +130,57 @@ class PaymentActivity : BaseMVVMActivity<ActivityPaymentBinding, PaymentViewMode
|
|
|
viewModel.saveConsultation(purchaseConsultationBean!!, fail = {
|
|
|
it.toast()
|
|
|
}, success = {
|
|
|
+ startTimer()
|
|
|
if (it != null) {
|
|
|
- val dialog = PaymentQrCodeDialog()
|
|
|
- dialog.onQueryPaymentStatusListener = {
|
|
|
+ orderNo = it.orderNo
|
|
|
+ paymentQrCodeDialog = PaymentQrCodeDialog()
|
|
|
+ paymentQrCodeDialog?.onQueryPaymentStatusListener = {
|
|
|
RxBus.get().send(RxBusCodes.SuccessfulPurchase)
|
|
|
finish()
|
|
|
}
|
|
|
- dialog.setPaymentQrCodeBean(it.orderNo, it.qrCode)
|
|
|
- dialog.show(supportFragmentManager, "paymentQrCodeDialog")
|
|
|
+ paymentQrCodeDialog?.setPaymentQrCodeBean(it.orderNo, it.qrCode)
|
|
|
+ paymentQrCodeDialog?.show(supportFragmentManager, "paymentQrCodeDialog")
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消支付
|
|
|
+ */
|
|
|
+ private fun delPayOrder() {
|
|
|
+ viewModel.delPayOrder(orderNo, fail = {
|
|
|
+ it.toast()
|
|
|
+ }, success = {
|
|
|
+ if (paymentQrCodeDialog != null && paymentQrCodeDialog?.dialog?.isShowing == true) {
|
|
|
+ paymentQrCodeDialog?.dismiss()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开始计时
|
|
|
+ */
|
|
|
+ private fun startTimer() {
|
|
|
+ val m: Long = 1000
|
|
|
+ rxTimer.interval(m) {
|
|
|
+ time = 60 * 15 * 1 - it - 1
|
|
|
+// val minutes = time / 60
|
|
|
+// val seconds = time % 60
|
|
|
+// binding.tvTime.text = if (minutes > 0) {
|
|
|
+// if (seconds > 0) {
|
|
|
+// "请在 $minutes 分钟 $seconds 秒内完成支付,超时将取消"
|
|
|
+// } else {
|
|
|
+// "请在 $minutes 分钟 内完成支付,超时将取消"
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// "请在 $seconds 秒内完成支付,超时将取消"
|
|
|
+// }
|
|
|
+ if (it == time - 1) {
|
|
|
+ delPayOrder()
|
|
|
+ rxTimer.cancel()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|