Files
danyang-match/miniapp/components/user-card/index.js
T

31 lines
950 B
JavaScript

/**
* UserCard 用户卡片(列表项 / Discover / 活动互选)
*
* 不携带任何操作按钮,纯展示;操作按钮由调用方 slot 注入。
* 用法:
* <ui-user-card user="{{user}}" bind:tap="onTap">
* <view slot="actions">…自定义按钮…</view>
* </ui-user-card>
*/
Component({
options: { addGlobalClass: true, multipleSlots: true },
properties: {
user: { type: Object, value: null },
showReasons: { type: Boolean, value: false }, // 是否展示推荐理由
selectable: { type: Boolean, value: false }, // 是否显示选择框
selected: { type: Boolean, value: false },
},
methods: {
onTap() {
if (!this.data.user) return;
this.triggerEvent('tap', { userId: this.data.user.userId });
},
onToggleSelect() {
this.triggerEvent('select', {
userId: this.data.user.userId,
selected: !this.data.selected,
});
},
},
});