💪 optimize: 优化代码

This commit is contained in:
wangsongsole 2023-06-29 17:51:07 +08:00
parent 80635ea7c4
commit 0fe0c5f978
1 changed files with 6 additions and 10 deletions

View File

@ -159,13 +159,13 @@ export function additionalRules(params, computeMin, computeMax) {
if (model.cash_amount_type === "2") { if (model.cash_amount_type === "2") {
/* TODO: 2:微信 1:支付宝 */ /* TODO: 2:微信 1:支付宝 */
if (model.channel === 2) { if (model.channel === 2) {
if (!rulesRandom(model, 0.1)) { if (rulesRandom(model, 0.1)) {
return false return false
} }
} }
if (model.channel === 1) { if (model.channel === 1) {
if (!rulesRandom(model, 0.01)) { if (rulesRandom(model, 0.01)) {
return false return false
} }
} }
@ -210,13 +210,13 @@ export function additionalRules(params, computeMin, computeMax) {
if (model.cash_amount_type === "1") { if (model.cash_amount_type === "1") {
/* TODO: 2:微信 1:支付宝 */ /* TODO: 2:微信 1:支付宝 */
if (model.channel === 2) { if (model.channel === 2) {
if (!rulesFixed(model, 0.1)) { if (rulesFixed(model, 0.1)) {
return false return false
} }
} }
if (model.channel === 1) { if (model.channel === 1) {
if (!rulesFixed(model, 0.01)) { if (rulesFixed(model, 0.01)) {
return false return false
} }
} }
@ -243,22 +243,18 @@ function rulesRandom(model, num) {
) { ) {
if (model.min_denomination > model.max_denomination) { if (model.min_denomination > model.max_denomination) {
Notify.error("随机红包最小面额不得大于最大面额") Notify.error("随机红包最小面额不得大于最大面额")
return false return true
} else { } else {
Notify.error(`请输入${num} ~ 200的面额且保留2位小数`) Notify.error(`请输入${num} ~ 200的面额且保留2位小数`)
return false
}
} else {
return true return true
} }
} }
}
/* 固定额度微信/支付宝验证方法 */ /* 固定额度微信/支付宝验证方法 */
function rulesFixed(model, num) { function rulesFixed(model, num) {
if (model.denomination < num || model.denomination > 200 || !fP.test(model.denomination)) { if (model.denomination < num || model.denomination > 200 || !fP.test(model.denomination)) {
Notify.error(`请输入${num} ~ 200的面额且保留2位小数`) Notify.error(`请输入${num} ~ 200的面额且保留2位小数`)
return false
} else {
return true return true
} }
} }