From 14bcca097a591d3d7c08bf3c73eec92a59721048 Mon Sep 17 00:00:00 2001 From: wangxiangwen <1906413238@qq.com> Date: Wed, 23 Jul 2025 18:12:17 +0800 Subject: [PATCH 1/3] =?UTF-8?q?set=E5=8F=AA=E6=9C=89=E4=B8=80=E6=AC=A1+?= =?UTF-8?q?=E8=83=BD=E8=BE=93=E5=85=A5=E8=B4=9F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/zhongchou/activity/set/index.vue | 76 ++++++++++++++++------ activitylink/src/views/zhongchou/index.vue | 1 - 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/activitylink/src/views/zhongchou/activity/set/index.vue b/activitylink/src/views/zhongchou/activity/set/index.vue index bb98281..2bb33be 100644 --- a/activitylink/src/views/zhongchou/activity/set/index.vue +++ b/activitylink/src/views/zhongchou/activity/set/index.vue @@ -9,17 +9,21 @@

数据设置:

- - -   分钟 -      - 确认 + +
+ +   分钟 +      + 确认 +
+
{{ initialData }}分钟
+
- +      确认      @@ -29,7 +33,7 @@
- +      确认      @@ -37,9 +41,9 @@
-
+ @@ -54,7 +58,7 @@ - 您确定要设置初始数据为 {{ setinitiaData }} 分钟吗? + 您确定要设置初始数据为 {{ setinitiaData }} 分钟吗?(只能修改一次!) @@ -132,7 +131,62 @@ const marketTwoName = ref(''); // } // }; +const timerOne = ref(null); +const timerTwo = ref(null); + +const handleIntegerInput1 = (value) => { + // 清除之前的定时器 + if (timerOne.value) { + clearTimeout(timerOne.value); + } + + // 1. 替换所有非数字和非负号的字符 + let filtered = value.replace(/[^-0-9]/g, ''); + // 2. 如果以负号开头,只保留第一个负号,其余负号删除 + if (filtered.includes('-')) { + const firstChar = filtered[0]; + const rest = filtered.slice(1).replace(/-/g, ''); // 删除其余负号 + filtered = firstChar === '-' ? '-' + rest : rest; + } + + // 3. 如果是单独的 '-',设置延迟校验 + if (filtered === '-') { + timerOne.value = setTimeout(() => { + addCountOne.value = ''; + timerOne.value = null; + }, 1000); // 延迟200ms + } else { + // 4. 更新绑定值 + addCountOne.value = filtered; + } +}; + +const handleIntegerInput2 = (value) => { + // 清除之前的定时器 + if (timerTwo.value) { + clearTimeout(timerTwo.value); + } + + // 同上逻辑 + let filtered = value.replace(/[^-0-9]/g, ''); + + if (filtered.includes('-')) { + const firstChar = filtered[0]; + const rest = filtered.slice(1).replace(/-/g, ''); + filtered = firstChar === '-' ? '-' + rest : rest; + } + + // 如果是单独的 '-',设置延迟校验 + if (filtered === '-') { + timerTwo.value = setTimeout(() => { + addCountTwo.value = ''; + timerTwo.value = null; + }, 1000); // 延迟200ms + } else { + addCountTwo.value = filtered; + } +}; const fetchData = async () => { try { // ✅ 修改传参方式为对象 @@ -382,6 +436,34 @@ const goBack = () => { flex: 0 0 auto; } +.setting-item { + display: flex; + align-items: center; + margin-bottom: 25px; +} + +.fixed-label { + width: 250px; /* 固定宽度 */ + text-align: left; /* 右对齐,更美观 */ + margin-right: 20px; /* 固定间距 */ + white-space: nowrap; /* 防止换行 */ +} + +.fixed-input { + width: 230px; /* 固定宽度 */ + margin-right: 30px; /* 固定间距 */ +} + +.fixed-button { + margin-right: 20px; /* 固定间距 */ +} + +/* 确保最后一个 label 不需要右边距 */ +.setting-item .fixed-label:last-child { + margin-right: 0; +} + + h3 { font-size: 1.8rem; margin-bottom: 20px; diff --git a/activitylink/src/views/zhongchou/level/index.vue b/activitylink/src/views/zhongchou/level/index.vue index 1fd1884..9d720e0 100644 --- a/activitylink/src/views/zhongchou/level/index.vue +++ b/activitylink/src/views/zhongchou/level/index.vue @@ -43,16 +43,28 @@ - + - + - +