From 38152de7c96949f235c13a23b24ec7571c0c0122 Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Mon, 22 Dec 2025 10:48:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=85=85=E5=80=BC=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E9=A1=B5):=20=E8=BD=AC=E8=B4=A6=E6=95=B0=E9=A2=9D=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A1=86=E5=8F=96=E6=B6=88=E5=B0=8F=E6=95=B0=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/RechargeAgency/index.vue | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/views/RechargeAgency/index.vue b/src/views/RechargeAgency/index.vue index 217511e..e891b3d 100644 --- a/src/views/RechargeAgency/index.vue +++ b/src/views/RechargeAgency/index.vue @@ -200,8 +200,11 @@ v-model="rechargeAmount" type="number" min="1" + step="1" :placeholder="t('enter_recharge_amount')" class="amount-input" + @input="preventDecimalInput" + @keydown="onKeyDown" /> @@ -438,6 +441,27 @@ const Confirm = () => { closedPopup() } +// 防止输入小数点的函数 +const preventDecimalInput = (event) => { + // 移除小数点和其他非整数字符 + event.target.value = event.target.value.replace(/[^0-9]/g, '') + + // 确保最小值为1 + if (event.target.value === '' || parseInt(event.target.value) < 1) { + event.target.value = '' + } + + rechargeAmount.value = event.target.value +} + +// 键盘按下事件,阻止某些按键 +const onKeyDown = (event) => { + // 阻止小数点、e、+、- 等特殊字符 + if (['.', 'e', '+', '-'].includes(event.key)) { + event.preventDefault() + } +} + // 校验销售商权限 const checkDealerAccess = async () => { try {