Browse Source

Merge branch '815' into dev

dev
wangyx 1 week ago
parent
commit
ede691874a
  1. 152
      pagesA/kfPage/list.vue

152
pagesA/kfPage/list.vue

@ -24,12 +24,9 @@
scroll-y="true"
:lower-threshold="150"
@scrolltolower="handleLoadMore"
@scroll="handleScroll"
:refresher-enabled="true"
:refresher-triggered="refreshing"
@refresherrefresh="handleRefresh"
:scroll-top="scrollTop"
:scroll-with-animation="false"
:enable-back-to-top="true"
>
<view
@ -72,16 +69,18 @@
</view>
</view>
<!-- 底部加载与无更多提示 -->
<view class="list-footer" v-if="loadingMore">加载中...</view>
<view class="list-footer" v-else-if="!hasMore && appointmentList.length > 0">没有更多了</view>
<view v-if="loading" class="loading-more">
<text>加载中...</text>
</view>
<view v-if="!hasMore && appointmentList.length > 0" class="no-more">
<text>没有更多数据了</text>
</view>
</scroll-view>
<!-- 空状态 -->
<u-empty
v-if="appointmentList.length === 0 && !loading"
text="暂无预约信息"
mode="list"
></u-empty>
<view v-if="appointmentList.length === 0 && !loading" class="empty-state">
<text class="empty-text">暂无预约信息</text>
</view>
<!-- 加载状态 -->
<u-loading-page
@ -199,20 +198,16 @@ import { listViewing, viewingRegister,viewingDetail } from "@/pages/api";
export default {
data() {
return {
searchPhone: "", //
loading: false, //
appointmentList: [],
queryParams: {
pageNum: 1,
pageSize: 10,
telephone: "",
},
total: 0,
hasMore: true,
refreshing: false,
loadingMore: false,
scrollTop: 0,
isScrolling: false,
scrollTimer: null,
showRegisterPopup: false, //
currentAppointment: {}, //
viewingStatus: "1", // (1: , 0: ,2: )
@ -227,16 +222,16 @@ export default {
],
};
},
onLoad() {
this.resetAndLoad();
async onLoad() {
await this.resetAndLoad();
},
//
onPullDownRefresh() {
this.handleRefresh();
async onPullDownRefresh() {
await this.handleRefresh();
},
//
onReachBottom() {
this.handleLoadMore();
async onReachBottom() {
await this.handleLoadMore();
},
methods: {
formatCheckInTime(fromTime, toTime) {
@ -268,97 +263,84 @@ export default {
}
},
//
resetAndLoad() {
async resetAndLoad() {
this.appointmentList = [];
this.queryParams.pageNum = 1;
this.hasMore = true;
this.refreshing = false;
this.loadingMore = false;
this.scrollTop = 0; //
this.loadAppointmentList();
await this.loadAppointmentList(true);
},
//
handleRefresh() {
if (this.loading || this.refreshing) return;
this.refreshing = true;
async handleRefresh() {
this.queryParams.pageNum = 1;
this.refreshing = true;
this.hasMore = true;
this.scrollTop = 0; //
this.loadAppointmentList();
await this.loadAppointmentList(true);
},
//
handleScroll(e) {
this.isScrolling = true;
//
clearTimeout(this.scrollTimer);
this.scrollTimer = setTimeout(() => {
this.isScrolling = false;
}, 100);
},
//
handleLoadMore() {
if (this.loading || this.loadingMore || !this.hasMore || this.isScrolling) return;
this.loadingMore = true;
this.loadAppointmentList();
async handleLoadMore() {
if (!this.hasMore || this.loading) return;
await this.loadAppointmentList();
},
//
loadAppointmentList() {
if (this.loading || this.refreshing || this.loadingMore) {
//
}
// loading
if (this.queryParams.pageNum === 1 && !this.refreshing) {
async loadAppointmentList(isRefresh = false) {
if (this.loading) return;
this.loading = true;
}
listViewing(this.queryParams)
.then((response) => {
try {
const response = await listViewing(this.queryParams);
if (response.code === 200) {
const rows = Array.isArray(response?.rows) ? response.rows : [];
if (this.queryParams.pageNum === 1) {
if (isRefresh) {
this.appointmentList = rows;
} else if (rows.length) {
this.queryParams.pageNum = 1;
} else {
this.appointmentList = [...this.appointmentList, ...rows];
}
this.total = Number(response?.total || 0);
// pageSize total
const pageHasMore = rows.length >= this.queryParams.pageSize;
const totalHasMore = this.appointmentList.length < this.total;
this.hasMore = pageHasMore && (this.total ? totalHasMore : true);
if (this.hasMore) {
//
if (rows.length < this.queryParams.pageSize) {
this.hasMore = false;
} else {
this.hasMore = true;
this.queryParams.pageNum++;
}
})
.catch((err) => {
//
})
.finally(() => {
//
if (this.refreshing) {
uni.stopPullDownRefresh();
this.refreshing = false;
}
} catch (error) {
console.error("加载预约列表失败:", error);
} finally {
this.loading = false;
this.loadingMore = false;
});
this.refreshing = false;
}
},
//
handleSearch(value) {
async handleSearch(value) {
this.queryParams.pageNum = 1;
this.loadAppointmentList();
this.hasMore = true;
await this.loadAppointmentList(true);
},
//
handleClear() {
async handleClear() {
this.queryParams = {
pageNum: 1,
pageSize: 10,
telephone: "",
};
this.loadAppointmentList();
this.hasMore = true;
await this.loadAppointmentList(true);
},
//
@ -696,4 +678,26 @@ export default {
font-size: 26rpx;
padding: 20rpx 0;
}
.loading-more,
.no-more {
text-align: center;
padding: 30rpx;
color: #999;
font-size: 26rpx;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 100rpx 30rpx;
color: #999;
}
.empty-text {
font-size: 28rpx;
color: #999;
}
</style>

Loading…
Cancel
Save