新增每日签到与补签卡功能

This commit is contained in:
2026-04-24 22:47:27 +08:00
parent 34356a26ae
commit be9fc09d9d
46 changed files with 3934 additions and 55 deletions
@@ -1204,7 +1204,7 @@ async function generateWechatBindCode() {
{
label: '🎭 道具',
desc: '',
type: 'one_time'
type: 'tools'
},
];
@@ -1212,7 +1212,7 @@ async function generateWechatBindCode() {
list.innerHTML = '';
groups.forEach(g => {
const items = data.items.filter(i => i.type === g.type);
const items = data.items.filter(i => g.type === 'tools' ? ['one_time', 'sign_repair'].includes(i.type) : i.type === g.type);
if (!items.length) return;
// 分组标题(独占一整行)
@@ -1235,6 +1235,9 @@ async function generateWechatBindCode() {
const effName = effItem ? effItem.name : effKey;
groupSuffix =
` <span style="display:inline-block;margin-left:8px;padding:1px 8px;background:#16a34a;color:#fff;border-radius:10px;font-size:10px;font-weight:bold;vertical-align:middle;">✅ 已激活:${effName}</span>`;
} else if (g.type === 'tools' && (data.sign_repair_card_count || 0) > 0) {
groupSuffix =
` <span style="display:inline-block;margin-left:8px;padding:1px 8px;background:#0f766e;color:#fff;border-radius:10px;font-size:10px;font-weight:bold;vertical-align:middle;">🎫 可用 ${data.sign_repair_card_count} 张</span>`;
}
header.innerHTML = `${g.label}${groupSuffix}${g.desc ? ` <span>${g.desc}</span>` : ''}`;
list.appendChild(header);
@@ -1295,10 +1298,15 @@ async function generateWechatBindCode() {
btn.className = 'shop-btn';
btn.innerHTML = `💰 ${Number(item.price).toLocaleString()}`;
btn.onclick = async () => {
let quantity = 1;
if (item.type === 'sign_repair') {
quantity = await window.promptSignRepairQuantity?.(item);
if (quantity === null || quantity === undefined) return;
}
const confirmMsg =
`确认花费 💰 ${Number(item.price).toLocaleString()} 金币购买\n【${item.name}】吗?`;
`确认花费 💰 ${Number(item.price * quantity).toLocaleString()} 金币购买\n【${item.name}】${quantity > 1 ? ' × ' + quantity : ''} 吗?`;
const ok = await window.chatDialog.confirm(confirmMsg, '确认购买');
if (ok) buyItem(item.id, item.name, item.price, 'all', '');
if (ok) buyItem(item.id, item.name, item.price, 'all', '', quantity);
};
}
card.appendChild(btn);
@@ -1341,7 +1349,7 @@ async function generateWechatBindCode() {
};
/** 购买商品(最终执行) */
window.buyItem = function(itemId, name, price, recipient, message) {
window.buyItem = function(itemId, name, price, recipient, message, quantity = 1) {
const roomId = window.chatContext?.roomId ?? 0;
fetch('{{ route('shop.buy') }}', {
method: 'POST',
@@ -1354,6 +1362,7 @@ async function generateWechatBindCode() {
item_id: itemId,
recipient: recipient || 'all',
message: message || '',
quantity: quantity || 1,
room_id: roomId,
}),
})