feat: 重构律师列表卡片展示

- 简化筛选栏与列表快捷入口

- 为律师卡片增加 featured 布局和联系方式展示
This commit is contained in:
2026-03-21 22:02:15 +08:00
parent 63685f8644
commit 96feda4364
8 changed files with 193 additions and 187 deletions

View File

@@ -1,24 +1,44 @@
Component({
data: {
specialtiesText: '',
isFeatured: false,
layoutClass: '',
visibleSpecialties: [] as string[],
moreSpecialtiesCount: 0,
contactItems: [] as string[],
},
properties: {
lawyer: {
type: Object,
value: null,
},
showOffice: {
type: Boolean,
value: true,
layout: {
type: String,
value: 'compact',
},
},
observers: {
lawyer(lawyer: { specialties?: string[] } | null) {
'lawyer, layout'(lawyer: {
specialties?: string[];
phone?: string;
email?: string;
} | null, layout: string) {
const specialties =
lawyer && Array.isArray(lawyer.specialties) ? lawyer.specialties : [];
const isFeatured = layout === 'featured';
const visibleLimit = isFeatured ? 4 : 3;
const phone = lawyer && typeof lawyer.phone === 'string' ? lawyer.phone.trim() : '';
const email = lawyer && typeof lawyer.email === 'string' ? lawyer.email.trim() : '';
const phoneText = phone ? `电话:${phone}` : '';
const emailText = email ? `邮箱:${email}` : '';
const contactItems = isFeatured
? [phoneText, emailText].filter((item) => Boolean(item)).slice(0, 2)
: [];
this.setData({
specialties, // Expose array for wx:for
specialtiesText: specialties.join(' | '),
isFeatured,
layoutClass: isFeatured ? 'lawyer-card--featured' : 'lawyer-card--compact',
visibleSpecialties: specialties.slice(0, visibleLimit),
moreSpecialtiesCount: Math.max(0, specialties.length - visibleLimit),
contactItems,
});
},
},