展示客户真实头像

This commit is contained in:
2026-07-03 00:20:31 +08:00
parent f26a7ec956
commit 073eeffbb2
2 changed files with 62 additions and 5 deletions
@@ -3,7 +3,10 @@
<LoadingState v-if="loading" text="正在加载客户" />
<template v-else-if="customer">
<section class="card customer-card">
<div class="avatar">{{ firstName }}</div>
<div class="avatar">
<img v-if="customer.avatar" :src="customer.avatar" alt="" />
<span v-else>{{ firstName }}</span>
</div>
<div class="customer-card__body">
<h2>{{ customer.nickname || customer.account || '未命名客户' }}</h2>
<p>{{ customer.contactPhone || customer.phone || '未填写手机号' }}</p>
@@ -159,11 +162,24 @@ onMounted(() => {
}
.avatar {
display: grid;
place-items: center;
width: 58px;
height: 58px;
}
.avatar img,
.avatar span {
display: grid;
place-items: center;
width: 100%;
height: 100%;
border-radius: 20px;
}
.avatar img {
object-fit: cover;
}
.avatar span {
background: var(--accent-soft);
color: var(--accent);
font-size: 24px;
+43 -2
View File
@@ -9,8 +9,12 @@
<EmptyState v-else-if="customers.length === 0" title="暂无客户" description="新增客户后会显示在这里" />
<section v-else class="list section">
<article v-for="customer in customers" :key="String(customer.id)" class="card list-card" @click="router.push(`/customers/${customer.id}`)">
<div class="row-between">
<div>
<div class="customer-list-row">
<div class="customer-avatar">
<img v-if="customer.avatar" :src="customer.avatar" alt="" />
<span v-else>{{ String(customer.nickname || customer.account || '客').slice(0, 1) }}</span>
</div>
<div class="customer-list-row__body">
<h2 class="list-card__title">{{ customer.nickname || customer.account || '未命名客户' }}</h2>
<div class="list-card__subtitle">{{ customer.contactPhone || customer.phone || '未填写手机号' }}</div>
</div>
@@ -172,4 +176,41 @@ watch(createModalVisible, syncCreateDraft)
gap: 12px;
padding: 14px;
}
.customer-list-row {
display: flex;
align-items: center;
gap: 12px;
}
.customer-list-row__body {
min-width: 0;
flex: 1;
}
.customer-avatar {
flex: 0 0 auto;
width: 46px;
height: 46px;
}
.customer-avatar img,
.customer-avatar span {
display: grid;
place-items: center;
width: 100%;
height: 100%;
border-radius: 16px;
}
.customer-avatar img {
object-fit: cover;
}
.customer-avatar span {
background: var(--accent-soft);
color: var(--accent);
font-size: 18px;
font-weight: 900;
}
</style>