Commit a4ee5825 by Lin

feat(CustomerSide, HomeFrame): 添加加载状态和空状态处理

- 在 CustomerSide 组件中引入 ListSkeleton 以显示加载状态。
- 增加 loading prop 以控制加载状态的显示。
- 实现空状态处理,显示暂无客户档案的提示。
- 在 HomeFrame 组件中更新 customerProfileLoading 状态以反映数据加载过程。
1 parent b1cb0904
<template>
<view class="list-skeleton">
<view
v-for="groupIndex in groupCount"
:key="'skeleton-group-' + groupIndex"
class="list-skeleton__group"
>
<view class="list-skeleton__count">
<view class="list-skeleton__block list-skeleton__count-left"></view>
<view class="list-skeleton__block list-skeleton__count-right"></view>
</view>
<view
v-for="itemIndex in itemCount"
:key="'skeleton-item-' + groupIndex + '-' + itemIndex"
class="list-skeleton__item"
>
<view class="list-skeleton__block list-skeleton__avatar"></view>
<view class="list-skeleton__body">
<view class="list-skeleton__block list-skeleton__line list-skeleton__line--name"></view>
<view class="list-skeleton__block list-skeleton__line list-skeleton__line--meta"></view>
<view class="list-skeleton__block list-skeleton__line list-skeleton__line--group"></view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'ListSkeleton',
props: {
groupCount: {
type: Number,
default: 2
},
itemCount: {
type: Number,
default: 2
}
}
}
</script>
<style lang="scss" scoped>
$card-shadow-space: 4px;
$content-h-gap: 12px;
$item-side-margin: $content-h-gap - $card-shadow-space;
@keyframes list-skeleton-shimmer {
0% {
background-position: 200% 0;
}
100% {
background-position: -200% 0;
}
}
.list-skeleton {
&__group {
margin-bottom: 8px;
&:last-child {
margin-bottom: 0;
}
}
&__block {
border-radius: 4px;
background: linear-gradient(90deg, #F0F2F5 25%, #E4E8ED 50%, #F0F2F5 75%);
background-size: 200% 100%;
animation: list-skeleton-shimmer 1.4s ease-in-out infinite;
}
&__count {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 12px;
margin: 0 $item-side-margin 8px;
border-radius: 10px;
background: rgba(44, 102, 247, 0.03);
box-sizing: border-box;
min-height: 32px;
}
&__count-left {
width: 120px;
height: 14px;
}
&__count-right {
width: 56px;
height: 14px;
}
&__item {
display: flex;
align-items: flex-start;
gap: 8px;
padding: 10px 12px;
margin: 0 $item-side-margin 8px;
background: #FFFFFF;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(44, 102, 247, 0.06);
box-sizing: border-box;
}
&__avatar {
width: 32px;
height: 32px;
border-radius: 50%;
flex-shrink: 0;
}
&__body {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 8px;
padding-top: 2px;
}
&__line {
height: 14px;
&--name {
width: 72%;
}
&--meta {
width: 55%;
}
&--group {
width: 40%;
}
}
}
</style>
......@@ -32,76 +32,95 @@
</view>
<scroll-view class="customer-list" scroll-y show-scrollbar="false">
<view class="customer-list-inner">
<view
v-for="group in customerProfile"
:key="group.date"
class="customer-day-group"
>
<view class="customer-count">
<view class="customer-count-left">
<image
class="customer-count-icon"
:src="require('@/assets/images/common/icon-customer-count.png')"
mode="aspectFit"
/>
<text class="customer-count-label">{{ formatDateLabel(group.date) }}已建档</text>
</view>
<view class="customer-count-right">
<text class="customer-count-num">{{ group.number || 0 }}</text>
<text class="customer-count-unit">位客户</text>
</view>
</view>
<!-- 加载骨架屏 -->
<ListSkeleton v-if="loading" />
<!-- 空状态 -->
<view v-else-if="isEmpty" class="customer-empty">
<image
class="customer-empty-icon"
:src="require('@/assets/images/common/noData.webp')"
mode="aspectFit"
/>
<text class="customer-empty-text">暂无客户档案</text>
</view>
<!-- 客户列表 -->
<template v-else>
<view
v-for="item in group.customerProfileInfoDTOS || []"
:key="item.id"
class="customer-item"
v-for="group in customerProfile"
:key="group.date"
class="customer-day-group"
>
<view class="customer-item-avatar">
<text class="customer-item-avatar-text">{{ getCustomerSurname(item.customerName) }}</text>
<view class="customer-count">
<view class="customer-count-left">
<image
class="customer-count-icon"
:src="require('@/assets/images/common/icon-customer-count.png')"
mode="aspectFit"
/>
<text class="customer-count-label">{{ formatDateLabel(group.date) }}已建档</text>
</view>
<view class="customer-count-right">
<text class="customer-count-num">{{ group.number || 0 }}</text>
<text class="customer-count-unit">位客户</text>
</view>
</view>
<view class="customer-item-body" @click="handleGoCustomerDetail(item)">
<view class="customer-item-row customer-item-row--name">
<view class="customer-item-name-left">
<text class="customer-item-name">{{ item.customerName }}</text>
<view v-if="item.carSeriesName" class="customer-item-car-tag">
<text class="customer-item-car-text">{{ item.carSeriesName }}</text>
<view
v-for="item in group.customerProfileInfoDTOS || []"
:key="item.id"
class="customer-item"
>
<view class="customer-item-avatar">
<text class="customer-item-avatar-text">{{ getCustomerSurname(item.customerName) }}</text>
</view>
<view class="customer-item-body" @click="handleGoCustomerDetail(item)">
<view class="customer-item-row customer-item-row--name">
<view class="customer-item-name-left">
<text class="customer-item-name">{{ item.customerName }}</text>
<view v-if="item.carSeriesName" class="customer-item-car-tag">
<text class="customer-item-car-text">{{ item.carSeriesName }}</text>
</view>
</view>
<view
v-if="getCustomerStatusLabel(item.customerStatus)"
:class="['customer-item-status', getCustomerStatusClass(item.customerStatus)]"
>
<text class="customer-item-status-text">{{ getCustomerStatusLabel(item.customerStatus) }}</text>
</view>
</view>
<view
v-if="getCustomerStatusLabel(item.customerStatus)"
:class="['customer-item-status', getCustomerStatusClass(item.customerStatus)]"
>
<text class="customer-item-status-text">{{ getCustomerStatusLabel(item.customerStatus) }}</text>
<view class="customer-item-row customer-item-row--meta">
<text class="customer-item-meta">{{ formatPhone(item.customerPhone) }}</text>
<template v-if="hasDisplayDate(item.deliveryDate)">
<view class="customer-item-divider"></view>
<text class="customer-item-meta">交付{{ formatDisplayDate(item.deliveryDate) }}</text>
</template>
<template v-if="hasDisplayDate(item.inviteDate)">
<view class="customer-item-divider"></view>
<text class="customer-item-meta">到店{{ formatDisplayDate(item.inviteDate) }}</text>
</template>
</view>
</view>
<view class="customer-item-row customer-item-row--meta">
<text class="customer-item-meta">{{ formatPhone(item.customerPhone) }}</text>
<template v-if="hasDisplayDate(item.deliveryDate)">
<view class="customer-item-divider"></view>
<text class="customer-item-meta">交付{{ formatDisplayDate(item.deliveryDate) }}</text>
</template>
<template v-if="hasDisplayDate(item.inviteDate)">
<view class="customer-item-divider"></view>
<text class="customer-item-meta">到店{{ formatDisplayDate(item.inviteDate) }}</text>
</template>
</view>
<view class="customer-item-row customer-item-row--group">
<text v-if="item.qwGroupName" class="customer-item-group">客户群:{{ item.qwGroupName }}</text>
<view class="customer-item-arrow">
<view class="sprite-icon icon-arrow-right"></view>
<view class="customer-item-row customer-item-row--group">
<text v-if="item.qwGroupName" class="customer-item-group">客户群:{{ item.qwGroupName }}</text>
<view class="customer-item-arrow">
<view class="sprite-icon icon-arrow-right"></view>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
</view>
</scroll-view>
</view>
</template>
<script>
import ListSkeleton from './ListSkeleton.vue'
export default {
name: 'CustomerSide',
components: {
ListSkeleton
},
props: {
type: {
type: String,
......@@ -111,6 +130,10 @@ export default {
type: Array,
default: () => []
},
loading: {
type: Boolean,
default: false
},
showHeaderIcon: {
type: Boolean,
default: true
......@@ -125,6 +148,12 @@ export default {
}
},
computed: {
isEmpty() {
if (!this.customerProfile.length) return true
return !this.customerProfile.some(
group => (group.customerProfileInfoDTOS || []).length > 0
)
},
headerStyle() {
if (!this.enableHeaderGradient) return {}
const {
......@@ -349,6 +378,29 @@ $item-side-margin: $content-h-gap - $card-shadow-space;
// 阴影绘制空间放在 inner,避免 scroll-view 裁剪左右 box-shadow
padding: 12px $card-shadow-space calc(4px + #{$card-shadow-space});
box-sizing: border-box;
min-height: 100%;
}
.customer-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 48px 12px;
min-height: 200px;
box-sizing: border-box;
.customer-empty-icon {
width: 120px;
height: 120px;
}
.customer-empty-text {
margin-top: 8px;
font-size: 14px;
line-height: 20px;
color: #999EA8;
}
}
.customer-day-group {
......
......@@ -98,6 +98,7 @@
<view class="content-right-customer-inner">
<CustomerSide
:customerProfile="customerProfileList"
:loading="customerProfileLoading"
enable-header-gradient
:showHeaderIcon="false"
:headerGradient="customerHeaderGradient"
......@@ -114,7 +115,10 @@
@entranceClick="entranceClick"
/>
<view class="line"></view>
<CustomerSide :customerProfile="customerProfileList" />
<CustomerSide
:customerProfile="customerProfileList"
:loading="customerProfileLoading"
/>
</view>
</view>
<!-- 挖掘潜客机会 -->
......@@ -391,6 +395,7 @@ export default {
activityProductList: [],
prelearnData: {},
customerProfileList: [],
customerProfileLoading: true,
customerHeaderGradient: Object.freeze({
afterGradient: 'linear-gradient(0deg, #94c2ff00 0%, #5294ff 100%)',
beforeGradient: 'linear-gradient(-44.4deg, #94c2ff00 0%, #5294ff 100%)',
......@@ -770,7 +775,8 @@ export default {
}
},
/**
* 查询当前进行中的营销活动商品列表
* @function 营销活动:
* @desc 查询当前进行中的营销活动商品列表
*/
async getActivityProductList() {
const { shopMerchantId: merchantId } = uni.$storage.get('userInfo') || {}
......@@ -793,22 +799,27 @@ export default {
},
/**
* 查询客户建档分页查询-月按天分组
* @function 客户档案:
* @desc 查询客户建档分页查询-月按天分组
*/
async getCustomerProfileGroupInfo() {
const { shopMerchantId: merchantId } = uni.$storage.get('userInfo') || {}
if (!merchantId) {
this.customerProfileList = []
this.customerProfileLoading = false
return
}
this.customerProfileLoading = true
try {
const res = await uni.$api.customerApi.getCustomerProfileGroupInfoAPI({ merchantId })
console.log('getCustomerProfileListInfo***')
console.log('getCustomerProfileGroupInfo***', res)
this.customerProfileList = Array.isArray(res) ? res : []
} catch (error) {
console.error('查询客户建档分组信息失败:', error)
this.customerProfileList = []
} finally {
this.customerProfileLoading = false
}
},
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!