新增微信支付

This commit is contained in:
2026-04-13 17:25:33 +08:00
parent dca43a2d0d
commit d060e1b797
8 changed files with 165 additions and 29 deletions
@@ -1695,11 +1695,24 @@ async function generateWechatBindCode() {
<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:${btnColor}; color:${btnTextColor}; ${isDisabled ? 'cursor:not-allowed;' : ''}">
${!d.vipPaymentEnabled && !isLower ? '支付暂未开启' : btnText}
</button>
${!d.vipPaymentEnabled || isDisabled
? `<button ${isDisabled ? 'disabled' : 'disabled'}
style="width:100%; border:none; border-radius:8px; padding:10px; font-size:13px; font-weight:bold; cursor:not-allowed; transition:all .2s;
background:${btnColor}; color:${btnTextColor};">
${!d.vipPaymentEnabled && !isLower ? '支付暂未开启' : btnText}
</button>`
: `<div style="display:grid; grid-template-columns:1fr 1fr; gap:8px;">
<button onclick="buyVip(${v.id}, 'alipay')"
style="border:none; border-radius:8px; padding:10px; font-size:13px; font-weight:bold; cursor:pointer; transition:all .2s; background:${btnColor}; color:${btnTextColor};">
支付宝
</button>
<button onclick="buyVip(${v.id}, 'wechat')"
style="border:none; border-radius:8px; padding:10px; font-size:13px; font-weight:bold; cursor:pointer; transition:all .2s; background:#16a34a; color:#fff;">
微信
</button>
</div>
<div style="font-size:10px; color:#64748b; margin-top:8px; text-align:center;">${btnText}后将跳转到对应支付页面</div>`
}
</div>
</div>
`;
@@ -1798,7 +1811,7 @@ async function generateWechatBindCode() {
}
}
window.buyVip = function(levelId) {
window.buyVip = function(levelId, provider = 'alipay') {
// 这里我们模拟提交表单,因为支付逻辑通常需要页面跳转
// 修改为在新窗口打开支付,避免聊天室页面丢失
const form = document.createElement('form');
@@ -1818,6 +1831,12 @@ async function generateWechatBindCode() {
idInput.value = levelId;
form.appendChild(idInput);
const providerInput = document.createElement('input');
providerInput.type = 'hidden';
providerInput.name = 'provider';
providerInput.value = provider;
form.appendChild(providerInput);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
@@ -1825,7 +1844,8 @@ async function generateWechatBindCode() {
// 提交后关闭弹窗并提示用户
closeVipModal();
if (window.chatDialog) {
window.chatDialog.alert('正在为您前往支付中心,请在新页面完成支付。', '支付提示', '#3b82f6');
const providerText = provider === 'wechat' ? '微信支付二维码页' : '支付宝支付页';
window.chatDialog.alert(`正在为您打开${providerText},请在新页面完成支付。`, '支付提示', '#3b82f6');
}
};