update
This commit is contained in:
parent
68f0990528
commit
36bca020a6
@ -3,7 +3,7 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: tradus-web:1.3.49
|
||||
image: tradus-web:1.4.0
|
||||
container_name: tradus-web
|
||||
ports:
|
||||
- '6000:80'
|
||||
|
||||
162
src/App.vue
162
src/App.vue
@ -415,6 +415,19 @@ const closeUserInfoModal = () => {
|
||||
showUserInfoModal.value = false
|
||||
}
|
||||
|
||||
// 格式化过期时间
|
||||
const formatExpireTime = (expireTime: string | undefined) => {
|
||||
if (!expireTime) return ''
|
||||
const date = new Date(expireTime)
|
||||
return date
|
||||
.toLocaleDateString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
})
|
||||
.replace(/\//g, '/')
|
||||
}
|
||||
|
||||
// 切换主题
|
||||
// const toggleTheme = () => {
|
||||
// themeStore.toggleTheme()
|
||||
@ -568,6 +581,20 @@ onUnmounted(() => {
|
||||
</svg>
|
||||
<span class="agent-name">AI 交易智能体</span>
|
||||
</RouterLink>
|
||||
<RouterLink to="/subscription" class="agent-item" @click="showMobileMenu = false">
|
||||
<svg
|
||||
class="agent-icon"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
>
|
||||
<path
|
||||
d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"
|
||||
/>
|
||||
</svg>
|
||||
<span class="agent-name">会员订阅</span>
|
||||
</RouterLink>
|
||||
<RouterLink to="/download" class="agent-item" @click="showMobileMenu = false">
|
||||
<svg
|
||||
class="agent-icon"
|
||||
@ -608,9 +635,10 @@ onUnmounted(() => {
|
||||
<span class="user-email-display" :title="userInfo?.mail">{{
|
||||
userInfo?.mail || '未设置邮箱'
|
||||
}}</span>
|
||||
<div class="user-points">
|
||||
<span class="points-icon">💰</span>
|
||||
<span class="points-value">{{ userInfo?.points || 0 }} 积分</span>
|
||||
<div class="user-member-tag" v-if="userInfo?.member_name">
|
||||
<span class="member-tag" :class="{ 'svip-tag': userInfo?.member_name === 'SVIP' }">
|
||||
{{ userInfo.member_name }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<svg
|
||||
@ -644,9 +672,10 @@ onUnmounted(() => {
|
||||
<span class="user-email-display" :title="userInfo?.mail">{{
|
||||
userInfo?.mail || '未设置邮箱'
|
||||
}}</span>
|
||||
<div class="user-points">
|
||||
<span class="points-icon">💰</span>
|
||||
<span class="points-value">{{ userInfo?.points || 0 }} 积分</span>
|
||||
<div class="user-member-tag" v-if="userInfo?.member_name">
|
||||
<span class="member-tag" :class="{ 'svip-tag': userInfo?.member_name === 'SVIP' }">
|
||||
{{ userInfo.member_name }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<svg
|
||||
@ -972,9 +1001,15 @@ onUnmounted(() => {
|
||||
</div>
|
||||
<div class="user-basic-info">
|
||||
<h3 class="user-display-name">{{ userInfo?.mail || '未设置邮箱' }}</h3>
|
||||
<div class="user-points-display">
|
||||
<span class="points-icon">💰</span>
|
||||
<span class="points-text">积分余额:{{ userInfo?.points || 0 }}</span>
|
||||
<div class="user-member-info" v-if="userInfo?.member_name">
|
||||
<span class="member-tag" :class="{ 'svip-tag': userInfo?.member_name === 'SVIP' }">
|
||||
{{ userInfo.member_name }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="user-expire-info" v-if="userInfo?.is_subscribed && userInfo?.expire_time">
|
||||
<span class="expire-text"
|
||||
>到期时间:{{ formatExpireTime(userInfo.expire_time) }}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -1542,27 +1577,6 @@ body {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.mobile-user-info .user-points {
|
||||
font-size: 0.85rem;
|
||||
color: var(--color-text-secondary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
}
|
||||
|
||||
.mobile-user-info .user-points::before {
|
||||
content: none;
|
||||
}
|
||||
|
||||
.mobile-user-info .points-icon {
|
||||
color: var(--color-accent);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.mobile-user-info .points-value {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 移除旧的退出按钮样式 */
|
||||
.logout-button {
|
||||
display: none;
|
||||
@ -1759,10 +1773,6 @@ body {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
.desktop-user-info .user-info-box:hover .user-points {
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
.dropdown-icon {
|
||||
color: var(--color-text-secondary);
|
||||
transition: transform 0.2s ease;
|
||||
@ -2066,28 +2076,6 @@ body {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.desktop-user-info .user-points {
|
||||
font-size: 0.8rem;
|
||||
color: var(--color-text-secondary);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.desktop-user-info .user-points::before {
|
||||
content: none;
|
||||
}
|
||||
|
||||
.desktop-user-info .points-icon {
|
||||
color: var(--color-accent);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.desktop-user-info .points-value {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* 全局滚动条样式 */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
@ -2321,23 +2309,6 @@ html {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.user-points-display {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.user-points-display .points-icon {
|
||||
font-size: 1.2rem;
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
.user-points-display .points-text {
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
.settings-section {
|
||||
padding: 1.5rem 2rem;
|
||||
}
|
||||
@ -2507,6 +2478,51 @@ html {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* 用户会员标签样式 */
|
||||
.user-member-tag {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.member-tag {
|
||||
display: inline-block;
|
||||
padding: 0.2rem 0.5rem;
|
||||
background: #3b82f6;
|
||||
color: white;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
border-radius: 0.375rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.member-tag.svip-tag {
|
||||
background: linear-gradient(135deg, #d4af37, #ffd700);
|
||||
color: #2d1810;
|
||||
box-shadow: 0 2px 4px rgba(212, 175, 55, 0.3);
|
||||
}
|
||||
|
||||
.member-tag:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.member-tag.svip-tag:hover {
|
||||
box-shadow: 0 4px 8px rgba(212, 175, 55, 0.4);
|
||||
}
|
||||
|
||||
/* 模态框中的用户会员信息 */
|
||||
.user-member-info {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.user-expire-info {
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.expire-text {
|
||||
font-size: 0.85rem;
|
||||
color: var(--color-text-secondary);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.desktop-user-info .user-info-box:hover .user-email-display {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
@ -63,6 +63,22 @@ const router = createRouter({
|
||||
title: 'AI 交易智能体',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/subscription',
|
||||
name: 'subscription',
|
||||
component: () => import('../views/SubscriptionView.vue'),
|
||||
meta: {
|
||||
title: '会员订阅',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/subscription-success',
|
||||
name: 'subscription-success',
|
||||
component: () => import('../views/SubscriptionSuccessView.vue'),
|
||||
meta: {
|
||||
title: '订阅成功',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/contact',
|
||||
name: 'contact',
|
||||
|
||||
@ -8,6 +8,9 @@ export interface UserInfo {
|
||||
level: number
|
||||
create_time: string
|
||||
points?: number
|
||||
member_name?: string
|
||||
is_subscribed?: boolean
|
||||
expire_time?: string
|
||||
}
|
||||
|
||||
export interface AuthResponse {
|
||||
|
||||
@ -8,10 +8,7 @@ import { useUserStore } from '../stores/user'
|
||||
const userStore = useUserStore()
|
||||
const userInfo = computed(() => userStore.userInfo)
|
||||
|
||||
// 计算属性:用户积分余额,直接从store获取
|
||||
const userPoints = computed(() => {
|
||||
return userInfo.value?.points || 0
|
||||
})
|
||||
// 注释:userPoints已移除,因为当前页面不需要显示积分信息
|
||||
|
||||
// 配置marked选项
|
||||
onMounted(() => {
|
||||
@ -677,18 +674,6 @@ const stopStreaming = async () => {
|
||||
</div>
|
||||
<h3>AI交易智能体</h3>
|
||||
<p>为您提供市场分析、交易建议和投资策略</p>
|
||||
|
||||
<!-- 积分消耗提示 -->
|
||||
<div class="points-notice">
|
||||
<div class="points-notice-icon">💰</div>
|
||||
<div class="points-notice-text">
|
||||
每次分析消耗
|
||||
<strong class="points-amount">20 积分</strong>
|
||||
<!-- <div class="points-balance">
|
||||
(剩余积分:{{ userPoints.toLocaleString() }} 积分)
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -759,6 +744,15 @@ const stopStreaming = async () => {
|
||||
|
||||
<!-- 输入区域 -->
|
||||
<div class="chat-input">
|
||||
<!-- 使用限制提示 -->
|
||||
<div v-if="!userInfo?.is_subscribed" class="usage-tips">
|
||||
<div class="tips-icon">💡</div>
|
||||
<div class="tips-content">
|
||||
<span class="tips-text">非订阅用户每天只有 1 次体验分析,</span>
|
||||
<router-link to="/subscription" class="tips-link">订阅后解锁无限次分析</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 快速分析按钮区域 -->
|
||||
<div class="quick-analysis-buttons">
|
||||
<button
|
||||
@ -1489,6 +1483,50 @@ const stopStreaming = async () => {
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* 使用限制提示样式 */
|
||||
.usage-tips {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background: linear-gradient(135deg, #fff3cd, #ffeaa7);
|
||||
border: 1px solid #ffd60a;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 1rem;
|
||||
box-shadow: 0 2px 8px rgba(255, 214, 10, 0.1);
|
||||
}
|
||||
|
||||
.tips-icon {
|
||||
font-size: 1.25rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.tips-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.tips-text {
|
||||
font-size: 0.9rem;
|
||||
color: #856404;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.tips-link {
|
||||
font-size: 0.9rem;
|
||||
color: #0066cc;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.tips-link:hover {
|
||||
color: #004080;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* 快速分析按钮样式 */
|
||||
.quick-analysis-buttons {
|
||||
display: flex;
|
||||
@ -1934,6 +1972,26 @@ const stopStreaming = async () => {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* 移动端使用限制提示样式 */
|
||||
.usage-tips {
|
||||
padding: 0.6rem 0.75rem;
|
||||
margin-bottom: 0.75rem;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.tips-icon {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.tips-content {
|
||||
gap: 0.2rem;
|
||||
}
|
||||
|
||||
.tips-text,
|
||||
.tips-link {
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
.conversation-header {
|
||||
padding: 0.6rem 0.75rem;
|
||||
height: 4rem;
|
||||
|
||||
199
src/views/SubscriptionSuccessView.vue
Normal file
199
src/views/SubscriptionSuccessView.vue
Normal file
@ -0,0 +1,199 @@
|
||||
<template>
|
||||
<div class="subscription-success-view">
|
||||
<!-- 成功图标和标题 -->
|
||||
<section class="success-section">
|
||||
<div class="success-content">
|
||||
<div class="success-icon">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
|
||||
<polyline points="22,4 12,14.01 9,11.01"></polyline>
|
||||
</svg>
|
||||
</div>
|
||||
<h1 class="success-title">订阅成功!</h1>
|
||||
<p class="success-subtitle">恭喜您成为尊享会员,享受专属权益</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<section class="actions-section">
|
||||
<button class="btn btn-primary" @click="goToDashboard">开始体验</button>
|
||||
<button class="btn btn-secondary" @click="goToHome">返回首页</button>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
// 清理本地存储的订阅信息
|
||||
onMounted(() => {
|
||||
// 清除本地存储的订阅信息,避免重复显示
|
||||
localStorage.removeItem('subscription_info')
|
||||
})
|
||||
|
||||
// 跳转到仪表板
|
||||
const goToDashboard = () => {
|
||||
router.push('/ai-agent')
|
||||
}
|
||||
|
||||
// 返回首页
|
||||
const goToHome = () => {
|
||||
router.push('/')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.subscription-success-view {
|
||||
min-height: 100vh;
|
||||
background: #ffffff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 2rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 成功提示区域 */
|
||||
.success-section {
|
||||
padding: 2rem 0;
|
||||
text-align: center;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.success-content {
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.success-icon {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background: #f0f9ff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 0 auto 2rem;
|
||||
border: 2px solid #3b82f6;
|
||||
}
|
||||
|
||||
.success-icon svg {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
color: #3b82f6;
|
||||
}
|
||||
|
||||
.success-title {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 1rem;
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.success-subtitle {
|
||||
font-size: 1.25rem;
|
||||
color: #64748b;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* 操作按钮 */
|
||||
.actions-section {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 0.875rem 2rem;
|
||||
border-radius: 0.75rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
border: none;
|
||||
min-width: 140px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #3b82f6;
|
||||
color: white;
|
||||
box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #2563eb;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #ffffff;
|
||||
color: #64748b;
|
||||
border: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: #f8fafc;
|
||||
color: #374151;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.success-title {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.success-subtitle {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.success-icon {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
}
|
||||
|
||||
.success-icon svg {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.actions-section {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
max-width: 300px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.subscription-success-view {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.success-section {
|
||||
padding: 1rem 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* 深色主题适配 */
|
||||
[data-theme='dark'] .btn-secondary {
|
||||
background: rgba(51, 65, 85, 0.9);
|
||||
color: #94a3b8;
|
||||
border: 1px solid rgba(71, 85, 105, 0.6);
|
||||
}
|
||||
|
||||
[data-theme='dark'] .btn-secondary:hover {
|
||||
background: rgba(51, 65, 85, 1);
|
||||
}
|
||||
</style>
|
||||
786
src/views/SubscriptionView.vue
Normal file
786
src/views/SubscriptionView.vue
Normal file
@ -0,0 +1,786 @@
|
||||
<template>
|
||||
<div class="subscription-view">
|
||||
<!-- 页面头部 -->
|
||||
<section class="hero-section">
|
||||
<div class="hero-content">
|
||||
<h1 class="hero-title">选择您的<span class="accent">会员计划</span></h1>
|
||||
<p class="hero-subtitle">解锁全部功能,享受无限制的AI分析服务</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 订阅计划 -->
|
||||
<section class="subscription-plans">
|
||||
<div class="container">
|
||||
<div class="plans-grid">
|
||||
<!-- 尊享会员计划 -->
|
||||
<div class="plan-card premium-plan">
|
||||
<div class="plan-header">
|
||||
<div class="plan-badge">推荐</div>
|
||||
<h2 class="plan-title">尊享会员</h2>
|
||||
<p class="plan-description">适合个人用户和专业投资者</p>
|
||||
</div>
|
||||
<div class="plan-pricing">
|
||||
<div class="price-display">
|
||||
<template v-if="!isLoadingPricing && pricing">
|
||||
<span class="price" v-if="premiumBilling === 'monthly'">
|
||||
¥{{ pricing.price_month }}
|
||||
<span class="period">/月</span>
|
||||
</span>
|
||||
<span class="price" v-else>
|
||||
¥{{ pricing.price_year }}
|
||||
<span class="period">/年</span>
|
||||
</span>
|
||||
</template>
|
||||
<template v-else-if="isLoadingPricing">
|
||||
<span class="price loading">加载中...</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="price error">暂不可用</span>
|
||||
</template>
|
||||
</div>
|
||||
<div class="billing-toggle">
|
||||
<button
|
||||
class="billing-option"
|
||||
:class="{ active: premiumBilling === 'monthly' }"
|
||||
@click="premiumBilling = 'monthly'"
|
||||
>
|
||||
包月
|
||||
</button>
|
||||
<button
|
||||
class="billing-option"
|
||||
:class="{ active: premiumBilling === 'yearly' }"
|
||||
@click="premiumBilling = 'yearly'"
|
||||
>
|
||||
按年
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="plan-features">
|
||||
<ul class="features-list">
|
||||
<li class="feature-item highlight">
|
||||
<svg class="check-icon" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
每天无限次分析额度
|
||||
</li>
|
||||
<li class="feature-item">
|
||||
<svg class="check-icon" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
专属技术支持
|
||||
</li>
|
||||
<li class="feature-item">
|
||||
<svg class="check-icon" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
优先处理
|
||||
</li>
|
||||
<li class="feature-item">
|
||||
<svg class="check-icon" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
高级功能解锁
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<button
|
||||
class="plan-button premium-button"
|
||||
@click="selectPlan('premium', premiumBilling)"
|
||||
:disabled="isLoadingPricing || !pricing"
|
||||
>
|
||||
立刻订阅
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 订阅确认对话框 -->
|
||||
<div v-if="showConfirmDialog" class="modal-overlay" @click="closeConfirmDialog">
|
||||
<div class="confirm-dialog" @click.stop>
|
||||
<div class="dialog-header">
|
||||
<h3>确认订阅</h3>
|
||||
<button class="close-button" @click="closeConfirmDialog">
|
||||
<svg viewBox="0 0 20 20" fill="currentColor">
|
||||
<path
|
||||
fill-rule="evenodd"
|
||||
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
||||
clip-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="plan-info">
|
||||
<h4>{{ selectedPlan?.title }}</h4>
|
||||
<div class="price">
|
||||
¥{{ selectedPlan?.price }} / {{ selectedPlan?.period.replace('订阅', '') }}
|
||||
</div>
|
||||
<p class="description">{{ selectedPlan?.quota }}</p>
|
||||
</div>
|
||||
<div class="dialog-actions">
|
||||
<button class="btn btn-secondary" @click="closeConfirmDialog" :disabled="isCreatingOrder">
|
||||
取消
|
||||
</button>
|
||||
<button class="btn btn-primary" @click="confirmSubscription" :disabled="isCreatingOrder">
|
||||
<span v-if="isCreatingOrder">创建订单中...</span>
|
||||
<span v-else>确认订阅</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
|
||||
// 订阅周期
|
||||
const premiumBilling = ref<'monthly' | 'yearly'>('monthly')
|
||||
|
||||
// 价格数据
|
||||
const pricing = ref<{
|
||||
price_month: number
|
||||
price_year: number
|
||||
} | null>(null)
|
||||
|
||||
// 加载状态
|
||||
const isLoadingPricing = ref(true)
|
||||
const isCreatingOrder = ref(false)
|
||||
|
||||
// 获取定价信息
|
||||
const fetchPricing = async () => {
|
||||
try {
|
||||
isLoadingPricing.value = true
|
||||
const response = await fetch(
|
||||
`${import.meta.env.MODE === 'development' ? 'http://127.0.0.1:8000' : 'https://api.ibtc.work'}/payment/pricing`,
|
||||
)
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('获取定价信息失败')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
if (data.code === 200) {
|
||||
pricing.value = data.data
|
||||
} else {
|
||||
console.error('获取定价失败:', data)
|
||||
// 使用默认价格作为fallback
|
||||
pricing.value = {
|
||||
price_month: 29,
|
||||
price_year: 219,
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取定价信息出错:', error)
|
||||
// 使用默认价格作为fallback
|
||||
pricing.value = {
|
||||
price_month: 29,
|
||||
price_year: 219,
|
||||
}
|
||||
} finally {
|
||||
isLoadingPricing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 组件挂载时获取定价
|
||||
onMounted(() => {
|
||||
fetchPricing()
|
||||
})
|
||||
|
||||
// 确认对话框
|
||||
const showConfirmDialog = ref(false)
|
||||
const selectedPlan = ref<{
|
||||
type: string
|
||||
title: string
|
||||
price: string
|
||||
period: string
|
||||
quota: string
|
||||
} | null>(null)
|
||||
|
||||
// 选择订阅计划
|
||||
const selectPlan = (type: 'premium', billing: 'monthly' | 'yearly') => {
|
||||
if (!pricing.value) {
|
||||
alert('价格信息加载中,请稍后再试')
|
||||
return
|
||||
}
|
||||
|
||||
const planInfo = {
|
||||
premium: {
|
||||
monthly: {
|
||||
title: '尊享会员',
|
||||
price: pricing.value.price_month.toString(),
|
||||
period: '包月订阅',
|
||||
quota: '每天无限次分析额度',
|
||||
},
|
||||
yearly: {
|
||||
title: '尊享会员',
|
||||
price: pricing.value.price_year.toString(),
|
||||
period: '按年订阅',
|
||||
quota: '每天无限次分析额度',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
selectedPlan.value = {
|
||||
type,
|
||||
...planInfo[type][billing],
|
||||
}
|
||||
|
||||
showConfirmDialog.value = true
|
||||
}
|
||||
|
||||
// 关闭确认对话框
|
||||
const closeConfirmDialog = () => {
|
||||
showConfirmDialog.value = false
|
||||
selectedPlan.value = null
|
||||
}
|
||||
|
||||
// 确认订阅
|
||||
const confirmSubscription = async () => {
|
||||
if (!selectedPlan.value || isCreatingOrder.value) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查用户是否已登录
|
||||
const accessToken = localStorage.getItem('access_token')
|
||||
if (!accessToken) {
|
||||
alert('请先登录再进行订阅')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
isCreatingOrder.value = true
|
||||
|
||||
// 将订阅类型转换为API需要的数字格式
|
||||
const subscribeType = premiumBilling.value === 'monthly' ? 1 : 2
|
||||
|
||||
const response = await fetch(
|
||||
`${import.meta.env.MODE === 'development' ? 'http://127.0.0.1:8000' : 'https://api.ibtc.work'}/payment/create_order`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
subscribe_type: subscribeType,
|
||||
}),
|
||||
},
|
||||
)
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('创建订单失败')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
if (data.code === 200) {
|
||||
// 订单创建成功,保存订阅信息并跳转到支付页面
|
||||
const { order_no, pay_url, status } = data.data
|
||||
|
||||
console.log('订单创建成功:', { order_no, status })
|
||||
|
||||
// 保存订阅信息到本地存储,用于支付成功后的页面显示
|
||||
const subscriptionInfo = {
|
||||
type: selectedPlan.value.type,
|
||||
period: premiumBilling.value,
|
||||
title: selectedPlan.value.title,
|
||||
price: selectedPlan.value.price,
|
||||
order_no: order_no,
|
||||
}
|
||||
localStorage.setItem('subscription_info', JSON.stringify(subscriptionInfo))
|
||||
|
||||
// 自动跳转到支付页面
|
||||
if (pay_url) {
|
||||
window.location.href = pay_url
|
||||
} else {
|
||||
throw new Error('支付链接无效')
|
||||
}
|
||||
} else {
|
||||
throw new Error(data.message || '创建订单失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('创建订单失败:', error)
|
||||
alert(error instanceof Error ? error.message : '创建订单失败,请重试')
|
||||
} finally {
|
||||
isCreatingOrder.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.subscription-view {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 页面头部 */
|
||||
.hero-section {
|
||||
padding: 4rem 2rem 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hero-content {
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 1rem;
|
||||
background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
.accent {
|
||||
background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
font-size: 1.25rem;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
/* 订阅计划 */
|
||||
.subscription-plans {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.plans-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
|
||||
gap: 2rem;
|
||||
margin-bottom: 4rem;
|
||||
justify-items: center;
|
||||
}
|
||||
|
||||
.plan-card {
|
||||
background: #ffffff;
|
||||
border-radius: 1.5rem;
|
||||
padding: 2rem;
|
||||
border: 2px solid #f1f5f9;
|
||||
transition: all 0.3s ease;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
[data-theme='dark'] .plan-card {
|
||||
background: linear-gradient(135deg, #334155, #1e293b);
|
||||
border: 2px solid #475569;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.plan-card.premium-plan {
|
||||
background: linear-gradient(135deg, #fafbff, #f0f4ff);
|
||||
border: 2px solid #3b82f6;
|
||||
box-shadow: 0 4px 20px rgba(59, 130, 246, 0.2);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.plan-card.premium-plan::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 4px;
|
||||
background: linear-gradient(90deg, #3b82f6, #1d4ed8);
|
||||
border-radius: 1.5rem 1.5rem 0 0;
|
||||
}
|
||||
|
||||
[data-theme='dark'] .plan-card.premium-plan {
|
||||
background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
|
||||
border: 2px solid #3b82f6;
|
||||
box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
|
||||
}
|
||||
|
||||
.plan-card:hover {
|
||||
transform: translateY(-6px);
|
||||
box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
|
||||
border-color: #3b82f6;
|
||||
}
|
||||
|
||||
.plan-card.premium-plan:hover {
|
||||
transform: translateY(-6px);
|
||||
box-shadow: 0 12px 40px rgba(59, 130, 246, 0.3);
|
||||
border-color: #2563eb;
|
||||
}
|
||||
|
||||
.plan-header {
|
||||
text-align: center;
|
||||
margin-bottom: 2rem;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.plan-badge {
|
||||
display: inline-block;
|
||||
background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
|
||||
color: white;
|
||||
padding: 0.5rem 1rem;
|
||||
border-radius: 2rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.plan-title {
|
||||
font-size: 1.75rem;
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.plan-description {
|
||||
color: var(--text-secondary);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* 价格显示 */
|
||||
.plan-pricing {
|
||||
text-align: center;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.price-display {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.price {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.price.loading {
|
||||
color: var(--text-secondary);
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.price.error {
|
||||
color: #ef4444;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.period {
|
||||
font-size: 1rem;
|
||||
color: var(--text-secondary);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.billing-toggle {
|
||||
display: flex;
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
border-radius: 0.75rem;
|
||||
padding: 0.25rem;
|
||||
}
|
||||
|
||||
[data-theme='dark'] .billing-toggle {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.billing-option {
|
||||
flex: 1;
|
||||
padding: 0.75rem 1rem;
|
||||
border: none;
|
||||
background: transparent;
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
font-weight: 500;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.billing-option.active {
|
||||
background: white;
|
||||
color: var(--primary-color);
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
[data-theme='dark'] .billing-option.active {
|
||||
background: var(--bg-primary);
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
/* 功能特性 */
|
||||
.features-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0 0 2rem 0;
|
||||
}
|
||||
|
||||
.feature-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.75rem 0;
|
||||
color: var(--text-primary);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.feature-item.highlight {
|
||||
color: var(--primary-color);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.check-icon {
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
color: #10b981;
|
||||
margin-right: 0.75rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* 订阅按钮 */
|
||||
.plan-button {
|
||||
width: 100%;
|
||||
padding: 1rem 2rem;
|
||||
border: none;
|
||||
border-radius: 0.75rem;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.premium-button {
|
||||
background: linear-gradient(135deg, #3b82f6, #1d4ed8);
|
||||
color: white;
|
||||
box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.premium-button:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #2563eb, #1e40af);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 24px rgba(59, 130, 246, 0.5);
|
||||
}
|
||||
|
||||
.premium-button:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* 确认对话框 */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.confirm-dialog {
|
||||
background: #ffffff;
|
||||
border-radius: 0.75rem;
|
||||
padding: 0;
|
||||
max-width: 420px;
|
||||
width: 100%;
|
||||
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
|
||||
border: 1px solid #e2e8f0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dialog-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 1.5rem 2rem;
|
||||
border-bottom: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.dialog-header h3 {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.close-button {
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
padding: 0.5rem;
|
||||
border-radius: 0.5rem;
|
||||
color: #64748b;
|
||||
transition: all 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.close-button:hover {
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
color: #1e293b;
|
||||
}
|
||||
|
||||
.close-button svg {
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
}
|
||||
|
||||
/* 简化的计划信息 */
|
||||
.plan-info {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
.plan-info h4 {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
color: #1e293b;
|
||||
margin: 0 0 1rem 0;
|
||||
}
|
||||
|
||||
.plan-info .price {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #3b82f6;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.plan-info .description {
|
||||
color: #64748b;
|
||||
font-size: 0.95rem;
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
padding: 1.5rem 2rem;
|
||||
border-top: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.btn {
|
||||
flex: 1;
|
||||
padding: 0.875rem 1.5rem;
|
||||
border-radius: 0.75rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: linear-gradient(135deg, #3b82f6, #1d4ed8);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
background: linear-gradient(135deg, #2563eb, #1e40af);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background: #f8fafc;
|
||||
color: #64748b;
|
||||
border: 1px solid #e2e8f0;
|
||||
}
|
||||
|
||||
.btn-secondary:hover:not(:disabled) {
|
||||
background: #ffffff;
|
||||
color: #1e293b;
|
||||
border-color: #cbd5e1;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.hero-title {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.plans-grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
.plan-card {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.price {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
.confirm-dialog {
|
||||
padding: 1.5rem;
|
||||
margin: 1rem;
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.hero-section {
|
||||
padding: 2rem 1rem 1rem;
|
||||
}
|
||||
|
||||
.subscription-plans {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.plan-card {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.price {
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user