Commit 74b026d7 authored by shiyl's avatar shiyl

解决 生活圈C端项目SHQCLIENT-1539

parent 504959b0
...@@ -17,7 +17,7 @@ interface BaseViewComponent<VM : BaseViewModel> { ...@@ -17,7 +17,7 @@ interface BaseViewComponent<VM : BaseViewModel> {
val loadingDialog: LoadingDialog val loadingDialog: LoadingDialog
fun showLoading() { fun showLoading() {
loadingDialog.showDialog("努力加载中...") loadingDialog.showDialog("加载中...")
} }
fun hideLoading() { fun hideLoading() {
......
...@@ -97,7 +97,7 @@ object OrderRemoteDataSource { ...@@ -97,7 +97,7 @@ object OrderRemoteDataSource {
} }
override fun onFailure(result: HttpResult<CreateOrderResDto?>?) { override fun onFailure(result: HttpResult<CreateOrderResDto?>?) {
callback?.invoke(null)
} }
}) })
} }
...@@ -118,7 +118,7 @@ object OrderRemoteDataSource { ...@@ -118,7 +118,7 @@ object OrderRemoteDataSource {
} }
override fun onFailure(result: HttpResult<List<PingPayResult>?>?) { override fun onFailure(result: HttpResult<List<PingPayResult>?>?) {
callback?.invoke(null)
} }
}) })
} }
......
...@@ -117,6 +117,10 @@ class ConfirmOrderActivity : BaseMvvmActivity<BorderActivityConfirmOrderBinding, ...@@ -117,6 +117,10 @@ class ConfirmOrderActivity : BaseMvvmActivity<BorderActivityConfirmOrderBinding,
Pingpp.createPayment(this, it) Pingpp.createPayment(this, it)
Timber.tag("确认订单").e("支付charge:$it") Timber.tag("确认订单").e("支付charge:$it")
} }
// 设置立即支付按钮是否可用,防止多次重复创建订单和打开支付页面
vm.payEnableEvent.observe(this) {
binding.tvPayNow.isEnabled = it
}
} }
...@@ -163,7 +167,8 @@ class ConfirmOrderActivity : BaseMvvmActivity<BorderActivityConfirmOrderBinding, ...@@ -163,7 +167,8 @@ class ConfirmOrderActivity : BaseMvvmActivity<BorderActivityConfirmOrderBinding,
Timber.tag("确认订单").e("支付失败,错误原因:$errorMsg \n $extraMsg") Timber.tag("确认订单").e("支付失败,错误原因:$errorMsg \n $extraMsg")
CommonHintDialog(this, "交易失败,是否继续支付?", arrayListOf("取消", "确定"), object : CommonHintDialog.OnHintOptionCallback { CommonHintDialog(this, "交易失败,是否继续支付?", arrayListOf("取消", "确定"), object : CommonHintDialog.OnHintOptionCallback {
override fun onLeftOption() { override fun onLeftOption() {
// 支付失败后,取消继续支付,这时允许再次创建订单并进行支付
vm.paymentEnable(true)
} }
override fun onRightOption() { override fun onRightOption() {
......
...@@ -61,6 +61,12 @@ class ConfirmOrderViewModel : BaseViewModel() { ...@@ -61,6 +61,12 @@ class ConfirmOrderViewModel : BaseViewModel() {
private val _toPaymentEvent = MutableLiveData<String>() private val _toPaymentEvent = MutableLiveData<String>()
val toPaymentEvent: LiveData<String> = _toPaymentEvent val toPaymentEvent: LiveData<String> = _toPaymentEvent
/**
* 立即支付按钮是否可用 Event
*/
private val _payEnableEvent = MutableLiveData<Boolean>()
val payEnableEvent: LiveData<Boolean> = _payEnableEvent
/** /**
* 请求订单信息 * 请求订单信息
*/ */
...@@ -182,6 +188,8 @@ class ConfirmOrderViewModel : BaseViewModel() { ...@@ -182,6 +188,8 @@ class ConfirmOrderViewModel : BaseViewModel() {
postErrorEvent(ErrorInfo(message = "请输入11位手机号码")) postErrorEvent(ErrorInfo(message = "请输入11位手机号码"))
return return
} }
// 防止重复多次点击立即支付按钮
paymentEnable(false)
if (!selectedCouponList.value.isNullOrEmpty()) {// 添加上选中的优惠券 if (!selectedCouponList.value.isNullOrEmpty()) {// 添加上选中的优惠券
currentParamsJson.put("coupon_list", JSONArray(selectedCouponList.value)) currentParamsJson.put("coupon_list", JSONArray(selectedCouponList.value))
} }
...@@ -190,7 +198,9 @@ class ConfirmOrderViewModel : BaseViewModel() { ...@@ -190,7 +198,9 @@ class ConfirmOrderViewModel : BaseViewModel() {
currentParamsJson.put("receiver_mobile", receivingPhone.value) currentParamsJson.put("receiver_mobile", receivingPhone.value)
currentParamsJson.put("comment", remark.value) currentParamsJson.put("comment", remark.value)
OrderRemoteDataSource.requestCreateOrder(currentParamsJson) { OrderRemoteDataSource.requestCreateOrder(currentParamsJson) {
it?.let { if (it == null) {
paymentEnable(true)
} else {
if (it.payment == 0) {// 0元单不用支付直接进订单详情 if (it.payment == 0) {// 0元单不用支付直接进订单详情
_toOrderDetailEvent.value = it.orderId _toOrderDetailEvent.value = it.orderId
} else { } else {
...@@ -210,7 +220,9 @@ class ConfirmOrderViewModel : BaseViewModel() { ...@@ -210,7 +220,9 @@ class ConfirmOrderViewModel : BaseViewModel() {
requestParams["order_id"] = orderId requestParams["order_id"] = orderId
requestParams["pay_method_id"] = "105"// 微信 App 支付 requestParams["pay_method_id"] = "105"// 微信 App 支付
OrderRemoteDataSource.requestPayOrder(requestParams) { OrderRemoteDataSource.requestPayOrder(requestParams) {
it?.let { if (it == null) {
paymentEnable(true)
} else {
// 调起支付 // 调起支付
_toPaymentEvent.value = Gson().toJson(it[0].v) _toPaymentEvent.value = Gson().toJson(it[0].v)
} }
...@@ -232,6 +244,13 @@ class ConfirmOrderViewModel : BaseViewModel() { ...@@ -232,6 +244,13 @@ class ConfirmOrderViewModel : BaseViewModel() {
_toOrderDetailEvent.value = payOrderId _toOrderDetailEvent.value = payOrderId
} }
/**
* 立即支付按钮状态
*/
fun paymentEnable(enable: Boolean) {
_payEnableEvent.value = enable
}
/** /**
* 页面浏览的埋点 * 页面浏览的埋点
* 页面可见且有业务数据时上传 * 页面可见且有业务数据时上传
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment