完善职务礼包红包默认配置
This commit is contained in:
@@ -296,42 +296,82 @@
|
||||
/**
|
||||
* superlevel 点击「礼包」按钮,弹出 chatBanner 三按钮选择类型后发包。
|
||||
*/
|
||||
window.sendRedPacket = function() {
|
||||
window.chatBanner.show({
|
||||
icon: '🧧',
|
||||
title: '发出礼包',
|
||||
name: '选择礼包类型',
|
||||
body: '将发出 <b>8888</b> 数量共 <b>10</b> 份的礼包,系统凭空发放,房间成员先到先得!',
|
||||
gradient: ['#991b1b', '#dc2626', '#ea580c'],
|
||||
titleColor: '#fde68a',
|
||||
autoClose: 0,
|
||||
buttons: [{
|
||||
label: '💰 金币礼包',
|
||||
color: '#d97706',
|
||||
onClick(btn, close) {
|
||||
close();
|
||||
doSendRedPacket('gold');
|
||||
window.sendRedPacket = async function() {
|
||||
const btn = document.getElementById('red-packet-btn');
|
||||
if (btn) {
|
||||
btn.disabled = true;
|
||||
btn.textContent = '读取中…';
|
||||
}
|
||||
|
||||
try {
|
||||
const config = await fetchRedPacketConfig();
|
||||
const amountText = Number(config.amount || 0).toLocaleString('zh-CN');
|
||||
const countText = Number(config.count || 0).toLocaleString('zh-CN');
|
||||
|
||||
window.chatBanner.show({
|
||||
icon: '🧧',
|
||||
title: '发出礼包',
|
||||
name: '选择礼包类型',
|
||||
body: `将发出 ${amountText} 数量共 ${countText} 份的礼包,系统凭空发放,房间成员先到先得!`,
|
||||
gradient: ['#991b1b', '#dc2626', '#ea580c'],
|
||||
titleColor: '#fde68a',
|
||||
autoClose: 0,
|
||||
buttons: [{
|
||||
label: '💰 金币礼包',
|
||||
color: '#d97706',
|
||||
onClick(button, close) {
|
||||
close();
|
||||
doSendRedPacket('gold');
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '✨ 经验礼包',
|
||||
color: '#7c3aed',
|
||||
onClick(btn, close) {
|
||||
close();
|
||||
doSendRedPacket('exp');
|
||||
{
|
||||
label: '✨ 经验礼包',
|
||||
color: '#7c3aed',
|
||||
onClick(button, close) {
|
||||
close();
|
||||
doSendRedPacket('exp');
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '取消',
|
||||
color: 'rgba(255,255,255,0.15)',
|
||||
onClick(btn, close) {
|
||||
close();
|
||||
{
|
||||
label: '取消',
|
||||
color: 'rgba(255,255,255,0.15)',
|
||||
onClick(button, close) {
|
||||
close();
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
],
|
||||
});
|
||||
} catch (e) {
|
||||
await window.chatDialog.alert(e.message || '读取礼包配置失败', '操作失败', '#cc4444');
|
||||
} finally {
|
||||
if (btn) {
|
||||
btn.disabled = false;
|
||||
btn.innerHTML = '🧧 礼包';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 读取当前职务的礼包红包默认配置。
|
||||
*
|
||||
* @returns {Promise<{amount:number,count:number,expire_seconds:number}>}
|
||||
*/
|
||||
async function fetchRedPacketConfig() {
|
||||
const res = await fetch('/command/red-packet/config', {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
|
||||
},
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
if (!res.ok || data.status !== 'success') {
|
||||
throw new Error(data.message || '读取礼包配置失败');
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实际发包请求(由 chatBanner 按钮回调触发)。
|
||||
*
|
||||
@@ -624,7 +664,7 @@
|
||||
// 弹出全局 Toast
|
||||
window.chatToast.show({
|
||||
title: '🧧 礼包到账',
|
||||
message: `恭喜您抢到了礼包 <b>${data.amount}</b> ${typeLabel}!`,
|
||||
message: `恭喜您抢到了礼包 ${data.amount} ${typeLabel}!`,
|
||||
icon: '🧧',
|
||||
color: (_rpType === 'exp') ? '#7c3aed' : '#dc2626',
|
||||
duration: 8000,
|
||||
|
||||
Reference in New Issue
Block a user