823bdcafcf
CI / build (push) Failing after 15m11s
- billingApi(products/verifyGoogle), native/billing(테스트 구매 토큰 생성) - Android 앱: 상품(월간/연간) 구매 버튼 → 검증 → 프로필 갱신 - PC(웹/데스크톱): 구매 대신 앱 다운로드 안내 - 프리미엄 이용 중이면 만료일 표시 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
317 lines
7.7 KiB
Vue
317 lines
7.7 KiB
Vue
<script setup>
|
|
import { computed, onMounted, ref } from 'vue'
|
|
import { useRouter } from 'vue-router'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
import { billingApi } from '@/api/billingApi'
|
|
import { billing } from '@/native/billing'
|
|
|
|
const router = useRouter()
|
|
const auth = useAuthStore()
|
|
const isPremium = computed(() => auth.isPremium)
|
|
|
|
// 결제는 Android 앱에서만 — PC(웹/데스크톱)는 앱 다운로드로 유도
|
|
const isNative = billing.isNative()
|
|
const APP_DOWNLOAD_URL = 'https://app.sblog.kr' // TODO: 실제 앱(APK/Play 스토어) 다운로드 주소로 교체
|
|
|
|
const products = ref([])
|
|
const purchasing = ref('')
|
|
const message = ref('')
|
|
const error = ref('')
|
|
|
|
// 만료일 표시
|
|
const expiresAt = computed(() => auth.user?.planExpiresAt)
|
|
function fmtDate(s) {
|
|
if (!s) return ''
|
|
const d = new Date(s)
|
|
if (Number.isNaN(d.getTime())) return s
|
|
const p = (n) => String(n).padStart(2, '0')
|
|
return `${d.getFullYear()}.${p(d.getMonth() + 1)}.${p(d.getDate())}`
|
|
}
|
|
|
|
onMounted(async () => {
|
|
if (!isNative) return // PC 는 상품 목록 불필요
|
|
try {
|
|
products.value = await billingApi.products()
|
|
} catch {
|
|
products.value = []
|
|
}
|
|
})
|
|
|
|
async function buy(product) {
|
|
if (purchasing.value) return
|
|
purchasing.value = product.id
|
|
message.value = ''
|
|
error.value = ''
|
|
try {
|
|
const receipt = await billing.purchase(product.id)
|
|
await billingApi.verifyGoogle(receipt)
|
|
await auth.refreshProfile() // plan/만료일 갱신
|
|
message.value = '결제가 완료되어 프리미엄이 적용되었습니다. 감사합니다!'
|
|
} catch (e) {
|
|
error.value = e.response?.data?.message || '결제에 실패했습니다. 다시 시도해 주세요.'
|
|
} finally {
|
|
purchasing.value = ''
|
|
}
|
|
}
|
|
|
|
// 무료 / 유료 기능 비교 (docs/plan-membership-tiers.md 기준)
|
|
const freeFeatures = [
|
|
'가계부 내역 기록 · 조회',
|
|
'계좌 관리 (개수 제한 없음)',
|
|
'자주 쓰는 내역',
|
|
'월별 수입/지출 요약',
|
|
'기본 분류',
|
|
'게시판 · 다크 모드',
|
|
]
|
|
const premiumFeatures = [
|
|
'전체 통계 (분류별·추이·자산)',
|
|
'예산 설정',
|
|
'고정 지출 자동 반영',
|
|
'영수증 OCR 인식',
|
|
'카드 알림 자동 인식',
|
|
'투자 · 자산 관리',
|
|
'태그 · 소분류 무제한',
|
|
'데이터 백업 / 복구 (엑셀)',
|
|
'광고 제거',
|
|
]
|
|
|
|
function goBack() {
|
|
if (window.history.length > 1) router.back()
|
|
else router.push('/account/entries')
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="upgrade">
|
|
<header class="up-head">
|
|
<div class="crown">👑</div>
|
|
<h1 v-if="isPremium">유료 멤버십 이용 중</h1>
|
|
<h1 v-else>유료 멤버십으로 더 많은 기능을</h1>
|
|
<p v-if="isPremium" class="sub">모든 프리미엄 기능을 사용할 수 있습니다. 감사합니다!</p>
|
|
<p v-else class="sub">통계·예산·자동화·백업까지, 가계부를 200% 활용하세요.</p>
|
|
</header>
|
|
|
|
<div class="plans">
|
|
<section class="plan">
|
|
<h2>무료</h2>
|
|
<ul>
|
|
<li v-for="f in freeFeatures" :key="f"><span class="dot ok">✓</span>{{ f }}</li>
|
|
</ul>
|
|
</section>
|
|
<section class="plan premium">
|
|
<h2>유료 <span class="badge">PREMIUM</span></h2>
|
|
<ul>
|
|
<li v-for="f in premiumFeatures" :key="f"><span class="dot pro">★</span>{{ f }}</li>
|
|
</ul>
|
|
</section>
|
|
</div>
|
|
|
|
<div class="cta">
|
|
<!-- 이미 유료 회원 -->
|
|
<p v-if="isPremium" class="status-premium">
|
|
프리미엄 이용 중<span v-if="expiresAt"> · {{ fmtDate(expiresAt) }}까지</span>
|
|
</p>
|
|
|
|
<!-- 미가입 + Android 앱: 상품 구매 -->
|
|
<template v-else-if="isNative">
|
|
<div class="products">
|
|
<button
|
|
v-for="p in products"
|
|
:key="p.id"
|
|
type="button"
|
|
class="buy-btn"
|
|
:disabled="!!purchasing"
|
|
@click="buy(p)"
|
|
>
|
|
<span class="buy-label">{{ p.label }}</span>
|
|
<span class="buy-price">{{ p.priceKrw.toLocaleString('ko-KR') }}원<span class="buy-per"> / {{ p.months }}개월</span></span>
|
|
<span v-if="purchasing === p.id" class="buy-ing">처리 중…</span>
|
|
</button>
|
|
</div>
|
|
<p v-if="!products.length" class="notice">상품을 불러오지 못했습니다.</p>
|
|
</template>
|
|
|
|
<!-- 미가입 + PC(웹/데스크톱): 앱 다운로드 유도 -->
|
|
<template v-else>
|
|
<p class="notice">
|
|
📱 구독 결제는 <b>모바일 앱</b>에서 진행됩니다.<br />
|
|
앱을 설치한 뒤 로그인하여 프리미엄을 구독해 주세요.
|
|
</p>
|
|
<a class="primary-link" :href="APP_DOWNLOAD_URL" target="_blank" rel="noopener">앱 다운로드</a>
|
|
</template>
|
|
|
|
<p v-if="message" class="msg-ok">{{ message }}</p>
|
|
<p v-if="error" class="msg-err">{{ error }}</p>
|
|
|
|
<button type="button" class="ghost" @click="goBack">돌아가기</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.upgrade {
|
|
max-width: 760px;
|
|
margin: 0 auto;
|
|
}
|
|
.up-head {
|
|
text-align: center;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
.crown {
|
|
font-size: 2.4rem;
|
|
}
|
|
.up-head h1 {
|
|
font-size: 1.4rem;
|
|
margin: 0.4rem 0 0.3rem;
|
|
color: var(--color-heading);
|
|
}
|
|
.sub {
|
|
color: var(--color-text);
|
|
opacity: 0.8;
|
|
font-size: 0.95rem;
|
|
}
|
|
.plans {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 1rem;
|
|
}
|
|
.plan {
|
|
border: 1px solid var(--color-border);
|
|
border-radius: 12px;
|
|
padding: 1.1rem 1.2rem;
|
|
background: var(--color-background-soft);
|
|
}
|
|
.plan.premium {
|
|
border-color: hsla(40, 90%, 55%, 0.7);
|
|
background: hsla(40, 90%, 55%, 0.06);
|
|
}
|
|
.plan h2 {
|
|
font-size: 1.05rem;
|
|
margin: 0 0 0.8rem;
|
|
color: var(--color-heading);
|
|
}
|
|
.badge {
|
|
font-size: 0.65rem;
|
|
font-weight: 700;
|
|
padding: 0.1rem 0.4rem;
|
|
border-radius: 999px;
|
|
background: hsla(40, 90%, 50%, 0.9);
|
|
color: #3a2a00;
|
|
vertical-align: middle;
|
|
}
|
|
.plan ul {
|
|
list-style: none;
|
|
padding: 0;
|
|
margin: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.55rem;
|
|
}
|
|
.plan li {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
font-size: 0.9rem;
|
|
}
|
|
.dot {
|
|
flex: none;
|
|
width: 18px;
|
|
text-align: center;
|
|
}
|
|
.dot.ok {
|
|
color: hsla(160, 100%, 37%, 1);
|
|
}
|
|
.dot.pro {
|
|
color: hsla(40, 90%, 50%, 1);
|
|
}
|
|
.cta {
|
|
margin-top: 1.6rem;
|
|
text-align: center;
|
|
}
|
|
.notice {
|
|
font-size: 0.88rem;
|
|
color: var(--color-text);
|
|
opacity: 0.85;
|
|
margin-bottom: 0.9rem;
|
|
line-height: 1.6;
|
|
}
|
|
.status-premium {
|
|
font-size: 1rem;
|
|
font-weight: 700;
|
|
color: #b8860b;
|
|
margin-bottom: 1rem;
|
|
}
|
|
.products {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.6rem;
|
|
max-width: 360px;
|
|
margin: 0 auto 0.9rem;
|
|
}
|
|
.buy-btn {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
padding: 0.85rem 1.1rem;
|
|
border: 1px solid hsla(40, 90%, 50%, 0.8);
|
|
border-radius: 10px;
|
|
background: hsla(40, 90%, 55%, 0.08);
|
|
color: var(--color-text);
|
|
cursor: pointer;
|
|
font-size: 0.95rem;
|
|
}
|
|
.buy-btn:disabled {
|
|
opacity: 0.6;
|
|
cursor: default;
|
|
}
|
|
.buy-label {
|
|
font-weight: 700;
|
|
}
|
|
.buy-price {
|
|
margin-left: auto;
|
|
font-weight: 700;
|
|
color: #b8860b;
|
|
}
|
|
.buy-per {
|
|
font-weight: 400;
|
|
font-size: 0.82rem;
|
|
opacity: 0.7;
|
|
}
|
|
.buy-ing {
|
|
font-size: 0.82rem;
|
|
opacity: 0.7;
|
|
}
|
|
.primary-link {
|
|
display: inline-block;
|
|
padding: 0.6rem 1.6rem;
|
|
border-radius: 8px;
|
|
background: hsla(160, 100%, 37%, 1);
|
|
color: #fff;
|
|
font-weight: 700;
|
|
margin-bottom: 0.9rem;
|
|
}
|
|
.msg-ok {
|
|
color: hsla(160, 100%, 37%, 1);
|
|
font-weight: 600;
|
|
margin-bottom: 0.9rem;
|
|
}
|
|
.msg-err {
|
|
color: #c0392b;
|
|
margin-bottom: 0.9rem;
|
|
}
|
|
.ghost {
|
|
padding: 0.55rem 1.4rem;
|
|
border: 1px solid var(--color-border);
|
|
border-radius: 8px;
|
|
background: var(--color-background);
|
|
color: var(--color-text);
|
|
cursor: pointer;
|
|
font-weight: 600;
|
|
}
|
|
@media (max-width: 560px) {
|
|
.plans {
|
|
grid-template-columns: 1fr;
|
|
}
|
|
}
|
|
</style>
|