feat(discover): chip-targeted filter panel — scroll to + highlight target section

- Each filter chip (年龄/学历/婚姻) carries data-target pointing to its section
- openFilterPanel receives TouchEvent, maps target to section id, sets panelScrollTo + panelHighlight
- Panel uses scroll-view scroll-into-view with scroll-with-animation for smooth scroll
- Targeted section gets pink outline highlight via .hl class
- Non-targeted sections remain normally visible for context
This commit is contained in:
Codex
2026-09-14 11:27:52 +08:00
parent adfa4ff31e
commit 22325ec2b0
3 changed files with 54 additions and 44 deletions
+11 -5
View File
@@ -44,6 +44,9 @@ interface DiscoverData {
educations: Array<{ code: string; label: string }>;
maritalStatuses: Array<{ code: string; label: string }>;
actionLoadingUserId: string;
// 抽屉滚动/高亮定位
panelScrollTo: string;
panelHighlight: string;
}
const DEFAULT_MIN_AGE = 18;
@@ -89,6 +92,8 @@ Page({
{ code: 'divorced', label: '离异' },
],
actionLoadingUserId: '',
panelScrollTo: '',
panelHighlight: '',
} as DiscoverData,
onLoad() {
@@ -186,9 +191,10 @@ Page({
this.fetchDiscover(true);
},
/** 打开筛选面板,并同步当前 applied 状态到 temp */
openFilterPanel() {
console.log('[discover] openFilterPanel called');
/** 打开筛选面板,并同步当前 applied 状态到 temp,可选定位到 target section */
openFilterPanel(e?: WechatMiniprogram.TouchEvent) {
const target = e ? (e.currentTarget.dataset as any).target as string | undefined : undefined;
const sectionMap: Record<string, string> = { age: 'sec-age', education: 'sec-education', marital: 'sec-marital', region: 'sec-region' };
const a = this.data.applied;
this.setData({
showFilter: true,
@@ -197,8 +203,8 @@ Page({
tempMaxAge: a.maxAge,
tempEducationCode: a.educationCode,
tempMaritalStatus: a.maritalStatus,
}, () => {
console.log('[discover] showFilter set to true, current state:', JSON.stringify(this.data.applied));
panelScrollTo: target ? (sectionMap[target] || '') : '',
panelHighlight: target || '',
});
},