KEEPONEVIRTUAL STUDIO 🐴已登录 岗位举证部门生成器
'; $('drawerBody').innerHTML = ''; $('drawerBody').appendChild(frame); }) .catch(function (e) { $('drawerBody').innerHTML = '
!
' + KC.esc(e.message || '预览加载失败') + '
'; }); } function downloadPdf(id, name) { KC.toast('正在准备 PDF…'); fetch('/api/sandbox/reports/' + id + '/pdf', { headers: { 'X-KC-SSO': KC.token() } }) .then(function (r) { if (r.status === 401) { KC.clearToken(); KC.goLogin(); throw new Error('unauth'); } if (!r.ok) throw new Error('下载失败(' + r.status + ')'); return r.blob(); }) .then(function (blob) { var url = URL.createObjectURL(blob); var a = document.createElement('a'); a.href = url; a.download = '岗位报告-' + (name || id) + '.pdf'; document.body.appendChild(a); a.click(); a.remove(); setTimeout(function () { URL.revokeObjectURL(url); }, 4000); }) .catch(function (e) { if (e.message !== 'unauth') KC.toast(e.message || 'PDF 下载失败', 'err'); }); } /* ---------- 付款 ---------- */ var PAY_PLANS = [ { id: 'basic', name: '初级', price: 59, note: '100 万虚拟盘 · 3 个智能体 · 3 个岗位' }, { id: 'pro', name: '中级', price: 99, note: '1000 万虚拟盘 · 6 个智能体 · 8 个岗位' }, { id: 'elite', name: '高级', price: 199, note: '1 亿虚拟盘 · 10 个智能体 · 10 个岗位' } ]; function payPlans() { var icon = function (t, soon) { return '' + t + ''; }; return '
' + PAY_PLANS.map(function (p) { return '
' + '
' + p.name + '
' + '
¥' + p.price + '' + ' / 30 天
' + '
' + p.note + '
' + '' + '
' + icon('VISA') + icon('MC') + icon('AMEX') + icon('Alipay', true) + icon('WeChat', true) + '
' + '
'; }).join('') + '
' + '
' + '支付走 Stripe Checkout,现在支持支付宝与信用卡。单次付款,不会自动扣款。
'; } function bindPay() { Array.prototype.forEach.call(document.querySelectorAll('[data-pay]'), function (b) { b.addEventListener('click', function () { var plan = b.getAttribute('data-pay'); var old = b.textContent; b.disabled = true; b.textContent = '正在打开支付…'; KC.api('/subscription/checkout', { method: 'POST', body: { plan: plan } }) .then(function (d) { if (d && d.url) { location.href = d.url; return; } throw new Error('未返回支付地址'); }) .catch(function (e) { b.disabled = false; b.textContent = old; KC.toast(KC.errText(e), 'err'); }); }); }); } /* ---------- 05 续费 ---------- */ function renderRenew() { var sub = state.sub; if (!sub) { $('renewBody').innerHTML = '
订阅信息加载中…
'; return; } if (!sub.expire_at || sub.active === false) { var never = !sub.expire_at; $('renewBody').innerHTML = '

' + (never ? '尚未开通订阅' : '订阅已过期') + '

' + '

' + (never ? '选一档开通,30 天内可创建沙盘、看岗位日报。' : '到期日 ' + KC.date(sub.expire_at) + '。选一档直接付款,30 天内沙盘与报告恢复。') + '

' + payPlans() + '
'; bindPay(); return; } var soon = typeof sub.days_left === 'number' && sub.days_left <= 3; $('renewBody').innerHTML = (soon ? '
订阅将在 ' + sub.days_left + ' 天后到期。
' : '') + '
' + '
' + '
' + '
Current plan
' + '
' + KC.esc(KC.tierName(sub.plan)) + '' + '¥' + KC.tierPrice(sub.plan) + ' / 月
' + '
到期日 ' + KC.date(sub.expire_at) + ' · 剩余 ' + KC.esc(sub.days_left) + ' 天 · ' + (sub.auto_renew ? '已开启自动续费' : '未开启自动续费') + '
' + '
' + '
' + '
' + KC.esc(sub.days_left) + '
' + '
DAYS LEFT
' + '
' + '
' + '' + '' + '
' + '
' + '
' + '
i
' + '支付走 Stripe Checkout,现在支持支付宝与信用卡。单次付款,不会自动扣款。' + '沙盘额度与本月初始化次数不因续费重置,按订阅周期计算。
' + '
Upgrade
' + '升级档位(只补差价)' + '
差价 =(目标档位月费 − 当前档位月费)× 剩余天数 ÷ 30;升级后到期日不变。
' + '
' + upgradeRows(sub) + '
' + '
Plans
' + '
' + '' + '' + '' + '
档位月费沙盘额度初始化组合上限
初级¥59100 万1 次/月3 个
中级¥991000 万3 次/月6 个
高级¥1991 亿4 次/月10 个
' + '
价格与权益以本页「订阅与续费」为准。
' + '
'; var switchBtn = $('switchPlanBtn'); if (switchBtn) switchBtn.addEventListener('click', function () { KC.modal('

换档 / 续费

' + '付款后按新档位重算额度;到期时间从今天起算 30 天。

