fix(h5/code-pay): 金额输入零值死锁预防,拦截0.00等零值填满小数位

This commit is contained in:
daxpay
2026-07-30 13:40:07 +08:00
parent 6b890aba2f
commit 2081416d82

View File

@@ -164,6 +164,13 @@ export function useCodePayPage(options: UseCodePayPageOptions) {
else {
current += k
}
// 防止零值死锁: 结果金额为零且小数位满2位(如"0.00"), 拦截
if (Number(current) === 0) {
const zeroDot = current.indexOf('.')
if (zeroDot >= 0 && current.length - zeroDot > 2) {
return
}
}
// 上限:对齐后端 amount @Max(9999999999 分),超限则忽略本次按键
if (isAmountOverMax(current)) {
return