feat(pay): VIP package purchase service and user-center open flow
Add AKSRT_Vip_Service (GET/POST /pay/vip), activate aksrt_vip_level/expires on order paid, package UI in credits panel, and deep-link VIP CTA to credits tab.
This commit is contained in:
1 parent
8e9e05c859
commit
d0b8f7805f
10 files changed
+957
-24
No files matched your search
@@ -321,3 +321,194 @@
|
||||
color: var(--color-ink-4);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* ==================== VIP 会员开通 ==================== */
|
||||
|
||||
.uc-vip-card {
|
||||
position: relative;
|
||||
border-radius: var(--radius);
|
||||
overflow: hidden;
|
||||
margin-bottom: 16px;
|
||||
box-shadow: 0 4px 20px rgba(245, 158, 11, 0.18);
|
||||
}
|
||||
.uc-vip-card__bg {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(135deg, #f59e0b 0%, #f97316 55%, #ef4444 100%);
|
||||
z-index: 0;
|
||||
}
|
||||
.uc-vip-card--active .uc-vip-card__bg {
|
||||
background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 55%, #8b5cf6 100%);
|
||||
}
|
||||
.uc-vip-card__content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
padding: 22px;
|
||||
color: #fff;
|
||||
}
|
||||
.uc-vip-card__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.uc-vip-card__icon {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
border-radius: 12px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(255,255,255,0.18);
|
||||
font-size: 18px;
|
||||
}
|
||||
.uc-vip-card__label {
|
||||
display: block;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.uc-vip-card__status {
|
||||
display: inline-block;
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
opacity: 0.9;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
background: rgba(255,255,255,0.16);
|
||||
}
|
||||
.uc-vip-card__status--active {
|
||||
background: rgba(16, 185, 129, 0.25);
|
||||
}
|
||||
.uc-vip-card__benefits {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 12px;
|
||||
font-size: 12px;
|
||||
opacity: 0.95;
|
||||
}
|
||||
.uc-vip-card__benefit i { margin-right: 4px; }
|
||||
.uc-vip-card__desc {
|
||||
margin: 12px 0 0;
|
||||
font-size: 12px;
|
||||
opacity: 0.85;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.uc-vip-shop {
|
||||
background: var(--surface-1, #fff);
|
||||
border: 1px solid var(--color-line-soft, rgba(0,0,0,0.06));
|
||||
border-radius: var(--radius, 10px);
|
||||
padding: 16px 18px 18px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.uc-vip-shop__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: var(--color-ink, #111);
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.uc-vip-shop__title i { color: #f59e0b; }
|
||||
.uc-vip-shop__group { margin-bottom: 16px; }
|
||||
.uc-vip-shop__group-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--color-ink-2, #374151);
|
||||
margin-bottom: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.uc-vip-shop__badge {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #047857;
|
||||
background: #ecfdf5;
|
||||
border-radius: 999px;
|
||||
padding: 2px 8px;
|
||||
}
|
||||
.uc-vip-shop__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
.uc-vip-shop__item {
|
||||
appearance: none;
|
||||
border: 1px solid var(--color-line, #e5e7eb);
|
||||
background: var(--surface-0, #fafafa);
|
||||
border-radius: 12px;
|
||||
padding: 14px 12px;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
}
|
||||
.uc-vip-shop__item:hover {
|
||||
border-color: #f59e0b;
|
||||
box-shadow: 0 8px 20px rgba(245, 158, 11, 0.12);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.uc-vip-shop__item.is-loading {
|
||||
opacity: 0.65;
|
||||
pointer-events: none;
|
||||
}
|
||||
.uc-vip-shop__item-title {
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: var(--color-ink, #111);
|
||||
}
|
||||
.uc-vip-shop__item-days {
|
||||
font-size: 12px;
|
||||
color: var(--color-ink-3, #6b7280);
|
||||
}
|
||||
.uc-vip-shop__item-price {
|
||||
margin-top: 6px;
|
||||
font-size: 18px;
|
||||
font-weight: 800;
|
||||
color: #dc2626;
|
||||
}
|
||||
.uc-vip-shop__item-cta {
|
||||
margin-top: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #b45309;
|
||||
}
|
||||
.uc-vip-shop__methods {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px 12px;
|
||||
margin-top: 8px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid var(--color-line-soft, rgba(0,0,0,0.06));
|
||||
}
|
||||
.uc-vip-shop__methods-label {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--color-ink-3, #6b7280);
|
||||
}
|
||||
.uc-vip-shop__method {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.uc-vip-shop__tip {
|
||||
margin: 10px 0 0;
|
||||
font-size: 12px;
|
||||
color: var(--color-ink-3, #6b7280);
|
||||
min-height: 1.2em;
|
||||
}
|
||||
.uc-vip-shop__tip.is-error { color: #dc2626; }
|
||||
.uc-vip-shop__empty {
|
||||
font-size: 13px;
|
||||
color: var(--color-ink-3, #6b7280);
|
||||
margin: 0 0 16px;
|
||||
}
|
||||
@@ -317,13 +317,98 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// ===== VIP 开通 =====
|
||||
function initVipShop() {
|
||||
var root = document.querySelector('[data-aksrt-vip-shop]');
|
||||
if (!root) return;
|
||||
var tip = root.querySelector('[data-aksrt-vip-tip]');
|
||||
var busy = false;
|
||||
|
||||
function setTip(text, isError) {
|
||||
if (!tip) return;
|
||||
tip.textContent = text || '';
|
||||
tip.classList.toggle('is-error', !!isError);
|
||||
}
|
||||
|
||||
function selectedMethod() {
|
||||
var fixed = root.querySelector('[data-aksrt-vip-method-fixed]');
|
||||
if (fixed && fixed.value) return fixed.value;
|
||||
var checked = root.querySelector('input[name="aksrt_vip_pay_method"]:checked');
|
||||
if (checked) return checked.value;
|
||||
var first = root.querySelector('input[name="aksrt_vip_pay_method"]');
|
||||
return first ? first.value : 'balance';
|
||||
}
|
||||
|
||||
function pollOrder(orderNumber) {
|
||||
if (!orderNumber) return;
|
||||
var tries = 0;
|
||||
var maxTries = 40;
|
||||
var timer = setInterval(function () {
|
||||
tries += 1;
|
||||
api('/pay/content/order/' + encodeURIComponent(orderNumber)).then(function (r) {
|
||||
if (r.ok && r.json && r.json.paid) {
|
||||
clearInterval(timer);
|
||||
setTip('支付成功,正在刷新…');
|
||||
window.location.reload();
|
||||
}
|
||||
}).catch(function () { /* ignore */ });
|
||||
if (tries >= maxTries) clearInterval(timer);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
root.addEventListener('click', function (e) {
|
||||
var btn = e.target.closest('[data-aksrt-vip-buy]');
|
||||
if (!btn || busy) return;
|
||||
e.preventDefault();
|
||||
var packageId = parseInt(btn.getAttribute('data-package-id') || '0', 10);
|
||||
if (!packageId) return;
|
||||
busy = true;
|
||||
btn.classList.add('is-loading');
|
||||
setTip('正在创建订单…');
|
||||
|
||||
api('/pay/vip', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
package_id: packageId,
|
||||
payment_method: selectedMethod()
|
||||
})
|
||||
}).then(function (r) {
|
||||
busy = false;
|
||||
btn.classList.remove('is-loading');
|
||||
if (!r.ok || (r.json && r.json.code && !r.json.success)) {
|
||||
var msg = (r.json && r.json.message) || '开通失败';
|
||||
setTip(msg, true);
|
||||
return;
|
||||
}
|
||||
var data = (r.json && r.json.data) ? r.json.data : r.json;
|
||||
if (data && data.redirect && (data.payment_url || data.qr_content)) {
|
||||
if (data.payment_url) {
|
||||
window.open(data.payment_url, '_blank');
|
||||
}
|
||||
setTip(data.message || '请完成支付,支付成功后将自动刷新。');
|
||||
if (data.order_number) pollOrder(data.order_number);
|
||||
return;
|
||||
}
|
||||
setTip((data && data.message) || '开通成功,正在刷新…');
|
||||
window.location.reload();
|
||||
}).catch(function () {
|
||||
busy = false;
|
||||
btn.classList.remove('is-loading');
|
||||
setTip('网络错误,请重试', true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
initSignin();
|
||||
initInvite();
|
||||
initVipShop();
|
||||
});
|
||||
} else {
|
||||
initSignin();
|
||||
initInvite();
|
||||
initVipShop();
|
||||
}
|
||||
})();
|
||||
Reference in new issue
Block a user