Files
danyang-match/miniapp/pages/discover/discover.wxml
T
WorkBuddy 1fc34f1bcd fix(miniapp): 修复导航页与微信胶囊重合,并把首页两个栏目卡缩到 1/3
问题 1:五个导航页顶部与右上角胶囊按钮(··· ⊙)重合
- 根因:自定义导航用 env(safe-area-inset-top) 取的是设备物理安全区,
  在 Android 上常为 0,完全不反映胶囊位置;且右对齐元素从未为胶囊让出宽度。
- 新增 miniapp/utils/nav-metrics.js 作为唯一事实源:以
  wx.getMenuButtonBoundingClientRect() 实测胶囊矩形,反推并导出四个 CSS 变量
  --nav-status / --nav-h / --nav-right / --nav-top,并提供无接口时的兜底值。
- nav-bar 组件改为自行获取导航度量(attached + observer 双触发),
  标题按胶囊垂直居中并收窄 max-width;外部传参降级为兜底。
- index / discover / messages / activity / mine 五页根结点注入同一组变量,
  WXSS 里的 env(safe-area-inset-top)、硬编码 88rpx 与右对齐 right:0 全量替换。

问题 2:首页「善缘公益服务」「善缘安全提醒」两个栏目过宽
- 根因:封面 <image> 只声明 width 未声明 height,小程序默认按 240px 计算,
  实际把卡片撑到约 480rpx 高。
- 按「整体等比缩到 1/3」重构:两栏改为 mini-card 小卡,宽度
  calc((100% - 2*gap)/3)、高度写死 168rpx,封面 height:100%;
  公益服务一行三卡横向排布,安全提醒为「标题小卡 + 右侧文案条」,
  长文案收进详情页,安全提示原文保留。

守卫与验证
- 新增 ui-tests/miniapp-capsule-safe-contracts.mjs:
  A 层多机型断言导航行与胶囊垂直居中、右对齐让位、navTop 与兜底值;
  B 层纯函数审计五个自带导航行页面(页面清单由文件系统推导,失配直接报红);
  C 层断言首页小卡宽为 1/3 且显式声明高度,并钉住旧 service-/safety- 选择器回归。
  审计前剥离注释,避免守卫被自身示例文本误伤。
- 新增 scripts/audit-image-height.mjs:按属性名精确比对,审计全仓
  「有 width 无 height」的 <image>,当前 30 个类 0 命中。
- 负向注入 N1~N7(含 nav-safe 未接入、旧选择器回归、极小屏幕、无胶囊兜底等)
  全部被守卫咬住并 exit 1,还原后复跑通过。
- 真编译(wcc/wcsc):WXSS 88 / WXML 86,失败 0;
  tsc --noEmit 通过;UI 契约门控 21/21 PASS(新增第 21 个守卫并抬高 MIN_GUARDS)。
- 渲染探针实测:单卡 213rpx x 168rpx;五页右对齐元素右缘 423~528px,
  均在胶囊右缘 365px 之外。

未纳入本次提交:miniapp/project.config.json(微信开发者工具自动改写,
仅追加若干布尔开关并删掉文件末换行)与生成的预览页 artifacts preview.html
(约 7900 行生成产物),以免淹没代码评审视线。
2026-09-23 09:55:40 +08:00

