Add admin-frontend and user-frontend standalone projects, certification/invoice/discovery features, fix auth header and theme consistency
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8" v-for="p in plans" :key="p.id">
|
||||
<el-card shadow="hover" :class="{ 'plan-highlight': p.id === currentPlan }">
|
||||
<template #header>
|
||||
<div style="text-align:center">
|
||||
<h3 style="margin:0">{{ p.name }}</h3>
|
||||
<p style="font-size:28px;font-weight:700;color:#409eff;margin:12px 0">
|
||||
¥{{ p.price || 0 }}<span style="font-size:14px;font-weight:400;color:#999">/月</span>
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
<div>
|
||||
<p v-for="f in p.features || []" :key="f" style="font-size:13px;color:#666;margin:8px 0">
|
||||
<el-icon color="#67c23a" style="margin-right:6px"><Check /></el-icon>{{ f }}
|
||||
</p>
|
||||
</div>
|
||||
<div style="text-align:center;margin-top:16px">
|
||||
<el-button v-if="p.id === currentPlan" type="default" disabled>当前套餐</el-button>
|
||||
<el-button v-else type="primary" :loading="loadingId === p.id" @click="upgrade(p.id)">升级</el-button>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-empty v-if="!plans.length" description="暂无套餐信息" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getPlans, getSubscription, createOrder } from '@/api'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const plans = ref([])
|
||||
const currentPlan = ref(null)
|
||||
const loadingId = ref(null)
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const [plansRes, subRes] = await Promise.all([getPlans(), getSubscription().catch(() => null)])
|
||||
const pd = plansRes.data || plansRes
|
||||
plans.value = pd.plans || pd.items || pd || []
|
||||
if (subRes) {
|
||||
const sd = subRes.data || subRes
|
||||
currentPlan.value = sd.plan_id || sd.plan
|
||||
}
|
||||
} catch { /* ignore */ }
|
||||
})
|
||||
|
||||
async function upgrade(planId) {
|
||||
loadingId.value = planId
|
||||
try {
|
||||
const res = await createOrder(planId)
|
||||
ElMessage.success('订单已创建' + (res.pay_url ? ',正在跳转支付...' : ''))
|
||||
if (res.pay_url) window.open(res.pay_url)
|
||||
} catch (e) { ElMessage.error(e?.detail || '升级失败') }
|
||||
finally { loadingId.value = null }
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.plan-highlight { border: 2px solid #409eff; transform: scale(1.02); }
|
||||
</style>
|
||||
Reference in New Issue
Block a user