修复充值商店配置500错误:getParam参数不匹配+前端防重复提交
This commit is contained in:
@@ -3622,11 +3622,16 @@ async function saveShopConfig() {
|
||||
const price = parseFloat(document.getElementById('scfPrice').value) || 0;
|
||||
const bond = document.getElementById('scfBond').value.trim();
|
||||
const active = parseInt(document.getElementById('scfActive').value) || 1;
|
||||
|
||||
|
||||
if (!name) { glassAlert('请输入商品名称'); return; }
|
||||
if (price <= 0) { glassAlert('售价必须大于0'); return; }
|
||||
if (!/^\d+(-\d+)?$/.test(bond)) { glassAlert('债券范围格式错误,应为数字或范围如"1-10"'); return; }
|
||||
|
||||
|
||||
// 防重复点击:获取按钮并禁用
|
||||
const btn = event.target;
|
||||
btn.disabled = true;
|
||||
btn.textContent = '保存中...';
|
||||
|
||||
const params = new URLSearchParams({
|
||||
action: 'shop_config',
|
||||
method: 'save',
|
||||
@@ -3639,7 +3644,7 @@ async function saveShopConfig() {
|
||||
bond_reward: bond,
|
||||
is_active: active
|
||||
});
|
||||
|
||||
|
||||
try {
|
||||
const r = await fetch('api/recharge_orders_api.php?'+params.toString());
|
||||
const d = await r.json();
|
||||
@@ -3651,6 +3656,10 @@ async function saveShopConfig() {
|
||||
glassAlert('保存失败: '+(d.message||'未知错误'));
|
||||
}
|
||||
} catch(e) { glassAlert('请求失败: '+e.message); }
|
||||
finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = '保存';
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleShopConfig(id) {
|
||||
|
||||
@@ -457,14 +457,14 @@ function handleShopConfigList($db) {
|
||||
* 保存商店配置(添加或编辑)
|
||||
*/
|
||||
function handleShopConfigSave($db) {
|
||||
$id = getParam('id', 0);
|
||||
$id = intval(getParam('id', 0));
|
||||
$itemName = getParam('item_name', '');
|
||||
$stock = getParam('stock', -1, 'intval');
|
||||
$stock = intval(getParam('stock', -1));
|
||||
$temporaryOffer = getParam('temporary_offer', '');
|
||||
$offerExpire = getParam('offer_expire', '');
|
||||
$price = getParam('price', 0, 'floatval');
|
||||
$price = floatval(getParam('price', 0));
|
||||
$bondReward = getParam('bond_reward', '1-1');
|
||||
$isActive = getParam('is_active', 1, 'intval');
|
||||
$isActive = intval(getParam('is_active', 1));
|
||||
|
||||
// 验证库存
|
||||
if ($stock < -1) {
|
||||
@@ -529,7 +529,7 @@ function handleShopConfigSave($db) {
|
||||
* 删除商店配置
|
||||
*/
|
||||
function handleShopConfigDelete($db) {
|
||||
$id = getParam('id', 0, 'intval');
|
||||
$id = intval(getParam('id', 0));
|
||||
if ($id <= 0) {
|
||||
error('无效的配置ID');
|
||||
}
|
||||
@@ -549,7 +549,7 @@ function handleShopConfigDelete($db) {
|
||||
* 切换商店配置上下架状态
|
||||
*/
|
||||
function handleShopConfigToggle($db) {
|
||||
$id = getParam('id', 0, 'intval');
|
||||
$id = intval(getParam('id', 0));
|
||||
if ($id <= 0) {
|
||||
error('无效的配置ID');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user