优化vip

This commit is contained in:
2026-04-12 23:25:38 +08:00
parent 353aaaf6ce
commit dca43a2d0d
9 changed files with 346 additions and 100 deletions
@@ -1648,7 +1648,34 @@ async function generateWechatBindCode() {
// 会员等级
const grid = document.getElementById('vip-levels-grid');
grid.innerHTML = d.vipLevels.map(v => {
const isCurrent = d.user.vip_level_id === v.id && d.user.is_vip;
const isCurrent = v.is_current;
const isHigher = v.is_higher;
const isLower = v.is_lower;
let btnText = '立即购买';
let btnColor = '#1e293b';
let btnTextColor = '#fff';
let priceToDisplay = v.price;
let isDisabled = !d.vipPaymentEnabled;
let showUpgradeInfo = false;
if (isCurrent) {
btnText = '立即续费';
btnColor = '#f59e0b';
btnTextColor = '#fff';
} else if (isHigher && d.user.is_vip) {
btnText = '补差价升级';
btnColor = '#4f46e5';
btnTextColor = '#fff';
priceToDisplay = v.upgrade_price;
showUpgradeInfo = true;
} else if (isLower) {
btnText = '无法降级';
btnColor = '#f1f5f9';
btnTextColor = '#94a3b8';
isDisabled = true;
}
return `
<div class="vip-level-card ${isCurrent ? 'current' : ''}">
${isCurrent ? '<span class="vip-level-badge">当前档位</span>' : ''}
@@ -1663,11 +1690,15 @@ async function generateWechatBindCode() {
<div class="vip-feature-item"><span class="vip-feature-icon"></span> 专属入场特效 & 横幅</div>
</div>
<div style="margin-top:auto; padding-top:10px;">
<div style="font-size:18px; font-weight:900; color:#e11d48; margin-bottom:10px;">¥${Number(v.price).toFixed(2)} <span style="font-size:11px; font-weight:normal; color:#94a3b8;">/ ${v.duration_days}</span></div>
<button onclick="buyVip(${v.id})" ${!d.vipPaymentEnabled ? 'disabled' : ''}
<div style="font-size:18px; font-weight:900; color:#e11d48; margin-bottom:5px;">
¥${Number(priceToDisplay).toFixed(2)}
<span style="font-size:11px; font-weight:normal; color:#94a3b8;">/ ${v.duration_days}</span>
</div>
${showUpgradeInfo ? `<div style="font-size:10px; color:#4f46e5; font-weight:bold; margin-bottom:8px;">已省 ¥${(v.price - v.upgrade_price).toFixed(2)}</div>` : ''}
<button onclick="buyVip(${v.id})" ${isDisabled ? 'disabled' : ''}
style="width:100%; border:none; border-radius:8px; padding:10px; font-size:13px; font-weight:bold; cursor:pointer; transition:all .2s;
background:${isCurrent ? '#fef3c7' : '#1e293b'}; color:${isCurrent ? '#b45309' : '#fff'};">
${!d.vipPaymentEnabled ? '支付暂未开启' : (isCurrent ? '立即续费' : '立即购买')}
background:${btnColor}; color:${btnTextColor}; ${isDisabled ? 'cursor:not-allowed;' : ''}">
${!d.vipPaymentEnabled && !isLower ? '支付暂未开启' : btnText}
</button>
</div>
</div>
@@ -1769,9 +1800,11 @@ async function generateWechatBindCode() {
window.buyVip = function(levelId) {
// 这里我们模拟提交表单,因为支付逻辑通常需要页面跳转
// 修改为在新窗口打开支付,避免聊天室页面丢失
const form = document.createElement('form');
form.method = 'POST';
form.action = '{{ route('vip.payment.store') }}';
form.target = '_blank'; // 新窗口打开支付
const csrfInput = document.createElement('input');
csrfInput.type = 'hidden';
@@ -1787,6 +1820,13 @@ async function generateWechatBindCode() {
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
// 提交后关闭弹窗并提示用户
closeVipModal();
if (window.chatDialog) {
window.chatDialog.alert('正在为您前往支付中心,请在新页面完成支付。', '支付提示', '#3b82f6');
}
};
window.saveVipPresenceSettings = async function() {
@@ -132,6 +132,9 @@
}
const styleConfig = getVipPresenceStyleConfig(payload.presence_banner_style, payload.presence_color);
const bannerTypeLabel = payload.presence_type === 'leave'
? '离场提示'
: (payload.presence_type === 'purchase' ? '开通喜报' : '闪耀登场');
const banner = document.createElement('div');
banner.id = 'vip-presence-banner';
banner.className = 'vip-presence-banner';
@@ -141,7 +144,7 @@
<div class="vip-presence-banner__meta">
<span class="vip-presence-banner__icon">${escapeHtml(payload.presence_icon || '👑')}</span>
<span class="vip-presence-banner__level">${escapeHtml(payload.presence_level_name || '尊贵会员')}</span>
<span class="vip-presence-banner__type">${payload.presence_type === 'leave' ? '离场提示' : '闪耀登场'}</span>
<span class="vip-presence-banner__type">${bannerTypeLabel}</span>
</div>
<div class="vip-presence-banner__text" style="color:${styleConfig.accent};">${escapePresenceText(payload.presence_text)}</div>
</div>
@@ -783,7 +786,9 @@
const icon = escapeHtml(msg.presence_icon || '👑');
const levelName = escapeHtml(msg.presence_level_name || '尊贵会员');
const typeLabel = msg.presence_type === 'leave' ? '华丽离场' : '荣耀入场';
const typeLabel = msg.presence_type === 'leave'
? '华丽离场'
: (msg.presence_type === 'purchase' ? '荣耀开通' : '荣耀入场');
const safeText = escapePresenceText(msg.presence_text || '');
html = `