Files
danyang-match/miniapp/components/recommend-card/index.js
T
WorkBuddy c0298c27a5 fix(miniapp): 小程序界面全量中文化,消除英文/非中文枚举码上屏
- 新增 miniapp/constants/profileLabels.js 作为「枚举码→中文简体」唯一字典
  (婚姻/子女/学历/职业/吸烟饮酒/择偶子女/红娘状态),覆盖表单值与种子
  实际值两套并集,保证详情页无论后端返回哪种码都显示中文
- 修复「择偶条件-子女」下拉英文选项(any/accept/reject→不限/可接受/不接受),
  改用 value/label 数组 + range-key="label"
- 修复 recommend-card / user-card / profile-detail / profile-confirm 直接渲染
  后端枚举码(educationCode/maritalStatus/occupationCode…)的问题,改由
  observers 派生中文 label 上屏
- 清理残留英文文案:Required 条件→必须符合的条件、喜欢TA/向Ta→喜欢对方/向对方、
  U51 服务预约→服务预约、U64 公益服务记录→公益服务记录
- 修复 7 个英文窗口标题与 3 个英文占位页正文
- matchmaker 历史服务状态消除原始码兜底,统一走字典
- 加固 scripts/audit-miniapp-language.mjs(A 整行先剥离 mustache、B 排除
  bind:action 处理器、F 窗口标题、JPG/PNG 入白名单)
- 新增 ui-tests/miniapp-language-contracts.mjs 语种守卫(复用审计脚本,断言 0 命中),
  UI 契约门禁 MIN_GUARDS 21→22;已做负向注入验证判别力
2026-09-23 11:19:17 +08:00

69 lines
2.3 KiB
JavaScript
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.
/**
* RecommendCard 推荐卡片(规范 §22-25, §107-108)
*
* 推荐首页核心卡片,包含:头像 + 基本信息 + 推荐理由 + Like/Pass 操作。
* 不变量(AGENTS.md):
* - 第 2 条:Required 不可自动放宽——推荐理由仅作弱文字提示,
* 不暴露"放宽了 X 条件才得到这个推荐"的字样,前端只显示后端返回的 reasons。
* - 第 5 条:红娘不可替用户操作——本卡片仅由当前用户操作,不接受 matchmakerId 参数。
*/
const { STATUS_BADGE, profileLabelOf } = require('../../constants');
Component({
options: { addGlobalClass: true },
properties: {
recommendation: { type: Object, value: null },
// 是否显示操作按钮(详情页用,可能用底部固定按钮替代)
showActions: { type: Boolean, value: true },
// 是否禁用按钮(操作进行中)
actionLoading: { type: Boolean, value: false },
},
data: {
levelTextMap: {
high: '很合适',
medium: '比较合适',
normal: '值得了解',
},
levelKindMap: {
high: 'success',
medium: 'info',
normal: 'warning',
},
// 由后端枚举码派生的中文展示值(界面不得出现英文码)
educationLabel: '',
occupationLabel: '',
},
observers: {
recommendation(rec) {
if (!rec) {
this.setData({ educationLabel: '', occupationLabel: '' })
return
}
this.setData({
educationLabel: profileLabelOf('educationCode', rec.educationCode),
occupationLabel: profileLabelOf('occupationCode', rec.occupationCode),
})
},
},
methods: {
onViewDetail() {
if (!this.data.recommendation) return;
this.triggerEvent('view', { userId: this.data.recommendation.userId });
},
onLike() {
if (this.data.actionLoading) return;
if (!this.data.recommendation) return;
this.triggerEvent('like', { userId: this.data.recommendation.userId });
},
onPass() {
if (this.data.actionLoading) return;
if (!this.data.recommendation) return;
this.triggerEvent('pass', { userId: this.data.recommendation.userId });
},
onBlock(e) {
// 阻止冒泡避免触发 view
this.triggerEvent('block', { userId: this.data.recommendation.userId });
},
},
});