fix: 周期账单弹窗 — Numpad 移到 scroll-view 外 + 防重复提交 + @confirm 绑定

This commit is contained in:
2026-06-09 09:13:28 +08:00
parent df6f1a54d6
commit 4e4b7dac69

View File

@@ -135,9 +135,11 @@
</picker>
</view>
<!-- 数字键盘内嵌模式不固定在底部 -->
<Numpad v-model="amountStr" :fixed="false" />
</scroll-view>
<!-- 数字键盘在滚动区外始终可见避免 scroll-view 吞事件 -->
<Numpad v-model="amountStr" :fixed="false" @confirm="handleSubmit" />
<view class="modal-footer" @tap="handleSubmit">
<text class="submit-text">{{ editingId ? '保存修改' : '添加' }}</text>
</view>
@@ -167,6 +169,7 @@ const loading = ref(true)
const showModal = ref(false)
const editingId = ref<number | null>(null)
const amountStr = ref('')
const saving = ref(false)
const syncCount = ref(0)
const freqMap: Record<string, string> = {
@@ -254,6 +257,7 @@ async function toggleActive(item: RecurringTemplate) {
}
async function handleSubmit() {
if (saving.value) return
const amount = Math.round(parseFloat(amountStr.value || '0') * 100)
if (isNaN(amount) || amount <= 0) {
uni.showToast({ title: '请输入金额', icon: 'none' })
@@ -264,6 +268,7 @@ async function handleSubmit() {
return
}
saving.value = true
try {
const data = {
amount,
@@ -284,6 +289,8 @@ async function handleSubmit() {
uni.showToast({ title: editingId.value ? '已更新' : '已添加', icon: 'success' })
} catch {
uni.showToast({ title: '保存失败', icon: 'none' })
} finally {
saving.value = false
}
}
@@ -426,7 +433,7 @@ function goBack() { uni.navigateBack() }
&:active { background: darken($border, 5%); }
}
.modal-close-text { font-size: $font-2xl; color: $text-sec; line-height: 1; }
.modal-body { flex: 1; padding: $space-md $space-xl; max-height: 60vh; }
.modal-body { flex: 1; padding: $space-md $space-xl; max-height: 45vh; }
.modal-footer {
padding: $space-md $space-xl; border-top: 2rpx solid $border;
}