项目提交

This commit is contained in:
Ghost
2026-03-20 18:20:47 +08:00
parent 2f82ee3b23
commit 79512b2fc6
26 changed files with 268 additions and 175 deletions

View File

@@ -1,6 +1,7 @@
// pages/result/disc.js - DISC结果页支持付费墙 + 历史详情拉取)
const app = getApp()
const payment = require('../../utils/payment')
const { isProfileComplete } = require('../../utils/phoneAuth.js')
function toIntPercent(v) {
if (v == null) return 0
@@ -32,7 +33,14 @@ Page({
],
payInfo: { requiresPayment: false, isPaid: false, amountYuan: 0 },
testResultId: null,
hasReloadedAfterPay: false
hasReloadedAfterPay: false,
isProfileComplete: false,
maintenanceMode: false
},
onShow() {
const maintenanceMode = !!(getApp().globalData && getApp().globalData.maintenanceMode)
this.setData({ isProfileComplete: isProfileComplete(), maintenanceMode })
},
onLoad(options) {
@@ -77,7 +85,8 @@ Page({
isPaid,
amountYuan: needPaymentToUnlock ? amountYuan : 0
}
this.setData({ payInfo })
const maintenanceMode = !!(getApp().globalData && getApp().globalData.maintenanceMode)
this.setData({ payInfo, isProfileComplete: isProfileComplete(), maintenanceMode })
} else {
wx.showToast({ title: res.data?.message || '加载失败', icon: 'none' })
}
@@ -101,8 +110,13 @@ Page({
.catch(() => this.setData({ payInfo: { requiresPayment: false, isPaid: false, amountYuan: 0 } }))
},
goToCompleteProfile() {
wx.navigateTo({ url: '/pages/user-profile/index' })
},
unlockFullReport() {
const { payInfo, testResultId, hasReloadedAfterPay } = this.data
const { payInfo, testResultId, hasReloadedAfterPay, isProfileComplete } = this.data
if (!isProfileComplete) return
if (!payInfo.requiresPayment || payInfo.isPaid) return
app.ensureLogin && app.ensureLogin().then((logged) => {
if (!logged) { wx.showToast({ title: '请先登录', icon: 'none' }); return }

View File

@@ -9,7 +9,7 @@
<text class="type-description" wx:if="{{result.description && result.description.description}}">{{result.description.description}}</text>
</view>
<view class="paywall-card" wx:if="{{payInfo.requiresPayment && !payInfo.isPaid}}">
<view class="paywall-card" wx:if="{{(!maintenanceMode && !isProfileComplete) || ((maintenanceMode || isProfileComplete) && payInfo.requiresPayment && !payInfo.isPaid)}}">
<view class="paywall-content">
<view class="paywall-blur">
<text class="paywall-fake-title">完整DISC报告</text>
@@ -18,14 +18,25 @@
<text class="paywall-fake-line">• 职业匹配建议</text>
</view>
<view class="paywall-mask"></view>
<view class="paywall-btn" bindtap="unlockFullReport">
<view
class="paywall-btn"
wx:if="{{!maintenanceMode && !isProfileComplete}}"
bindtap="goToCompleteProfile"
>
<text class="paywall-btn-main">完善资料</text>
</view>
<view
wx:elif="{{payInfo.requiresPayment && !payInfo.isPaid}}"
class="paywall-btn"
bindtap="unlockFullReport"
>
<text class="paywall-btn-main">解锁完整报告</text>
<text class="paywall-btn-price">¥{{payInfo.amountYuan}} / 次</text>
</view>
</view>
</view>
<view class="scores-section" wx:if="{{!payInfo.requiresPayment || payInfo.isPaid}}">
<view class="scores-section" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid)}}">
<text class="section-title">DISC得分详情</text>
<view class="score-item" wx:for="{{typeList}}" wx:key="type">
<view class="score-header">
@@ -39,7 +50,7 @@
</view>
</view>
<view class="analysis-card" wx:if="{{!payInfo.requiresPayment || payInfo.isPaid}}">
<view class="analysis-card" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid)}}">
<text class="card-title">主要性格特征分析</text>
<view class="trait-section">
<text class="trait-title">优势</text>
@@ -57,7 +68,7 @@
</view>
</view>
<view class="analysis-card" wx:if="{{!payInfo.requiresPayment || payInfo.isPaid}}">
<view class="analysis-card" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid)}}">
<text class="card-title">职业匹配度分析</text>
<view class="career-item" wx:for="{{result.description.careers}}" wx:key="*this">
<view class="career-dot"></view>

