重新上架 - 输入新价格
将价格 ${escapeHtml(oldPrice)} 的 ${count} 件商品以新价格重新上架${suggestedCents > 0 ? `(建议到手价 ${escapeHtml(fmtAmount(suggestedCents))})` : ''}:
`;
document.body.appendChild(overlay);
const receivedInput = overlay.querySelector('#sme-price-received');
const buyerInput = overlay.querySelector('#sme-price-buyer');
const cleanup = (result) => { overlay.remove(); resolve(result); };
// 解析用户输入金额为分(兼容千分位逗号与欧式小数逗号)
const parseAmount = (str) => {
let s = String(str).replace(/\s/g, '').replace(/[^\d.,]/g, '');
if (!s) return 0;
if (s.includes(',') && s.includes('.')) {
s = s.replace(/,/g, '');
} else if (/\d,\d{3}(?:\D|$)/.test(s)) {
s = s.replace(/,/g, '');
} else {
s = s.replace(',', '.');
}
const num = parseFloat(s);
return (!isNaN(num) && num > 0) ? Math.round(num * unit) : 0;
};
receivedInput.addEventListener('input', () => {
const receivedCents = parseAmount(receivedInput.value);
if (!receivedCents) { buyerInput.value = ''; return; }
buyerInput.value = fmtAmount(calcAmountToSend(receivedCents).amount);
});
buyerInput.addEventListener('input', () => {
const buyerCents = parseAmount(buyerInput.value);
if (!buyerCents) { receivedInput.value = ''; return; }
receivedInput.value = fmtAmount(calcReceivedAmount(buyerCents));
});
overlay.querySelector('#sme-price-cancel').addEventListener('click', () => cleanup(null));
overlay.querySelector('#sme-price-ok').addEventListener('click', () => {
const receivedCents = parseAmount(receivedInput.value);
if (!receivedCents) { receivedInput.focus(); return; }
const buyerCents = calcAmountToSend(receivedCents).amount;
cleanup({ receivedCents, buyerCents });
});
[receivedInput, buyerInput].forEach(inp => inp.addEventListener('keydown', (e) => {
if (e.key === 'Enter') overlay.querySelector('#sme-price-ok').click();
}));
// v1.5.1 P2-C:ESC 关闭对话框
overlay.addEventListener('keydown', (e) => { if (e.key === 'Escape') cleanup(null); });
overlay.addEventListener('click', (e) => { if (e.target === overlay) cleanup(null); });
receivedInput.focus();
receivedInput.select();
});
}
// ==================== 下架后 assetid 重新获取 ====================
// 参考 steam-market-listings-group 2.6.2:下架回库后 assetid 可能变化,
// 需要按 classid 轮询库存 API 定位可用资产
/**
* 查询库存中指定 classid 的可用 assetid
* @param {string} appId
* @param {string} contextId
* @param {string} classid
* @param {Set