/** * LikersBadge 喜欢我的人计数徽标(规范 §22 / §107) * * 不变量(AGENTS.md 第 6 条):单向意向不泄露—— * - 仅展示计数("3 人喜欢你"),不展示具体身份列表入口。 * - 详情由用户主动进入"喜欢我的人"页查看,且后端对该列表做匿名化处理 * (未 Mutual 前对方不会被告知你看过了谁)。 * * 用法: * */ Component({ options: { addGlobalClass: true }, properties: { count: { type: Number, value: 0 }, size: { type: String, value: 'md' }, // sm | md | lg }, data: { displayText: '', }, observers: { count(n) { let text; if (n <= 0) text = '还没有人喜欢你'; else if (n === 1) text = '1 人喜欢你'; else text = `${n} 人喜欢你`; this.setData({ displayText: text }); }, }, methods: { onTap() { if (this.data.count <= 0) return; this.triggerEvent('tap', { count: this.data.count }); }, }, });