Commit d36bd5ee by Lin

feat: 骨架屏/切换优化

1 parent 99fa49ed
...@@ -959,7 +959,6 @@ getCustomerListImpl = async (append: boolean): Promise<void> => { ...@@ -959,7 +959,6 @@ getCustomerListImpl = async (append: boolean): Promise<void> => {
if (append) { if (append) {
customerFilePageNum.value = customerFilePageNum.value + 1 customerFilePageNum.value = customerFilePageNum.value + 1
pageBumped = true pageBumped = true
customerListLoadingMore.value = true
} else { } else {
customerListHasMore.value = true customerListHasMore.value = true
} }
...@@ -968,10 +967,11 @@ getCustomerListImpl = async (append: boolean): Promise<void> => { ...@@ -968,10 +967,11 @@ getCustomerListImpl = async (append: boolean): Promise<void> => {
console.warn('[getCustomerList] 无登录门店信息,跳过客户档案列表请求') console.warn('[getCustomerList] 无登录门店信息,跳过客户档案列表请求')
if (pageBumped) { if (pageBumped) {
customerFilePageNum.value = customerFilePageNum.value - 1 customerFilePageNum.value = customerFilePageNum.value - 1
customerListLoadingMore.value = false
} }
return return
} }
// 首屏/筛选重置与加载更多统一置位,供列表骨架屏、底部「加载中」与空态判断使用(append=false 原先未置 true,导致首屏一直空白)
customerListLoadingMore.value = true
try { try {
const res = await getCustomerFileList(fileParams) const res = await getCustomerFileList(fileParams)
console.log('[ReceptionCenter] 获取客户列表res', res) console.log('[ReceptionCenter] 获取客户列表res', res)
...@@ -1040,9 +1040,7 @@ getCustomerListImpl = async (append: boolean): Promise<void> => { ...@@ -1040,9 +1040,7 @@ getCustomerListImpl = async (append: boolean): Promise<void> => {
} }
uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' }) uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' })
} finally { } finally {
if (append == true) { customerListLoadingMore.value = false
customerListLoadingMore.value = false
}
} }
} }
...@@ -1060,7 +1058,6 @@ getReceptionRecordListImpl = async (append: boolean): Promise<void> => { ...@@ -1060,7 +1058,6 @@ getReceptionRecordListImpl = async (append: boolean): Promise<void> => {
if (append) { if (append) {
receptionPageNum.value = receptionPageNum.value + 1 receptionPageNum.value = receptionPageNum.value + 1
pageBumped = true pageBumped = true
receptionListLoadingMore.value = true
} else { } else {
receptionListHasMore.value = true receptionListHasMore.value = true
} }
...@@ -1069,10 +1066,10 @@ getReceptionRecordListImpl = async (append: boolean): Promise<void> => { ...@@ -1069,10 +1066,10 @@ getReceptionRecordListImpl = async (append: boolean): Promise<void> => {
console.warn('[getReceptionRecordList] 无登录门店信息,跳过接待复盘列表请求') console.warn('[getReceptionRecordList] 无登录门店信息,跳过接待复盘列表请求')
if (pageBumped) { if (pageBumped) {
receptionPageNum.value = receptionPageNum.value - 1 receptionPageNum.value = receptionPageNum.value - 1
receptionListLoadingMore.value = false
} }
return return
} }
receptionListLoadingMore.value = true
console.log("receptionParams接待复盘参数",receptionParams); console.log("receptionParams接待复盘参数",receptionParams);
try { try {
const res = await getReceptionList(receptionParams) const res = await getReceptionList(receptionParams)
...@@ -1142,9 +1139,7 @@ getReceptionRecordListImpl = async (append: boolean): Promise<void> => { ...@@ -1142,9 +1139,7 @@ getReceptionRecordListImpl = async (append: boolean): Promise<void> => {
} }
uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' }) uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' })
} finally { } finally {
if (append == true) { receptionListLoadingMore.value = false
receptionListLoadingMore.value = false
}
} }
} }
......
<template> <template>
<!-- 客户录入列表:与 customervisits.customerInfoPage 字段对齐(ownerPhone / brandModel / customerTagName / arrivalDate / ownerName) --> <!-- 客户录入列表:与 customervisits.customerInfoPage 字段对齐(ownerPhone / brandModel / customerTagName / arrivalDate / ownerName) -->
<view :class="['customer-entry-list', isListDualColumn ? 'customer-entry-list-landscape' : '']"> <view :class="['customer-entry-list', isListDualColumn ? 'customer-entry-list-landscape' : '']">
<!-- 首次加载:列表为空时,用骨架卡片占位,避免空白 --> <!-- 首次加载:列表为空时,用骨架卡片占位,避免空白(v-if 与 v-for 分节点,避免与编译器优先级问题) -->
<view <view
v-if="loading && (props.customerList == null || props.customerList.length == 0)" v-if="loading && (props.customerList == null || props.customerList.length == 0)"
v-for="i in skeletonCardCount" :class="['customer-entry-skeleton-wrap', isListDualColumn ? 'customer-entry-skeleton-wrap-landscape' : '']"
:key="'entry-skeleton-' + i"
:class="['list-card', 'list-card-entry', 'glass-card', isListDualColumn ? 'list-card-entry-landscape' : '']"
> >
<un-skeleton rows="4" title loading></un-skeleton> <view
v-for="i in skeletonCardCount"
:key="'entry-skeleton-' + i"
:class="['list-card', 'list-card-entry', 'glass-card', isListDualColumn ? 'list-card-entry-landscape' : '']"
>
<un-skeleton rows="4" title loading></un-skeleton>
</view>
</view> </view>
<view <view
v-else v-else
...@@ -76,7 +80,7 @@ const props = defineProps<{ ...@@ -76,7 +80,7 @@ const props = defineProps<{
}>() }>()
const loading = computed<boolean>(() => props.loading === true) const loading = computed<boolean>(() => props.loading === true)
const skeletonCardCount = 3 const skeletonCardCount = 4
/** 是否横屏(w > h)。uni-app x UTS 当前编译目标不支持 onWindowResize,使用轮询响应旋转 */ /** 是否横屏(w > h)。uni-app x UTS 当前编译目标不支持 onWindowResize,使用轮询响应旋转 */
const isLandscape = ref(false) const isLandscape = ref(false)
...@@ -328,6 +332,17 @@ function onEntryCardMaskDelete(item: UTSJSONObject): void { ...@@ -328,6 +332,17 @@ function onEntryCardMaskDelete(item: UTSJSONObject): void {
width: 100%; width: 100%;
} }
.customer-entry-skeleton-wrap {
flex-direction: column;
width: 100%;
}
.customer-entry-skeleton-wrap-landscape {
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
.customer-entry-list-landscape { .customer-entry-list-landscape {
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
......
...@@ -3,12 +3,16 @@ ...@@ -3,12 +3,16 @@
<view :class="['reception-record-list', isListDualColumn ? 'reception-record-list-landscape' : '']"> <view :class="['reception-record-list', isListDualColumn ? 'reception-record-list-landscape' : '']">
<!-- 首次加载:列表为空时,用骨架卡片占位,避免空白 --> <!-- 首次加载:列表为空时,用骨架卡片占位,避免空白 -->
<view <view
v-if="!loading && (props.receptionRecordList == null || props.receptionRecordList.length == 0)" v-if="loading && (props.receptionRecordList == null || props.receptionRecordList.length == 0)"
v-for="i in skeletonCardCount" :class="['reception-record-skeleton-wrap', isListDualColumn ? 'reception-record-skeleton-wrap-landscape' : '']"
:key="'reception-skeleton-' + i"
:class="['list-card', 'glass-card', isListDualColumn ? 'list-card-landscape' : '']"
> >
<un-skeleton rows="4" title loading></un-skeleton> <view
v-for="i in skeletonCardCount"
:key="'reception-skeleton-' + i"
:class="['list-card', 'glass-card', isListDualColumn ? 'list-card-landscape' : '']"
>
<un-skeleton rows="3" title loading></un-skeleton>
</view>
</view> </view>
<view <view
v-else v-else
...@@ -64,7 +68,7 @@ const props = defineProps<{ ...@@ -64,7 +68,7 @@ const props = defineProps<{
}>() }>()
const loading = computed<boolean>(() => props.loading === true) const loading = computed<boolean>(() => props.loading === true)
const skeletonCardCount = 3 const skeletonCardCount = 4
/** 是否横屏(w > h)。uni-app x UTS 当前编译目标不支持 onWindowResize,使用轮询响应旋转 */ /** 是否横屏(w > h)。uni-app x UTS 当前编译目标不支持 onWindowResize,使用轮询响应旋转 */
const isLandscape = ref(false) const isLandscape = ref(false)
...@@ -307,6 +311,17 @@ function onCardClick(item: UTSJSONObject): void { ...@@ -307,6 +311,17 @@ function onCardClick(item: UTSJSONObject): void {
justify-content: space-between; justify-content: space-between;
} }
.reception-record-skeleton-wrap {
flex-direction: column;
width: 100%;
}
.reception-record-skeleton-wrap-landscape {
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
}
.glass-card { .glass-card {
background-color: rgba(255, 255, 255, 0.85); background-color: rgba(255, 255, 255, 0.85);
border: 1px solid rgba(255, 255, 255, 0.6); border: 1px solid rgba(255, 255, 255, 0.6);
......
...@@ -112,6 +112,7 @@ ...@@ -112,6 +112,7 @@
v-if="showCustomerEmpty != true" v-if="showCustomerEmpty != true"
:customer-list="customerList" :customer-list="customerList"
:entry-filter-index="entryFilterIndex" :entry-filter-index="entryFilterIndex"
:loading="customerListLoadingMore == true && customerList.length == 0"
@entry-click="emit('entryClick', $event)" @entry-click="emit('entryClick', $event)"
@entry-edit="emit('entryEdit', $event)" @entry-edit="emit('entryEdit', $event)"
@entry-delete="emit('entryDelete', $event)" @entry-delete="emit('entryDelete', $event)"
...@@ -123,6 +124,7 @@ ...@@ -123,6 +124,7 @@
<ListReception <ListReception
v-if="showReceptionEmpty != true" v-if="showReceptionEmpty != true"
:reception-record-list="receptionRecordList" :reception-record-list="receptionRecordList"
:loading="receptionListLoadingMore == true && receptionRecordList.length == 0"
@reception-click="emit('receptionClick', $event)" @reception-click="emit('receptionClick', $event)"
/> />
</view> </view>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!