Commit af834644 authored by shiyl's avatar shiyl

选择代金券逻辑优化

parent bc03a3cc
......@@ -45,8 +45,6 @@ data class CouponDto(
val endTime: String? = null,// 有效期结束时间
@SerializedName("status")
val status: Int? = null,// 优惠券状态
@SerializedName("selected")
var selected: Boolean? = false,// 优惠券是否被选中
) : Parcelable
/**
......
......@@ -126,6 +126,8 @@ class ConfirmOrderViewModel : BaseViewModel() {
* 选择代金券, 如果有上次选中的带过去最新的列表
*/
fun chooseVoucher() {
//选择之前先将上次的金额清零
couponAmount = 0.00
_chooseCouponEvent.value = couponsAvailableList.value
}
......@@ -137,11 +139,9 @@ class ConfirmOrderViewModel : BaseViewModel() {
val list = mutableListOf<CouponDto>()
indexList.forEach {
val coupon = couponsAvailableList.value?.get(it)
//将该优惠券更新为选中状态
coupon?.let { couponDto ->
// 累加优惠券金额
couponAmount += couponDto.amount?.toDouble() ?: 0.00
couponDto.selected = true
list.add(couponDto)
}
}
......
......@@ -296,7 +296,7 @@
android:paddingTop="@dimen/dp2"
android:paddingEnd="@dimen/dp5"
android:paddingBottom="@dimen/dp2"
android:text="@{@string/amount(vm.couponAmountValue)}"
android:text='@{"- " + @string/amount(vm.couponAmountValue)}'
android:textColor="@color/color_FD7823"
android:textSize="11sp"
app:isShow="@{vm.selectedCouponList.size() > 0}"
......
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