test: lock miniapp reference page scope

This commit is contained in:
Codex
2026-09-14 06:19:11 +08:00
parent 8b8972a77b
commit 311f251609
15 changed files with 155 additions and 34 deletions
+55 -18
View File
@@ -2,12 +2,36 @@
* 首页 - V1.1 新版(U18)
* 结构:品牌区 → 用户状态条 → Banner → 8入口 → 推荐 → 服务建议 → 活动 → 服务站 → 安全提醒
*/
const authStore = require('../../stores/authStore')
const { authStore, appStore } = require('../../stores')
const api = require('../../utils/api')
const ENTRY_VISUALS = {
find_object: { tone: 'rose', iconAsset: '/assets/tabbar/discover-active.png' },
matchmaker: { tone: 'purple', iconAsset: '/assets/brand/logo-mark.png' },
activities: { tone: 'blue', iconAsset: '/assets/tabbar/activity-active.png' },
counseling: { tone: 'pink', iconAsset: '/assets/tabbar/message-active.png' },
classroom: { tone: 'amber', iconAsset: '/assets/covers/classroom-default.jpg' },
premarital: { tone: 'indigo', iconAsset: '/assets/tabbar/home-active.png' },
anti_fraud: { tone: 'red', iconAsset: '/assets/covers/anti-fraud-default.jpg' },
service_station: { tone: 'green', iconAsset: '/assets/covers/station-default.jpg' },
}
const QUICK_ENTRIES = [
{ code: 'find_object', label: '找对象', targetPage: '/pages/discover/discover', enabled: true },
{ code: 'matchmaker', label: '公益红娘', targetPage: '/pages/matchmaker/matchmaker', enabled: true },
{ code: 'activities', label: '公益活动', targetPage: '/pages/activity/activity', enabled: true },
{ code: 'counseling', label: '婚恋咨询', targetPage: '/pages/counseling-intro/counseling-intro', enabled: true },
{ code: 'classroom', label: '婚恋课堂', targetPage: '/pages/content/content', enabled: true },
{ code: 'premarital', label: '婚前辅导', targetPage: '/pages/premarital-intro/premarital-intro', enabled: true },
{ code: 'anti_fraud', label: '婚恋反诈', targetPage: '/pages/anti-fraud/anti-fraud', enabled: true },
{ code: 'service_station', label: '善缘服务站', targetPage: '/pages/service-station/service-station', enabled: true },
].map((entry) => ({ ...entry, ...ENTRY_VISUALS[entry.code] }))
Page({
data: {
unreadCount: 0,
loading: true,
loadError: false,
userState: null,
isOnboarding: false,
isVerified: false,
@@ -18,7 +42,7 @@ Page({
statusChecks: [],
banners: [],
currentBannerIndex: 0,
quickEntries: [],
quickEntries: QUICK_ENTRIES,
recommendations: [],
recState: 'idle',
actionLoadingUserId: '',
@@ -42,7 +66,7 @@ Page({
},
onShow() {
if (authStore.state.isLoggedIn) {
if (authStore.state.isLoggedIn && !this.data.loading) {
this.loadHomeData()
}
},
@@ -56,6 +80,7 @@ Page({
async checkAuthAndLoad() {
if (!authStore.state.isLoggedIn) {
this.setData({
loading: false,
isOnboarding: true,
onboardingMessage: '登录后即可开始寻找合适的人',
onboardingActions: [{ text: '去登录', event: 'login', variant: 'primary' }],
@@ -66,12 +91,13 @@ Page({
},
async loadHomeData() {
this.setData({ loading: true, loadError: false })
try {
const res = await api.get('/home')
this.processHomeData(res)
} catch (err) {
console.error('首页数据加载失败', err)
this.setData({ recState: 'error' })
this.setData({ loading: false, loadError: true, recState: 'error' })
}
},
@@ -83,33 +109,40 @@ Page({
const profileStatus = userState?.profileStatus || ''
const eligStatus = userState?.localEligibilityStatus || 'not_declared'
const isOnboarding = !userState || profileStatus !== 'approved'
const isOnboarding = !userState || !userState.verified || (profileStatus !== 'approved' && profileStatus !== 'completed')
const isPaused = relStatus === 'paused'
const isSuccessful = relStatus === 'matched_successfully'
const isVerified = eligStatus === 'verified'
const checks = [
{ label: '已实名', done: userState?.verified || false },
{ label: '本地资格', done: eligStatus === 'verified' || eligStatus === 'pending_review' },
{ label: '本地资格', done: eligStatus === 'verified' },
{ label: '资料已审核', done: profileStatus === 'approved' || profileStatus === 'completed' },
]
this.setData({
loading: false, loadError: false,
userState,
isOnboarding, isVerified, isPaused, isSuccessful,
onboardingMessage: this.buildOnboardingMessage(userState, profileStatus, eligStatus),
onboardingActions: this.buildOnboardingActions(userState, profileStatus, eligStatus),
statusChecks: checks,
banners, quickEntries,
banners: banners || [],
quickEntries: quickEntries?.length
? quickEntries.map((entry) => ({ ...entry, ...ENTRY_VISUALS[entry.code] }))
: QUICK_ENTRIES,
recommendations: recommendations || [],
recState: (recommendations && recommendations.length > 0) ? 'loaded' : 'empty',
serviceRecommendations, activities, serviceLocation,
serviceRecommendations: serviceRecommendations || [], activities: activities || [], serviceLocation,
articles: data.articles || [],
safetyNotice: safetyNotice || this.data.safetyNotice,
})
},
buildOnboardingMessage(state, profileStatus, eligStatus) {
if (!state) return '登录后即可开始寻找合适的人'
if (!state.verified) return '完成实名认证后,即可继续完善资料并使用公益婚恋服务'
if (profileStatus === 'pending_review') return '资料正在人工审核,请耐心等待审核结果'
if (eligStatus === 'not_declared') return '完成本地资格声明后即可开始寻找合适的人'
if (eligStatus === 'needs_evidence') return '补充本地资格佐证后即可开始寻找合适的人'
if (profileStatus !== 'approved' && profileStatus !== 'completed') return '资料审核通过后即可开始寻找合适的人'
@@ -143,20 +176,21 @@ Page({
wx.navigateTo({ url: `/pages/activity-detail/activity-detail?id=${targetValue}` })
} else if (targetType === 'matchmaker') {
wx.navigateTo({ url: '/pages/matchmaker/matchmaker' })
} else if (targetType === 'service_location' && targetValue) {
wx.navigateTo({ url: `/pages/local-eligibility/local-eligibility?from=service_station&id=${targetValue}` })
} else {
const routes = { matchmaker: '/pages/matchmaker/matchmaker', counseling: '/pages/counseling-intro/counseling-intro', premarital: '/pages/premarital-intro/premarital-intro', service_location: '/pages/service-station/service-station', article: '/pages/content-detail/content-detail', internal_page: targetValue }
const url = routes[targetType]
if (url && /^\/pages\//.test(url)) wx.navigateTo({ url })
}
},
onEntryTap(e) {
const { code, enabled, targetPage } = e.currentTarget.dataset.entry
if (!enabled) {
wx.showToast({ title: '完成资料后可使用此功能', icon: 'none' })
wx.showToast({ title: e.currentTarget.dataset.entry.disabledReason || '暂不可使用此功能', icon: 'none' })
return
}
if (targetPage.startsWith('pages/')) {
wx.navigateTo({ url: targetPage })
}
if (targetPage === '/pages/discover/discover' || targetPage === '/pages/activity/activity') wx.switchTab({ url: targetPage })
else if (targetPage?.startsWith('/pages/')) wx.navigateTo({ url: targetPage })
},
onViewDetail(e) {
@@ -203,7 +237,7 @@ Page({
},
onResume() {
wx.showToast({ title: '功能开发中', icon: 'none' })
wx.navigateTo({ url: '/pages/relationship-status/relationship-status' })
},
onSeeMore() { wx.switchTab({ url: '/pages/discover/discover' }) },
@@ -213,7 +247,7 @@ Page({
if (id) wx.navigateTo({ url: `/pages/activity-detail/activity-detail?id=${id}` })
},
onStationTap() {
wx.navigateTo({ url: '/pages/local-eligibility/local-eligibility?from=service_station' })
wx.navigateTo({ url: '/pages/service-station/service-station' })
},
onServiceTap(e) {
const type = e.currentTarget.dataset.type
@@ -221,14 +255,17 @@ Page({
case 'matchmaker': wx.navigateTo({ url: '/pages/matchmaker/matchmaker' })
break
case 'counseling':
wx.navigateTo({ url: '/pages/counseling-intro/counseling-intro' })
break
case 'premarital':
wx.navigateTo({ url: `/pages/local-eligibility/local-eligibility?from=${type}` })
wx.navigateTo({ url: '/pages/premarital-intro/premarital-intro' })
break
}
},
onSafetyTap() {
wx.navigateTo({ url: '/pages/local-eligibility/local-eligibility?from=anti_fraud' })
wx.navigateTo({ url: '/pages/anti-fraud/anti-fraud' })
},
onArticleTap(e) { wx.navigateTo({ url: `/pages/content-detail/content-detail?id=${e.currentTarget.dataset.id}` }) },
onMessages() { wx.switchTab({ url: '/pages/messages/messages' }) },
formatDate(timestamp) {
+1 -1
View File
@@ -1,4 +1,4 @@
<view class="page">
<view class="page app-page reference-page">
<!-- 品牌区 -->
<view class="brand-bar">
<view><text class="brand-name">善缘丹阳</text><text class="brand-slogan">真实相识 · 公益牵线</text></view>