Commit 74b026d7 authored by shiyl's avatar shiyl

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

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