View File

@@ -1,7 +1,7 @@
// pages/result/mbti.js - MBTI结果页支持付费墙 + 历史详情拉取)
const app = getApp()
const payment = require('../../utils/payment')
const { hasPhone, bindPhoneByCode, ensureProfileCompleteAndRedirect } = require('../../utils/phoneAuth.js')
const { hasPhone, bindPhoneByCode, isProfileComplete } = require('../../utils/phoneAuth.js')
Page({
data: {
@@ -22,7 +22,9 @@ Page({
},
testResultId: null,
hasReloadedAfterPay: false,
hasPhone: false
hasPhone: false,
isProfileComplete: false,
maintenanceMode: false
},
onLoad(options) {
@@ -46,8 +48,8 @@ Page({
},
onShow() {
if (!ensureProfileCompleteAndRedirect()) return
this.setData({ hasPhone: hasPhone() })
const maintenanceMode = !!(getApp().globalData && getApp().globalData.maintenanceMode)
this.setData({ hasPhone: hasPhone(), isProfileComplete: isProfileComplete(), maintenanceMode })
},
loadDetail(id) {
@@ -77,7 +79,8 @@ Page({
isPaid,
amountYuan: needPaymentToUnlock ? amountYuan : 0
}
this.setData({ payInfo })
const maintenanceMode = !!(getApp().globalData && getApp().globalData.maintenanceMode)
this.setData({ payInfo, isProfileComplete: isProfileComplete(), maintenanceMode })
} else {
wx.showToast({ title: res.data?.message || '加载失败', icon: 'none' })
}
@@ -157,16 +160,20 @@ Page({
})
},
// 完善资料:用户点击后手动跳转,不强制
goToCompleteProfile() {
wx.navigateTo({ url: '/pages/user-profile/index' })
},
// 付费解锁按钮:就地触发微信手机号授权,然后调用 unlockFullReport
onGetPhoneNumberForMbtiPay(e) {
if (!ensureProfileCompleteAndRedirect()) return
const { code, errMsg } = e.detail || {}
if (errMsg && errMsg.indexOf('getPhoneNumber:fail') === 0) {
if (!hasPhone()) {
if (hasPhone()) {
this.unlockFullReport()
} else {
wx.showToast({ title: '需要授权手机号才能继续', icon: 'none' })
return
}
this.unlockFullReport()
return
}
if (!code) {

View File

@@ -10,8 +10,8 @@
<text class="type-description">{{mbtiDesc.description}}</text>
</view>
<!-- 付费墙:未解锁时显示 -->
<view class="paywall-card" wx:if="{{payInfo.requiresPayment && !payInfo.isPaid}}">
<!-- 付费墙:审核模式下跳过资料检查;非审核模式下未完善资料显示「完善资料」 -->
<view class="paywall-card" wx:if="{{(!maintenanceMode && !isProfileComplete) || ((maintenanceMode || isProfileComplete) && payInfo.requiresPayment && !payInfo.isPaid)}}">
<view class="paywall-content">
<view class="paywall-blur">
<text class="paywall-fake-title">完整性格分析</text>
@@ -20,29 +20,38 @@
<text class="paywall-fake-line">• 职业匹配与人际关系建议</text>
</view>
<view class="paywall-mask"></view>
<!-- 未有手机号:使用微信系统手机号授权 -->
<button
<!-- 未完善资料(非审核模式):显示完善资料按钮,用户点击后手动跳转 -->
<view
class="paywall-btn"
wx:if="{{!hasPhone}}"
open-type="getPhoneNumber"
bindgetphonenumber="onGetPhoneNumberForMbtiPay"
wx:if="{{!maintenanceMode && !isProfileComplete}}"
bindtap="goToCompleteProfile"
>
<text class="paywall-btn-main">解锁完整报告</text>
<text class="paywall-btn-price">¥{{payInfo.amountYuan}} / 次</text>
</button>
<!-- 已有手机号:普通按钮,直接解锁 -->
<button
class="paywall-btn"
wx:elif="{{hasPhone}}"
bindtap="unlockFullReport"
>
<text class="paywall-btn-main">解锁完整报告</text>
<text class="paywall-btn-price">¥{{payInfo.amountYuan}} / 次</text>
</button>
<text class="paywall-btn-main">完善资料</text>
</view>
<!-- 有价格:解锁按钮 -->
<block wx:elif="{{payInfo.requiresPayment && !payInfo.isPaid}}">
<button
class="paywall-btn"
wx:if="{{!hasPhone}}"
open-type="getPhoneNumber"
bindgetphonenumber="onGetPhoneNumberForMbtiPay"
>
<text class="paywall-btn-main">解锁完整报告</text>
<text class="paywall-btn-price">¥{{payInfo.amountYuan}} / 次</text>
</button>
<view
class="paywall-btn"
wx:elif="{{hasPhone}}"
bindtap="unlockFullReport"
>
<text class="paywall-btn-main">解锁完整报告</text>
<text class="paywall-btn-price">¥{{payInfo.amountYuan}} / 次</text>
</view>
</block>
</view>
</view>
<view class="dimensions-section" wx:if="{{!payInfo.requiresPayment || payInfo.isPaid}}">
<view class="dimensions-section" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid)}}">
<view class="dimension-item" wx:for="{{dimensions}}" wx:key="key">
<view class="dimension-labels">
<text class="label-left">{{item.left}}</text>
@@ -59,7 +68,7 @@
</view>
</view>
<view class="analysis-card" wx:if="{{!payInfo.requiresPayment || payInfo.isPaid}}">
<view class="analysis-card" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid)}}">
<text class="card-title">性格特征分析</text>
<view class="trait-section">
<text class="trait-title">优势</text>
@@ -78,7 +87,7 @@
</view>
</view>
<view class="analysis-card" wx:if="{{!payInfo.requiresPayment || payInfo.isPaid}}">
<view class="analysis-card" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid)}}">
<text class="card-title">职业匹配度分析</text>
<view class="career-item" wx:for="{{mbtiDesc.careers}}" wx:key="*this">
<view class="career-dot"></view>
@@ -86,7 +95,7 @@
</view>
</view>
<view class="analysis-card" wx:if="{{(!payInfo.requiresPayment || payInfo.isPaid) && mbtiDesc.relationships}}">
<view class="analysis-card" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid) && mbtiDesc.relationships}}">
<text class="card-title">人际关系分析</text>
<text class="relationship-text">{{mbtiDesc.relationships}}</text>
</view>

