54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
/**
|
||||
|
|
* RecommendCard 推荐卡片(规范 §22-25, §107-108)
|
|||
|
|
*
|
|||
|
|
* 推荐首页核心卡片,包含:头像 + 基本信息 + 推荐理由 + Like/Pass 操作。
|
|||
|
|
* 不变量(AGENTS.md):
|
|||
|
|
* - 第 2 条:Required 不可自动放宽——推荐理由仅作弱文字提示,
|
|||
|
|
* 不暴露"放宽了 X 条件才得到这个推荐"的字样,前端只显示后端返回的 reasons。
|
|||
|
|
* - 第 5 条:红娘不可替用户操作——本卡片仅由当前用户操作,不接受 matchmakerId 参数。
|
|||
|
|
*/
|
|||
|
|
const { STATUS_BADGE } = 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',
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
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 });
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
});
|