Commit 9fd0f18f by Lin

feat(接待中心): 优化客户和接待记录列表加载体验

- 在客户列表和接待记录列表中添加骨架屏占位效果,提升首次加载时的用户体验
- 调整列表项的渲染逻辑,确保在加载状态下不触发点击事件
- 优化样式,统一骨架屏和列表项的展示方式,增强视觉一致性
- 移除冗余的日志输出,简化代码结构
1 parent 21bf162f
...@@ -236,6 +236,7 @@ function getPerformanceData(): Promise<void> { ...@@ -236,6 +236,7 @@ function getPerformanceData(): Promise<void> {
} }
function getCustomerList(append: boolean): Promise<void> { function getCustomerList(append: boolean): Promise<void> {
console.log('[ReceptionCenter] 获取客户列表触底加载', append)
return getCustomerListImpl(append) return getCustomerListImpl(append)
} }
...@@ -625,7 +626,6 @@ function getDefaultReceptionListParams(): UTSJSONObject | null { ...@@ -625,7 +626,6 @@ function getDefaultReceptionListParams(): UTSJSONObject | null {
// 页面加载/模块切换时请求门店业绩数据 // 页面加载/模块切换时请求门店业绩数据
getPerformanceDataImpl = async (): Promise<void> => { getPerformanceDataImpl = async (): Promise<void> => {
const raw = storage.get('userInfo') as UTSJSONObject | null const raw = storage.get('userInfo') as UTSJSONObject | null
console.log('[getPerformanceData] userInfo:', raw)
if (raw == null) { if (raw == null) {
performanceData.value = getMockPerformanceData() performanceData.value = getMockPerformanceData()
return return
...@@ -660,7 +660,6 @@ getPerformanceDataImpl = async (): Promise<void> => { ...@@ -660,7 +660,6 @@ getPerformanceDataImpl = async (): Promise<void> => {
try { try {
const res = await getMerchantPerformance(params) const res = await getMerchantPerformance(params)
console.log('获取业绩数据成功res:', res)
const resObj = res as UTSJSONObject const resObj = res as UTSJSONObject
const bizData = resObj['data'] as UTSJSONObject | null const bizData = resObj['data'] as UTSJSONObject | null
// performanceData.value = isPerformanceDataEmpty(bizData) ? getMockPerformanceData() : (bizData as UTSJSONObject) // performanceData.value = isPerformanceDataEmpty(bizData) ? getMockPerformanceData() : (bizData as UTSJSONObject)
...@@ -687,11 +686,6 @@ getCustomerListImpl = async (append: boolean): Promise<void> => { ...@@ -687,11 +686,6 @@ getCustomerListImpl = async (append: boolean): Promise<void> => {
return return
} }
} }
const fileParams = getDefaultCustomerFileParams()
if (fileParams == null) {
console.warn('[getCustomerList] 无登录门店信息,跳过客户档案列表请求')
return
}
let pageBumped = false let pageBumped = false
if (append) { if (append) {
customerFilePageNum.value = customerFilePageNum.value + 1 customerFilePageNum.value = customerFilePageNum.value + 1
...@@ -700,8 +694,18 @@ getCustomerListImpl = async (append: boolean): Promise<void> => { ...@@ -700,8 +694,18 @@ getCustomerListImpl = async (append: boolean): Promise<void> => {
} else { } else {
customerListHasMore.value = true customerListHasMore.value = true
} }
const fileParams = getDefaultCustomerFileParams()
if (fileParams == null) {
console.warn('[getCustomerList] 无登录门店信息,跳过客户档案列表请求')
if (pageBumped) {
customerFilePageNum.value = customerFilePageNum.value - 1
customerListLoadingMore.value = false
}
return
}
try { try {
const res = await getCustomerFileList(fileParams) const res = await getCustomerFileList(fileParams)
console.log('[ReceptionCenter] 获取客户列表res', res)
const resObj = res as UTSJSONObject const resObj = res as UTSJSONObject
const codeRaw = resObj['code'] const codeRaw = resObj['code']
if (`${codeRaw}` != '0') { if (`${codeRaw}` != '0') {
...@@ -783,11 +787,6 @@ getReceptionRecordListImpl = async (append: boolean): Promise<void> => { ...@@ -783,11 +787,6 @@ getReceptionRecordListImpl = async (append: boolean): Promise<void> => {
return return
} }
} }
const receptionParams = getDefaultReceptionListParams()
if (receptionParams == null) {
console.warn('[getReceptionRecordList] 无登录门店信息,跳过接待复盘列表请求')
return
}
let pageBumped = false let pageBumped = false
if (append) { if (append) {
receptionPageNum.value = receptionPageNum.value + 1 receptionPageNum.value = receptionPageNum.value + 1
...@@ -796,6 +795,15 @@ getReceptionRecordListImpl = async (append: boolean): Promise<void> => { ...@@ -796,6 +795,15 @@ getReceptionRecordListImpl = async (append: boolean): Promise<void> => {
} else { } else {
receptionListHasMore.value = true receptionListHasMore.value = true
} }
const receptionParams = getDefaultReceptionListParams()
if (receptionParams == null) {
console.warn('[getReceptionRecordList] 无登录门店信息,跳过接待复盘列表请求')
if (pageBumped) {
receptionPageNum.value = receptionPageNum.value - 1
receptionListLoadingMore.value = false
}
return
}
console.log("receptionParams接待复盘参数",receptionParams); console.log("receptionParams接待复盘参数",receptionParams);
try { try {
const res = await getReceptionList(receptionParams) const res = await getReceptionList(receptionParams)
......
...@@ -24,10 +24,9 @@ ...@@ -24,10 +24,9 @@
> >
<view class="filter-tabs-row entry-filter-segmented-wrap"> <view class="filter-tabs-row entry-filter-segmented-wrap">
<un-segmented <un-segmented
shape="circle"
type="card" type="card"
:height="40" :height="40"
bg-color="rgba(241, 245, 249, 0.5)" bg-color="#f1f5f9"
active-color="#000000" active-color="#000000"
:model-value="filterTabIndex" :model-value="filterTabIndex"
@update:model-value="emit('switchFilterTab', $event)" @update:model-value="emit('switchFilterTab', $event)"
......
...@@ -102,7 +102,6 @@ const reviewTabLabel = computed((): string => { ...@@ -102,7 +102,6 @@ const reviewTabLabel = computed((): string => {
background-color: rgba(255, 255, 255, 0.5); background-color: rgba(255, 255, 255, 0.5);
padding: 4px 12px; padding: 4px 12px;
border-radius: 999px; border-radius: 999px;
border: 1px solid rgba(226, 232, 240, 1);
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
} }
...@@ -116,8 +115,7 @@ const reviewTabLabel = computed((): string => { ...@@ -116,8 +115,7 @@ const reviewTabLabel = computed((): string => {
justify-content: space-between; justify-content: space-between;
border-radius: 10px; border-radius: 10px;
background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%); background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
border: 1px solid #dbe6f5; box-shadow: 0 1px 3px rgba(30, 41, 59, 0.06), inset 0 1px 0 #ffffff;
box-shadow: 0 1px 3px rgba(30, 41, 59, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);
box-sizing: border-box; box-sizing: border-box;
} }
...@@ -141,7 +139,7 @@ const reviewTabLabel = computed((): string => { ...@@ -141,7 +139,7 @@ const reviewTabLabel = computed((): string => {
.tag-box--filter .tag-arrow-icon { .tag-box--filter .tag-arrow-icon {
width: 14px; width: 14px;
height: 14px; height: 14px;
margin-left: 8px; margin-left: 6px;
opacity: 0.8; opacity: 0.8;
} }
</style> </style>
<template> <template>
<!-- 客户录入列表:与 customervisits.customerInfoPage 字段对齐(ownerPhone / brandModel / customerTagName / arrivalDate / ownerName) --> <!-- 客户录入列表:与 customervisits.customerInfoPage 字段对齐(ownerPhone / brandModel / customerTagName / arrivalDate / ownerName) -->
<view class="customer-entry-list"> <view class="customer-entry-list">
<!-- 首次加载:列表为空时,用骨架卡片占位,避免空白 -->
<view <view
v-for="item in customerList" v-if="loading && (props.customerList == null || props.customerList.length == 0)"
v-for="i in skeletonCardCount"
:key="'entry-skeleton-' + i"
class="list-card list-card-entry glass-card"
>
<un-skeleton rows="3" title loading></un-skeleton>
</view>
<view
v-else
v-for="item in props.customerList"
:key="getStr(item, 'id')" :key="getStr(item, 'id')"
class="list-card list-card-entry glass-card" class="list-card list-card-entry glass-card"
@click="onEntryCardClick(item)" @click="onEntryCardClick(item)"
@longpress="onEntryCardLongPress(item)" @longpress="onEntryCardLongPress(item)"
> >
<un-skeleton :rows="3" title :loading="loading">
<view class="card-header-row"> <view class="card-header-row">
<view class="card-title-box"> <view class="card-title-box">
<text class="card-name">{{ getStr(item, 'ownerName') }}</text> <text class="card-name">{{ getStr(item, 'ownerName') }}</text>
...@@ -20,8 +31,9 @@ ...@@ -20,8 +31,9 @@
<view class="info-row"><text class="info-label">客户标签</text><text class="info-value">{{ getStr(item, 'customerTagName') }}</text></view> <view class="info-row"><text class="info-label">客户标签</text><text class="info-value">{{ getStr(item, 'customerTagName') }}</text></view>
<view class="info-row"><text class="info-label">到店日期</text><text class="info-value">{{ formatArrivalDateOnly(getArrivalTsForEntry(item)) }}</text></view> <view class="info-row"><text class="info-label">到店日期</text><text class="info-value">{{ formatArrivalDateOnly(getArrivalTsForEntry(item)) }}</text></view>
</view> </view>
</un-skeleton>
<view <view
v-if="isEntryCardMaskVisible(item)" v-if="!loading && isEntryCardMaskVisible(item)"
class="entry-card-mask" class="entry-card-mask"
@click.stop="onEntryCardMaskAbsorbTap" @click.stop="onEntryCardMaskAbsorbTap"
> >
...@@ -46,15 +58,20 @@ ...@@ -46,15 +58,20 @@
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { ref, watch } from 'vue' import { computed, ref, watch } from 'vue'
const props = defineProps<{ const props = defineProps<{
/** 客户档案列表(由父级拉取并传入) */ /** 客户档案列表(由父级拉取并传入) */
customerList: UTSJSONObject[] customerList: UTSJSONObject[]
/** 与父级「今日到店 / 全部客户」分段器同步;切换时关闭长按遮罩 */ /** 与父级「今日到店 / 全部客户」分段器同步;切换时关闭长按遮罩 */
entryFilterIndex: number entryFilterIndex: number
/** 加载中:骨架屏覆盖卡片内容;列表为空时用骨架卡片占位 */
loading?: boolean
}>() }>()
const loading = computed<boolean>(() => props.loading === true)
const skeletonCardCount = 3
const emit = defineEmits<{ const emit = defineEmits<{
/** 点击卡片:打开客户档案详情 */ /** 点击卡片:打开客户档案详情 */
'entry-click': [item: UTSJSONObject] 'entry-click': [item: UTSJSONObject]
...@@ -170,11 +187,17 @@ function formatArrivalDateOnly(ts: number | null): string { ...@@ -170,11 +187,17 @@ function formatArrivalDateOnly(ts: number | null): string {
} }
function onEntryCardClick(item: UTSJSONObject): void { function onEntryCardClick(item: UTSJSONObject): void {
if (loading.value) {
return
}
entryOverlayEntryId.value = '' entryOverlayEntryId.value = ''
emit('entry-click', item) emit('entry-click', item)
} }
function onEntryCardLongPress(item: UTSJSONObject): void { function onEntryCardLongPress(item: UTSJSONObject): void {
if (loading.value) {
return
}
entryOverlayEntryId.value = getStr(item, 'id') entryOverlayEntryId.value = getStr(item, 'id')
} }
......
<template> <template>
<!-- 接待复盘记录列表:与接待接口字段对齐,数据由父级拉取后传入 --> <!-- 接待复盘记录列表:与接待接口字段对齐,数据由父级拉取后传入 -->
<view class="reception-record-list"> <view class="reception-record-list">
<!-- 首次加载:列表为空时,用骨架卡片占位,避免空白 -->
<view <view
v-for="(item, idx) in receptionRecordList" v-if="!loading && (props.receptionRecordList == null || props.receptionRecordList.length == 0)"
v-for="i in skeletonCardCount"
:key="'reception-skeleton-' + i"
class="list-card glass-card"
>
<un-skeleton rows="3" title loading></un-skeleton>
</view>
<view
v-else
v-for="(item, idx) in props.receptionRecordList"
:key="getStr(item, 'batchId') != '' ? getStr(item, 'batchId') + '-' + idx : 'recv-' + idx" :key="getStr(item, 'batchId') != '' ? getStr(item, 'batchId') + '-' + idx : 'recv-' + idx"
class="list-card glass-card" class="list-card glass-card"
@click="onCardClick(item)" @click="onCardClick(item)"
> >
<un-skeleton :rows="3" title :loading="loading">
<view class="card-header-row"> <view class="card-header-row">
<view class="card-title-box"> <view class="card-title-box">
<text class="card-name">{{ getStr(item, 'customerName') }}</text> <text class="card-name">{{ getStr(item, 'customerName') }}</text>
...@@ -31,16 +42,24 @@ ...@@ -31,16 +42,24 @@
<view class="info-row"><text class="info-label">开始接待</text><text class="info-value">{{ formatTimestamp(getTs(item, 'receptionStartTime')) }}</text></view> <view class="info-row"><text class="info-label">开始接待</text><text class="info-value">{{ formatTimestamp(getTs(item, 'receptionStartTime')) }}</text></view>
<view class="info-row info-row-last"><text class="info-label">结束接待</text><text class="info-value">{{ formatTimestamp(getTs(item, 'receptionEndTime')) }}</text></view> <view class="info-row info-row-last"><text class="info-label">结束接待</text><text class="info-value">{{ formatTimestamp(getTs(item, 'receptionEndTime')) }}</text></view>
</view> </view>
</un-skeleton>
</view> </view>
</view> </view>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
defineProps<{ import { computed } from 'vue'
const props = defineProps<{
/** 接待记录列表(由父级拉取并传入) */ /** 接待记录列表(由父级拉取并传入) */
receptionRecordList: UTSJSONObject[] receptionRecordList: UTSJSONObject[]
/** 加载中:骨架屏覆盖卡片内容;列表为空时用骨架卡片占位 */
loading?: boolean
}>() }>()
const loading = computed<boolean>(() => props.loading === true)
const skeletonCardCount = 3
const emit = defineEmits<{ const emit = defineEmits<{
/** 点击卡片:父级根据 filterTabIndex 等处理详情或 toast */ /** 点击卡片:父级根据 filterTabIndex 等处理详情或 toast */
'reception-click': [item: UTSJSONObject] 'reception-click': [item: UTSJSONObject]
...@@ -177,6 +196,9 @@ function formatReceptionDuration(item: UTSJSONObject): string { ...@@ -177,6 +196,9 @@ function formatReceptionDuration(item: UTSJSONObject): string {
} }
function onCardClick(item: UTSJSONObject): void { function onCardClick(item: UTSJSONObject): void {
if (loading.value) {
return
}
emit('reception-click', item) emit('reception-click', item)
} }
</script> </script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!