View File

@@ -1,6 +1,7 @@
// pages/result/pdp.js - PDP结果页支持付费墙 + 历史详情拉取)
const app = getApp()
const payment = require('../../utils/payment')
const { isProfileComplete } = require('../../utils/phoneAuth.js')
const PDP_KEYS = ['Tiger', 'Peacock', 'Koala', 'Owl', 'Chameleon']
@@ -32,7 +33,14 @@ Page({
],
payInfo: { requiresPayment: false, isPaid: false, amountYuan: 0 },
testResultId: null,
hasReloadedAfterPay: false
hasReloadedAfterPay: false,
isProfileComplete: false,
maintenanceMode: false
},
onShow() {
const maintenanceMode = !!(getApp().globalData && getApp().globalData.maintenanceMode)
this.setData({ isProfileComplete: isProfileComplete(), maintenanceMode })
},
onLoad(options) {
@@ -77,7 +85,8 @@ Page({
isPaid,
amountYuan: needPaymentToUnlock ? amountYuan : 0
}
this.setData({ payInfo })
const maintenanceMode = !!(getApp().globalData && getApp().globalData.maintenanceMode)
this.setData({ payInfo, isProfileComplete: isProfileComplete(), maintenanceMode })
} else {
wx.showToast({ title: res.data?.message || '加载失败', icon: 'none' })
}
@@ -101,8 +110,13 @@ Page({
.catch(() => this.setData({ payInfo: { requiresPayment: false, isPaid: false, amountYuan: 0 } }))
},
goToCompleteProfile() {
wx.navigateTo({ url: '/pages/user-profile/index' })
},
unlockFullReport() {
const { payInfo, testResultId, hasReloadedAfterPay } = this.data
const { payInfo, testResultId, hasReloadedAfterPay, isProfileComplete } = this.data
if (!isProfileComplete) return
if (!payInfo.requiresPayment || payInfo.isPaid) return
app.ensureLogin && app.ensureLogin().then((logged) => {
if (!logged) { wx.showToast({ title: '请先登录', icon: 'none' }); return }

View File

@@ -10,7 +10,7 @@
<text class="type-description" wx:if="{{result.description.description}}">{{result.description.description}}</text>
</view>
<view class="paywall-card" wx:if="{{payInfo.requiresPayment && !payInfo.isPaid}}">
<view class="paywall-card" wx:if="{{(!maintenanceMode && !isProfileComplete) || ((maintenanceMode || isProfileComplete) && payInfo.requiresPayment && !payInfo.isPaid)}}">
<view class="paywall-content">
<view class="paywall-blur">
<text class="paywall-fake-title">完整PDP报告</text>
@@ -19,14 +19,25 @@
<text class="paywall-fake-line">• 推荐职业</text>
</view>
<view class="paywall-mask"></view>
<view class="paywall-btn" bindtap="unlockFullReport">
<view
class="paywall-btn"
wx:if="{{!maintenanceMode && !isProfileComplete}}"
bindtap="goToCompleteProfile"
>
<text class="paywall-btn-main">完善资料</text>
</view>
<view
wx:elif="{{payInfo.requiresPayment && !payInfo.isPaid}}"
class="paywall-btn"
bindtap="unlockFullReport"
>
<text class="paywall-btn-main">解锁完整报告</text>
<text class="paywall-btn-price">¥{{payInfo.amountYuan}} / 次</text>
</view>
</view>
</view>
<view class="scores-section" wx:if="{{!payInfo.requiresPayment || payInfo.isPaid}}">
<view class="scores-section" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid)}}">
<text class="section-title">PDP得分详情</text>
<view class="score-item" wx:for="{{typeList}}" wx:key="type">
<view class="score-header">
@@ -40,7 +51,7 @@
</view>
</view>
<view class="analysis-card" wx:if="{{!payInfo.requiresPayment || payInfo.isPaid}}">
<view class="analysis-card" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid)}}">
<text class="card-title">性格特征</text>
<view class="trait-section">
<text class="trait-title">优势</text>
@@ -58,12 +69,12 @@
</view>
</view>
<view class="analysis-card" wx:if="{{!payInfo.requiresPayment || payInfo.isPaid}}">
<view class="analysis-card" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid)}}">
<text class="card-title">团队角色</text>
<text class="relationship-text">{{result.description.teamRole}}</text>
</view>
<view class="analysis-card" wx:if="{{!payInfo.requiresPayment || payInfo.isPaid}}">
<view class="analysis-card" wx:if="{{(maintenanceMode || isProfileComplete) && (!payInfo.requiresPayment || payInfo.isPaid)}}">
<text class="card-title">推荐职业</text>
<view class="career-item" wx:for="{{result.description.careers}}" wx:key="*this">
<view class="career-dot"></view>