fix: 前端优惠金额不能为负数
This commit is contained in:
@@ -278,8 +278,12 @@ export default {
|
||||
return sum + (item.price * item.quantity)
|
||||
}, 0)
|
||||
|
||||
// 2. 优惠金额直接使用用户输入的值
|
||||
this.discountAmount = parseFloat(this.discountMoney) || 0
|
||||
// 2. 优惠金额直接使用用户输入的值,不能为负
|
||||
let discountVal = parseFloat(this.discountMoney)
|
||||
if (isNaN(discountVal) || discountVal < 0) {
|
||||
discountVal = 0
|
||||
}
|
||||
this.discountAmount = discountVal
|
||||
|
||||
// 3. 计算实付金额 = 原价 - 优惠金额
|
||||
this.actualAmount = this.totalAmount - this.discountAmount
|
||||
@@ -302,6 +306,13 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
// 校验:优惠金额不能为负
|
||||
const discountVal = parseFloat(this.discountMoney) || 0
|
||||
if (discountVal < 0) {
|
||||
uni.showToast({ title: '优惠金额不能为负', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
const data = {
|
||||
customerId: this.selectedCustomer ? this.selectedCustomer.customerId : null,
|
||||
items: this.orderItems.map(item => ({
|
||||
|
||||
Reference in New Issue
Block a user