支付页面统一副屏逻辑
This commit is contained in:
@@ -14,11 +14,10 @@ import com.sw.dualscreen.ext.gone
|
||||
import com.sw.dualscreen.model.response.FoodInfo
|
||||
import com.sw.dualscreen.model.response.MemberInfo
|
||||
import com.sw.dualscreen.model.response.PaySuccessEvent
|
||||
import com.sw.dualscreen.presentation.pay.ScanQrCodePayPresentation
|
||||
import com.sw.dualscreen.presentation.pay.PayPresentation
|
||||
import com.sw.dualscreen.utils.SPUtil
|
||||
import com.sw.dualscreen.viewmodel.BaseViewModel
|
||||
import com.sw.dualscreen.viewmodel.UserViewModel
|
||||
import com.sw.plate.utils.ToastUtils
|
||||
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
@@ -62,9 +61,19 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
|
||||
var foodOrderId: String = ""
|
||||
var eatNum: Int = 1
|
||||
|
||||
val presentation by lazy {
|
||||
PayPresentation(
|
||||
activity = this@PayActivity,
|
||||
userViewModel = userViewModel,
|
||||
recognizeViewModel = recognizeViewModel,
|
||||
display = displays[1]
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun initialize() {
|
||||
super.initialize()
|
||||
presentation.show()
|
||||
foodInfo = intent.getParcelableExtra(FOOD_INFO)
|
||||
foodOrderId = intent.getStringExtra(FOOD_ORDER_ID) ?: ""
|
||||
eatNum = intent.getIntExtra(FOOD_EAT_NUM, 1)
|
||||
@@ -101,7 +110,6 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
|
||||
}
|
||||
showFacePay()
|
||||
}
|
||||
|
||||
showScanQrCodePay()
|
||||
}
|
||||
|
||||
@@ -136,39 +144,43 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
qrCodePayFragment?.presentation?.dismiss()
|
||||
cashPayFragment?.presentation?.dismiss()
|
||||
numberPayFragment?.presentation?.dismiss()
|
||||
facePayFragment?.presentation?.dismiss()
|
||||
scanQrCodePayPresentation?.dismiss()
|
||||
presentation?.dismiss()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
private var scanQrCodePayPresentation: ScanQrCodePayPresentation? = null
|
||||
var memberInfo: MemberInfo? = null
|
||||
fun showPayInfo(type: Int = 1, isVip: Boolean = false, memberInfo: MemberInfo? = null) {
|
||||
this.memberInfo = memberInfo
|
||||
payResultFragment = PayResultFragment.instance(type, memberInfo)
|
||||
showFragment(payResultFragment!!, TAG_PAY_RESULT)
|
||||
if (displays.size > 1) {
|
||||
scanQrCodePayPresentation = ScanQrCodePayPresentation(
|
||||
activity = this,
|
||||
display = displays[1],
|
||||
type = type
|
||||
) {
|
||||
scanQrCodePayPresentation?.dismiss()
|
||||
}.also {
|
||||
it.foodName = foodInfo?.foodName
|
||||
//确认使用vipPrice 还是 specPrice
|
||||
val onePrice = if (isVip) foodInfo?.vipPrice else foodInfo?.specPrice
|
||||
it.totalPrice = (onePrice ?: 0.0) * eatNum
|
||||
}
|
||||
scanQrCodePayPresentation?.show()
|
||||
// if (displays.size > 1) {
|
||||
// scanQrCodePayPresentation = ScanQrCodePayPresentation(
|
||||
// activity = this,
|
||||
// display = displays[1],
|
||||
// type = type
|
||||
// ) {
|
||||
// scanQrCodePayPresentation?.dismiss()
|
||||
// }.also {
|
||||
// it.foodName = foodInfo?.foodName
|
||||
// //确认使用vipPrice 还是 specPrice
|
||||
// val onePrice = if (isVip) foodInfo?.vipPrice else foodInfo?.specPrice
|
||||
// it.totalPrice = (onePrice ?: 0.0) * eatNum
|
||||
// }
|
||||
// scanQrCodePayPresentation?.show()
|
||||
// }
|
||||
presentation.let {
|
||||
it.type = type
|
||||
it.foodName = foodInfo?.foodName
|
||||
//确认使用vipPrice 还是 specPrice
|
||||
val onePrice = if (isVip) foodInfo?.vipPrice else foodInfo?.specPrice
|
||||
it.totalPrice = (onePrice ?: 0.0) * eatNum
|
||||
presentation.initView()
|
||||
}
|
||||
}
|
||||
|
||||
fun updateQrCodeImage(qrCodeUrl: String?) {
|
||||
scanQrCodePayPresentation?.loadQrCodeImage(qrCodeUrl)
|
||||
// scanQrCodePayPresentation?.loadQrCodeImage(qrCodeUrl)
|
||||
presentation?.loadQrCodeImage(qrCodeUrl)
|
||||
}
|
||||
|
||||
fun showPaySuccess(isVip: Boolean) {
|
||||
|
||||
Reference in New Issue
Block a user