| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- <template>
- <view class="page-payment">
- <view class="header">
- <text class="header-title">{{ pageTitle }}</text>
- <text class="header-desc">{{ pageDesc }}</text>
- </view>
- <template v-if="loading">
- <view class="loading-state"><text class="loading-text">加载中...</text></view>
- </template>
- <template v-else-if="product === 'annual'">
- <!-- C端年费 ¥131 -->
- <view class="plan-card selected">
- <view class="plan-badge popular">推荐</view>
- <view class="plan-top">
- <text class="plan-name">C端会员</text>
- <view class="plan-price-row">
- <text class="price-symbol">¥</text>
- <text class="price">{{ formatYuan(pricing.annualFee) }}</text>
- <text class="per">/年</text>
- </view>
- <text class="price-daily">每天仅 ¥{{ (pricing.annualFee / 100 / 365).toFixed(2) }}</text>
- </view>
- <view class="plan-features">
- <text class="feature">✦ AI 互动问答 — 无限次</text>
- <text class="feature">✦ 获得推广权限,赚取佣金</text>
- <text class="feature">✦ 一级 40% + 二级 5% 佣金比例</text>
- <text class="feature">✦ VIP 标识</text>
- </view>
- </view>
- <button class="pay-btn" @click="onPay" :disabled="paying">
- {{ paying ? '处理中...' : `立即开通 · C端会员 ¥${formatYuan(pricing.annualFee)}/年` }}
- </button>
- </template>
- <template v-else-if="product === 'practitioner'">
- <!-- 能量师 种子价/标准价 -->
- <view class="plan-card plan-pro selected">
- <view class="plan-badge pro">专业</view>
- <view class="plan-top">
- <text class="plan-name">能量师</text>
- <view class="plan-price-row">
- <text class="price-symbol">¥</text>
- <text class="price">{{ formatYuan(currentPrice) }}</text>
- <text class="per">/年</text>
- </view>
- <view v-if="pricing.isSeedPrice" class="seed-badge">
- 种子价 · 仅剩 {{ pricing.remainingSeats }}/{{ pricing.seedLimit }} 个名额
- </view>
- <text v-else class="standard-label">标准定价</text>
- <!-- US-4.4 Upgrade breakdown -->
- <view v-if="isUpgrade" class="upgrade-info">
- <view class="upgrade-row">
- <text class="upgrade-label">原年费金额</text>
- <text class="upgrade-value">¥{{ formatYuan(pricing.originalPaidAmount) }}</text>
- </view>
- <view class="upgrade-row">
- <text class="upgrade-label">年费剩余价值</text>
- <text class="upgrade-value minus">-¥{{ formatYuan(pricing.remainingValue) }}</text>
- </view>
- <view class="upgrade-row total">
- <text class="upgrade-label">应付差价</text>
- <text class="upgrade-value highlight">¥{{ formatYuan(pricing.upgradePrice) }}</text>
- </view>
- </view>
- <text class="price-daily">每天仅 ¥{{ (currentPrice / 100 / 365).toFixed(2) }}</text>
- </view>
- <view class="plan-features">
- <text class="feature">✦ 包含 C 端全部权益</text>
- <text class="feature">✦ 无限能量盘生成</text>
- <text class="feature">✦ AI 五区完整解读,随问随答</text>
- <text class="feature">✦ 全部历史记录永久保存</text>
- <text class="feature">✦ 推广佣金 — 固定 ¥500/人 + 二级 ¥100/人</text>
- </view>
- </view>
- <button class="pay-btn pro-btn" @click="onPay" :disabled="paying">
- {{ paying ? '处理中...' : `立即开通 · 能量师 ${priceLabel} ¥${formatYuan(currentPrice)}/年` }}
- </button>
- </template>
- <text class="note">支付即表示同意《订阅协议》</text>
- </view>
- </template>
- <script setup>
- import { ref, computed, onMounted } from 'vue'
- import { useUserStore } from '@/stores/user'
- import { payApi, pricingApi } from '@/utils/api'
- const userStore = useUserStore()
- const paying = ref(false)
- const loading = ref(true)
- const product = ref('annual')
- const isUpgrade = ref(false)
- const pricing = ref({
- seedPrice: 131400,
- standardPrice: 198600,
- annualFee: 13100,
- isSeedPrice: true,
- remainingSeats: 300,
- seedLimit: 300
- })
- const pageTitle = computed(() => {
- return product.value === 'annual' ? 'C端会员' : '能量师专业版'
- })
- const pageDesc = computed(() => {
- return product.value === 'annual' ? '解锁无限AI解读,获取推广佣金' : '获取完整能量盘分析、AI解读与分销推广权限'
- })
- const currentPrice = computed(() => {
- if (product.value === 'annual') return pricing.value.annualFee
- if (isUpgrade.value) return pricing.value.upgradePrice
- return pricing.value.isSeedPrice ? pricing.value.seedPrice : pricing.value.standardPrice
- })
- const priceLabel = computed(() => {
- if (isUpgrade.value) return '升级价'
- return pricing.value.isSeedPrice ? '种子价' : '标准价'
- })
- function formatYuan(cents) {
- if (cents == null) return '0'
- return (cents / 100).toLocaleString()
- }
- onMounted(async () => {
- // Ensure user profile is loaded (vipType, etc.)
- try {
- await userStore.fetchProfile()
- } catch (e) {
- // ignore, use cached
- }
- // Read product param from URL
- const pages = getCurrentPages()
- const page = pages[pages.length - 1]
- const params = page?.options || {}
- product.value = params.product || 'annual'
- // Determine upgrade scenario: annual member upgrading to practitioner
- if (product.value === 'practitioner' && userStore.vipType === 'annual') {
- isUpgrade.value = true
- }
- // Always get base pricing first (isSeedPrice + correct practitioner price)
- try {
- const res = await pricingApi.current()
- if (res) pricing.value = res
- } catch (e) {
- // Use defaults if API fails
- }
- // If upgrade, overlay upgrade-specific fields (upgradePrice, remainingValue, etc.)
- if (isUpgrade.value) {
- try {
- const upgradeRes = await pricingApi.upgrade()
- if (upgradeRes) {
- pricing.value = {
- ...pricing.value, // base: isSeedPrice, seedPrice, standardPrice, annualFee
- ...upgradeRes // overlay: upgradePrice, remainingValue, originalPaidAmount, usedDays
- }
- }
- } catch (e) {
- // Fallback: treat as non-upgrade
- isUpgrade.value = false
- }
- }
- loading.value = false
- })
- async function onPay() {
- paying.value = true
- try {
- const totalFee = currentPrice.value
- const productType = product.value
- await payApi.create({
- totalFee,
- payType: 'wxpay',
- productType,
- isUpgrade: isUpgrade.value
- })
- // Refresh user profile to reflect VIP status change
- await userStore.fetchProfile()
- uni.showToast({ title: '开通成功!', icon: 'success' })
- setTimeout(() => uni.navigateBack(), 1500)
- } catch (e) {
- uni.showToast({ title: '支付失败,请重试', icon: 'none' })
- }
- paying.value = false
- }
- </script>
- <style scoped lang="scss">
- .page-payment {
- padding: 20px;
- min-height: 100vh;
- background: linear-gradient(180deg, #0c0a1a 0%, #120d28 60%, #0f0c1e 100%);
- }
- .header {
- text-align: center;
- margin-bottom: 20px;
- }
- .header-title {
- font-size: 22px;
- font-weight: 700;
- color: rgba(255,255,255,0.9);
- display: block;
- }
- .header-desc {
- font-size: 13px;
- color: rgba(255,255,255,0.4);
- margin-top: 6px;
- display: block;
- }
- .loading-state {
- padding: 60px 0;
- text-align: center;
- }
- .loading-text {
- font-size: 14px;
- color: rgba(255,255,255,0.3);
- }
- /* Plan Cards */
- .plan-card {
- position: relative;
- background: rgba(255,255,255,0.03);
- border: 1px solid rgba(255,255,255,0.08);
- border-radius: 16px;
- padding: 22px 18px 18px;
- margin-bottom: 12px;
- }
- .plan-card.selected {
- border-color: #fbbf24;
- background: rgba(251,191,36,0.06);
- }
- .plan-card.plan-pro.selected {
- border-color: #a78bfa;
- background: rgba(167,139,250,0.06);
- }
- .plan-badge {
- position: absolute;
- top: -1px;
- right: 20px;
- font-size: 11px;
- font-weight: 600;
- padding: 3px 14px;
- border-radius: 0 0 8px 8px;
- }
- .plan-badge.popular {
- background: #f59e0b;
- color: #fff;
- }
- .plan-badge.pro {
- background: #7c3aed;
- color: #fff;
- }
- .plan-top { text-align: center; }
- .plan-name {
- font-size: 17px;
- font-weight: 600;
- color: rgba(255,255,255,0.85);
- display: block;
- margin-bottom: 10px;
- }
- .plan-price-row {
- display: flex;
- align-items: baseline;
- justify-content: center;
- }
- .price-symbol {
- font-size: 20px;
- color: #fbbf24;
- font-weight: 600;
- }
- .price {
- font-size: 38px;
- font-weight: 700;
- color: #fbbf24;
- margin: 0 2px;
- }
- .plan-pro .price-symbol,
- .plan-pro .price {
- color: #a78bfa;
- }
- .per {
- font-size: 14px;
- color: rgba(255,255,255,0.4);
- }
- .price-daily {
- display: block;
- font-size: 12px;
- color: rgba(255,255,255,0.3);
- margin-top: 4px;
- }
- .seed-badge {
- display: inline-block;
- margin-top: 6px;
- font-size: 11px;
- color: #fbbf24;
- background: rgba(251,191,36,0.12);
- padding: 2px 12px;
- border-radius: 4px;
- }
- .standard-label {
- display: inline-block;
- margin-top: 6px;
- font-size: 11px;
- color: rgba(255,255,255,0.35);
- padding: 2px 12px;
- border-radius: 4px;
- border: 1px solid rgba(255,255,255,0.1);
- }
- /* US-4.4 Upgrade breakdown */
- .upgrade-info {
- margin-top: 12px;
- padding: 10px 12px;
- background: rgba(255,255,255,0.04);
- border-radius: 8px;
- border: 1px dashed rgba(255,255,255,0.15);
- }
- .upgrade-row {
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 13px;
- margin-bottom: 6px;
- }
- .upgrade-row:last-child {
- margin-bottom: 0;
- }
- .upgrade-row.total {
- margin-top: 6px;
- padding-top: 6px;
- border-top: 1px solid rgba(255,255,255,0.1);
- }
- .upgrade-label {
- color: rgba(255,255,255,0.5);
- }
- .upgrade-value {
- color: rgba(255,255,255,0.9);
- font-weight: 500;
- }
- .upgrade-value.minus {
- color: #fbbf24;
- }
- .upgrade-value.highlight {
- color: #a78bfa;
- font-weight: 600;
- }
- .plan-features {
- margin-top: 16px;
- }
- .feature {
- display: block;
- padding: 5px 0;
- font-size: 13px;
- color: rgba(255,255,255,0.6);
- line-height: 1.5;
- }
- .plan-card.selected .feature {
- color: rgba(255,255,255,0.8);
- }
- .pay-btn {
- width: 100%;
- padding: 16px;
- background: linear-gradient(135deg, #f59e0b, #d97706);
- color: #fff;
- border: none;
- border-radius: 14px;
- font-size: 17px;
- font-weight: 600;
- letter-spacing: 2px;
- margin-bottom: 8px;
- }
- .pay-btn.pro-btn {
- background: linear-gradient(135deg, #7c3aed, #6d28d9);
- }
- .pay-btn[disabled] { opacity: 0.4; }
- .note {
- display: block;
- text-align: center;
- font-size: 12px;
- color: rgba(255,255,255,0.25);
- }
- </style>
|