添加微信小程序支付
This commit is contained in:
parent
d8ac807fdb
commit
1e39df6961
|
|
@ -20,8 +20,8 @@ android {
|
||||||
applicationId "com.cheng.BoLe"
|
applicationId "com.cheng.BoLe"
|
||||||
minSdk 26
|
minSdk 26
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 260
|
versionCode 270
|
||||||
versionName "2.6.0"
|
versionName "2.7.0"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
|
|
@ -180,6 +180,8 @@ dependencies {
|
||||||
implementation 'com.tencent.vasdolly:helper:3.0.4' //腾讯分包
|
implementation 'com.tencent.vasdolly:helper:3.0.4' //腾讯分包
|
||||||
implementation files('libs/humesdk-1.0.0.aar') //巨量分包
|
implementation files('libs/humesdk-1.0.0.aar') //巨量分包
|
||||||
|
|
||||||
|
implementation 'com.bytedance.ads:AppConvert:2.0.0' //巨量融合归因
|
||||||
|
|
||||||
implementation 'com.getui:gysdk:3.1.7.0' //一键认证sdk
|
implementation 'com.getui:gysdk:3.1.7.0' //一键认证sdk
|
||||||
implementation 'com.getui:gtsdk:3.3.8.0' // 推送sdk
|
implementation 'com.getui:gtsdk:3.3.8.0' // 推送sdk
|
||||||
implementation 'com.getui:gtc:3.2.16.0' //个推公共库,如已接其他个推sdk则保留一个最高版本即可
|
implementation 'com.getui:gtc:3.2.16.0' //个推公共库,如已接其他个推sdk则保留一个最高版本即可
|
||||||
|
|
|
||||||
|
|
@ -18,4 +18,6 @@ class VipGoodsEntity: Serializable {
|
||||||
var member_limit: String = ""
|
var member_limit: String = ""
|
||||||
var member_price: String = ""
|
var member_price: String = ""
|
||||||
var origin_member_price: String = ""
|
var origin_member_price: String = ""
|
||||||
|
|
||||||
|
var weixinMpOriId = ""
|
||||||
}
|
}
|
||||||
|
|
@ -6,11 +6,13 @@ import android.graphics.Color
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.text.TextUtils
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.cheng.blzb.R
|
import com.cheng.blzb.R
|
||||||
|
|
@ -22,6 +24,7 @@ import com.cheng.blzb.databinding.DialogBuySeatBinding
|
||||||
import com.cheng.blzb.event.PayStatusEnum
|
import com.cheng.blzb.event.PayStatusEnum
|
||||||
import com.cheng.blzb.event.PayStatusEvent
|
import com.cheng.blzb.event.PayStatusEvent
|
||||||
import com.cheng.blzb.event.PaySuccessEvent
|
import com.cheng.blzb.event.PaySuccessEvent
|
||||||
|
import com.cheng.blzb.manager.DialogEnum
|
||||||
import com.cheng.blzb.manager.EventReportManager
|
import com.cheng.blzb.manager.EventReportManager
|
||||||
import com.cheng.blzb.manager.LoginManager
|
import com.cheng.blzb.manager.LoginManager
|
||||||
import com.cheng.blzb.manager.UserConfigManager
|
import com.cheng.blzb.manager.UserConfigManager
|
||||||
|
|
@ -41,6 +44,9 @@ import com.google.gson.JsonObject
|
||||||
import com.tencent.mm.opensdk.openapi.IWXAPI
|
import com.tencent.mm.opensdk.openapi.IWXAPI
|
||||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory
|
import com.tencent.mm.opensdk.openapi.WXAPIFactory
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.cancel
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
|
|
@ -60,6 +66,11 @@ class BuySeatDialog : DialogFragment() {
|
||||||
|
|
||||||
private var payStatusDisposable: Disposable? = null
|
private var payStatusDisposable: Disposable? = null
|
||||||
|
|
||||||
|
//是否显示订单支付结果查询提示
|
||||||
|
private var showQueryTip = false
|
||||||
|
|
||||||
|
var queryOrderJob: Job? = null
|
||||||
|
|
||||||
private var mOnBackListener: (() -> Unit)? = null //回调事件
|
private var mOnBackListener: (() -> Unit)? = null //回调事件
|
||||||
|
|
||||||
private lateinit var binding: DialogBuySeatBinding
|
private lateinit var binding: DialogBuySeatBinding
|
||||||
|
|
@ -73,10 +84,13 @@ class BuySeatDialog : DialogFragment() {
|
||||||
windowParams?.gravity = Gravity.BOTTOM
|
windowParams?.gravity = Gravity.BOTTOM
|
||||||
windowParams?.windowAnimations = R.style.dialog_bottom
|
windowParams?.windowAnimations = R.style.dialog_bottom
|
||||||
dialog?.window?.attributes = windowParams
|
dialog?.window?.attributes = windowParams
|
||||||
|
|
||||||
|
showQueryTipDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||||
|
isCancelable = false
|
||||||
return super.onCreateView(inflater, container, savedInstanceState)
|
return super.onCreateView(inflater, container, savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -166,7 +180,11 @@ class BuySeatDialog : DialogFragment() {
|
||||||
return@onClick
|
return@onClick
|
||||||
}
|
}
|
||||||
if (payType == 0) {
|
if (payType == 0) {
|
||||||
|
if (!TextUtils.isEmpty(goodsEntity!!.weixinMpOriId)) {
|
||||||
|
payCreateOrder("combo")
|
||||||
|
} else {
|
||||||
payCreateOrder("weixin")
|
payCreateOrder("weixin")
|
||||||
|
}
|
||||||
} else if (payType == 1) {
|
} else if (payType == 1) {
|
||||||
payCreateOrder("alipay")
|
payCreateOrder("alipay")
|
||||||
}
|
}
|
||||||
|
|
@ -182,13 +200,7 @@ class BuySeatDialog : DialogFragment() {
|
||||||
payStatusDisposable = RxBus.defaultInstance.toObservable(PayStatusEvent::class.java).subscribe {
|
payStatusDisposable = RxBus.defaultInstance.toObservable(PayStatusEvent::class.java).subscribe {
|
||||||
when (it.payStatus) {
|
when (it.payStatus) {
|
||||||
PayStatusEnum.PAY_SUCCESS -> {
|
PayStatusEnum.PAY_SUCCESS -> {
|
||||||
toast("支付成功")
|
getOrderInfo(orderEntity!!.orderId)
|
||||||
EventReportManager.eventReport(
|
|
||||||
EventConstants.PAY_SUCCESS,
|
|
||||||
if (payType == 0) "weixin" else "alipay",
|
|
||||||
"{orderId:${orderEntity?.orderId}, meal:${Gson().toJson(goodsEntity)}}"
|
|
||||||
)
|
|
||||||
RxBus.defaultInstance.post(PaySuccessEvent())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PayStatusEnum.PAY_CANCEL -> {
|
PayStatusEnum.PAY_CANCEL -> {
|
||||||
|
|
@ -221,7 +233,12 @@ class BuySeatDialog : DialogFragment() {
|
||||||
if (response.status) {
|
if (response.status) {
|
||||||
orderEntity = response.data
|
orderEntity = response.data
|
||||||
if (this@BuySeatDialog.payType == 0) {
|
if (this@BuySeatDialog.payType == 0) {
|
||||||
|
if (!TextUtils.isEmpty(goodsEntity?.weixinMpOriId)) {
|
||||||
|
PayUtils.toWXMPPay(requireActivity(), orderEntity!!.outTradeNo, goodsEntity!!.weixinMpOriId)
|
||||||
|
showQueryTip = true
|
||||||
|
} else {
|
||||||
PayUtils.toWXPay(requireActivity(), response.data)
|
PayUtils.toWXPay(requireActivity(), response.data)
|
||||||
|
}
|
||||||
} else if (this@BuySeatDialog.payType == 1) {
|
} else if (this@BuySeatDialog.payType == 1) {
|
||||||
PayUtils.toAliPay(requireActivity(), response.data.payParam, "")
|
PayUtils.toAliPay(requireActivity(), response.data.payParam, "")
|
||||||
}
|
}
|
||||||
|
|
@ -234,23 +251,63 @@ class BuySeatDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getOrderInfo(orderId: String) {
|
||||||
|
loadingDialog.show()
|
||||||
|
loadingDialog.setMessage("支付结果查询中")
|
||||||
|
cancelJob()
|
||||||
|
queryOrderJob = lifecycleScope.launch {
|
||||||
|
try {
|
||||||
|
repeat(10) {
|
||||||
|
val response = ApiFactory.apiService.getOrderInfo(orderId)
|
||||||
|
if (response.status) {
|
||||||
|
if (response.data.status == "2") {
|
||||||
|
toast("支付成功")
|
||||||
|
EventReportManager.eventReport(
|
||||||
|
EventConstants.PAY_SUCCESS,
|
||||||
|
if (payType == 0) "weixin" else "alipay",
|
||||||
|
"{orderId:${orderEntity?.orderId}, meal:${Gson().toJson(goodsEntity)}}"
|
||||||
|
)
|
||||||
|
RxBus.defaultInstance.post(PaySuccessEvent())
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
delay(2000)
|
||||||
|
} else {
|
||||||
|
loadingDialog.dismiss()
|
||||||
|
toast(response.message, true)
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
loadingDialog.dismiss()
|
||||||
|
L.d(e)
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cancelJob() {
|
||||||
|
queryOrderJob?.cancel()
|
||||||
|
queryOrderJob = null
|
||||||
|
}
|
||||||
|
|
||||||
private fun releasePayType() {
|
private fun releasePayType() {
|
||||||
val list = goodsEntity?.pay_type?.split(",")?.map { it.trim() }?.toList()
|
val list = goodsEntity?.pay_type?.split(",")?.map { it.trim() }?.toList()
|
||||||
if (list?.find { it == "alipay" } != null) {
|
val globalPayType = UserConfigManager.getPayType()
|
||||||
|
if (list?.find { it == "alipay" } != null && globalPayType.find { it == "alipay" } != null) {
|
||||||
binding.tvAliPay.visible()
|
binding.tvAliPay.visible()
|
||||||
} else {
|
} else {
|
||||||
binding.tvAliPay.gone()
|
binding.tvAliPay.gone()
|
||||||
}
|
}
|
||||||
if (list?.find { it == "weixin" } != null) {
|
if (list?.find { it == "weixin" } != null && globalPayType.find { it == "weixin" } != null) {
|
||||||
binding.tvWxPay.visible()
|
binding.tvWxPay.visible()
|
||||||
} else {
|
} else {
|
||||||
binding.tvWxPay.gone()
|
binding.tvWxPay.gone()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (goodsEntity?.pay_type!!.startsWith("weixin")) {
|
if (goodsEntity?.pay_type!!.startsWith("weixin") && binding.tvWxPay.isVisible) {
|
||||||
payType = 0
|
payType = 0
|
||||||
}
|
}
|
||||||
if (goodsEntity?.pay_type!!.startsWith("alipay")) {
|
if (goodsEntity?.pay_type!!.startsWith("alipay") && binding.tvAliPay.isVisible) {
|
||||||
payType = 1
|
payType = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,6 +334,19 @@ class BuySeatDialog : DialogFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showQueryTipDialog() {
|
||||||
|
if (showQueryTip) {
|
||||||
|
val f = TipDialog.newInstance("温馨提示", "是否已完成支付", "未支付", "已支付", false)
|
||||||
|
f.setOnSelectListener {
|
||||||
|
if (it == DialogEnum.CLICK_OK) {
|
||||||
|
getOrderInfo(orderEntity!!.orderId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.show(childFragmentManager, TipDialog::class.java.simpleName)
|
||||||
|
showQueryTip = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setOnSelectListener(listener: () -> Unit) {
|
fun setOnSelectListener(listener: () -> Unit) {
|
||||||
mOnBackListener = listener
|
mOnBackListener = listener
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ import com.cheng.blzb.common.EventConstants
|
||||||
import com.cheng.blzb.databinding.FragmentGuideVipBinding
|
import com.cheng.blzb.databinding.FragmentGuideVipBinding
|
||||||
import com.cheng.blzb.event.PayStatusEnum
|
import com.cheng.blzb.event.PayStatusEnum
|
||||||
import com.cheng.blzb.event.PayStatusEvent
|
import com.cheng.blzb.event.PayStatusEvent
|
||||||
|
import com.cheng.blzb.event.PaySuccessEvent
|
||||||
|
import com.cheng.blzb.manager.DialogEnum
|
||||||
import com.cheng.blzb.manager.EventReportManager
|
import com.cheng.blzb.manager.EventReportManager
|
||||||
import com.cheng.blzb.manager.LoginManager
|
import com.cheng.blzb.manager.LoginManager
|
||||||
import com.cheng.blzb.manager.UserConfigManager
|
import com.cheng.blzb.manager.UserConfigManager
|
||||||
|
|
@ -34,6 +36,7 @@ import com.cheng.blzb.ui.activity.MainActivity
|
||||||
import com.cheng.blzb.ui.activity.PublicActivity
|
import com.cheng.blzb.ui.activity.PublicActivity
|
||||||
import com.cheng.blzb.ui.dialog.GuideSaleDialog
|
import com.cheng.blzb.ui.dialog.GuideSaleDialog
|
||||||
import com.cheng.blzb.ui.dialog.PayTipDialog
|
import com.cheng.blzb.ui.dialog.PayTipDialog
|
||||||
|
import com.cheng.blzb.ui.dialog.TipDialog
|
||||||
import com.cheng.blzb.ui.fragment.mine.order.cert.CertificateFragment
|
import com.cheng.blzb.ui.fragment.mine.order.cert.CertificateFragment
|
||||||
import com.cheng.blzb.utils.DateUtils
|
import com.cheng.blzb.utils.DateUtils
|
||||||
import com.cheng.blzb.utils.UrlHelper
|
import com.cheng.blzb.utils.UrlHelper
|
||||||
|
|
@ -81,6 +84,8 @@ class GuideVipFragment: BaseFragment<FragmentGuideVipBinding, GuideVipViewModel>
|
||||||
|
|
||||||
private lateinit var api: IWXAPI
|
private lateinit var api: IWXAPI
|
||||||
private var isAgree = false
|
private var isAgree = false
|
||||||
|
//是否显示订单支付结果查询提示
|
||||||
|
private var showQueryTip = false
|
||||||
private var totalPrice = 0f
|
private var totalPrice = 0f
|
||||||
private var lastGoodsPrice = 0f
|
private var lastGoodsPrice = 0f
|
||||||
|
|
||||||
|
|
@ -222,7 +227,11 @@ class GuideVipFragment: BaseFragment<FragmentGuideVipBinding, GuideVipViewModel>
|
||||||
f.setOnSelectListener {
|
f.setOnSelectListener {
|
||||||
binding.cbAgree.isChecked = true
|
binding.cbAgree.isChecked = true
|
||||||
if (payType == 0) {
|
if (payType == 0) {
|
||||||
|
if (!TextUtils.isEmpty(goodsEntity!!.weixinMpOriId)) {
|
||||||
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "combo")
|
||||||
|
} else {
|
||||||
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "weixin")
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "weixin")
|
||||||
|
}
|
||||||
} else if (payType == 1) {
|
} else if (payType == 1) {
|
||||||
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "alipay")
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "alipay")
|
||||||
} else if (payType == 2) {
|
} else if (payType == 2) {
|
||||||
|
|
@ -232,7 +241,11 @@ class GuideVipFragment: BaseFragment<FragmentGuideVipBinding, GuideVipViewModel>
|
||||||
f.show(childFragmentManager, PayTipDialog::class.java.simpleName)
|
f.show(childFragmentManager, PayTipDialog::class.java.simpleName)
|
||||||
} else {
|
} else {
|
||||||
if (payType == 0) {
|
if (payType == 0) {
|
||||||
|
if (!TextUtils.isEmpty(goodsEntity!!.weixinMpOriId)) {
|
||||||
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "combo")
|
||||||
|
} else {
|
||||||
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "weixin")
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "weixin")
|
||||||
|
}
|
||||||
} else if (payType == 1) {
|
} else if (payType == 1) {
|
||||||
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "alipay")
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "alipay")
|
||||||
} else if (payType == 2) {
|
} else if (payType == 2) {
|
||||||
|
|
@ -268,7 +281,12 @@ class GuideVipFragment: BaseFragment<FragmentGuideVipBinding, GuideVipViewModel>
|
||||||
mViewModel.createOrderLiveData.observe(this) {
|
mViewModel.createOrderLiveData.observe(this) {
|
||||||
orderEntity = it
|
orderEntity = it
|
||||||
if (payType == 0) {
|
if (payType == 0) {
|
||||||
|
if (!TextUtils.isEmpty(goodsEntity?.weixinMpOriId)) {
|
||||||
|
PayUtils.toWXMPPay(requireActivity(), it.outTradeNo, goodsEntity!!.weixinMpOriId)
|
||||||
|
showQueryTip = true
|
||||||
|
} else {
|
||||||
PayUtils.toWXPay(requireActivity(), it)
|
PayUtils.toWXPay(requireActivity(), it)
|
||||||
|
}
|
||||||
} else if (payType == 1) {
|
} else if (payType == 1) {
|
||||||
PayUtils.toAliPay(requireActivity(), it.payParam, "")
|
PayUtils.toAliPay(requireActivity(), it.payParam, "")
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -276,6 +294,18 @@ class GuideVipFragment: BaseFragment<FragmentGuideVipBinding, GuideVipViewModel>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mViewModel.orderInfoLiveData.observe(this) {
|
||||||
|
if (it.status == "2") {
|
||||||
|
toast("支付成功")
|
||||||
|
EventReportManager.eventReport(
|
||||||
|
EventConstants.PAY_SUCCESS,
|
||||||
|
if (payType == 0) "weixin" else "alipay",
|
||||||
|
"{isGuide: true, orderId:${orderEntity?.orderId}, meal:${Gson().toJson(goodsEntity)}}"
|
||||||
|
)
|
||||||
|
requireActivity().startActivity<MainActivity>()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mViewModel.payTipsLiveData.observe(this) {
|
mViewModel.payTipsLiveData.observe(this) {
|
||||||
userTipsList.addAll(it)
|
userTipsList.addAll(it)
|
||||||
userTipsAdapter.notifyDataSetChanged()
|
userTipsAdapter.notifyDataSetChanged()
|
||||||
|
|
@ -289,13 +319,7 @@ class GuideVipFragment: BaseFragment<FragmentGuideVipBinding, GuideVipViewModel>
|
||||||
val payStatusDisposable = RxBus.defaultInstance.toObservable(PayStatusEvent::class.java).subscribe {
|
val payStatusDisposable = RxBus.defaultInstance.toObservable(PayStatusEvent::class.java).subscribe {
|
||||||
when (it.payStatus) {
|
when (it.payStatus) {
|
||||||
PayStatusEnum.PAY_SUCCESS -> {
|
PayStatusEnum.PAY_SUCCESS -> {
|
||||||
toast("支付成功")
|
mViewModel.getOrderInfo(orderEntity!!.orderId)
|
||||||
EventReportManager.eventReport(
|
|
||||||
EventConstants.PAY_SUCCESS,
|
|
||||||
if (payType == 0) "weixin" else "alipay",
|
|
||||||
"{isGuide: true, orderId:${orderEntity?.orderId}, meal:${Gson().toJson(goodsEntity)}}"
|
|
||||||
)
|
|
||||||
requireActivity().startActivity<MainActivity>()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PayStatusEnum.PAY_CANCEL -> {
|
PayStatusEnum.PAY_CANCEL -> {
|
||||||
|
|
@ -312,6 +336,19 @@ class GuideVipFragment: BaseFragment<FragmentGuideVipBinding, GuideVipViewModel>
|
||||||
addDisposable(payStatusDisposable)
|
addDisposable(payStatusDisposable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showQueryTipDialog() {
|
||||||
|
if (showQueryTip) {
|
||||||
|
val f = TipDialog.newInstance("温馨提示", "是否已完成支付", "未支付", "已支付", false)
|
||||||
|
f.setOnSelectListener {
|
||||||
|
if (it == DialogEnum.CLICK_OK) {
|
||||||
|
mViewModel.getOrderInfo(orderEntity!!.orderId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.show(childFragmentManager, TipDialog::class.java.simpleName)
|
||||||
|
showQueryTip = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setData() {
|
private fun setData() {
|
||||||
totalInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
totalInfo = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
arguments?.getSerializable("total", GuideTotalBidEntity::class.java)
|
arguments?.getSerializable("total", GuideTotalBidEntity::class.java)
|
||||||
|
|
@ -704,6 +741,7 @@ class GuideVipFragment: BaseFragment<FragmentGuideVipBinding, GuideVipViewModel>
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
startScroll()
|
startScroll()
|
||||||
|
showQueryTipDialog()
|
||||||
super.onStart()
|
super.onStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.cheng.blzb.ui.fragment.guide.vip
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.cheng.blzb.bean.GuideUpdateEntity
|
import com.cheng.blzb.bean.GuideUpdateEntity
|
||||||
|
import com.cheng.blzb.bean.OrderEntity
|
||||||
import com.cheng.blzb.bean.OrderPayEntity
|
import com.cheng.blzb.bean.OrderPayEntity
|
||||||
import com.cheng.blzb.bean.VipGoodsEntity
|
import com.cheng.blzb.bean.VipGoodsEntity
|
||||||
import com.cheng.blzb.net.ApiFactory
|
import com.cheng.blzb.net.ApiFactory
|
||||||
|
|
@ -9,11 +10,17 @@ import com.example.base.extensions.toast
|
||||||
import com.example.base.utils.L
|
import com.example.base.utils.L
|
||||||
import com.example.base.viewmodel.BaseViewModel
|
import com.example.base.viewmodel.BaseViewModel
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.cancel
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
|
|
||||||
class GuideVipViewModel: BaseViewModel() {
|
class GuideVipViewModel: BaseViewModel() {
|
||||||
|
var queryOrderJob: Job? = null
|
||||||
|
|
||||||
val goodsListLiveData = MutableLiveData<List<VipGoodsEntity>>()
|
val goodsListLiveData = MutableLiveData<List<VipGoodsEntity>>()
|
||||||
val createOrderLiveData = MutableLiveData<OrderPayEntity>()
|
val createOrderLiveData = MutableLiveData<OrderPayEntity>()
|
||||||
|
val orderInfoLiveData = MutableLiveData<OrderEntity>()
|
||||||
val payTipsLiveData = MutableLiveData<List<String>>()
|
val payTipsLiveData = MutableLiveData<List<String>>()
|
||||||
val updateLiveData = MutableLiveData<List<GuideUpdateEntity>>()
|
val updateLiveData = MutableLiveData<List<GuideUpdateEntity>>()
|
||||||
|
|
||||||
|
|
@ -52,6 +59,31 @@ class GuideVipViewModel: BaseViewModel() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getOrderInfo(orderId: String) {
|
||||||
|
setMessage("支付结果查询中", true)
|
||||||
|
cancelJob()
|
||||||
|
queryOrderJob = launchOnUiTryCatch({
|
||||||
|
repeat(10) {
|
||||||
|
val response = ApiFactory.apiService.getOrderInfo(orderId)
|
||||||
|
if (response.status) {
|
||||||
|
orderInfoLiveData.postValue(response.data)
|
||||||
|
if (response.data.status == "2") {
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
delay(2000)
|
||||||
|
} else {
|
||||||
|
dismissDialog()
|
||||||
|
toast(response.message, true)
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
dismissDialog()
|
||||||
|
L.d(it)
|
||||||
|
cancel()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fun getPayUserTips() {
|
fun getPayUserTips() {
|
||||||
launchOnUiTryCatch({
|
launchOnUiTryCatch({
|
||||||
val response = ApiFactory.apiService.getPayUserTips()
|
val response = ApiFactory.apiService.getPayUserTips()
|
||||||
|
|
@ -75,4 +107,14 @@ class GuideVipViewModel: BaseViewModel() {
|
||||||
L.d(it)
|
L.d(it)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun cancelJob() {
|
||||||
|
queryOrderJob?.cancel()
|
||||||
|
queryOrderJob = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCleared() {
|
||||||
|
super.onCleared()
|
||||||
|
cancelJob()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,11 +21,13 @@ import com.cheng.blzb.databinding.FragmentVipBinding
|
||||||
import com.cheng.blzb.event.PayStatusEnum
|
import com.cheng.blzb.event.PayStatusEnum
|
||||||
import com.cheng.blzb.event.PayStatusEvent
|
import com.cheng.blzb.event.PayStatusEvent
|
||||||
import com.cheng.blzb.event.PaySuccessEvent
|
import com.cheng.blzb.event.PaySuccessEvent
|
||||||
|
import com.cheng.blzb.manager.DialogEnum
|
||||||
import com.cheng.blzb.manager.EventReportManager
|
import com.cheng.blzb.manager.EventReportManager
|
||||||
import com.cheng.blzb.manager.LoginManager
|
import com.cheng.blzb.manager.LoginManager
|
||||||
import com.cheng.blzb.manager.UserConfigManager
|
import com.cheng.blzb.manager.UserConfigManager
|
||||||
import com.cheng.blzb.ui.activity.PublicActivity
|
import com.cheng.blzb.ui.activity.PublicActivity
|
||||||
import com.cheng.blzb.ui.dialog.PayTipDialog
|
import com.cheng.blzb.ui.dialog.PayTipDialog
|
||||||
|
import com.cheng.blzb.ui.dialog.TipDialog
|
||||||
import com.cheng.blzb.ui.fragment.mine.order.cert.CertificateFragment
|
import com.cheng.blzb.ui.fragment.mine.order.cert.CertificateFragment
|
||||||
import com.cheng.blzb.utils.DateUtils
|
import com.cheng.blzb.utils.DateUtils
|
||||||
import com.cheng.blzb.utils.UrlHelper
|
import com.cheng.blzb.utils.UrlHelper
|
||||||
|
|
@ -61,9 +63,10 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
||||||
|
|
||||||
private lateinit var api: IWXAPI
|
private lateinit var api: IWXAPI
|
||||||
private var isAgree = false
|
private var isAgree = false
|
||||||
|
//是否显示订单支付结果查询提示
|
||||||
|
private var showQueryTip = false
|
||||||
private var payType = 0 //0微信支付 1支付宝支付
|
private var payType = 0 //0微信支付 1支付宝支付
|
||||||
private var totalPrice = 0f
|
private var totalPrice = 0f
|
||||||
|
|
||||||
private var lastGoodsPrice = 0f
|
private var lastGoodsPrice = 0f
|
||||||
|
|
||||||
private var seatPrice = 0f
|
private var seatPrice = 0f
|
||||||
|
|
@ -216,7 +219,11 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
||||||
f.setOnSelectListener {
|
f.setOnSelectListener {
|
||||||
binding.cbAgree.isChecked = true
|
binding.cbAgree.isChecked = true
|
||||||
if (payType == 0) {
|
if (payType == 0) {
|
||||||
|
if (!TextUtils.isEmpty(goodsEntity!!.weixinMpOriId)) {
|
||||||
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "combo", origin, "${seatCount - seatCountLimit}")
|
||||||
|
} else {
|
||||||
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "weixin", origin, "${seatCount - seatCountLimit}")
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "weixin", origin, "${seatCount - seatCountLimit}")
|
||||||
|
}
|
||||||
} else if (payType == 1) {
|
} else if (payType == 1) {
|
||||||
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "alipay", origin, "${seatCount - seatCountLimit}")
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "alipay", origin, "${seatCount - seatCountLimit}")
|
||||||
} else if (payType == 2) {
|
} else if (payType == 2) {
|
||||||
|
|
@ -226,7 +233,11 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
||||||
f.show(childFragmentManager, PayTipDialog::class.java.simpleName)
|
f.show(childFragmentManager, PayTipDialog::class.java.simpleName)
|
||||||
} else {
|
} else {
|
||||||
if (payType == 0) {
|
if (payType == 0) {
|
||||||
|
if (!TextUtils.isEmpty(goodsEntity!!.weixinMpOriId)) {
|
||||||
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "combo", origin, "${seatCount - seatCountLimit}")
|
||||||
|
} else {
|
||||||
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "weixin", origin, "${seatCount - seatCountLimit}")
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "weixin", origin, "${seatCount - seatCountLimit}")
|
||||||
|
}
|
||||||
} else if (payType == 1) {
|
} else if (payType == 1) {
|
||||||
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "alipay", origin, "${seatCount - seatCountLimit}")
|
mViewModel.payCreateOrder(goodsEntity!!.goods_id, "alipay", origin, "${seatCount - seatCountLimit}")
|
||||||
} else if (payType == 2) {
|
} else if (payType == 2) {
|
||||||
|
|
@ -306,7 +317,12 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
||||||
mViewModel.createOrderLiveData.observe(this) {
|
mViewModel.createOrderLiveData.observe(this) {
|
||||||
orderEntity = it
|
orderEntity = it
|
||||||
if (payType == 0) {
|
if (payType == 0) {
|
||||||
|
if (!TextUtils.isEmpty(goodsEntity?.weixinMpOriId)) {
|
||||||
|
PayUtils.toWXMPPay(requireActivity(), it.outTradeNo, goodsEntity!!.weixinMpOriId)
|
||||||
|
showQueryTip = true
|
||||||
|
} else {
|
||||||
PayUtils.toWXPay(requireActivity(), it)
|
PayUtils.toWXPay(requireActivity(), it)
|
||||||
|
}
|
||||||
} else if (payType == 1) {
|
} else if (payType == 1) {
|
||||||
PayUtils.toAliPay(requireActivity(), it.payParam, "")
|
PayUtils.toAliPay(requireActivity(), it.payParam, "")
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -314,6 +330,19 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mViewModel.orderInfoLiveData.observe(this) {
|
||||||
|
if (it.status == "2") {
|
||||||
|
toast("支付成功")
|
||||||
|
EventReportManager.eventReport(
|
||||||
|
EventConstants.PAY_SUCCESS,
|
||||||
|
if (payType == 0) "weixin" else "alipay",
|
||||||
|
"{orderId:${orderEntity?.orderId}, meal:${Gson().toJson(goodsEntity)}}"
|
||||||
|
)
|
||||||
|
RxBus.defaultInstance.post(PaySuccessEvent())
|
||||||
|
requireActivity().finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mViewModel.payTipsLiveData.observe(this) {
|
mViewModel.payTipsLiveData.observe(this) {
|
||||||
userTipsList.addAll(it)
|
userTipsList.addAll(it)
|
||||||
userTipsAdapter.notifyDataSetChanged()
|
userTipsAdapter.notifyDataSetChanged()
|
||||||
|
|
@ -323,14 +352,7 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
||||||
val payStatusDisposable = RxBus.defaultInstance.toObservable(PayStatusEvent::class.java).subscribe {
|
val payStatusDisposable = RxBus.defaultInstance.toObservable(PayStatusEvent::class.java).subscribe {
|
||||||
when (it.payStatus) {
|
when (it.payStatus) {
|
||||||
PayStatusEnum.PAY_SUCCESS -> {
|
PayStatusEnum.PAY_SUCCESS -> {
|
||||||
toast("支付成功")
|
mViewModel.getOrderInfo(orderEntity!!.orderId)
|
||||||
EventReportManager.eventReport(
|
|
||||||
EventConstants.PAY_SUCCESS,
|
|
||||||
if (payType == 0) "weixin" else "alipay",
|
|
||||||
"{orderId:${orderEntity?.orderId}, meal:${Gson().toJson(goodsEntity)}}"
|
|
||||||
)
|
|
||||||
RxBus.defaultInstance.post(PaySuccessEvent())
|
|
||||||
requireActivity().finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PayStatusEnum.PAY_CANCEL -> {
|
PayStatusEnum.PAY_CANCEL -> {
|
||||||
|
|
@ -347,6 +369,19 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
||||||
addDisposable(payStatusDisposable)
|
addDisposable(payStatusDisposable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showQueryTipDialog() {
|
||||||
|
if (showQueryTip) {
|
||||||
|
val f = TipDialog.newInstance("温馨提示", "是否已完成支付", "未支付", "已支付", false)
|
||||||
|
f.setOnSelectListener {
|
||||||
|
if (it == DialogEnum.CLICK_OK) {
|
||||||
|
mViewModel.getOrderInfo(orderEntity!!.orderId)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f.show(childFragmentManager, TipDialog::class.java.simpleName)
|
||||||
|
showQueryTip = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkPayType() {
|
private fun checkPayType() {
|
||||||
if (payType == 0) {
|
if (payType == 0) {
|
||||||
val start1 = ContextCompat.getDrawable(requireContext(), R.mipmap.ic_wx_pay)
|
val start1 = ContextCompat.getDrawable(requireContext(), R.mipmap.ic_wx_pay)
|
||||||
|
|
@ -601,6 +636,7 @@ class VipFragment : BaseFragment<FragmentVipBinding, VipViewModel>() {
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
startScroll()
|
startScroll()
|
||||||
|
showQueryTipDialog()
|
||||||
super.onStart()
|
super.onStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.cheng.blzb.ui.fragment.mine.vip
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.cheng.blzb.bean.CorpEntity
|
import com.cheng.blzb.bean.CorpEntity
|
||||||
import com.cheng.blzb.bean.CouponEntity
|
import com.cheng.blzb.bean.CouponEntity
|
||||||
|
import com.cheng.blzb.bean.OrderEntity
|
||||||
import com.cheng.blzb.bean.OrderPayEntity
|
import com.cheng.blzb.bean.OrderPayEntity
|
||||||
import com.cheng.blzb.bean.UserEntity
|
import com.cheng.blzb.bean.UserEntity
|
||||||
import com.cheng.blzb.bean.VipGoodsEntity
|
import com.cheng.blzb.bean.VipGoodsEntity
|
||||||
|
|
@ -12,13 +13,19 @@ import com.example.base.utils.L
|
||||||
import com.example.base.viewmodel.BaseViewModel
|
import com.example.base.viewmodel.BaseViewModel
|
||||||
import com.google.gson.JsonObject
|
import com.google.gson.JsonObject
|
||||||
import com.ylqh.cube.bean.CouponActivityEntity
|
import com.ylqh.cube.bean.CouponActivityEntity
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.coroutines.cancel
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
|
|
||||||
class VipViewModel : BaseViewModel() {
|
class VipViewModel : BaseViewModel() {
|
||||||
|
var queryOrderJob: Job? = null
|
||||||
|
|
||||||
val userInfoLiveData = MutableLiveData<UserEntity>()
|
val userInfoLiveData = MutableLiveData<UserEntity>()
|
||||||
val goodsListLiveData = MutableLiveData<List<VipGoodsEntity>>()
|
val goodsListLiveData = MutableLiveData<List<VipGoodsEntity>>()
|
||||||
val corpInfoLiveData = MutableLiveData<CorpEntity>()
|
val corpInfoLiveData = MutableLiveData<CorpEntity>()
|
||||||
val createOrderLiveData = MutableLiveData<OrderPayEntity>()
|
val createOrderLiveData = MutableLiveData<OrderPayEntity>()
|
||||||
|
val orderInfoLiveData = MutableLiveData<OrderEntity>()
|
||||||
val payTipsLiveData = MutableLiveData<List<String>>()
|
val payTipsLiveData = MutableLiveData<List<String>>()
|
||||||
val couponListLiveData = MutableLiveData<List<CouponEntity>>()
|
val couponListLiveData = MutableLiveData<List<CouponEntity>>()
|
||||||
val couponActivityLiveData = MutableLiveData<List<CouponActivityEntity>>()
|
val couponActivityLiveData = MutableLiveData<List<CouponActivityEntity>>()
|
||||||
|
|
@ -97,6 +104,31 @@ class VipViewModel : BaseViewModel() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getOrderInfo(orderId: String) {
|
||||||
|
setMessage("支付结果查询中", true)
|
||||||
|
cancelJob()
|
||||||
|
queryOrderJob = launchOnUiTryCatch({
|
||||||
|
repeat(10) {
|
||||||
|
val response = ApiFactory.apiService.getOrderInfo(orderId)
|
||||||
|
if (response.status) {
|
||||||
|
orderInfoLiveData.postValue(response.data)
|
||||||
|
if (response.data.status == "2") {
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
delay(2000)
|
||||||
|
} else {
|
||||||
|
dismissDialog()
|
||||||
|
toast(response.message, true)
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
dismissDialog()
|
||||||
|
L.d(it)
|
||||||
|
cancel()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fun getPayUserTips() {
|
fun getPayUserTips() {
|
||||||
launchOnUiTryCatch({
|
launchOnUiTryCatch({
|
||||||
val response = ApiFactory.apiService.getPayUserTips()
|
val response = ApiFactory.apiService.getPayUserTips()
|
||||||
|
|
@ -151,4 +183,14 @@ class VipViewModel : BaseViewModel() {
|
||||||
L.d(it)
|
L.d(it)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun cancelJob() {
|
||||||
|
queryOrderJob?.cancel()
|
||||||
|
queryOrderJob = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCleared() {
|
||||||
|
super.onCleared()
|
||||||
|
cancelJob()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,6 +11,7 @@ import com.cheng.blzb.common.Constants
|
||||||
import com.example.base.common.RxBus
|
import com.example.base.common.RxBus
|
||||||
import com.example.base.extensions.toast
|
import com.example.base.extensions.toast
|
||||||
import com.example.base.utils.L
|
import com.example.base.utils.L
|
||||||
|
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram
|
||||||
import com.tencent.mm.opensdk.modelpay.PayReq
|
import com.tencent.mm.opensdk.modelpay.PayReq
|
||||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory
|
import com.tencent.mm.opensdk.openapi.WXAPIFactory
|
||||||
|
|
||||||
|
|
@ -41,6 +42,22 @@ object PayUtils {
|
||||||
api.sendReq(request)
|
api.sendReq(request)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信小程序支付
|
||||||
|
*/
|
||||||
|
fun toWXMPPay(mActivity: Activity, outTradeNo: String, mpAppId: String) {
|
||||||
|
try {
|
||||||
|
val api = WXAPIFactory.createWXAPI(mActivity, Constants.WechatAppId)
|
||||||
|
val req = WXLaunchMiniProgram.Req()
|
||||||
|
req.userName = mpAppId // 填小程序原始id
|
||||||
|
req.path = "pages/index/index?outTradeNo=$outTradeNo"
|
||||||
|
req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE
|
||||||
|
api.sendReq(req)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
toast("跳转支付失败,请检查是否安装最新版微信")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝
|
* 支付宝
|
||||||
*/
|
*/
|
||||||
|
|
@ -90,19 +107,16 @@ object PayUtils {
|
||||||
when {
|
when {
|
||||||
TextUtils.equals(resultStatus, "9000") -> {
|
TextUtils.equals(resultStatus, "9000") -> {
|
||||||
// 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
|
// 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
|
||||||
toast("支付成功")
|
|
||||||
RxBus.defaultInstance.post(com.cheng.blzb.event.PayStatusEvent(com.cheng.blzb.event.PayStatusEnum.PAY_SUCCESS))
|
RxBus.defaultInstance.post(com.cheng.blzb.event.PayStatusEvent(com.cheng.blzb.event.PayStatusEnum.PAY_SUCCESS))
|
||||||
}
|
}
|
||||||
|
|
||||||
TextUtils.equals(resultStatus, "6001") -> {
|
TextUtils.equals(resultStatus, "6001") -> {
|
||||||
// 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
|
// 该笔订单是否真实支付成功,需要依赖服务端的异步通知。
|
||||||
toast("支付取消")
|
|
||||||
RxBus.defaultInstance.post(com.cheng.blzb.event.PayStatusEvent(com.cheng.blzb.event.PayStatusEnum.PAY_CANCEL))
|
RxBus.defaultInstance.post(com.cheng.blzb.event.PayStatusEvent(com.cheng.blzb.event.PayStatusEnum.PAY_CANCEL))
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
// 该笔订单真实的支付结果,需要依赖服务端的异步通知。
|
// 该笔订单真实的支付结果,需要依赖服务端的异步通知。
|
||||||
toast("支付失败")
|
|
||||||
L.d("resultStatus=${resultStatus}")
|
L.d("resultStatus=${resultStatus}")
|
||||||
RxBus.defaultInstance.post(com.cheng.blzb.event.PayStatusEvent(com.cheng.blzb.event.PayStatusEnum.PAY_ERROR, resultInfo))
|
RxBus.defaultInstance.post(com.cheng.blzb.event.PayStatusEvent(com.cheng.blzb.event.PayStatusEnum.PAY_ERROR, resultInfo))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.example.base.dialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
|
import android.text.TextUtils
|
||||||
import android.view.Gravity
|
import android.view.Gravity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.Window
|
import android.view.Window
|
||||||
|
|
@ -57,7 +58,11 @@ class LoadingDialog(context: Context?) : AppCompatDialog(context!!) {
|
||||||
|
|
||||||
fun setMessage(msg: String) {
|
fun setMessage(msg: String) {
|
||||||
val textView = findViewById<TextView>(R.id.tvMessage)
|
val textView = findViewById<TextView>(R.id.tvMessage)
|
||||||
|
if (!TextUtils.isEmpty(msg)) {
|
||||||
textView?.visibility = View.VISIBLE
|
textView?.visibility = View.VISIBLE
|
||||||
textView?.text = msg
|
textView?.text = msg
|
||||||
|
} else {
|
||||||
|
textView?.visibility = View.GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -18,9 +18,10 @@ class DialogLiveEvent : SingleLiveEvent<DialogBean>() {
|
||||||
value = bean
|
value = bean
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setValue(isShow: Boolean, msg: String) {
|
fun setValue(isShow: Boolean, msg: String, cancelable: Boolean = false) {
|
||||||
bean.isShow = isShow
|
bean.isShow = isShow
|
||||||
bean.msg = msg
|
bean.msg = msg
|
||||||
|
bean.cancelable = cancelable
|
||||||
value = bean
|
value = bean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -47,8 +47,8 @@ abstract class BaseViewModel : ViewModel() {
|
||||||
showDialogLiveEvent.setValue(true, cancelable)
|
showDialogLiveEvent.setValue(true, cancelable)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setMessage(msg: String) {
|
fun setMessage(msg: String, cancelable: Boolean = false) {
|
||||||
showDialogLiveEvent.setValue(true, msg)
|
showDialogLiveEvent.setValue(true, msg, cancelable)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun dismissDialog() {
|
fun dismissDialog() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue