feat(buy): 站内支付页 /buy — 支付成功当场显示卡密;三处购买入口统一改指站内

- 新增 /buy 支付页:读本机机器码、列本项目可售套餐、支付宝/微信/QQ钱包、优惠码选填;
  拉起收银台后本页留守轮询,支付成功显示卡密并自动核验授权
- 购买入口改造:顶栏「永久解锁 13 个功能」、锁定弹窗「购买授权」、授权应用页
  「前往购买卡密」三处统一跳转站内 /buy(原跳外部 auth.88531.cn/#/shop)
- CardAuth 后端:订单支付完成时补发卡密写回订单(原带机器码下单只建授权不发卡)
- CHANGELOG 新增 Version 2026.11.11-it-tools-pro
This commit is contained in:
jinghui committed 2026-11-11 18:21:26 +08:00
1 parent 7b22e53d1a
commit f420785887
7 files changed
+732 -6

No files matched your search

+7
View File
@@ -2,6 +2,13 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
## Version 2026.11.11-it-tools-pro
### 📦 本次更新(2026-11-11)
- **站内支付页 `/buy`(本次核心)**:新增独立支付页——自动读取本机机器码,直接列出本项目可购套餐(名称/价格/时长)、支持支付宝 / 微信支付 / QQ 钱包三种方式、优惠码选填;点击「立即支付」拉起收银台(新标签打开,本页留守轮询),**支付成功当场显示卡密**并自动核验授权,13 个高级功能立即解锁,全程无需人工发货、无需跳出本站
- **购买入口全部改指 `/buy`**:顶栏浮条「永久解锁 13 个功能」、试用用尽锁定弹窗的「购买授权」、授权应用页的「💳 前往购买卡密」,三处统一跳转站内支付页(原先跳外部 `auth.88531.cn/#/shop`);页面未登录即可访问,支付状态本机留存,刷新/误关后自动恢复轮询
- **CardAuth 后端补发卡**:订单支付完成时同步签发一张卡密并写回订单(原先「带机器码下单」只创建授权、不发卡,导致订单查不到卡密、支付结果页无卡可显示);优先取卡池未用卡,卡池不足自动新建,并绑定下单机器码
## Version 2026.11.01-it-tools-pro
### 📦 本次更新(2026-11-01)
+1
View File
@@ -29,6 +29,7 @@ declare module '@vue/runtime-core' {
Bcrypt: typeof import('./src/tools/bcrypt/bcrypt.vue')['default']
BenchmarkBuilder: typeof import('./src/tools/benchmark-builder/benchmark-builder.vue')['default']
Bip39Generator: typeof import('./src/tools/bip39-generator/bip39-generator.vue')['default']
'Buy.page': typeof import('./src/pages/Buy.page.vue')['default']
CAlert: typeof import('./src/ui/c-alert/c-alert.vue')['default']
'CAlert.demo': typeof import('./src/ui/c-alert/c-alert.demo.vue')['default']
CameraRecorder: typeof import('./src/tools/camera-recorder/camera-recorder.vue')['default']
+702
View File
@@ -0,0 +1,702 @@
<script setup lang="ts">
import { useHead } from '@vueuse/head';
import { AUTH_BASE, getMachineId, licenseState, checkAuth } from '@/tools/license/license';
useHead({ title: '购买卡密 - IT-TOOLS-PRO' });
const PROJECT_ID = 6;
const ORDER_KEY = 'it-tools-buy-order';
const POLL_MS = 5000;
interface CardType {
id: number;
name: string;
description: string;
duration_days: number;
price: string;
original_price: string;
}
const machineId = ref('');
const loading = ref(true);
const loadErr = ref('');
const plans = ref<CardType[]>([]);
const selPlan = ref<CardType | null>(null);
const payType = ref('alipay');
const couponCode = ref('');
const ordering = ref(false);
const errMsg = ref('');
const orderNo = ref('');
const payUrl = ref('');
const orderStatus = ref<'pending' | 'paid' | 'expired' | ''>('');
const waitingPay = ref(false);
const cardKey = ref('');
const paidAt = ref('');
const authMsg = ref('');
const copied = ref<'machine' | 'card' | ''>('');
const PAY_METHODS = [
{ key: 'alipay', label: '支付宝', icon: '💳' },
{ key: 'wxpay', label: '微信支付', icon: '💚' },
{ key: 'qqpay', label: 'QQ 钱包', icon: '🐧' },
];
let timer: ReturnType<typeof setInterval> | null = null;
function fmtDays(d: number): string {
if (d >= 999999) return '永久有效';
if (d >= 365) return `${Math.floor(d / 365)} 年`;
if (d >= 30) return `${Math.floor(d / 30)} 个月`;
return `${d} 天`;
}
async function loadPlans(): Promise<void> {
loading.value = true;
loadErr.value = '';
try {
const res = await fetch(`${AUTH_BASE}/public/projects/${PROJECT_ID}/card-types`);
const j = await res.json();
if (j.code !== 200) throw new Error(j.message || '获取套餐失败');
plans.value = (j.data || []) as CardType[];
if (plans.value.length && !selPlan.value) selPlan.value = plans.value[0];
} catch (e: any) {
loadErr.value = e?.message || '加载失败,请刷新重试';
} finally {
loading.value = false;
}
}
function copyText(text: string, tag: 'machine' | 'card'): void {
navigator.clipboard?.writeText(text).then(() => {
copied.value = tag;
setTimeout(() => {
if (copied.value === tag) copied.value = '';
}, 1600);
});
}
function stopPoll(): void {
if (timer) {
clearInterval(timer);
timer = null;
}
waitingPay.value = false;
}
async function pollOnce(): Promise<void> {
if (!orderNo.value) return;
try {
const res = await fetch(
`${AUTH_BASE}/public/orders/query?order_no=${encodeURIComponent(orderNo.value)}`
);
const j = await res.json();
if (j.code !== 200) return;
const d = j.data || {};
orderStatus.value = d.status || '';
if (d.status === 'paid') {
stopPoll();
cardKey.value = d.card_key || '';
paidAt.value = d.paid_at || '';
await refreshAuth();
} else if (d.status === 'expired') {
stopPoll();
errMsg.value = '订单已过期,请重新下单';
}
} catch {
/* 网络抖动忽略,继续轮询 */
}
}
function startPoll(): void {
stopPoll();
waitingPay.value = true;
pollOnce();
timer = setInterval(pollOnce, POLL_MS);
}
async function refreshAuth(): Promise<void> {
authMsg.value = '正在核验授权…';
try {
const ok = await checkAuth();
authMsg.value = ok ? '授权已生效,13 个高级功能已解锁' : '卡密已发放,授权暂未刷新,请点击下方重新核验';
} catch {
authMsg.value = '授权核验失败,请稍后重试';
}
}
async function buy(): Promise<void> {
errMsg.value = '';
if (!selPlan.value) {
errMsg.value = '请先选择套餐';
return;
}
ordering.value = true;
try {
const body: Record<string, any> = {
project_id: PROJECT_ID,
card_type_id: selPlan.value.id,
pay_type: payType.value,
bot_qq: machineId.value,
contact_qq: machineId.value,
};
if (couponCode.value.trim()) body.coupon_code = couponCode.value.trim();
const res = await fetch(`${AUTH_BASE}/public/orders`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
});
const j = await res.json();
if (j.code !== 200) throw new Error(j.message || '下单失败');
orderNo.value = j.data.order_no;
payUrl.value = j.data.pay_url;
orderStatus.value = 'pending';
cardKey.value = '';
authMsg.value = '';
localStorage.setItem(ORDER_KEY, JSON.stringify({ order_no: orderNo.value }));
// 支付页新窗口打开,本页留守轮询
window.open(payUrl.value, '_blank', 'noopener');
startPoll();
} catch (e: any) {
errMsg.value = e?.message || '下单失败,请稍后重试';
} finally {
ordering.value = false;
}
}
function reopenPay(): void {
if (payUrl.value) window.open(payUrl.value, '_blank', 'noopener');
}
function clearOrder(): void {
stopPoll();
orderNo.value = '';
payUrl.value = '';
orderStatus.value = '';
cardKey.value = '';
authMsg.value = '';
errMsg.value = '';
localStorage.removeItem(ORDER_KEY);
}
onMounted(async () => {
machineId.value = getMachineId();
await loadPlans();
// 恢复未完成订单,继续轮询
try {
const saved = JSON.parse(localStorage.getItem(ORDER_KEY) || 'null');
if (saved?.order_no) {
orderNo.value = saved.order_no;
orderStatus.value = 'pending';
startPoll();
}
} catch {
/* 忽略脏数据 */
}
});
onUnmounted(stopPoll);
</script>
<template>
<div class="px-page">
<div class="hero">
<div class="hero-title">🔐 购买卡密</div>
<div class="hero-sub">
支付成功后本页直接显示卡密,同时本机立即解锁 13 个高级功能
</div>
</div>
<!-- 本机机器码 -->
<div class="box machine-box">
<div class="box-label">本机机器码</div>
<div class="machine-row">
<code class="machine-id">{{ machineId || '读取中…' }}</code>
<c-button size="small" @click="copyText(machineId, 'machine')">
{{ copied === 'machine' ? '已复制 ✓' : '复制' }}
</c-button>
</div>
<div class="box-hint">
下单会自动绑定到这台电脑;换电脑时用支付后得到的卡密重新激活即可。
</div>
</div>
<div v-if="licenseState.authorized" class="box ok-box">
✅ 本机已拥有授权,无需重复购买。
</div>
<!-- 套餐 -->
<div class="section">
<div class="section-title">① 选择套餐</div>
<div v-if="loading" class="tip">套餐加载中…</div>
<div v-else-if="loadErr" class="tip err">{{ loadErr }}</div>
<div v-else class="plan-grid">
<div
v-for="p in plans"
:key="p.id"
class="plan-card"
:class="{ on: selPlan?.id === p.id }"
@click="selPlan = p"
>
<div class="plan-name">{{ p.name }}</div>
<div class="plan-price">
<span class="cur">¥</span>{{ p.price }}
<span v-if="Number(p.original_price) > 0" class="origin">¥{{ p.original_price }}</span>
</div>
<div class="plan-meta">{{ fmtDays(p.duration_days) }} · 13 个高级功能</div>
<div v-if="p.description" class="plan-desc">{{ p.description }}</div>
</div>
<div v-if="!plans.length" class="tip">暂无可售套餐</div>
</div>
</div>
<!-- 支付方式 -->
<div class="section">
<div class="section-title">② 选择支付方式</div>
<div class="pay-grid">
<div
v-for="m in PAY_METHODS"
:key="m.key"
class="pay-card"
:class="{ on: payType === m.key }"
@click="payType = m.key"
>
<span class="pay-icon">{{ m.icon }}</span>{{ m.label }}
</div>
</div>
</div>
<!-- 优惠码 -->
<div class="section">
<div class="section-title">③ 优惠码<span class="opt">(选填)</span></div>
<input
v-model="couponCode"
class="coupon-input"
placeholder="没有可留空"
maxlength="32"
/>
</div>
<div class="buy-bar">
<div class="amount">
应付 <b>¥{{ selPlan ? selPlan.price : '0.00' }}</b>
</div>
<c-button type="primary" size="large" :loading="ordering" @click="buy">
{{ ordering ? '正在创建订单…' : '立即支付' }}
</c-button>
</div>
<div v-if="errMsg" class="tip err">{{ errMsg }}</div>
<!-- 订单状态 -->
<div v-if="orderNo" class="box order-box">
<div class="order-head">
<span>订单号 <code>{{ orderNo }}</code></span>
<a v-if="payUrl && orderStatus === 'pending'" href="javascript:;" class="lnk" @click="reopenPay">
打开支付页 ↗
</a>
</div>
<div v-if="orderStatus === 'pending'" class="order-wait">
<span class="dots" />
等待支付完成…(支付页已在新标签打开,付款后本页会自动刷新)
<a href="javascript:;" class="lnk" @click="pollOnce">刷新状态</a>
<a href="javascript:;" class="lnk dim" @click="clearOrder">取消此单</a>
</div>
<template v-if="orderStatus === 'paid'">
<div class="paid-head">✅ 支付成功</div>
<div class="card-box">
<div class="card-label">你的卡密(请妥善保存)</div>
<div class="card-row">
<code class="card-key">{{ cardKey || '—' }}</code>
<c-button
v-if="cardKey"
size="small"
type="primary"
@click="copyText(cardKey, 'card')"
>
{{ copied === 'card' ? '已复制 ✓' : '复制卡密' }}
</c-button>
</div>
<div v-if="paidAt" class="box-hint">支付时间:{{ paidAt }}</div>
</div>
<div class="auth-line" :class="{ pending: licenseState.authorized === false }">
{{ authMsg || '授权核验中…' }}
</div>
<div class="auth-actions">
<c-button size="small" :loading="licenseState.checking" @click="refreshAuth">
重新核验授权
</c-button>
<c-button size="small" @click="clearOrder">再买一单</c-button>
</div>
</template>
<div v-if="orderStatus === 'expired'" class="tip err">订单已过期</div>
</div>
<div class="notes">
<div class="note-item">🔒 买断制:不按次、不按月,一次付费永久使用。</div>
<div class="note-item">🧭 授权跟随机器码绑定,换电脑用卡密重新激活即可恢复。</div>
<div class="note-item">🎁 支付成功即解锁 13 个高级功能,无需等待人工发货。</div>
<div class="note-item">❓ 卡密丢失可凭订单号联系管理员找回。</div>
</div>
</div>
</template>
<style lang="less" scoped>
.px-page {
max-width: 860px;
margin: 0 auto;
padding: 40px 20px 80px;
}
.hero {
text-align: center;
margin-bottom: 30px;
.hero-title {
font-size: 30px;
font-weight: 800;
background: linear-gradient(48deg, rgba(37, 99, 108, 1) 0%, rgba(59, 149, 111, 1) 55%, rgba(20, 160, 88, 1) 100%);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.hero-sub {
margin-top: 10px;
font-size: 14.5px;
opacity: 0.65;
}
}
.box {
border: 1px solid rgba(128, 128, 128, 0.25);
border-radius: 12px;
padding: 14px 16px;
margin-bottom: 22px;
}
.machine-box {
.box-label,
.card-label {
font-size: 12.5px;
opacity: 0.6;
margin-bottom: 8px;
}
.machine-row {
display: flex;
align-items: center;
gap: 10px;
flex-wrap: wrap;
}
.machine-id {
font-size: 17px;
font-weight: 700;
letter-spacing: 1px;
user-select: all;
}
}
.box-hint {
margin-top: 8px;
font-size: 12.5px;
opacity: 0.6;
}
.ok-box {
color: #18a058;
font-weight: 600;
}
.section {
margin-bottom: 24px;
.section-title {
font-size: 16px;
font-weight: 700;
margin-bottom: 12px;
}
.opt {
font-size: 12.5px;
font-weight: 400;
opacity: 0.55;
}
}
.tip {
font-size: 13.5px;
opacity: 0.7;
&.err {
color: #d03050;
opacity: 1;
margin-top: 8px;
}
}
.plan-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
gap: 12px;
}
.plan-card {
border: 1px solid rgba(128, 128, 128, 0.25);
border-radius: 12px;
padding: 16px;
cursor: pointer;
transition: border-color 0.15s, box-shadow 0.15s;
&:hover {
border-color: rgba(24, 160, 88, 0.5);
}
&.on {
border-color: #18a058;
box-shadow: 0 0 0 1px rgba(24, 160, 88, 0.35), 0 6px 18px rgba(24, 160, 88, 0.12);
}
.plan-name {
font-size: 15.5px;
font-weight: 700;
}
.plan-price {
margin-top: 8px;
font-size: 30px;
font-weight: 800;
color: #18a058;
.cur {
font-size: 16px;
margin-right: 2px;
}
.origin {
margin-left: 8px;
font-size: 13px;
font-weight: 400;
opacity: 0.45;
text-decoration: line-through;
}
}
.plan-meta {
margin-top: 6px;
font-size: 13px;
opacity: 0.7;
}
.plan-desc {
margin-top: 6px;
font-size: 12.5px;
opacity: 0.55;
}
}
.pay-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 10px;
}
.pay-card {
border: 1px solid rgba(128, 128, 128, 0.25);
border-radius: 10px;
padding: 12px 14px;
font-size: 14px;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
transition: border-color 0.15s, box-shadow 0.15s;
&:hover {
border-color: rgba(24, 160, 88, 0.5);
}
&.on {
border-color: #18a058;
box-shadow: 0 0 0 1px rgba(24, 160, 88, 0.35);
font-weight: 600;
}
.pay-icon {
font-size: 17px;
}
}
.coupon-input {
width: 100%;
max-width: 320px;
padding: 9px 12px;
border: 1px solid rgba(128, 128, 128, 0.3);
border-radius: 8px;
background: transparent;
color: inherit;
font-size: 14px;
outline: none;
&:focus {
border-color: #18a058;
}
}
.buy-bar {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
padding: 16px;
border: 1px solid rgba(128, 128, 128, 0.25);
border-radius: 12px;
margin-bottom: 12px;
flex-wrap: wrap;
.amount {
font-size: 14.5px;
opacity: 0.75;
b {
font-size: 26px;
color: #18a058;
margin-left: 4px;
}
}
}
.order-box {
border-color: rgba(24, 160, 88, 0.45);
}
.order-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
font-size: 13.5px;
opacity: 0.8;
flex-wrap: wrap;
code {
user-select: all;
}
}
.lnk {
color: #18a058;
text-decoration: none;
font-size: 13.5px;
&.dim {
opacity: 0.6;
margin-left: 12px;
}
&:hover {
text-decoration: underline;
}
}
.order-wait {
margin-top: 12px;
font-size: 14px;
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.dots {
width: 10px;
height: 10px;
border-radius: 50%;
background: #f0a020;
animation: blink 1s infinite alternate;
flex-shrink: 0;
}
@keyframes blink {
from { opacity: 0.25; }
to { opacity: 1; }
}
.paid-head {
margin-top: 14px;
font-size: 18px;
font-weight: 800;
color: #18a058;
}
.card-box {
margin-top: 12px;
padding: 14px;
border: 1px dashed rgba(24, 160, 88, 0.55);
border-radius: 10px;
background: rgba(24, 160, 88, 0.06);
.card-label {
font-size: 12.5px;
opacity: 0.7;
margin-bottom: 8px;
}
.card-row {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.card-key {
font-size: 19px;
font-weight: 800;
letter-spacing: 1.2px;
user-select: all;
word-break: break-all;
}
}
.auth-line {
margin-top: 12px;
font-size: 14px;
color: #18a058;
font-weight: 600;
&.pending {
color: #f0a020;
}
}
.auth-actions {
margin-top: 12px;
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.notes {
margin-top: 28px;
border-top: 1px solid rgba(128, 128, 128, 0.2);
padding-top: 18px;
.note-item {
font-size: 13.5px;
opacity: 0.65;
line-height: 1.9;
}
}
</style>
+9 -2
View File
@@ -1,9 +1,16 @@
<script setup lang="ts">
import { useHead } from '@vueuse/head';
import { BUY_URL, PROTECTED_TOOLS, getMachineId } from '@/tools/license/license';
import { PROTECTED_TOOLS, getMachineId } from '@/tools/license/license';
useHead({ title: '授权应用 - IT-TOOLS-PRO' });
const router = useRouter();
/** 「前往购买卡密」→ 站内支付页 /buy */
function goBuy(): void {
router.push('/buy');
}
interface Feature {
path: string;
name: string;
@@ -189,7 +196,7 @@ async function copyMachine() {
</div>
</div>
<div class="cta-right">
<c-button type="primary" class="cta-btn" tag="a" :href="BUY_URL" target="_blank" rel="noopener">
<c-button type="primary" class="cta-btn" @click="goBuy">
💳 前往购买卡密
</c-button>
<div class="cta-hint">
+5
View File
@@ -46,6 +46,11 @@ const router = createRouter({
name: 'pricing',
component: () => import('./pages/Pricing.page.vue'),
},
{
path: '/buy',
name: 'buy',
component: () => import('./pages/Buy.page.vue'),
},
...toolsRoutes,
...toolsRedirectRoutes,
...(config.app.env === 'development' ? demoRoutes : []),
+7 -3
View File
@@ -17,6 +17,11 @@ const props = defineProps<{ path: string }>();
const router = useRouter();
/** 跳转到站内支付页 /buy(未授权状态下所有购买入口统一走这里) */
function goBuy(): void {
router.push('/buy');
}
const displayName = computed(() => PROTECTED_TOOLS[props.path] ?? '');
const protectedTool = computed(() => !!PROTECTED_TOOLS[props.path]);
@@ -161,10 +166,9 @@ onUnmounted(() => {
<template v-if="!licenseState.authorized">
<a
:href="BUY_URL"
target="_blank"
rel="noopener"
class="lg-buy"
title="买断制授权,不按次不按月;一次激活,13 个高级功能全部解锁,授权跟随账号、换电脑可恢复"
@click.prevent="goBuy"
>永久解锁 13 个功能</a>
<a href="javascript:;" class="lg-link" @click="showCardInput = !showCardInput">卡密</a>
</template>
@@ -202,7 +206,7 @@ onUnmounted(() => {
</p>
<div class="lg-modal-actions">
<c-button type="primary" :href="BUY_URL" target="_blank" rel="noopener">
<c-button type="primary" @click="goBuy">
购买授权
</c-button>
<c-button @click="showCardInput = !showCardInput">
+1 -1
View File
@@ -2,7 +2,7 @@ import { reactive } from 'vue';
// ====== 授权服务器 (CardAuth) ======
export const AUTH_BASE = 'https://auth.88531.cn/api';
export const BUY_URL = 'https://auth.88531.cn/#/shop';
export const BUY_URL = '/buy'; // 站内支付页:下单 -> 支付 -> 当场显示卡密
// 受控功能(消耗服务器性能:翻译走服务器代理、OCR 走本机识别服务)
export const PROTECTED_TOOLS: Record<string, string> = {