v4.2 冲刺版+每日推送+支付修复+全量代码评审
## 新增功能 - 冲刺版 ¥49.9/月:完整支付→激活→权益扣减链路 - 每日一题定时推送(@nestjs/schedule,早8点微信订阅消息) - miniprogram-ci 编译上传脚本(scripts/upload-mp.js) ## Bug修复 - 套餐值统一:vip→growth/sprint(interview轮次限制、analyze次数检查) - member/pay 移除开发绕过:改为订单校验后激活 - progress→report 参数名不匹配:id→interviewId - result.vue resume.create() 参数传错(对象→独立参数) - resume.vue analyze请求缺少Authorization header - bank.vue contribution请求缺少Authorization header - member.vue startPay() 缺少try/catch导致网络错误崩溃 - login.vue 调试面板 v-if="true" 生产泄漏 ## 配置 - 微信支付生产证书就位(商户号1113760598) - .env 清理冗余文件(删除.example/.production) - WX_NOTIFY_URL 更新为 zhiyinwx.yzrcloud.cn ## 文档 - PROJECT-STATUS.md v4.1→v4.2,状态全面更新 - DEPLOYMENT.md 新增小程序编译上传章节、清理检查清单
This commit is contained in:
@@ -10,17 +10,13 @@
|
||||
|
||||
<view class="plans">
|
||||
<!-- 免费版 -->
|
||||
<view class="plan-card free" :class="{ active: isLoggedIn && plan === 'free' }">
|
||||
<view class="plan-card free" :class="{ active: plan === 'free' && isLoggedIn }">
|
||||
<view class="plan-header">
|
||||
<text class="plan-name">免费版</text>
|
||||
<view class="plan-price"><text class="price-num">免费</text></view>
|
||||
</view>
|
||||
<view class="plan-features">
|
||||
<text class="feat">✓ 每日 {{ limits.interview.dailyFreeLimit || 3 }} 次 AI 模拟面试</text>
|
||||
<text class="feat">✓ 每场最多 {{ limits.interview.maxRoundsFree || 5 }} 轮 AI 对话</text>
|
||||
<text class="feat">✓ 基础面试报告</text>
|
||||
<text class="feat">✓ 简历诊断</text>
|
||||
<text class="feat">✓ 简历优化</text>
|
||||
<text class="feat" v-for="f in freeFeatures" :key="f">✓ {{ f }}</text>
|
||||
</view>
|
||||
<view class="plan-status" v-if="isLoggedIn && plan === 'free'">当前使用</view>
|
||||
<view class="plan-status hint" v-else-if="!isLoggedIn">注册即用</view>
|
||||
@@ -31,47 +27,62 @@
|
||||
<view class="plan-badge">⭐ 推荐</view>
|
||||
<view class="plan-header">
|
||||
<text class="plan-name">成长版</text>
|
||||
<text class="plan-price"><text class="price-num">{{ priceText }}</text><text class="price-unit" v-if="plan !== 'growth' || !isLoggedIn">/月</text></text>
|
||||
<text class="plan-price"><text class="price-num">{{ growthPriceText }}</text><text class="price-unit">/月</text></text>
|
||||
</view>
|
||||
<view class="plan-features">
|
||||
<text class="feat">✓ 免费版全部权益</text>
|
||||
<text class="feat">✓ 无限面试次数</text>
|
||||
<text class="feat">✓ 每场最多 {{ limits.interview.maxRoundsVip || 10 }} 轮 AI 对话</text>
|
||||
<text class="feat">✓ 详细面试报告(四维评分)</text>
|
||||
<text class="feat">✓ 进步轨迹雷达图 + 打卡</text>
|
||||
<text class="feat">✓ 参考回答思路</text>
|
||||
<text class="feat">✓ 公司真题库</text>
|
||||
<text class="feat" v-for="f in growthFeatures" :key="f">✓ {{ f }}</text>
|
||||
</view>
|
||||
<view class="plan-action" v-if="!isLoggedIn" @click="goLogin">登录后开通</view>
|
||||
<view class="plan-action owned" v-else-if="plan === 'growth'">✅ 已开通</view>
|
||||
<view class="plan-action" v-else @click="startPay">{{ priceText }} 立即开通</view>
|
||||
<view class="plan-action owned" v-else-if="plan !== 'free'">✅ 已开通</view>
|
||||
<view class="plan-action" v-else @click="startPay('growth')">{{ growthPriceText }} 立即开通</view>
|
||||
</view>
|
||||
|
||||
<!-- 冲刺版 -->
|
||||
<view class="plan-card sprint" :class="{ active: plan === 'sprint' && isLoggedIn }">
|
||||
<view class="plan-badge sprint-badge">🚀 冲刺</view>
|
||||
<view class="plan-header">
|
||||
<text class="plan-name">冲刺版</text>
|
||||
<text class="plan-price"><text class="price-num price-sprint">¥49.9</text><text class="price-unit">/月</text></text>
|
||||
</view>
|
||||
<view class="plan-features">
|
||||
<text class="feat" v-for="f in sprintFeatures" :key="f">✓ {{ f }}</text>
|
||||
</view>
|
||||
<view class="plan-action" v-if="!isLoggedIn" @click="goLogin">登录后开通</view>
|
||||
<view class="plan-action owned" v-else-if="plan === 'sprint'">✅ 已开通</view>
|
||||
<view class="plan-action" v-else-if="plan === 'growth'" @click="startPay('sprint')">升级至冲刺版</view>
|
||||
<view class="plan-action" v-else @click="startPay('sprint')">¥49.9/月 立即开通</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 支付弹窗 -->
|
||||
<view class="modal-overlay" v-if="showPayModal" @click="showPayModal = false">
|
||||
<view class="modal-overlay" v-if="showPayModal" @click="cancelPay">
|
||||
<view class="modal-content" @click.stop>
|
||||
<!-- 二维码支付(H5) -->
|
||||
<template v-if="!isMp && payCodeUrl">
|
||||
<template v-if="payLoading">
|
||||
<text class="modal-title">正在创建支付...</text>
|
||||
</template>
|
||||
<template v-else-if="!isMp && payCodeUrl">
|
||||
<text class="modal-title">微信扫码支付</text>
|
||||
<canvas canvas-id="payQrcode" class="qr-canvas"></canvas>
|
||||
<text class="modal-hint">请用微信扫码完成支付</text>
|
||||
<text class="modal-close" @click="showPayModal = false">取消支付</text>
|
||||
<text class="modal-hint">支付成功后将自动跳转</text>
|
||||
<text class="modal-close" @click="cancelPay">取消支付</text>
|
||||
</template>
|
||||
<!-- JSAPI 支付(小程序) -->
|
||||
<template v-if="isMp">
|
||||
<template v-else-if="isMp && !payLoading">
|
||||
<text class="modal-title">微信支付</text>
|
||||
<text class="modal-hint">即将调起微信支付...</text>
|
||||
</template>
|
||||
<!-- 加载中 -->
|
||||
<text class="modal-title" v-if="!payCodeUrl && !isMp">正在创建支付...</text>
|
||||
<template v-if="payError">
|
||||
<text class="modal-title pay-error">支付异常</text>
|
||||
<text class="modal-hint">{{ payError }}</text>
|
||||
<text class="modal-close" @click="cancelPay">关闭</text>
|
||||
</template>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 成功提示 -->
|
||||
<!-- 支付中提示 -->
|
||||
<view class="pay-success" v-if="paySuccess">
|
||||
<text class="success-icon">🎉</text>
|
||||
<text class="success-text">开通成功!成长版已生效</text>
|
||||
<text class="success-text">开通成功!{{ payingPlanName }}已生效</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -88,13 +99,21 @@ const currentPlanName = ref('免费版')
|
||||
const paySuccess = ref(false)
|
||||
const showPayModal = ref(false)
|
||||
const payCodeUrl = ref('')
|
||||
const priceText = ref('¥19.9')
|
||||
const limits = ref({
|
||||
interview: { dailyFreeLimit: 3, maxRoundsFree: 5, maxRoundsVip: 10 },
|
||||
diagnosis: { dailyFreeLimit: 2 },
|
||||
optimize: { dailyFreeLimit: 2 },
|
||||
price: { monthly: 1990 },
|
||||
})
|
||||
const payLoading = ref(false)
|
||||
const payError = ref('')
|
||||
const payingPlanName = ref('')
|
||||
const payingPlan = ref('')
|
||||
const growthPriceText = ref('¥19.9')
|
||||
const currentOutTradeNo = ref('')
|
||||
const freeFeatures = ['每日 2 次 AI 模拟面试', '基础面试报告', '通用题库随机出题', '简历诊断(限 3 次)']
|
||||
const growthFeatures = [
|
||||
'免费版全部权益', '无限面试次数', '详细面试报告(四维评分)',
|
||||
'进步轨迹雷达图 + 打卡', '每日一题推送', '参考回答思路', '公司真题库',
|
||||
]
|
||||
const sprintFeatures = [
|
||||
'成长版全部权益', 'AI 语音分析(语气词/语速检测)', '技能缺口分析报告',
|
||||
'学习路径推荐', '真人导师 1v1 点评(每月 1 次)', '简历精修(每月 1 次)', '内推优先',
|
||||
]
|
||||
|
||||
const token = () => uni.getStorageSync('token') || ''
|
||||
|
||||
@@ -117,58 +136,88 @@ onMounted(async () => {
|
||||
plan.value = d.plan || 'free'
|
||||
currentPlanName.value = d.planName || '免费版'
|
||||
}
|
||||
if (lres.statusCode === 200 && lres.data) {
|
||||
const d = lres.data
|
||||
if (d.interview) limits.value.interview = d.interview
|
||||
if (d.diagnosis) limits.value.diagnosis = d.diagnosis
|
||||
if (d.optimize) limits.value.optimize = d.optimize
|
||||
if (d.price) {
|
||||
limits.value.price = d.price
|
||||
priceText.value = `¥${(d.price.monthly / 100).toFixed(1)}`
|
||||
}
|
||||
if (lres.statusCode === 200 && lres.data?.price) {
|
||||
const p = lres.data.price
|
||||
growthPriceText.value = `¥${(p.monthly / 100).toFixed(1)}`
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
})
|
||||
|
||||
const goLogin = () => uni.navigateTo({ url: '/pages/login/login' })
|
||||
|
||||
const cancelPay = () => {
|
||||
showPayModal.value = false
|
||||
payCodeUrl.value = ''
|
||||
payLoading.value = false
|
||||
payError.value = ''
|
||||
}
|
||||
|
||||
/** 创建支付订单 */
|
||||
const startPay = async () => {
|
||||
const startPay = async (selectedPlan) => {
|
||||
const t = token()
|
||||
if (!t) { uni.showToast({ title: '请先登录', icon: 'none' }); return }
|
||||
showPayModal.value = true
|
||||
|
||||
try {
|
||||
if (isMp.value) {
|
||||
// 小程序:JSAPI 支付
|
||||
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
|
||||
payError.value = ''
|
||||
|
||||
const planLabel = selectedPlan || 'growth'
|
||||
|
||||
if (isMp.value) {
|
||||
// 小程序:JSAPI 支付
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api('/payment/jsapi'), method: 'POST',
|
||||
data: { plan: planLabel },
|
||||
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
|
||||
})
|
||||
payLoading.value = false
|
||||
|
||||
if (res.statusCode === 200 && 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,
|
||||
signType: pp.signType || 'RSA',
|
||||
paySign: pp.paySign,
|
||||
success: () => checkPayResult(),
|
||||
fail: () => { showPayModal.value = false; uni.showToast({ title: '支付取消', icon: 'none' }) },
|
||||
success: () => pollPayResult(res.data.prepayId, planLabel),
|
||||
fail: (err) => { payError.value = '支付取消或失败'; uni.showToast({ title: '支付取消', icon: 'none' }) },
|
||||
})
|
||||
} else {
|
||||
showPayModal.value = false
|
||||
payLoading.value = false
|
||||
payError.value = res.data?.message || '创建订单失败'
|
||||
uni.showToast({ title: '创建订单失败', icon: 'none' })
|
||||
}
|
||||
} else {
|
||||
// H5:Native 二维码支付
|
||||
} catch (e) {
|
||||
payLoading.value = false
|
||||
payError.value = '网络错误,请重试'
|
||||
uni.showToast({ title: '网络错误', icon: 'none' })
|
||||
}
|
||||
} else {
|
||||
// H5:二维码支付
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api('/payment/create'), method: 'POST',
|
||||
data: { plan: planLabel },
|
||||
header: { 'Authorization': `Bearer ${t}`, 'Content-Type': 'application/json' },
|
||||
})
|
||||
payLoading.value = false
|
||||
|
||||
if (res.statusCode === 200 && res.data?.codeUrl) {
|
||||
payCodeUrl.value = res.data.codeUrl
|
||||
currentOutTradeNo.value = res.data.outTradeNo
|
||||
nextTick(() => {
|
||||
try {
|
||||
const ctx = uni.createCanvasContext('payQrcode')
|
||||
@@ -182,35 +231,71 @@ const startPay = async () => {
|
||||
uqrcode.drawCanvas(ctx)
|
||||
} catch(e) { console.error('二维码生成失败', e) }
|
||||
})
|
||||
// 轮询支付结果
|
||||
pollPayResult(res.data.outTradeNo, planLabel)
|
||||
} else {
|
||||
showPayModal.value = false
|
||||
payError.value = res.data?.message || '支付服务暂不可用'
|
||||
uni.showToast({ title: '支付服务暂不可用', icon: 'none' })
|
||||
}
|
||||
} catch (e) {
|
||||
payLoading.value = false
|
||||
payError.value = '网络错误,请重试'
|
||||
uni.showToast({ title: '网络错误', icon: 'none' })
|
||||
}
|
||||
} catch (e) {
|
||||
showPayModal.value = false
|
||||
uni.showToast({ title: '支付服务暂不可用', icon: 'none' })
|
||||
}
|
||||
}
|
||||
|
||||
/** 支付成功后查询并更新状态 */
|
||||
const checkPayResult = async () => {
|
||||
uni.showLoading({ title: '查询支付结果...' })
|
||||
/** 轮询订单状态 */
|
||||
const pollPayResult = async (outTradeNo, selectedPlan) => {
|
||||
if (!outTradeNo) return
|
||||
const maxAttempts = 30
|
||||
let attempts = 0
|
||||
|
||||
const poll = async () => {
|
||||
attempts++
|
||||
try {
|
||||
const res = await uni.request({
|
||||
url: api(`/payment/check/${outTradeNo}`), method: 'GET',
|
||||
header: { 'Authorization': `Bearer ${token()}` },
|
||||
})
|
||||
if (res.statusCode === 200 && res.data?.status === 'success') {
|
||||
// 支付成功,激活套餐
|
||||
await activatePlan(outTradeNo, selectedPlan)
|
||||
return
|
||||
}
|
||||
} catch (e) { /* ignore */ }
|
||||
|
||||
if (attempts < maxAttempts) {
|
||||
setTimeout(poll, 2000)
|
||||
} else {
|
||||
payError.value = '支付结果查询超时,请联系客服'
|
||||
uni.showToast({ title: '支付查询超时', icon: 'none' })
|
||||
}
|
||||
}
|
||||
setTimeout(poll, 2000)
|
||||
}
|
||||
|
||||
/** 激活套餐 */
|
||||
const activatePlan = async (outTradeNo, selectedPlan) => {
|
||||
try {
|
||||
await new Promise(r => setTimeout(r, 2000))
|
||||
const res = await uni.request({ url: api('/member/pay'), method: 'POST', header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' } })
|
||||
const res = await uni.request({
|
||||
url: api('/payment/activate'), method: 'POST',
|
||||
data: { outTradeNo },
|
||||
header: { 'Authorization': `Bearer ${token()}`, 'Content-Type': 'application/json' },
|
||||
})
|
||||
if (res.statusCode === 200 && res.data?.success) {
|
||||
paySuccess.value = true
|
||||
showPayModal.value = false
|
||||
plan.value = 'growth'
|
||||
currentPlanName.value = '成长版'
|
||||
uni.hideLoading()
|
||||
plan.value = selectedPlan === 'sprint' ? 'sprint' : 'growth'
|
||||
currentPlanName.value = selectedPlan === 'sprint' ? '冲刺版' : '成长版'
|
||||
uni.showToast({ title: '🎉 开通成功!', icon: 'success' })
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '支付未完成,请稍后重试', icon: 'none' })
|
||||
uni.showToast({ title: res.data?.message || '激活失败', icon: 'none' })
|
||||
}
|
||||
} catch { uni.hideLoading(); uni.showToast({ title: '查询失败', icon: 'none' }) }
|
||||
} catch (e) {
|
||||
payError.value = '激活失败,请联系客服'
|
||||
uni.showToast({ title: '激活失败', icon: 'none' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -222,12 +307,15 @@ const checkPayResult = async () => {
|
||||
.plans { padding: 0 32rpx; margin-top: -40rpx; display: flex; flex-direction: column; gap: 24rpx; }
|
||||
.plan-card { background: #FFFFFF; border-radius: var(--radius-xl); padding: 32rpx; box-shadow: var(--shadow-sm); position: relative; }
|
||||
.plan-card.growth { border: 2rpx solid var(--color-primary); }
|
||||
.plan-card.sprint { border: 2rpx solid #F59E0B; }
|
||||
.plan-card.active { border-color: var(--color-primary); }
|
||||
.plan-badge { position: absolute; top: -12rpx; right: 24rpx; background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-mid)); color: #FFF; font-size: 20rpx; padding: 4rpx 20rpx; border-radius: var(--radius-round); font-weight: 600; }
|
||||
.sprint-badge { background: linear-gradient(135deg, #F59E0B, #F97316); }
|
||||
.plan-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 20rpx; }
|
||||
.plan-name { font-size: 30rpx; font-weight: 700; color: var(--color-text); }
|
||||
.price-num { font-size: 44rpx; font-weight: 800; color: var(--color-primary); }
|
||||
.price-unit { font-size: 22rpx; color: var(--color-text-tertiary); }
|
||||
.price-sprint { color: #D97706; }
|
||||
.plan-features { display: flex; flex-direction: column; gap: 10rpx; margin-bottom: 24rpx; }
|
||||
.feat { font-size: 24rpx; color: var(--color-text-secondary); }
|
||||
.plan-status { text-align: center; background: #F3F4F6; padding: 14rpx; border-radius: var(--radius-sm); font-size: 24rpx; color: var(--color-text-secondary); }
|
||||
@@ -242,7 +330,8 @@ const checkPayResult = async () => {
|
||||
.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: 100; }
|
||||
.modal-content { background: #FFF; border-radius: var(--radius-xl); padding: 40rpx; width: 70%; display: flex; flex-direction: column; align-items: center; gap: 20rpx; }
|
||||
.modal-title { font-size: 28rpx; font-weight: 600; color: var(--color-text); }
|
||||
.pay-error { color: var(--color-error); }
|
||||
.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; }
|
||||
</style>
|
||||
</style>
|
||||
Reference in New Issue
Block a user