' + payPlans() + '
'); bindPay(); }); /* fillUpgradeInline */ setTimeout(function () { (function () { var box = document.getElementById('upgradeBox'); if (!box) return; var order = ['basic', 'pro', 'elite']; var cur = sub.plan || 'basic'; var prices = (KC._region && KC._region.prices) || { basic: 59, pro: 99, elite: 199 }; var names = (KC._region && KC._region.tier_name) || { basic: '初级', pro: '中级', elite: '高级' }; var days = Number(sub.days_left || 0); var higher = order.slice(order.indexOf(cur) + 1); if (!higher.length) { box.innerHTML = '
已经是最高档位。
'; return; } box.innerHTML = higher.map(function (pl) { var diff = Math.max(1, (Number(prices[pl]) - Number(prices[cur])) * Math.max(days, 1) / 30); return '
' + '
' + (names[pl] || pl) + '' + ' · ¥' + prices[pl] + '
' + '
¥' + diff.toFixed(2) + '
' + '
'; }).join(''); Array.prototype.forEach.call(box.querySelectorAll('[data-upgrade]'), function (b) { b.onclick = function () { var pl = b.getAttribute('data-upgrade'); b.disabled = true; KC.api('/studio/upgrade', { method: 'POST', body: { plan: pl } }) .then(function (d) { if (d && d.url) { location.href = d.url; return; } throw new Error('no url'); }) .catch(function (e) { b.disabled = false; KC.toast(KC.errText(e), 'err'); }); }; }); })(); }, 0); var btn = $('renewBtn'); if (btn) btn.addEventListener('click', function () { var b = this; b.disabled = true; b.textContent = '正在跳转…'; KC.api('/subscription/checkout', { method: 'POST', body: { plan: sub.plan } }) .then(function (d) { if (d && d.url) location.href = d.url; else throw new Error('未返回支付地址'); }) .catch(function (e) { b.disabled = false; b.textContent = '续费一个月'; KC.toast(KC.errText(e), 'err'); }); }); try { renderUpgrade(); } catch (e) {} } /* ---------- 启动 ---------- */ function boot() { // 工作室资料:头像 + 工作室名(拿到就更新头部) fetch('/api/studio/profile', { credentials: 'same-origin', cache: 'no-store' }) .then(function (r) { return r.ok ? r.json() : null; }) .then(function (d) { if (!d || d.ok === false) return; window.__studioProfile = d; var av = document.getElementById('userAvatar'); var nm = document.getElementById('userName'); if (av && d.avatar) av.textContent = d.avatar; if (nm && (d.studio_name || d.code)) nm.textContent = d.studio_name || d.code; }) .catch(function () {}); // cn.keepone.trade 与 keepone.win 同域:kc_sso cookie 直接生效, // 没有 localStorage 令牌也能进(以前这里直接踢去 /login,用户会被反复弹回登录页) if (!KC.token()) { fetch('/api/sandbox/me', { credentials: 'same-origin', cache: 'no-store' }) .then(function (r) { if (r.status === 401) { KC.goLogin(); return; } startUi(); }) .catch(function () { KC.goLogin(); }); return; } startUi(); } function startUi() { $('logoutBtn').addEventListener('click', function () { KC.modal('

退出登录?

退出后需要重新登录才能查看沙盘。

' + '
' + '
'); $('doLogout').addEventListener('click', KC.logout); }); $('drawerClose').addEventListener('click', function () { $('drawer').hidden = true; $('drawerBody').innerHTML = ''; }); $('drawerPdf').addEventListener('click', function () { if (state.currentReport && state.currentReport.id != null) downloadPdf(Number(state.currentReport.id), (state.currentReport.date || '') + '-' + (state.currentReport.role || '')); }); document.addEventListener('keydown', function (e) { if (e.key === 'Escape') { $('drawer').hidden = true; KC.closeModal(); } }); var tab = (location.hash || '#status').slice(1); setTab(TABS.indexOf(tab) >= 0 ? tab : 'status', true); loadCore(); } window.addEventListener('hashchange', function () { setTab((location.hash || '#status').slice(1), true); }); function loadAppMode() { return KC.api('/studio/mode') .then(function (d) { APP_MODE = (d && d.mode) || 'simple'; applyMode(); }) .catch(function () { APP_MODE = 'simple'; applyMode(); }); } loadAppMode().then(function () { bindModeSwitch(); }); boot(); })(); window.KCUpgrade = function (pl) { KC.api('/studio/upgrade', { method: 'POST', body: { plan: pl } }) .then(function (d) { if (d && d.url) { location.href = d.url; return; } throw new Error('no url'); }) .catch(function (e) { KC.toast(KC.errText(e), 'err'); }); }; function upgradeRows(sub) { var order = ['basic', 'pro', 'elite']; var cur = (sub && sub.plan) || 'basic'; var prices = (KC._region && KC._region.prices) || { basic: 59, pro: 99, elite: 199 }; var names = (KC._region && KC._region.tier_name) || { basic: '初级', pro: '中级', elite: '高级' }; var days = Number((sub && sub.days_left) || 0); var higher = order.slice(order.indexOf(cur) + 1); if (!higher.length) return '
已经是最高档位。
'; return higher.map(function (pl) { var diff = Math.max(1, (Number(prices[pl]) - Number(prices[cur])) * Math.max(days, 1) / 30); return '
' + '
' + (names[pl] || pl) + '' + ' · ¥' + prices[pl] + '
' + '
¥' + diff.toFixed(2) + '
' + '
'; }).join(''); }