From 00da16abb6820635c547f3c79d3802c641781175 Mon Sep 17 00:00:00 2001 From: ypsdf1 Date: Thu, 16 Jul 2026 17:38:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E6=AD=A3=E5=94=AE=E7=BD=84=E2=89=A0?= =?UTF-8?q?=E4=B8=8B=E6=9E=B6=EF=BC=9A=E5=94=AE=E7=BD=84=E5=95=86=E5=93=81?= =?UTF-8?q?=E4=BB=8D=E5=B1=95=E7=A4=BA=E4=BB=85=E7=A6=81=E6=AD=A2=E8=B4=AD?= =?UTF-8?q?=E4=B9=B0=EF=BC=8C=E4=BB=85=E4=B8=8B=E6=9E=B6(is=5Factive=3D0)?= =?UTF-8?q?=E6=89=8D=E9=9A=90=E8=97=8F=EF=BC=9B=E5=89=8D=E7=AB=AF=E5=94=AE?= =?UTF-8?q?=E7=BD=84=E6=8C=89=E9=92=AE=E7=BD=AE=E7=81=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/pay.php | 6 ++---- player.php | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/api/pay.php b/api/pay.php index 7b49f4d..a643c24 100644 --- a/api/pay.php +++ b/api/pay.php @@ -961,10 +961,8 @@ function getShopProducts() { $stmt = $db->query("SELECT * FROM shop_configs WHERE is_active = 1 ORDER BY id ASC"); $products = []; while ($row = $stmt->fetchArray(SQLITE3_ASSOC)) { - // 检查库存:stock=0(售罄)的商品不返回 - if ($row['stock'] == 0) { - continue; - } + // ★ 售罄(stock=0)不隐藏:仍返回给前端展示,仅禁止购买。 + // 只有 is_active=0(下架)才不返回(见上方 WHERE 条件)。 // 解析债券范围(支持 "1-10" 格式) $bondReward = $row['bond_reward']; diff --git a/player.php b/player.php index abec798..157c94c 100644 --- a/player.php +++ b/player.php @@ -1212,13 +1212,14 @@ if ($currentVersion !== $BUILD_VERSION) { const offerText = product.temporary_offer ? `
🎁 ${product.temporary_offer}${product.expire_display ? ' (有效期: ' + product.expire_display + ')' : ''}
` : ''; const stockText = product.stock === -1 ? '无限库存' : (product.stock > 0 ? `库存: ${product.stock}` : '售罄'); const stockColor = product.stock === -1 ? 'var(--green)' : (product.stock > 0 ? 'var(--dim)' : 'var(--red)'); + const isSoldOut = product.stock === 0; // 售罄:仍展示,但禁止购买 // ★ 盲盒不显示具体金额,用 ?? 代替 const bondDisplay = isBlindBox ? '🎲 ?? 债券' : `${product.bond_min} 债券`; // ★ 盲盒随机语录 const quoteText = isBlindBox ? `
${blindBoxQuotes[Math.floor(Math.random() * blindBoxQuotes.length)]}
` : ''; html += ` -
+
${product.item_name} ${stockText} @@ -1264,12 +1265,23 @@ if ($currentVersion !== $BUILD_VERSION) { const price = el.dataset.price; const bondMin = el.dataset.bondMin; const bondMax = el.dataset.bondMax; + const stock = parseInt(el.dataset.stock, 10) || 0; // ★ 盲盒不显示具体金额,用 ?? 代替 const bondText = bondMin === bondMax ? bondMin + ' 债券' : '🎲 ?? 债券'; btn.style.display = 'block'; - btn.textContent = `支付宝支付 ¥${price} → ${bondText}`; btn.dataset.productId = el.dataset.productId; + // ★ 售罄(stock=0):展示商品但禁止购买;只有下架(is_active=0)才不展示 + if (stock === 0) { + btn.disabled = true; + btn.textContent = '😔 已售罄'; + btn.onclick = null; + } else { + btn.disabled = false; + btn.textContent = `支付宝支付 ¥${price} → ${bondText}`; + btn.onclick = startRecharge; + } + // 保存选中商品信息 window.selectedShopProduct = { id: el.dataset.productId, @@ -1328,10 +1340,10 @@ if ($currentVersion !== $BUILD_VERSION) { if (res.data.status === 'paid') { st.innerHTML = '✅ 支付成功!游戏内债券发放中,请稍候刷新「余额查询」。可以发起新订单。'; if (rechargePollTimer) { clearInterval(rechargePollTimer); rechargePollTimer = null; } - // 支付成功后清除本地记录 + 恢复按钮允许新订单 + // 支付成功后清除本地记录 localStorage.removeItem('sdf1_last_recharge_no'); - const btn = document.getElementById('rechargeBtn'); - if (btn) { btn.disabled = false; btn.textContent = '🅰️ 支付宝支付 ¥0.01'; btn.onclick = startRecharge; } + // ★ 刷新商品列表:库存可能变化(如本次购买导致售罄),并正确重置按钮状态 + loadShopProducts(); } else { st.innerHTML = '⏳ 订单处理中(' + (res.message || '等待支付平台通知') + ')…'; }