优化vip
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user