fix: 加工确认弹窗重量改为固定值展示+刷新按钮,不可手动编辑

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
zhangyan
2026-06-17 09:35:22 +08:00
co-authored by Claude Opus 4.6
parent 769fcd5721
commit 6256f7b9fa
@@ -253,14 +253,19 @@
.modal__food { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px; }
.modal__food-icon { font-size: 24px; }
.modal__label { font-size: 12px; color: rgba(255,255,255,0.5); text-align: center; }
.modal__weight-input {
width: 120px; margin: 0 auto; background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.15);
border-radius: 8px; padding: 10px 12px; font-size: 20px; font-weight: 700;
color: #4a90d9; text-align: center; outline: none; font-family: inherit;
.modal__weight-row {
display: flex; align-items: center; justify-content: center; gap: 10px;
}
.modal__weight-input:focus { border-color: #4a90d9; }
.modal__weight-value {
font-size: 28px; font-weight: 700; color: #4a90d9; line-height: 1;
}
.modal__weight-refresh {
width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(74,144,217,0.25);
background: rgba(74,144,217,0.1); color: #4a90d9; font-size: 14px;
cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.modal__weight-refresh:hover { background: rgba(74,144,217,0.2); border-color: #4a90d9; }
.modal__weight-unit { text-align: center; font-size: 12px; color: rgba(255,255,255,0.4); margin-top: -8px; }
.modal__hint { font-size: 11px; color: rgba(255,255,255,0.35); text-align: center; }
.modal__actions { display: flex; gap: 10px; }
.modal__btn {
flex: 1; padding: 10px 0; border-radius: 8px; font-size: 13px; font-weight: 600;
@@ -367,9 +372,11 @@
<span id="modalFoodName">--</span>
</div>
<div class="modal__label">本次加工重量</div>
<input type="number" class="modal__weight-input" id="modalWeight" value="0.0" step="0.1" min="0">
<div class="modal__weight-row">
<span class="modal__weight-value" id="modalWeight">0.0</span>
<button class="modal__weight-refresh" onclick="refreshWeight()" title="重新获取秤上重量">&#x1F504;</button>
</div>
<div class="modal__weight-unit"></div>
<div class="modal__hint" id="modalHint"></div>
<div class="modal__actions">
<button class="modal__btn modal__btn--cancel" onclick="closeWeightModal()">取消</button>
<button class="modal__btn modal__btn--confirm" onclick="confirmWeight()">确认</button>
@@ -606,13 +613,8 @@
pendingWeightFood = food;
document.getElementById('modalIcon').textContent = food.icon;
document.getElementById('modalFoodName').textContent = food.name;
document.getElementById('modalWeight').value = detectedWeight;
document.getElementById('modalHint').textContent = '已加工 ' + food.processed.toFixed(1) + '斤 / 应加工 ' + food.target.toFixed(1) + '斤';
document.getElementById('modalWeight').textContent = detectedWeight.toFixed(1);
document.getElementById('weightModal').classList.add('show');
setTimeout(function() {
document.getElementById('modalWeight').focus();
document.getElementById('modalWeight').select();
}, 100);
}
// ---- 关闭弹窗 ----
@@ -621,11 +623,18 @@
pendingWeightFood = null;
}
// ---- 刷新秤上重量 ----
function refreshWeight() {
var newWeight = parseFloat((Math.random() * 2 + 0.2).toFixed(1));
document.getElementById('modalWeight').textContent = newWeight.toFixed(1);
showToast('重量已刷新:' + newWeight.toFixed(1) + '斤', 800);
}
// ---- 确认重量(累加) ----
function confirmWeight() {
var weight = parseFloat(document.getElementById('modalWeight').value);
var weight = parseFloat(document.getElementById('modalWeight').textContent);
if (isNaN(weight) || weight <= 0) {
showToast('请输入有效重量', 1200, 'warn');
showToast('效重量', 1200, 'warn');
return;
}
if (pendingWeightFood) {