feat(ui): 统一消息钱包与权益中心视觉
This commit is contained in:
@@ -9,6 +9,7 @@ import { useDistributionSiteStore } from '@/stores/distributionSite'
|
||||
|
||||
const router = useRouter()
|
||||
const distributionStore = useDistributionSiteStore()
|
||||
const currentUserId = Number(localStorage.getItem('user_id') || 0)
|
||||
const loading = ref(false)
|
||||
const refreshing = ref(false)
|
||||
const finished = ref(false)
|
||||
@@ -73,6 +74,29 @@ function roleLabel(role: string) {
|
||||
return map[role] || '成员'
|
||||
}
|
||||
|
||||
function conversationTypeLabel(item: ChatConversation) {
|
||||
if (item.type === 'listing_group') return '账号群'
|
||||
if (item.type === 'order_group' || item.order_id) return '订单'
|
||||
return '平台客服'
|
||||
}
|
||||
|
||||
function conversationAvatar(item: ChatConversation) {
|
||||
const candidates =
|
||||
item.participants?.filter(
|
||||
participant => participant.participant_type === 'user' && participant.avatar_url
|
||||
) || []
|
||||
const otherUser = candidates.find(participant => participant.participant_id !== currentUserId)
|
||||
return resolveAvatarURL((otherUser || candidates[0])?.avatar_url)
|
||||
}
|
||||
|
||||
function resolveAvatarURL(url: string | undefined | null) {
|
||||
if (!url) return ''
|
||||
if (url.includes('/api/files/object?key=avatar/')) {
|
||||
return url.replace('/api/files/object', '/api/public/files/object')
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
function previewText(item: ChatConversation) {
|
||||
return (
|
||||
item.last_message_preview ||
|
||||
@@ -94,9 +118,23 @@ const unreadTotal = computed(() =>
|
||||
<h1>
|
||||
{{ distributionStore.isDistribution ? `${distributionStore.siteName} · 消息` : '消息' }}
|
||||
</h1>
|
||||
<span class="header-count">{{ unreadTotal > 0 ? `${unreadTotal} 未读` : '' }}</span>
|
||||
<span class="header-count" :class="{ 'is-clear': unreadTotal === 0 }">
|
||||
{{ unreadTotal > 0 ? `${unreadTotal} 未读` : '全部已读' }}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<section class="inbox-summary">
|
||||
<span class="summary-icon">
|
||||
<van-icon name="chat-o" :size="19" />
|
||||
</span>
|
||||
<div class="summary-copy">
|
||||
<strong>会话消息</strong>
|
||||
<span>共 {{ total }} 个会话</span>
|
||||
</div>
|
||||
<span v-if="unreadTotal > 0" class="summary-unread">{{ unreadTotal }} 条未读</span>
|
||||
<span v-else class="summary-read">已读</span>
|
||||
</section>
|
||||
|
||||
<van-pull-refresh v-model="refreshing" class="scroll-container" @refresh="onRefresh">
|
||||
<van-list
|
||||
v-model:loading="loading"
|
||||
@@ -116,13 +154,14 @@ const unreadTotal = computed(() =>
|
||||
v-for="item in conversations"
|
||||
:key="item.id"
|
||||
class="conversation-item"
|
||||
:class="{ 'is-unread': item.unread_count > 0 }"
|
||||
type="button"
|
||||
@click="openConversation(item)"
|
||||
>
|
||||
<div class="avatar-stack">
|
||||
<span class="avatar main">{{ roleLabel(item.role).slice(0, 1) }}</span>
|
||||
<span class="avatar support">客</span>
|
||||
</div>
|
||||
<span class="conversation-avatar">
|
||||
<img v-if="conversationAvatar(item)" :src="conversationAvatar(item)" alt="" />
|
||||
<van-icon v-else name="chat-o" :size="20" />
|
||||
</span>
|
||||
<div class="conversation-main">
|
||||
<div class="conversation-title-row">
|
||||
<h2>{{ item.title }}</h2>
|
||||
@@ -132,9 +171,10 @@ const unreadTotal = computed(() =>
|
||||
</div>
|
||||
<div class="conversation-meta">
|
||||
<span class="role-chip">{{ roleLabel(item.role) }}</span>
|
||||
<span>{{ item.order_id ? `订单 #${item.order_id}` : '平台客服' }}</span>
|
||||
<span class="conversation-type">{{ conversationTypeLabel(item) }}</span>
|
||||
<span v-if="item.needs_reply" class="reply-chip">待回复</span>
|
||||
</div>
|
||||
<p>{{ previewText(item) }}</p>
|
||||
<p class="conversation-preview">{{ previewText(item) }}</p>
|
||||
</div>
|
||||
<span v-if="item.unread_count > 0" class="unread-badge">
|
||||
{{ item.unread_count > 99 ? '99+' : item.unread_count }}
|
||||
@@ -151,8 +191,9 @@ const unreadTotal = computed(() =>
|
||||
<style scoped>
|
||||
.mobile-messages {
|
||||
min-height: 100dvh;
|
||||
background: #f5f7fb;
|
||||
padding-bottom: calc(62px + env(safe-area-inset-bottom));
|
||||
padding-bottom: calc(52px + env(safe-area-inset-bottom));
|
||||
background: #f4f4f2;
|
||||
color: #252a31;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
@@ -160,103 +201,188 @@ const unreadTotal = computed(() =>
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
display: grid;
|
||||
grid-template-columns: 44px 1fr 72px;
|
||||
grid-template-columns: 44px minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
height: 48px;
|
||||
padding: 0 8px;
|
||||
height: 52px;
|
||||
padding: 0 10px;
|
||||
background: rgba(255, 255, 255, 0.96);
|
||||
border-bottom: 1px solid #edf0f5;
|
||||
backdrop-filter: blur(10px);
|
||||
border-bottom: 1px solid #ececea;
|
||||
box-shadow: 0 1px 8px rgba(26, 28, 31, 0.03);
|
||||
backdrop-filter: blur(12px);
|
||||
}
|
||||
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
color: #111827;
|
||||
overflow: hidden;
|
||||
color: #24282d;
|
||||
font-size: 17px;
|
||||
font-weight: 800;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
display: grid;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
place-items: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #374151;
|
||||
border: 1px solid #ececea;
|
||||
border-radius: 8px;
|
||||
background: #f7f7f5;
|
||||
color: #4f555b;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.header-count {
|
||||
color: #ef4444;
|
||||
font-size: 12px;
|
||||
min-width: 52px;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #ead8cb;
|
||||
border-radius: 999px;
|
||||
background: #f8f1eb;
|
||||
color: #9c542b;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
text-align: right;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.header-count.is-clear {
|
||||
border-color: #e8e8e6;
|
||||
background: #f6f6f4;
|
||||
color: #8a8e93;
|
||||
}
|
||||
|
||||
.inbox-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin: 12px 12px 0;
|
||||
padding: 11px 12px;
|
||||
border: 1px solid #e7e6e3;
|
||||
border-radius: 8px;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 4px 14px rgba(28, 31, 35, 0.035);
|
||||
}
|
||||
|
||||
.summary-icon {
|
||||
display: grid;
|
||||
flex: 0 0 34px;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
place-items: center;
|
||||
border-radius: 8px;
|
||||
background: #f7f1eb;
|
||||
color: #a65b31;
|
||||
}
|
||||
|
||||
.summary-copy {
|
||||
display: grid;
|
||||
min-width: 0;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.summary-copy strong {
|
||||
color: #2a2f35;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.summary-copy span {
|
||||
color: #858a90;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.summary-unread,
|
||||
.summary-read {
|
||||
margin-left: auto;
|
||||
padding: 3px 7px;
|
||||
border-radius: 999px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.summary-unread {
|
||||
background: #f8eee6;
|
||||
color: #9c542b;
|
||||
}
|
||||
|
||||
.summary-read {
|
||||
background: #f4f4f2;
|
||||
color: #858a90;
|
||||
}
|
||||
|
||||
.scroll-container {
|
||||
min-height: calc(100dvh - 48px - 62px - env(safe-area-inset-bottom));
|
||||
min-height: calc(100dvh - 52px - 52px - env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding-top: 90px;
|
||||
padding-top: 72px;
|
||||
}
|
||||
|
||||
.conversation-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding: 12px;
|
||||
gap: 8px;
|
||||
padding: 10px 12px 20px;
|
||||
}
|
||||
|
||||
.conversation-item {
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: 52px minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
grid-template-columns: 44px minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
padding: 12px;
|
||||
border: 1px solid #e8edf3;
|
||||
border: 1px solid #e7e6e3;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
background: #ffffff;
|
||||
text-align: left;
|
||||
box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
|
||||
box-shadow: 0 4px 14px rgba(28, 31, 35, 0.035);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background 0.15s,
|
||||
border-color 0.15s;
|
||||
}
|
||||
|
||||
.conversation-item.is-unread {
|
||||
border-color: #e5d5c9;
|
||||
}
|
||||
|
||||
.conversation-item.is-unread::before {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
bottom: 12px;
|
||||
left: 0;
|
||||
width: 3px;
|
||||
border-radius: 0 3px 3px 0;
|
||||
background: #b96538;
|
||||
content: '';
|
||||
}
|
||||
|
||||
.conversation-item:active {
|
||||
transform: scale(0.99);
|
||||
background: #faf8f6;
|
||||
}
|
||||
|
||||
.avatar-stack {
|
||||
position: relative;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
.conversation-avatar {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.avatar.main {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
background: #1477ff;
|
||||
font-size: 16px;
|
||||
place-items: center;
|
||||
overflow: hidden;
|
||||
border: 1px solid #eadfd7;
|
||||
border-radius: 8px;
|
||||
background: #f8f2ed;
|
||||
color: #a65b31;
|
||||
}
|
||||
|
||||
.avatar.support {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
border: 2px solid #fff;
|
||||
background: #10b981;
|
||||
font-size: 11px;
|
||||
.conversation-avatar img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.conversation-main {
|
||||
@@ -274,59 +400,79 @@ const unreadTotal = computed(() =>
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
color: #111827;
|
||||
font-size: 15px;
|
||||
font-weight: 800;
|
||||
color: #252a31;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.conversation-time {
|
||||
flex: none;
|
||||
color: #9ca3af;
|
||||
font-size: 11px;
|
||||
color: #95999e;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.conversation-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-top: 5px;
|
||||
color: #6b7280;
|
||||
font-size: 11px;
|
||||
color: #74797f;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.role-chip {
|
||||
padding: 1px 6px;
|
||||
border-radius: 999px;
|
||||
background: #eef6ff;
|
||||
color: #1477ff;
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
background: #f3f3f1;
|
||||
color: #656b71;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.conversation-type {
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
background: #f8f1eb;
|
||||
color: #985c38;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.reply-chip {
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
background: #f8ece3;
|
||||
color: #a45227;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.conversation-main p {
|
||||
.conversation-preview {
|
||||
margin: 7px 0 0;
|
||||
overflow: hidden;
|
||||
color: #4b5563;
|
||||
font-size: 13px;
|
||||
line-height: 1.4;
|
||||
color: #666c72;
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.unread-badge {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
bottom: 10px;
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
padding: 0 5px;
|
||||
border-radius: 9px;
|
||||
background: #ef4444;
|
||||
min-width: 20px;
|
||||
height: 20px;
|
||||
padding: 0 6px;
|
||||
border-radius: 999px;
|
||||
background: #b96538;
|
||||
color: #fff;
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
line-height: 18px;
|
||||
font-weight: 700;
|
||||
line-height: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.scroll-container :deep(.van-list__finished-text) {
|
||||
padding: 18px 0 4px;
|
||||
color: #9a9ea3;
|
||||
font-size: 11px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user