feat: unified gravity system - VIP members consume gravity instead of unlimited; add monthly gravity top-up cron

This commit is contained in:
yuzhiran
2026-06-19 22:43:52 +08:00
parent c2ba810a02
commit 2fbab1072f
22 changed files with 956 additions and 216 deletions
+138 -35
View File
@@ -22,7 +22,8 @@
<text class="tab" :class="{ active: tab === 'pricing' }" @click="switchTab('pricing')">定价</text>
<text class="tab" :class="{ active: tab === 'share' }" @click="switchTab('share')">分享</text>
<text class="tab" :class="{ active: tab === 'positions' }" @click="switchTab('positions')">岗位</text>
<text class="tab" :class="{ active: tab === 'admins' }" @click="switchTab('admins')">管理</text>
<text class="tab" :class="{ active: tab === 'analysis' }" @click="switchTab('analysis')">诊断</text>
<text class="tab" :class="{ active: tab === 'admins' }" @click="switchTab('admins')">管理员</text>
</view>
<!-- 概览 -->
@@ -66,10 +67,8 @@
</view>
<view class="user-badges">
<text class="user-plan" :class="{ vip: u.plan === 'growth' || u.plan === 'sprint' }">{{ u.plan === 'growth' || u.plan === 'sprint' ? '会员' : '免费' }}</text>
<text class="user-credit">面试:{{ u.interviewCredits ?? 0 }}</text>
<text class="user-credit">优化:{{ u.resumeOptimizeCredits ?? 0 }}</text>
<text class="user-credit">下载:{{ u.resumeDownloadCredits ?? 0 }}</text>
<text class="user-credit share">分享:{{ u.shareCredits ?? 0 }}</text>
<text class="user-credit">引力值:{{ u.gravity ?? 0 }}</text>
<text class="user-credit share" v-if="u.shareCredits > 0">分享:{{ u.shareCredits }}</text>
</view>
<view class="user-actions">
<text class="user-action-btn" v-if="u.plan === 'free'" @click="setVip(u._id)">设为会员</text>
@@ -83,6 +82,12 @@
<!-- 面试 -->
<view v-if="tab === 'interviews'" class="section">
<view class="search-bar">
<input v-model="ivKeyword" placeholder="搜索岗位/用户名" class="search-input" @confirm="loadInterviews" />
<picker :range="['全部状态','进行中','已完成']" @change="e => { ivStatusFilter=e.detail.value; loadInterviews() }">
<text class="search-btn">{{ ['全部状态','进行中','已完成'][ivStatusFilter] }}</text>
</picker>
</view>
<view class="iv-list" v-if="!ivLoading">
<view class="iv-row" v-for="iv in interviews" :key="iv._id">
<view class="iv-main">
@@ -95,13 +100,20 @@
<text class="iv-tag score">得分 {{ iv.totalScore ?? '-' }}</text>
<text class="iv-tag filler" v-if="iv.fillerScore != null && iv.fillerScore > 0">语分析 {{ iv.fillerScore }}/{{ iv.fillerDensity ?? '-' }}</text>
</view>
<text class="iv-time">{{ iv.createdAt?.slice(0,16).replace('T',' ') }}</text>
</view>
<text class="load-more" v-if="ivTotal > interviews.length" @click="loadMoreInterviews">加载更多</text>
<text class="empty-text" v-if="interviews.length === 0 && !ivLoading">暂无面试记录</text>
</view>
<text class="loading-text" v-if="ivLoading">加载中...</text>
</view>
<!-- 简历 -->
<view v-if="tab === 'resumes'" class="section">
<view class="search-bar">
<input v-model="resumeKeyword" placeholder="搜索简历标题" class="search-input" @confirm="loadResumes" />
<text class="search-btn" @click="loadResumes">搜索</text>
</view>
<view class="resume-list" v-if="!resumeLoading">
<view class="resume-row" v-for="r in resumes" :key="r._id">
<view class="resume-main">
@@ -114,6 +126,9 @@
<text class="resume-tag paid" v-if="r.paidDownload">付费下载</text>
</view>
<text class="resume-time">{{ r.createdAt?.slice(0,10) }}</text>
<view class="resume-actions">
<text class="admin-action-btn del" @click="deleteResume(r._id, r.title)">删除</text>
</view>
</view>
</view>
<text class="loading-text" v-if="resumeLoading">加载中...</text>
@@ -176,12 +191,32 @@
</view>
</view>
<view class="config-card">
<view class="cfg-title">引力值消耗</view>
<view class="cfg-row">
<text>面试消耗引力值/</text>
<input class="cfg-input" type="digit" v-model.number="pricing.gravityRates.interviewPerUse" />
</view>
<view class="cfg-row">
<text>优化消耗引力值/</text>
<input class="cfg-input" type="digit" v-model.number="pricing.gravityRates.optimizePerUse" />
</view>
<view class="cfg-row">
<text>下载消耗引力值/</text>
<input class="cfg-input" type="digit" v-model.number="pricing.gravityRates.downloadPerUse" />
</view>
</view>
<view class="config-card">
<view class="cfg-title">成长版 ¥{{ growthPriceDisplay }}</view>
<view class="cfg-row">
<text>价格/</text>
<input class="cfg-input" type="digit" v-model.number="growthPriceTemp" />
</view>
<view class="cfg-row">
<text>每月引力值</text>
<input class="cfg-input" type="digit" v-model.number="pricing.plans.growth.gravityPerMonth" />
</view>
<view class="cfg-row">
<text>面试额度/</text>
<input class="cfg-input" type="digit" v-model.number="pricing.plans.growth.credits.interview" />
@@ -207,7 +242,9 @@
<input class="cfg-input" type="digit" v-model.number="sprintPriceTemp" />
</view>
<view class="cfg-row">
<text>面试额度/</text>
<text>每月引力值</text>
<input class="cfg-input" type="digit" v-model.number="pricing.plans.sprint.gravityPerMonth" />
</view>
<input class="cfg-input" type="digit" v-model.number="pricing.plans.sprint.credits.interview" />
</view>
<view class="cfg-row">
@@ -300,13 +337,27 @@
<text class="loading-text" v-if="posLoading">加载中...</text>
</view>
<!-- 诊断分析 -->
<view v-if="tab === 'analysis'" class="section">
<view class="config-card">
<view class="cfg-title">简历诊断</view>
<view class="cfg-row"><text>总诊断次数</text><text class="cfg-val">{{ analysisStats.totalDiagnoses ?? 0 }}</text></view>
<view class="cfg-row"><text>今日诊断</text><text class="cfg-val">{{ analysisStats.todayDiagnoses ?? 0 }}</text></view>
</view>
<view class="config-card">
<view class="cfg-title">技能缺口分析</view>
<view class="cfg-row"><text>总分析次数</text><text class="cfg-val">{{ analysisStats.totalGapAnalysis ?? 0 }}</text></view>
</view>
<text class="loading-text" v-if="analysisLoading">加载中...</text>
</view>
<!-- 额度调整弹窗 -->
<view class="modal-mask" v-if="creditModal.show" @click="closeCreditModal">
<view class="modal-content" @click.stop>
<text class="modal-title">调整 {{ creditModal.user?.nickname || '用户' }} 的额度</text>
<view class="cfg-row" v-for="t in creditTypes" :key="t.key">
<text>{{ t.label }}</text>
<input class="cfg-input" type="digit" v-model.number="t.value" :placeholder="t.key" />
<view class="cfg-row">
<text>引力值</text>
<input class="cfg-input" type="digit" v-model.number="creditGravity" />
</view>
<view class="modal-actions">
<button class="modal-btn cancel" @click="closeCreditModal">取消</button>
@@ -333,6 +384,10 @@
<text class="cfg-val">{{ posForm.active ? '启用' : '停用' }}</text>
</picker>
</view>
<view class="cfg-row"><text>岗位描述</text></view>
<textarea class="cfg-textarea" v-model="posForm.description" placeholder="岗位职责描述,每行一个要点" />
<view class="cfg-row"><text>任职要求</text></view>
<textarea class="cfg-textarea" v-model="posForm.requirements" placeholder="任职资格要求,每行一个要点" />
<view class="modal-actions">
<button class="modal-btn cancel" @click="closePositionModal">取消</button>
<button class="modal-btn confirm" @click="savePosition">保存</button>
@@ -386,11 +441,10 @@
<text class="admin-set-btn" v-if="searchResult.role !== 'admin'" @click="setAdmin(searchResult._id)">设为管理员</text>
<text class="admin-set-btn done" v-else>已是管理员</text>
</view>
</view>
</view>
</view>
</view>
</template>
</template>
<script setup>
import { ref, computed, onMounted, reactive } from 'vue'
@@ -422,9 +476,10 @@ const pricing = ref({
interview: { pricePerSession: 500 },
resumeOptimize: { freeLimit: 3, pricePerOptimize: 300 },
resumeDownload: { pricePerDownload: 200 },
gravityRates: { interviewPerUse: 5, optimizePerUse: 3, downloadPerUse: 2 },
plans: {
growth: { price: 1990, durationDays: 30, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: ['免费版全部权益', 'AI 数字人面试无限次'] },
sprint: { price: 4990, durationDays: 30, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: ['成长版全部权益'] },
growth: { price: 1990, durationDays: 30, gravityPerMonth: 250, credits: { interview: 999, resumeOptimize: 20, resumeDownload: 10 }, features: ['免费版全部权益', '每月 250 引力值'] },
sprint: { price: 4990, durationDays: 30, gravityPerMonth: 600, credits: { interview: 999, resumeOptimize: 50, resumeDownload: 30 }, features: ['成长版全部权益', '每月 600 引力值'] },
},
})
const pricingLoading = ref(false)
@@ -432,6 +487,14 @@ const growthPriceTemp = ref(19.9)
const sprintPriceTemp = ref(49.9)
const growthFeaturesText = ref('')
const sprintFeaturesText = ref('')
const ivKeyword = ref('')
const ivStatusFilter = ref(0)
const ivTotal = ref(0)
const ivPage = ref(1)
const resumeKeyword = ref('')
const creditGravity = ref(0)
const analysisStats = ref({ totalDiagnoses: 0, todayDiagnoses: 0, totalGapAnalysis: 0 })
const analysisLoading = ref(false)
// Position management
const positions = ref([])
@@ -445,6 +508,8 @@ const posForm = reactive({
sort: 0,
active: true,
category: 'ai',
description: '',
requirements: '',
})
const growthPriceDisplay = computed(() => growthPriceTemp.value.toFixed(1))
@@ -466,12 +531,6 @@ const shareLoading = ref(false)
// Credit modal
const creditModal = ref({ show: false, user: null })
const creditTypes = ref([
{ key: 'interviewCredits', label: '面试次数', value: 0 },
{ key: 'resumeOptimizeCredits', label: '优化次数', value: 0 },
{ key: 'resumeDownloadCredits', label: '下载次数', value: 0 },
{ key: 'shareCredits', label: '分享积分', value: 0 },
])
// Refund modal
const refundModal = ref({ show: false, order: null })
@@ -578,6 +637,7 @@ const switchTab = (t) => {
if (t === 'admins' && adminList.value.length === 0) loadAdmins()
if (t === 'pricing') loadPricing()
if (t === 'orders') loadOrders()
if (t === 'analysis') loadAnalysis()
}
const loadUsers = async () => {
@@ -600,22 +660,55 @@ const loadMoreUsers = async () => {
const loadInterviews = async () => {
ivLoading.value = true
ivPage.value = 1
try {
const res = await apiAdmin('/interviews?page=1&limit=20')
if (res.statusCode === 200) interviews.value = res.data.interviews || []
let url = '/interviews?page=1&limit=20&keyword=' + encodeURIComponent(ivKeyword.value)
const statusMap = ['', 'in_progress', 'completed']
if (ivStatusFilter.value > 0) url += '&status=' + statusMap[ivStatusFilter.value]
const res = await apiAdmin(url)
if (res.statusCode === 200) { interviews.value = res.data.interviews || []; ivTotal.value = res.data.total || 0 }
} catch (e) { console.error(e) }
finally { ivLoading.value = false }
}
const loadMoreInterviews = async () => {
ivPage.value++
try {
let url = '/interviews?page=' + ivPage.value + '&limit=20&keyword=' + encodeURIComponent(ivKeyword.value)
const statusMap = ['', 'in_progress', 'completed']
if (ivStatusFilter.value > 0) url += '&status=' + statusMap[ivStatusFilter.value]
const res = await apiAdmin(url)
if (res.statusCode === 200) interviews.value = [...interviews.value, ...(res.data.interviews || [])]
} catch (e) { console.error(e) }
}
const loadResumes = async () => {
resumeLoading.value = true
try {
const res = await apiAdmin('/resumes?page=1&limit=20')
let url = '/resumes?page=1&limit=20'
if (resumeKeyword.value) url += '&keyword=' + encodeURIComponent(resumeKeyword.value)
const res = await apiAdmin(url)
if (res.statusCode === 200) resumes.value = res.data.list || []
} catch (e) { console.error(e) }
finally { resumeLoading.value = false }
}
const deleteResume = (id, title) => {
uni.showModal({
title: '删除简历', content: `确定删除"${title}"`,
success: async (r) => {
if (!r.confirm) return
try {
const res = await apiAdmin('/resume/' + id, { method: 'DELETE' })
if (res.statusCode === 200) {
uni.showToast({ title: '已删除', icon: 'success' })
loadResumes()
} else throw new Error()
} catch { uni.showToast({ title: '删除失败', icon: 'none' }) }
},
})
}
const loadPricing = async () => {
pricingLoading.value = true
try {
@@ -631,6 +724,15 @@ const loadPricing = async () => {
finally { pricingLoading.value = false }
}
const loadAnalysis = async () => {
analysisLoading.value = true
try {
const res = await apiAdmin('/analysis-stats')
if (res.statusCode === 200) analysisStats.value = res.data
} catch(e) { console.error(e) }
finally { analysisLoading.value = false }
}
const savePricing = async () => {
pricingLoading.value = true
try {
@@ -721,6 +823,8 @@ const openPositionModal = (position) => {
posForm.sort = position.sort ?? 0
posForm.active = position.active ?? true
posForm.category = position.category || 'traditional'
posForm.description = position.description || ''
posForm.requirements = position.requirements || ''
posModal.value = { show: true, isNew: false }
} else {
posForm.name = ''
@@ -730,6 +834,8 @@ const openPositionModal = (position) => {
posForm.sort = positions.value.length + 1
posForm.active = true
posForm.category = 'ai'
posForm.description = ''
posForm.requirements = ''
posModal.value = { show: true, isNew: true }
}
}
@@ -835,12 +941,7 @@ const loadShareVisitors = async () => {
}
const openCreditModal = (user) => {
creditTypes.value = [
{ key: 'interviewCredits', label: '面试次数', value: user.interviewCredits ?? 0 },
{ key: 'resumeOptimizeCredits', label: '优化次数', value: user.resumeOptimizeCredits ?? 0 },
{ key: 'resumeDownloadCredits', label: '下载次数', value: user.resumeDownloadCredits ?? 0 },
{ key: 'shareCredits', label: '分享积分', value: user.shareCredits ?? 0 },
]
creditGravity.value = user.gravity ?? 0
creditModal.value = { show: true, user }
}
@@ -852,12 +953,10 @@ const doAdjustCredits = async () => {
const userId = creditModal.value.user?._id
if (!userId) return
try {
for (const t of creditTypes.value) {
await apiAdmin('/user/credits', {
method: 'POST',
data: { userId, type: t.key, amount: t.value },
})
}
await apiAdmin('/user/credits', {
method: 'POST',
data: { userId, type: 'gravity', amount: creditGravity.value },
})
uni.showToast({ title: '调整成功', icon: 'success' })
closeCreditModal()
loadUsers()
@@ -877,7 +976,7 @@ onMounted(() => { doVerify() })
.btn-verify { height: 72rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #FFF; border-radius: var(--radius-sm); font-size: 26rpx; border: none; }
.body { padding: 20rpx 32rpx 48rpx; margin-top: -40rpx; }
.tabs { display: flex; gap: 8rpx; background: #FFF; border-radius: var(--radius-md); padding: 6rpx; margin-bottom: 20rpx; }
.tab { flex: 1; text-align: center; padding: 14rpx; font-size: 24rpx; color: var(--color-text-secondary); border-radius: var(--radius-sm); }
.tab { flex: 1; text-align: center; padding: 14rpx; font-size: 24rpx; color: var(--color-text-secondary); border-radius: var(--radius-sm); white-space: nowrap; }
.tab.active { background: var(--color-primary); color: #FFF; font-weight: 600; }
.stat-cards { display: flex; gap: 16rpx; }
.stat-card { flex: 1; background: #FFF; border-radius: var(--radius-lg); padding: 28rpx; text-align: center; box-shadow: var(--shadow-sm); }
@@ -988,4 +1087,8 @@ onMounted(() => { doVerify() })
.pos-mgr-btn { font-size: 20rpx; padding: 4rpx 16rpx; border-radius: var(--radius-round); }
.pos-mgr-btn.edit { color: var(--color-primary); border: 2rpx solid var(--color-primary); }
.pos-mgr-btn.del { color: #EF4444; border: 2rpx solid #EF4444; }
.iv-time { font-size: 18rpx; color: #D1D5DB; white-space: nowrap; margin-left: auto; }
.admin-action-btn { font-size: 20rpx; padding: 4rpx 16rpx; border-radius: var(--radius-round); cursor: pointer; }
.admin-action-btn.del { color: #EF4444; border: 2rpx solid #EF4444; }
.resume-actions { display: flex; gap: 8rpx; align-items: center; }
</style>
+1 -1
View File
@@ -13,7 +13,7 @@
<text class="user-name">{{ userInfo.nickname || '同学' }}</text>
<view class="user-tags">
<text class="tag tag-plan">{{ userInfo.plan || '免费版' }}</text>
<text class="tag tag-remaining">{{ userInfo.interviewCredits > 0 ? '剩余 ' + userInfo.interviewCredits + ' 次' : '已用完' }}</text>
<text class="tag tag-remaining">{{ (userInfo.gravity ?? 0) > 0 ? '引力值 ' + (userInfo.gravity ?? 0) : '引力值 0' }}</text>
</view>
</view>
<text class="arrow"></text>
+113 -3
View File
@@ -66,10 +66,53 @@
</view>
</view>
<!-- 岗位选择弹窗 -->
<view class="modal-overlay" v-if="showPositionPicker" @click="showPositionPicker = false">
<view class="modal-content" @click.stop>
<text class="modal-title">选择面试岗位</text>
<view class="pos-list">
<view class="pos-option" v-for="(pos, idx) in positions" :key="idx" @click="selectPosition(pos)">
<text class="pos-name">{{ pos.name }}</text>
<text class="pos-arrow"></text>
</view>
<view class="pos-option" v-if="positions.length === 0 && !positionsLoading">
<text class="pos-name disabled">暂无可用岗位</text>
</view>
<view class="pos-option" v-if="positionsLoading">
<text class="pos-name disabled">加载中...</text>
</view>
</view>
<text class="modal-close" @click="showPositionPicker = false">取消</text>
</view>
</view>
<view class="disclaimer-bar" v-if="!isComplete">AI 生成内容仅供参考请核实重要信息</view>
<view class="complete-bar" v-else>
<button class="cta-btn" @click="goResult">查看面试报告</button>
<button class="buy-btn" v-if="completedReason === 'noCredits'" @click="showPurchaseModal = true">引力值不足补充引力值或开通会员 </button>
</view>
<!-- 购买弹窗次数不足时 -->
<view class="modal-overlay" v-if="showPurchaseModal" @click="showPurchaseModal = false">
<view class="modal-content" @click.stop>
<text class="modal-title">引力值不足</text>
<text class="modal-hint">您的引力值不足请补充后继续面试每次面试消耗 5 引力值</text>
<view class="purchase-options">
<view class="purchase-option" @click="goBuyProduct">
<text class="purchase-name">补充引力值</text>
<text class="purchase-price">¥5 </text>
<text class="purchase-desc">¥5 = 5 引力值可面试 1 </text>
</view>
<view class="purchase-option recommended" @click="goBuyMember">
<text class="purchase-badge">推荐</text>
<text class="purchase-name">开通成长版会员</text>
<text class="purchase-price">¥19.9<text class="purchase-unit">/</text></text>
<text class="purchase-desc">每月 250 引力值解锁全部权益</text>
</view>
</view>
<text class="modal-close" @click="showPurchaseModal = false">取消</text>
</view>
</view>
</view>
</template>
@@ -86,9 +129,14 @@ const aiLoading = ref(false)
const interviewId = ref('')
const answeredCount = ref(0)
const isComplete = ref(false)
const completedReason = ref('')
const scrollToId = ref('')
const position = ref('')
const avatarMode = ref(true)
const showPositionPicker = ref(false)
const showPurchaseModal = ref(false)
const positions = ref([])
const positionsLoading = ref(false)
const aiSpeechText = ref('')
const aiAudioUrl = ref('')
const aiAmplitudeData = ref([])
@@ -116,9 +164,37 @@ onLoad((options) => {
}
})
/** 加载热门岗位列表 */
const loadPositions = async () => {
positionsLoading.value = true
try {
const res = await uni.request({ url: api('/positions/hot'), method: 'GET' })
if (res.statusCode >= 200 && res.statusCode < 300 && Array.isArray(res.data)) {
positions.value = res.data
} else if (res.data?.data && Array.isArray(res.data.data)) {
positions.value = res.data.data
}
} catch (e) { console.error('加载岗位列表失败', e) }
finally { positionsLoading.value = false }
}
/** 用户选择岗位后开始面试 */
const selectPosition = (pos) => {
position.value = pos.name
showPositionPicker.value = false
messages.value = [{ role: 'ai', content: `你好!我是你的专属 ${pos.name} 面试官,准备好了就开始吧!` }]
startInterview()
}
onMounted(() => {
timerInterval = setInterval(() => timerSeconds++, 1000)
if (token()) startInterview()
if (!position.value) {
// 未传入岗位,展示选择弹窗(无论是否登录)
loadPositions()
showPositionPicker.value = true
} else if (token()) {
startInterview()
}
})
onBeforeUnmount(() => {
@@ -155,6 +231,11 @@ const startInterview = async () => {
const last = res.data.messages[res.data.messages.length - 1]
if (last?.role === 'ai') await speakAiText(last.content)
}
} else if (res.statusCode === 403) {
const errMsg = res.data?.message || '面试次数已用完'
messages.value.push({ role: 'ai', content: errMsg + ' 👉 购买后可继续面试' })
isComplete.value = true
completedReason.value = 'noCredits'
} else {
const msg = res.data?.message || '创建面试失败'
messages.value.push({ role: 'ai', content: msg })
@@ -198,8 +279,10 @@ const sendAnswer = async () => {
answeredCount.value = res.data.questionCount || answeredCount.value + 1
if (res.data.totalQuestions) MAX_QUESTIONS = res.data.totalQuestions
} else if (res.statusCode === 403) {
messages.value.push({ role: 'ai', content: res.data?.message || '面试次数已用完' })
const errMsg = res.data?.message || '面试次数已用完'
messages.value.push({ role: 'ai', content: errMsg + ' 👉 购买后可继续面试' })
isComplete.value = true
completedReason.value = 'noCredits'
} else {
messages.value.push({ role: 'ai', content: res.data?.message || '回答提交失败' })
}
@@ -240,6 +323,8 @@ function onAvatarSilent() {
}
const goResult = () => uni.navigateTo({ url: `/pages/report/report?interviewId=${interviewId.value}` })
const goBuyProduct = () => uni.navigateTo({ url: '/pages/member/member?buy=interview' })
const goBuyMember = () => uni.navigateTo({ url: '/pages/member/member' })
const scrollToBottom = () => {
nextTick(() => { scrollToId.value = ''; setTimeout(() => { scrollToId.value = 'msg-bottom' }, 100) })
}
@@ -389,7 +474,32 @@ function stopRecord() {
.send-btn.disabled { background: var(--color-border); }
.send-icon { font-size: 32rpx; color: #FFFFFF; transform: translateY(2rpx); }
.complete-bar { background: #FFFFFF; padding: 20rpx 24rpx; padding-bottom: calc(20rpx + var(--safe-bottom)); }
.complete-bar { background: #FFFFFF; padding: 20rpx 24rpx; padding-bottom: calc(20rpx + var(--safe-bottom)); display: flex; flex-direction: column; gap: 16rpx; }
.cta-btn { width: 100%; height: 88rpx; line-height: 88rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #FFFFFF; border-radius: var(--radius-md); font-size: 28rpx; font-weight: 600; border: none; }
.buy-btn { width: 100%; height: 72rpx; line-height: 72rpx; background: #FEF3C7; color: #92400E; border-radius: var(--radius-md); font-size: 26rpx; font-weight: 600; border: 2rpx solid #F59E0B; }
.disclaimer-bar { text-align: center; font-size: 20rpx; color: var(--color-text-tertiary); padding: 8rpx 24rpx; background: #FFFFFF; border-top: 1rpx solid var(--color-border); }
/* 岗位选择弹窗 */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.45); z-index: 999; display: flex; align-items: center; justify-content: center; }
.modal-content { background: #FFF; border-radius: 20rpx; width: 600rpx; max-height: 70vh; display: flex; flex-direction: column; align-items: center; padding: 40rpx 32rpx 32rpx; }
.modal-title { font-size: 30rpx; font-weight: 800; color: var(--color-text); margin-bottom: 24rpx; }
.pos-list { width: 100%; max-height: 440rpx; overflow-y: auto; }
.pos-option { display: flex; align-items: center; justify-content: space-between; padding: 24rpx 16rpx; border-bottom: 1rpx solid #F3F4F6; }
.pos-option:active { background: #F9FAFB; border-radius: 12rpx; }
.pos-name { font-size: 28rpx; color: var(--color-text); }
.pos-name.disabled { color: #9CA3AF; }
.pos-arrow { font-size: 32rpx; color: #9CA3AF; }
.modal-close { margin-top: 24rpx; font-size: 26rpx; color: #9CA3AF; padding: 12rpx 32rpx; }
/* 购买弹窗 */
.modal-hint { font-size: 24rpx; color: #6B7280; text-align: center; margin-bottom: 28rpx; padding: 0 16rpx; }
.purchase-options { width: 100%; display: flex; flex-direction: column; gap: 16rpx; }
.purchase-option { background: #F9FAFB; border-radius: var(--radius-md); padding: 24rpx; border: 2rpx solid #E5E7EB; }
.purchase-option.recommended { background: #FFFBEB; border-color: #F59E0B; }
.purchase-option:active { transform: scale(0.97); }
.purchase-badge { font-size: 18rpx; color: #FFF; background: #F59E0B; padding: 2rpx 12rpx; border-radius: 6rpx; align-self: flex-start; margin-bottom: 8rpx; }
.purchase-name { font-size: 28rpx; font-weight: 700; color: var(--color-text); display: block; }
.purchase-price { font-size: 36rpx; font-weight: 800; color: var(--color-primary); margin-top: 8rpx; }
.purchase-unit { font-size: 22rpx; font-weight: 400; color: #9CA3AF; }
.purchase-desc { font-size: 22rpx; color: #6B7280; margin-top: 6rpx; }
</style>
+241 -21
View File
@@ -79,6 +79,30 @@
</view>
</view>
<!-- 数量选择弹窗补充引力值 -->
<view class="modal-overlay" v-if="showQuantityModal" @click="showQuantityModal = false">
<view class="modal-content" @click.stop>
<text class="modal-title">补充引力值</text>
<text class="modal-hint">购买后将获得相应引力值可用于面试优化下载</text>
<view class="qty-selector">
<text class="qty-label">购买数量</text>
<view class="qty-controls">
<text class="qty-btn" :class="{ disabled: buyQuantity <= 1 }" @click="changeQty(-1)"></text>
<input class="qty-input" type="number" v-model.number="buyQuantity" min="1" max="99" @blur="clampQty" />
<text class="qty-btn" :class="{ disabled: buyQuantity >= 99 }" @click="changeQty(1)">+</text>
</view>
</view>
<view class="qty-summary">
<text class="qty-unit-price">单价¥{{ (unitPrice / 100).toFixed(1) }}</text>
<text class="qty-total"> <text class="qty-total-num">{{ buyQuantity * buyGravityPerUnit }}</text> 引力值</text>
</view>
<view class="qty-actions">
<text class="qty-cancel" @click="showQuantityModal = false">取消</text>
<text class="qty-confirm" @click="confirmProductBuy">¥{{ totalPrice.toFixed(1) }} 去支付</text>
</view>
</view>
</view>
<!-- 支付中提示 -->
<view class="pay-success" v-if="paySuccess">
<text class="success-icon">🎉</text>
@@ -88,8 +112,8 @@
</template>
<script setup>
import { ref, onMounted, nextTick } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { ref, computed, onMounted, nextTick } from 'vue'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { api } from '../../config'
import UQRCode from 'uqrcodejs'
@@ -107,9 +131,25 @@ const payingPlan = ref('')
const growthPriceText = ref('¥19.9')
const sprintPriceText = ref('¥49.9')
const currentOutTradeNo = ref('')
const freeFeatures = ref(['AI 模拟面试 1 次(体验', '基础面试报告', '通用题库随机出题', '简历优化(限 3 次免费)'])
const growthFeatures = ref(['免费版全部权益', 'AI 数字人面试无限次', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题', '参考回答思路', '公司真题库'])
const sprintFeatures = ref(['成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '公司真题库精选'])
const freeFeatures = ref(['AI 模拟面试 1 次(注册送 5 引力值', '基础面试报告', '通用题库随机出题', '简历优化(限 3 次免费)'])
const growthFeatures = ref(['免费版全部权益', '每月 250 引力值(约 50 次面试)', '详细面试报告(四维评分)', '进步轨迹雷达图 + 打卡', '每日一题', '参考回答思路', '公司真题库'])
const sprintFeatures = ref(['成长版全部权益', '每月 600 引力值(约 120 次面试)', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告', '公司真题库精选'])
const products = ref([])
const gravityRates = ref({ interviewPerUse: 5, optimizePerUse: 3, downloadPerUse: 2 })
const productPayType = ref('')
const showQuantityModal = ref(false)
const buyQuantity = ref(1)
const buyProductType = ref('')
const pendingBuy = ref('')
const unitPrice = computed(() => {
const p = products.value.find(p => p.type === buyProductType.value)
return p?.price || 0
})
const totalPrice = computed(() => (unitPrice.value * buyQuantity.value) / 100)
const buyGravityPerUnit = computed(() => {
const p = products.value.find(p => p.type === buyProductType.value)
return p?.gravity || 0
})
const token = () => uni.getStorageSync('token') || ''
@@ -130,12 +170,12 @@ const refreshState = async () => {
uni.request({ url: api('/member/status'), method: 'GET', header: { 'Authorization': `Bearer ${t}` } }),
uni.request({ url: api('/member/plans'), method: 'GET' }),
])
if (sres.statusCode === 200) {
if (sres.statusCode >= 200 && sres.statusCode < 300) {
const d = sres.data
plan.value = d.plan || 'free'
currentPlanName.value = d.planName || '免费版'
}
if (lres.statusCode === 200 && lres.data) {
if (lres.statusCode >= 200 && lres.statusCode < 300 && lres.data) {
const plans = Array.isArray(lres.data.plans) ? lres.data.plans : (Array.isArray(lres.data) ? lres.data : [])
const growth = plans.find((p) => p.id === 'growth')
const sprint = plans.find((p) => p.id === 'sprint')
@@ -148,10 +188,33 @@ const refreshState = async () => {
if (lres.data.price?.monthly) {
growthPriceText.value = `¥${(lres.data.price.monthly / 100).toFixed(1)}`
}
if (lres.data?.products) {
const prodList = []
for (const [key, val] of Object.entries(lres.data.products)) {
if (val?.price > 0) prodList.push({ type: key, ...val })
}
products.value = prodList
}
if (lres.data?.gravityRates) {
gravityRates.value = lres.data.gravityRates
}
}
// 来自其他页面的补充次数请求 → 弹出数量选择
if (pendingBuy.value && products.value.length > 0) {
buyProductType.value = pendingBuy.value
buyQuantity.value = 1
pendingBuy.value = ''
showQuantityModal.value = true
}
} catch (e) { /* ignore */ }
}
onLoad((options) => {
if (options?.buy) {
pendingBuy.value = options.buy
}
})
onMounted(() => { refreshState() })
onShow(() => { refreshState() })
@@ -170,12 +233,7 @@ const startPay = async (selectedPlan) => {
if (!t) { uni.showToast({ title: '请先登录', icon: 'none' }); return }
payingPlan.value = selectedPlan
// #ifdef MP-WEIXIN
payingPlanName.value = selectedPlan === 'sprint' ? '冲刺版' : '成长版'
// #endif
// #ifndef MP-WEIXIN
payingPlanName.value = selectedPlan === 'sprint' ? '冲刺版' : '成长版'
// #endif
showPayModal.value = true
payLoading.value = true
@@ -186,18 +244,50 @@ const startPay = async (selectedPlan) => {
if (isMp.value) {
// 小程序:JSAPI 支付
try {
const res = await uni.request({
let res = await uni.request({
url: api('/payment/jsapi'), method: 'POST',
data: { plan: planLabel },
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
timeout: 30000,
})
// 如果没有 openid,自动绑定
if (res.statusCode === 400 && res.data?.needBindWx) {
payLoading.value = false
uni.showLoading({ title: '绑定微信中...' })
try {
const loginRes = await uni.login()
if (!loginRes?.errMsg?.includes('ok')) throw new Error('获取微信凭证失败')
const bindRes = await uni.request({
url: api('/user/bind-wx'), method: 'POST',
data: { code: loginRes.code },
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
})
if (bindRes.statusCode >= 200 && bindRes.statusCode < 300) {
// 绑定成功,重试支付
res = await uni.request({
url: api('/payment/jsapi'), method: 'POST',
data: { plan: planLabel },
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
timeout: 30000,
})
} else {
throw new Error(bindRes.data?.message || '微信绑定失败')
}
} catch (e) {
uni.hideLoading()
payError.value = '微信绑定失败,请重试'
uni.showToast({ title: '微信绑定失败', icon: 'none' })
return
}
uni.hideLoading()
}
payLoading.value = false
if (res.statusCode === 200 && res.data?.payParams) {
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.payParams) {
const pp = res.data.payParams
currentOutTradeNo.value = res.data.outTradeNo || ''
// 调起微信支付
uni.requestPayment({
provider: 'wxpay',
timeStamp: pp.timeStamp,
@@ -209,7 +299,7 @@ const startPay = async (selectedPlan) => {
const no = currentOutTradeNo.value || res.data.outTradeNo
pollPayResult(no, planLabel)
},
fail: (err) => { payError.value = '支付取消或失败'; uni.showToast({ title: '支付取消', icon: 'none' }) },
fail: (err) => { payError.value = '支付未完成'; uni.showToast({ title: '支付未完成', icon: 'none' }) },
})
} else if (!res.statusCode || res.statusCode === 0) {
payLoading.value = false
@@ -218,9 +308,12 @@ const startPay = async (selectedPlan) => {
uni.showToast({ title: errMsg, icon: 'none' })
} else {
payLoading.value = false
const errMsg = res.data?.message || '创建订单失败'
// DEBUG: 显示实际返回的状态和数据以便排查
const debugInfo = `[${res.statusCode}] ${JSON.stringify(res.data).substring(0, 120)}`
console.error('支付响应异常:', debugInfo)
const errMsg = res.data?.message || `创建订单失败(${debugInfo})`
payError.value = errMsg
uni.showToast({ title: errMsg, icon: 'none' })
uni.showToast({ title: errMsg, icon: 'none', duration: 4000 })
}
} catch (e) {
payLoading.value = false
@@ -237,7 +330,7 @@ const startPay = async (selectedPlan) => {
})
payLoading.value = false
if (res.statusCode === 200 && res.data?.codeUrl) {
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.codeUrl) {
payCodeUrl.value = res.data.codeUrl
currentOutTradeNo.value = res.data.outTradeNo
nextTick(() => {
@@ -272,6 +365,117 @@ const startPay = async (selectedPlan) => {
}
}
/** 数量增减 */
const changeQty = (delta) => {
const next = buyQuantity.value + delta
if (next >= 1 && next <= 99) buyQuantity.value = next
}
const clampQty = () => {
if (buyQuantity.value < 1) buyQuantity.value = 1
if (buyQuantity.value > 99) buyQuantity.value = 99
}
/** 确认购买(从数量选择弹窗触发) */
const confirmProductBuy = () => {
showQuantityModal.value = false
startProductPay(buyProductType.value, buyQuantity.value)
}
/** 按次购买 */
const startProductPay = async (type, quantity = 1) => {
const t = token()
if (!t) { uni.showToast({ title: '请先登录', icon: 'none' }); return }
productPayType.value = type
showPayModal.value = true
payLoading.value = true
payError.value = ''
const prod = products.value.find(p => p.type === type)
const prodTitle = prod?.title || type
if (isMp.value) {
// 小程序:JSAPI 按次支付
try {
let res = await uni.request({
url: api('/payment/jsapi-product'), method: 'POST',
data: { type, quantity },
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
timeout: 30000,
})
payLoading.value = false
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.payParams) {
const pp = res.data.payParams
currentOutTradeNo.value = res.data.outTradeNo || ''
uni.requestPayment({
provider: 'wxpay',
timeStamp: pp.timeStamp,
nonceStr: pp.nonceStr,
package: pp.package,
signType: pp.signType || 'RSA',
paySign: pp.paySign,
success: () => {
const no = currentOutTradeNo.value || res.data.outTradeNo
pollPayResult(no, 'growth')
},
fail: (err) => { payError.value = '支付未完成'; uni.showToast({ title: '支付未完成', icon: 'none' }) },
})
} else if (!res.statusCode || res.statusCode === 0) {
payLoading.value = false
uni.showToast({ title: '网络连接失败', icon: 'none' })
} else {
payLoading.value = false
const errMsg = res.data?.message || '购买失败'
payError.value = errMsg
uni.showToast({ title: errMsg, icon: 'none' })
}
} catch (e) {
payLoading.value = false
payError.value = '网络错误,请重试'
uni.showToast({ title: '网络错误', icon: 'none' })
}
} else {
// H5:扫码支付
try {
const res = await uni.request({
url: api('/payment/create-product'), method: 'POST',
data: { type, quantity },
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
})
payLoading.value = false
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.codeUrl) {
payCodeUrl.value = res.data.codeUrl
currentOutTradeNo.value = res.data.outTradeNo
nextTick(() => {
try {
const ctx = uni.createCanvasContext('payQrcode')
const uqrcode = new UQRCode()
uqrcode.data = res.data.codeUrl
uqrcode.size = 400
uqrcode.margin = 20
uqrcode.backgroundColor = '#FFFFFF'
uqrcode.foregroundColor = '#000000'
uqrcode.make()
uqrcode.drawCanvas(ctx)
} catch(e) { console.error('二维码生成失败', e) }
})
pollPayResult(res.data.outTradeNo, 'growth')
} else if (!res.statusCode || res.statusCode === 0) {
payLoading.value = false
uni.showToast({ title: '网络连接失败', icon: 'none' })
} else {
payError.value = res.data?.message || '购买失败'
uni.showToast({ title: res.data?.message || '购买失败', icon: 'none' })
}
} catch (e) {
payLoading.value = false
payError.value = '网络错误,请重试'
uni.showToast({ title: '网络错误', icon: 'none' })
}
}
}
/** 轮询订单状态 */
const pollPayResult = async (outTradeNo, selectedPlan) => {
if (!outTradeNo) return
@@ -285,7 +489,7 @@ const pollPayResult = async (outTradeNo, selectedPlan) => {
url: api(`/payment/check/${outTradeNo}`), method: 'GET',
header: { 'Authorization': `Bearer ${token()}` },
})
if (res.statusCode === 200 && res.data?.status === 'success') {
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.status === 'success') {
// 支付成功,激活套餐
await activatePlan(outTradeNo, selectedPlan)
return
@@ -310,7 +514,7 @@ const activatePlan = async (outTradeNo, selectedPlan) => {
data: { outTradeNo },
header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' },
})
if (res.statusCode === 200 && res.data?.success) {
if (res.statusCode >= 200 && res.statusCode < 300 && res.data?.success) {
paySuccess.value = true
showPayModal.value = false
plan.value = selectedPlan === 'sprint' ? 'sprint' : 'growth'
@@ -361,4 +565,20 @@ const activatePlan = async (outTradeNo, selectedPlan) => {
.qr-canvas { width: 400rpx; height: 400rpx; background: #FFF; border-radius: var(--radius-md); }
.modal-hint { font-size: 22rpx; color: var(--color-text-tertiary); }
.modal-close { font-size: 22rpx; color: var(--color-text-tertiary); padding: 8rpx; }
/* 数量选择弹窗 */
.qty-selector { width: 100%; }
.qty-label { font-size: 24rpx; color: #6B7280; margin-bottom: 16rpx; display: block; }
.qty-controls { display: flex; align-items: center; justify-content: center; gap: 24rpx; }
.qty-btn { width: 64rpx; height: 64rpx; border-radius: 50%; background: #F3F4F6; display: flex; align-items: center; justify-content: center; font-size: 36rpx; font-weight: 500; color: var(--color-text); }
.qty-btn.disabled { color: #D1D5DB; background: #F9FAFB; }
.qty-btn:active:not(.disabled) { transform: scale(0.9); background: #E5E7EB; }
.qty-input { width: 100rpx; height: 72rpx; text-align: center; font-size: 36rpx; font-weight: 700; color: var(--color-text); border: 2rpx solid #E5E7EB; border-radius: var(--radius-sm); }
.qty-summary { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 16rpx 0; border-top: 1rpx solid #F3F4F6; }
.qty-unit-price { font-size: 22rpx; color: #6B7280; }
.qty-total { font-size: 26rpx; color: var(--color-text); font-weight: 500; }
.qty-total-num { font-size: 36rpx; font-weight: 800; color: var(--color-primary); }
.qty-actions { width: 100%; display: flex; gap: 16rpx; margin-top: 8rpx; }
.qty-cancel { flex: 1; text-align: center; padding: 20rpx; border-radius: var(--radius-md); font-size: 26rpx; color: #6B7280; border: 2rpx solid #E5E7EB; }
.qty-confirm { flex: 2; text-align: center; padding: 20rpx; border-radius: var(--radius-md); font-size: 26rpx; font-weight: 600; color: #FFF; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); }
</style>
+40 -7
View File
@@ -4,8 +4,8 @@
<view class="stats-card">
<view class="stat-row">
<view class="stat-item">
<text class="stat-value">{{ stats.shareCredits || 0 }}</text>
<text class="stat-label">📦 我的积分</text>
<text class="stat-value">{{ stats.gravity ?? 0 }}</text>
<text class="stat-label">🌌 我的引力值</text>
</view>
</view>
<view class="stat-sub-row">
@@ -20,12 +20,12 @@
</view>
<view class="stat-arrow"></view>
<view class="stat-sub-item">
<text class="stat-sub-value">{{ stats.shareCredits || 0 }}</text>
<text class="stat-sub-label">获得积分</text>
<text class="stat-sub-value">{{ stats.gravity || 0 }}</text>
<text class="stat-sub-label">获得引力值</text>
</view>
</view>
<view class="hint">
💡 好友通过你的链接打开并 <text class="hint-em">登录/注册</text> 才算有效每次有效 1 积分
💡 好友通过你的链接打开并 <text class="hint-em">登录/注册</text> 才算有效每次有效 1 引力值每日上限 3
</view>
</view>
@@ -49,15 +49,31 @@
<view class="today-bar">
<view class="today-bar-fill" :style="{ width: Math.min(100, (todayStats.credited / 3) * 100) + '%' }"></view>
</view>
<text class="today-hint">每日最多 3 次有效积分</text>
<text class="today-hint">每日最多 3 次有效引力值分享给朋友圈可获更多</text>
</view>
<!-- 分享按钮 -->
<view class="share-actions">
<!-- #ifdef MP-WEIXIN -->
<button class="share-btn wx-share" open-type="share">
<text class="btn-icon">💬</text>
<text>分享给好友</text>
</button>
<button class="share-btn wx-share" open-type="share" data-mode="timeline">
<text class="btn-icon">🔄</text>
<text>分享朋友圈</text>
</button>
<!-- #endif -->
<!-- #ifdef H5 -->
<button class="share-btn wx-share" @click="shareToWechat" v-if="isWechat">
<text class="btn-icon">💬</text>
<text>分享给微信好友</text>
</button>
<button class="share-btn wx-timeline" @click="shareToWechat" v-if="isWechat">
<text class="btn-icon">🔄</text>
<text>分享朋友圈</text>
</button>
<!-- #endif -->
<button class="share-btn link-share" @click="copyLink">
<text class="btn-icon">🔗</text>
<text>复制分享链接</text>
@@ -113,10 +129,14 @@
<script setup>
import { ref, computed, onMounted } from 'vue'
// #ifdef MP-WEIXIN
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
// #endif
import { api } from '../../config'
const tab = ref('records')
const stats = ref({ totalShares: 0, totalVisits: 0, creditedCount: 0, todayCredited: 0, shareCredits: 0 })
const stats = ref({ totalShares: 0, totalVisits: 0, creditedCount: 0, todayCredited: 0, shareCredits: 0, gravity: 0 })
const shareLink = ref('')
const records = ref([])
const visitors = ref([])
@@ -127,6 +147,18 @@ const todayStats = computed(() => ({
const isWechat = ref(false)
// #ifdef MP-WEIXIN
onShareAppMessage(() => ({
title: 'AI磁场·职引 — AI模拟面试+简历优化',
path: '/pages/share/share',
imageUrl: 'https://zhiyinwx.yzrcloud.cn/static/share-card.png',
}))
onShareTimeline(() => ({
title: 'AI磁场·职引 — AI模拟面试+简历优化',
imageUrl: 'https://zhiyinwx.yzrcloud.cn/static/share-card.png',
}))
// #endif
onMounted(() => {
// #ifdef H5
isWechat.value = navigator?.userAgent?.toLowerCase().includes('micromessenger') || false
@@ -243,6 +275,7 @@ function formatTime(t) {
.share-btn:active { transform: scale(0.96); }
.btn-icon { margin-right: 8rpx; font-size: 28rpx; }
.wx-share { background: #07C160; color: #FFFFFF; }
.wx-timeline { background: #FF6600; color: #FFFFFF; }
.link-share { background: #FFFFFF; color: var(--color-text); border: 2rpx solid var(--color-border); }
/* Tabs */
+43 -1
View File
@@ -39,6 +39,20 @@
</view>
</view>
<!-- 配额与会员信息 -->
<view class="quota-card" v-if="isLoggedIn">
<view class="quota-row">
<view class="quota-info">
<text class="quota-plan">{{ memberInfo.planName || '免费版' }}</text>
<text class="quota-count">引力值 {{ memberInfo.gravity ?? 0 }}</text>
</view>
<view class="quota-actions">
<text class="quota-btn primary" @click="goBuyCredits">补充引力值</text>
<text class="quota-btn" :class="memberInfo.plan !== 'free' ? 'owned' : ''" @click="goUpgrade">{{ memberInfo.plan !== 'free' ? '已开通' : '升级会员' }}</text>
</view>
</view>
</view>
<!-- 菜单列表 -->
<view class="menu-area">
<view class="menu-group">
@@ -102,6 +116,7 @@ const userInfo = ref({})
const isAdmin = ref(false)
const stats = ref({ interviewCount: 0, avgScore: '--', completedCount: 0 })
const token = ref('')
const memberInfo = ref({ plan: 'free', planName: '免费版', remaining: 0, gravity: 0 })
const isLoggedIn = computed(() => !!token.value)
const maskedId = computed(() => {
@@ -114,6 +129,7 @@ const refreshState = () => {
if (!token.value) return
try { const s = uni.getStorageSync('userInfo'); if (s) userInfo.value = JSON.parse(s) } catch(e) {}
loadStats()
loadMemberStatus()
checkAdmin()
fetchUserInfo()
}
@@ -131,6 +147,16 @@ const fetchUserInfo = async () => {
onMounted(refreshState)
onShow(refreshState)
const loadMemberStatus = async () => {
if (!token.value) return
try {
const res = await uni.request({ url: api('/member/status'), method: 'GET', header: { 'Authorization': `Bearer ${token.value}` } })
if (res.statusCode >= 200 && res.statusCode < 300 && res.data) {
memberInfo.value = { plan: res.data.plan || 'free', planName: res.data.planName || '免费版', remaining: res.data.remaining ?? 0, gravity: res.data.gravity ?? 0 }
}
} catch(e) { /* silent */ }
}
const loadStats = async () => {
try {
const res = await uni.request({ url: api('/interview/stats/mine'), method: 'GET', header: { 'Authorization': `Bearer ${token.value}` } })
@@ -153,6 +179,11 @@ const checkAdmin = () => {
}
const goLogin = () => uni.navigateTo({ url: '/pages/login/login' })
const goBuyCredits = () => uni.navigateTo({ url: '/pages/member/member?buy=interview' })
const goUpgrade = () => {
if (memberInfo.value.plan !== 'free') return // already on a paid plan
uni.navigateTo({ url: '/pages/member/member' })
}
const goCareer = () => uni.navigateTo({ url: '/pages/career/career' })
const goHistory = () => uni.switchTab({ url: '/pages/history/history' })
const goReviewReview = () => uni.navigateTo({ url: '/pages/review/review' })
@@ -197,7 +228,18 @@ const doLogout = () => {
.guest-info { flex: 1; }
.guest-name { font-size: 30rpx; font-weight: 600; color: #FFFFFF; }
.menu-area { padding: 0 32rpx 32rpx; margin-top: -40rpx; }
.quota-card { margin: -48rpx 32rpx 16rpx; background: #FFFFFF; border-radius: var(--radius-lg); padding: 28rpx 24rpx; box-shadow: var(--shadow-sm); position: relative; z-index: 1; }
.quota-row { display: flex; align-items: center; justify-content: space-between; }
.quota-info { display: flex; flex-direction: column; gap: 4rpx; }
.quota-plan { font-size: 28rpx; font-weight: 700; color: var(--color-text); }
.quota-count { font-size: 22rpx; color: #6B7280; }
.quota-actions { display: flex; gap: 12rpx; }
.quota-btn { font-size: 22rpx; padding: 8rpx 20rpx; border-radius: var(--radius-sm); font-weight: 500; white-space: nowrap; }
.quota-btn.primary { background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #FFF; }
.quota-btn.owned { background: #F3F4F6; color: #9CA3AF; }
.quota-btn:not(.primary):not(.owned) { background: #FEF3C7; color: #92400E; border: 2rpx solid #F59E0B; }
.menu-area { padding: 0 32rpx 32rpx; margin-top: 8rpx; }
.menu-group { background: #FFFFFF; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 24rpx; box-shadow: var(--shadow-sm); }
.menu-item { display: flex; align-items: center; padding: 28rpx 32rpx; border-bottom: 1rpx solid var(--color-border); }
.menu-item:last-child { border-bottom: none; }