chore: establish V1.1 recovery baseline

This commit is contained in:
2026-09-09 22:05:00 +08:00
commit b46b48eb33
947 changed files with 155471 additions and 0 deletions
@@ -0,0 +1,187 @@
/**
* 婚恋态度页 U10(Phase 04 P04-T25)
*
* 重构要点(遵循 AGENTS.md 不变量):
* - 数据:profileService.getProfile + userStore.updateProfile(第 9 条)
* - V1 不做泛交友选项(功能清单 §4.5:默认"寻找以婚姻为目标的稳定关系")
* - 草稿恢复:onLoad 读 ONBOARDING_DRAFT.intent,保存前写回
* - 下一步:跳 profile-intro
*/
const { userStore, appStore } = require('../../stores');
const { profileService } = require('../../services');
const { ROUTE, STORAGE_KEYS } = require('../../constants');
const MARRIAGE_PLAN_OPTIONS = [
{ value: 'half_year', label: '半年内' },
{ value: 'one_year', label: '1年内' },
{ value: 'one_to_two_years', label: '1~2年' },
{ value: 'two_years_plus', label: '2年以上' },
{ value: 'let_it_be', label: '顺其自然' },
];
const ACTIVITY_WILLINGNESS_OPTIONS = [
{ value: 'willing', label: '愿意' },
{ value: 'not_now', label: '暂不考虑' },
];
const MATCHMAKER_WILLINGNESS_OPTIONS = [
{ value: 'accept', label: '接受' },
{ value: 'not_now', label: '暂不接受' },
];
const DEFAULT_GOAL = '寻找以婚姻为目标的稳定关系';
Page({
data: {
statusBarHeight: 20,
navBarHeight: 44,
loading: false,
saving: false,
relationshipGoal: DEFAULT_GOAL,
marriagePlan: '',
activityWillingness: '',
matchmakerWillingness: '',
// 选项
marriagePlanOptions: MARRIAGE_PLAN_OPTIONS,
activityWillingnessOptions: ACTIVITY_WILLINGNESS_OPTIONS,
matchmakerWillingnessOptions: MATCHMAKER_WILLINGNESS_OPTIONS,
marriagePlanIndex: -1,
activityWillingnessIndex: -1,
matchmakerWillingnessIndex: -1,
},
onLoad() {
this._initSystemInfo();
this._applyDraft();
this.loadProfile();
},
_initSystemInfo() {
try {
const sysInfo = wx.getSystemInfoSync();
this.setData({
statusBarHeight: sysInfo.statusBarHeight || 20,
navBarHeight: 44,
});
} catch (e) { /* 使用默认值 */ }
},
async loadProfile() {
this.setData({ loading: true });
try {
const profile = await profileService.getProfile();
this._mergeProfile(profile);
} catch (err) { /* 首次填写 */ } finally {
this.setData({ loading: false });
}
},
_mergeProfile(profile) {
if (!profile) return;
const d = this._readDraft();
const relationshipGoal = d.relationshipGoal || profile.relationshipGoal || DEFAULT_GOAL;
const marriagePlan = d.marriagePlan || profile.marriagePlan || '';
const activityWillingness = d.activityWillingness || profile.activityWillingness || '';
const matchmakerWillingness = d.matchmakerWillingness || profile.matchmakerWillingness || '';
this.setData({
relationshipGoal,
marriagePlan,
activityWillingness,
matchmakerWillingness,
marriagePlanIndex: MARRIAGE_PLAN_OPTIONS.findIndex((o) => o.value === marriagePlan),
activityWillingnessIndex: ACTIVITY_WILLINGNESS_OPTIONS.findIndex((o) => o.value === activityWillingness),
matchmakerWillingnessIndex: MATCHMAKER_WILLINGNESS_OPTIONS.findIndex((o) => o.value === matchmakerWillingness),
});
},
// ============ 草稿 ============
_readDraft() {
try {
const draft = wx.getStorageSync(STORAGE_KEYS.ONBOARDING_DRAFT) || {};
return draft.intent || {};
} catch (e) {
return {};
}
},
_applyDraft() {
const d = this._readDraft();
if (!d || Object.keys(d).length === 0) return;
const marriagePlan = d.marriagePlan || '';
const activityWillingness = d.activityWillingness || '';
const matchmakerWillingness = d.matchmakerWillingness || '';
this.setData({
relationshipGoal: d.relationshipGoal || DEFAULT_GOAL,
marriagePlan,
activityWillingness,
matchmakerWillingness,
marriagePlanIndex: MARRIAGE_PLAN_OPTIONS.findIndex((o) => o.value === marriagePlan),
activityWillingnessIndex: ACTIVITY_WILLINGNESS_OPTIONS.findIndex((o) => o.value === activityWillingness),
matchmakerWillingnessIndex: MATCHMAKER_WILLINGNESS_OPTIONS.findIndex((o) => o.value === matchmakerWillingness),
});
},
_writeDraft() {
try {
const draft = wx.getStorageSync(STORAGE_KEYS.ONBOARDING_DRAFT) || {};
draft.intent = {
relationshipGoal: this.data.relationshipGoal,
marriagePlan: this.data.marriagePlan,
activityWillingness: this.data.activityWillingness,
matchmakerWillingness: this.data.matchmakerWillingness,
};
draft.currentStep = 'intent';
wx.setStorageSync(STORAGE_KEYS.ONBOARDING_DRAFT, draft);
} catch (e) { /* ignore */ }
},
// ============ 表单交互 ============
onGoalInput(e) {
this.setData({ relationshipGoal: e.detail.value });
},
onMarriagePlanChange(e) {
const idx = Number(e.detail.value);
this.setData({ marriagePlanIndex: idx, marriagePlan: MARRIAGE_PLAN_OPTIONS[idx].value });
},
onActivityWillingnessChange(e) {
const idx = Number(e.detail.value);
this.setData({ activityWillingnessIndex: idx, activityWillingness: ACTIVITY_WILLINGNESS_OPTIONS[idx].value });
},
onMatchmakerWillingnessChange(e) {
const idx = Number(e.detail.value);
this.setData({ matchmakerWillingnessIndex: idx, matchmakerWillingness: MATCHMAKER_WILLINGNESS_OPTIONS[idx].value });
},
// ============ 导航 ============
onBack() {
this._writeDraft();
wx.navigateBack();
},
async onNext() {
if (this.data.saving) return;
const { relationshipGoal, marriagePlan, activityWillingness, matchmakerWillingness } = this.data;
if (!marriagePlan) return appStore.toast('请选择希望多久进入婚姻');
if (!activityWillingness) return appStore.toast('请选择是否参加公益活动');
if (!matchmakerWillingness) return appStore.toast('请选择是否接受红娘推荐');
this.setData({ saving: true });
this._writeDraft();
try {
await userStore.updateProfile({
relationshipGoal,
marriagePlan,
activityWillingness,
matchmakerWillingness,
});
this.setData({ saving: false });
wx.navigateTo({ url: ROUTE.ONBOARDING.PROFILE_INTRO });
} catch (err) {
this.setData({ saving: false });
appStore.toastError(err, '保存失败');
}
},
});
@@ -0,0 +1,9 @@
{
"navigationBarTitleText": "婚恋态度",
"navigationStyle": "custom",
"usingComponents": {
"ui-nav-bar": "/components/nav-bar/index",
"ui-section-header": "/components/section-header/index",
"ui-button": "/components/button/index"
}
}
@@ -0,0 +1,59 @@
<!-- 婚恋态度页 U10 -->
<view class="pt-page">
<ui-nav-bar
title="婚恋态度"
status-bar-height="{{statusBarHeight}}"
nav-bar-height="{{navBarHeight}}"
bind:back="onBack"
/>
<view class="pt-body">
<view class="pt-section card-base">
<ui-section-header title="婚恋态度" subtitle="让我们更了解你的期待" />
<view class="pt-form">
<!-- 婚恋目标 -->
<view class="pt-field pt-field--column">
<text class="pt-field__label">当前婚恋目标</text>
<textarea
class="pt-field__textarea"
value="{{relationshipGoal}}"
placeholder="寻找以婚姻为目标的稳定关系"
maxlength="100"
bindinput="onGoalInput"
/>
</view>
<picker mode="selector" range="{{marriagePlanOptions}}" range-key="label" value="{{marriagePlanIndex < 0 ? 0 : marriagePlanIndex}}" bindchange="onMarriagePlanChange">
<view class="pt-field">
<text class="pt-field__label">希望多久进入婚姻</text>
<view class="pt-field__value {{marriagePlanIndex >= 0 ? '' : 'pt-field__value--placeholder'}}">
{{marriagePlanIndex >= 0 ? marriagePlanOptions[marriagePlanIndex].label : '请选择'}}
</view>
</view>
</picker>
<picker mode="selector" range="{{activityWillingnessOptions}}" range-key="label" value="{{activityWillingnessIndex < 0 ? 0 : activityWillingnessIndex}}" bindchange="onActivityWillingnessChange">
<view class="pt-field">
<text class="pt-field__label">参加公益相亲活动</text>
<view class="pt-field__value {{activityWillingnessIndex >= 0 ? '' : 'pt-field__value--placeholder'}}">
{{activityWillingnessIndex >= 0 ? activityWillingnessOptions[activityWillingnessIndex].label : '请选择'}}
</view>
</view>
</picker>
<picker mode="selector" range="{{matchmakerWillingnessOptions}}" range-key="label" value="{{matchmakerWillingnessIndex < 0 ? 0 : matchmakerWillingnessIndex}}" bindchange="onMatchmakerWillingnessChange">
<view class="pt-field">
<text class="pt-field__label">接受公益红娘推荐</text>
<view class="pt-field__value {{matchmakerWillingnessIndex >= 0 ? '' : 'pt-field__value--placeholder'}}">
{{matchmakerWillingnessIndex >= 0 ? matchmakerWillingnessOptions[matchmakerWillingnessIndex].label : '请选择'}}
</view>
</view>
</picker>
</view>
</view>
</view>
<view class="pt-actions">
<ui-button variant="primary" size="lg" block loading="{{saving}}" bind:tap="onNext">下一步</ui-button>
</view>
</view>
@@ -0,0 +1,82 @@
/**
* 婚恋态度页 U10
*/
.pt-page {
min-height: 100vh;
background: var(--color-bg-page);
padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
}
.pt-body {
padding: var(--spacing-2) var(--spacing-page-x);
}
.pt-section {
margin-bottom: var(--spacing-3);
}
.pt-form {
margin-top: var(--spacing-2);
}
.pt-field {
display: flex;
align-items: center;
justify-content: space-between;
padding: var(--spacing-3) 0;
border-bottom: var(--border-width) solid var(--color-divider);
min-height: 88rpx;
}
.pt-field:last-child {
border-bottom: none;
}
.pt-field--column {
flex-direction: column;
align-items: flex-start;
}
.pt-field__label {
font-size: var(--font-size-md);
color: var(--color-text-primary);
flex-shrink: 0;
width: 280rpx;
}
.pt-field--column .pt-field__label {
width: auto;
margin-bottom: var(--spacing-2);
}
.pt-field__value {
flex: 1;
text-align: right;
font-size: var(--font-size-md);
color: var(--color-text-primary);
}
.pt-field__value--placeholder {
color: var(--color-text-placeholder);
}
.pt-field__textarea {
width: 100%;
min-height: 120rpx;
font-size: var(--font-size-md);
color: var(--color-text-secondary);
line-height: var(--line-height-relaxed);
}
.pt-actions {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: var(--spacing-2) var(--spacing-page-x);
padding-bottom: calc(var(--spacing-2) + env(safe-area-inset-bottom));
background: var(--color-bg-card);
border-top: var(--border-width) solid var(--color-divider);
z-index: var(--z-sticky);
}