114 lines
5.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<view class="page app-page reference-page" style="{{navVars}}">
<view class="discover-hero">
<view class="discover-nav">
<text class="nav-title">找对象</text>
<view class="nav-search" bindtap="{{showFilter ? 'closeFilterPanel' : 'openFilterPanel'}}">
<image src="/assets/icons/ui/search.png" mode="aspectFit" />
</view>
</view>
<view class="search-bar">
<view class="search-input">
<text class="search-label">搜索</text>
<input class="search-field" placeholder="姓名、职业或地区" placeholder-class="search-placeholder"
value="{{keywordInput}}" bindinput="onKeywordInput" confirm-type="search" bindconfirm="onSearch" />
</view>
</view>
<!-- 顶部 chip — 每个都有真实 active 状态,对应后端 5 个筛选参数 -->
<scroll-view scroll-x class="filter-scroll discover-filter-chips">
<view class="filter-chips">
<view class="filter-chip {{!hasActiveFilter ? 'active' : ''}}" bindtap="onResetFilter">推荐</view>
<view class="filter-chip {{applied.regionCode === '321181' ? 'active' : ''}}" bindtap="onTopRegionTap">丹阳本地</view>
<view class="filter-chip {{applied.minAge !== 18 || applied.maxAge !== 60 ? 'active' : ''}}" bindtap="openFilterPanel" data-target="age">年龄</view>
<view class="filter-chip {{!!applied.educationCode ? 'active' : ''}}" bindtap="openFilterPanel" data-target="education">学历</view>
<view class="filter-chip {{!!applied.maritalStatus ? 'active' : ''}}" bindtap="openFilterPanel" data-target="marital">婚姻</view>
</view>
</scroll-view>
</view>
<!-- 遮罩 + 底部抽屉筛选面板 -->
<block wx:if="{{showFilter}}">
<view class="filter-mask" bindtap="closeFilterPanel"></view>
<view class="filter-panel-wrap">
<scroll-view scroll-y class="filter-scroll-wrap" scroll-into-view="{{panelScrollTo}}" scroll-with-animation>
<!-- 年龄范围 -->
<view id="sec-age" class="filter-section {{panelHighlight === 'age' ? 'hl' : ''}}">
<view class="filter-heading">
<text class="filter-label">年龄范围</text>
<text class="filter-value">{{tempMinAge}}–{{tempMaxAge}} 岁</text>
</view>
<slider class="range-slider" min="18" max="60" value="{{tempMinAge}}" activeColor="#FF4F91"
backgroundColor="#E9EAF2" block-size="18" bindchange="onMinAgeChange" />
<slider class="range-slider" min="18" max="60" value="{{tempMaxAge}}" activeColor="#7B63D9"
backgroundColor="#E9EAF2" block-size="18" bindchange="onMaxAgeChange" />
</view>
<!-- 地区 -->
<view id="sec-region" class="filter-section {{panelHighlight === 'region' ? 'hl' : ''}}">
<text class="filter-label">地区</text>
<view class="tag-group">
<view wx:for="{{regions}}" wx:key="code"
class="tag {{tempRegionCode === item.code ? 'selected' : ''}}"
bindtap="onPanelRegionTap" data-code="{{item.code}}">{{item.label}}</view>
</view>
</view>
<!-- 学历 -->
<view id="sec-education" class="filter-section {{panelHighlight === 'education' ? 'hl' : ''}}">
<text class="filter-label">学历</text>
<view class="tag-group">
<view wx:for="{{educations}}" wx:key="code"
class="tag {{tempEducationCode === item.code ? 'selected' : ''}}"
bindtap="onPanelEducationTap" data-code="{{item.code}}">{{item.label}}</view>
</view>
</view>
<!-- 婚姻状态 -->
<view id="sec-marital" class="filter-section {{panelHighlight === 'marital' ? 'hl' : ''}}">
<text class="filter-label">婚姻状态</text>
<view class="tag-group">
<view wx:for="{{maritalStatuses}}" wx:key="code"
class="tag {{tempMaritalStatus === item.code ? 'selected' : ''}}"
bindtap="onPanelMaritalTap" data-code="{{item.code}}">{{item.label}}</view>
</view>
</view>
</scroll-view>
<view class="filter-actions">
<ui-button variant="ghost" size="md" block bind:tap="onResetFilter">重置</ui-button>
<ui-button variant="primary" size="md" block bind:tap="onApplyFilter">应用筛选</ui-button>
</view>
</view>
</block>
<!-- 结果区 -->
<view class="result-head" wx:if="{{users.length > 0 || loading}}">
<view>
<text class="result-title">为你推荐</text>
<text class="result-subtitle">{{hasActiveFilter ? '已按当前条件筛选' : '认真认识,再做选择'}}</text>
</view>
<text class="result-count">{{users.length}} 位</text>
</view>
<ui-loading wx:if="{{loading && users.length === 0}}" mode="skeleton" rows="5" />
<view wx:elif="{{users.length > 0}}" class="user-list candidate-list">
<ui-user-card wx:for="{{users}}" wx:key="userId" user="{{item}}" bind:tap="onViewDetail">
<view slot="actions" class="card-action" catchtap="onLike" data-user-id="{{item.userId}}">
<view class="like-button {{actionLoadingUserId === item.userId ? 'loading' : ''}}">
<image src="/assets/brand/logo-mark.png" mode="aspectFit" />
</view>
</view>
</ui-user-card>
<ui-loading wx:if="{{loadingMore}}" mode="spinner" inline text="加载更多…" />
<view wx:if="{{!hasMore && users.length > 0}}" class="list-end-hint">真诚相遇,认真选择</view>
</view>
<view wx:elif="{{!loading}}" class="discover-empty">
<image src="/assets/brand/logo-mark.png" mode="aspectFit" />
<text class="empty-title">暂无符合条件的人选</text>
<text class="empty-desc">Required 条件不会自动放宽,可以调整筛选后再看看</text>
<view class="empty-action" bindtap="onResetFilter">清空筛选</view>
</view>
</view>