|
|
@@ -8,6 +8,7 @@ import android.view.ViewGroup
|
|
|
import androidx.appcompat.widget.AppCompatButton
|
|
|
import androidx.appcompat.widget.AppCompatImageView
|
|
|
import androidx.appcompat.widget.AppCompatTextView
|
|
|
+import androidx.constraintlayout.widget.ConstraintLayout
|
|
|
import androidx.fragment.app.DialogFragment
|
|
|
import com.bumptech.glide.Glide
|
|
|
import com.google.zxing.common.BitmapUtils
|
|
|
@@ -16,9 +17,11 @@ import com.gyf.immersionbar.ktx.immersionBar
|
|
|
import com.yingyang.healthconsultation.R
|
|
|
import com.yingyang.healthconsultation.net.HealthConsultationsServiceFactory
|
|
|
import com.yingyangfly.baselib.ext.setOnSingleClickListener
|
|
|
+import com.yingyangfly.baselib.ext.show
|
|
|
import com.yingyangfly.baselib.ext.toast
|
|
|
import com.yingyangfly.baselib.net.BaseObserver
|
|
|
import com.yingyangfly.baselib.net.MyRxScheduler
|
|
|
+import com.yingyangfly.baselib.utils.RxTimer
|
|
|
import com.yingyangfly.baselib.utils.ViewTool
|
|
|
import gorden.rxbus2.RxBus
|
|
|
import io.reactivex.schedulers.Schedulers
|
|
|
@@ -28,8 +31,10 @@ class PaymentQrCodeDialog : DialogFragment() {
|
|
|
private var orderNo = ""
|
|
|
private var qrCode = ""
|
|
|
private var method = ""
|
|
|
-
|
|
|
- private var purchaseServicesBtn: AppCompatTextView? = null
|
|
|
+ private lateinit var rxTimer: RxTimer
|
|
|
+ var time: Long = 0
|
|
|
+ private var tvCountdown: AppCompatTextView? = null
|
|
|
+ private var purchaseServicesBtn: ConstraintLayout? = null
|
|
|
private var payImage: AppCompatImageView? = null
|
|
|
private var paySuccessBtn: AppCompatButton? = null
|
|
|
private var imageClose: AppCompatImageView? = null
|
|
|
@@ -76,6 +81,7 @@ class PaymentQrCodeDialog : DialogFragment() {
|
|
|
|
|
|
private fun findId(rootView: View) {
|
|
|
purchaseServicesBtn = rootView.findViewById(R.id.purchaseServicesBtn)
|
|
|
+ tvCountdown = rootView.findViewById(R.id.tvCountdown)
|
|
|
payImage = rootView.findViewById(R.id.payImage)
|
|
|
paySuccessBtn = rootView.findViewById(R.id.paySuccessBtn)
|
|
|
imageClose = rootView.findViewById(R.id.imageClose)
|
|
|
@@ -101,12 +107,42 @@ class PaymentQrCodeDialog : DialogFragment() {
|
|
|
}
|
|
|
|
|
|
private fun init() {
|
|
|
+ rxTimer = RxTimer()
|
|
|
if (qrCode.isEmpty().not()) {
|
|
|
val bitmap = BitmapUtils.create2DCode(qrCode)
|
|
|
if (bitmap != null) {
|
|
|
Glide.with(this).load(bitmap).into(payImage!!)
|
|
|
}
|
|
|
}
|
|
|
+ startTimer()
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开始倒计时
|
|
|
+ */
|
|
|
+ private fun startTimer() {
|
|
|
+ val m: Long = 1000
|
|
|
+ rxTimer.interval(m) {
|
|
|
+ time = 60 * 15 * 1 - it - 1
|
|
|
+ val minutes = time / 60
|
|
|
+ val seconds = time % 60
|
|
|
+ if (it == time - 1) {
|
|
|
+ rxTimer.cancel()
|
|
|
+ tvCountdown?.show(false)
|
|
|
+ delPayOrder()
|
|
|
+ } else {
|
|
|
+ tvCountdown?.show(true)
|
|
|
+ tvCountdown?.text = if (minutes > 0) {
|
|
|
+ if (seconds > 0) {
|
|
|
+ "支付倒计时:$minutes 分钟 $seconds 秒"
|
|
|
+ } else {
|
|
|
+ "支付倒计时:$minutes 分钟"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ "支付倒计时:$seconds 秒消"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|