|
@ -24,12 +24,9 @@ |
|
|
scroll-y="true" |
|
|
scroll-y="true" |
|
|
:lower-threshold="150" |
|
|
:lower-threshold="150" |
|
|
@scrolltolower="handleLoadMore" |
|
|
@scrolltolower="handleLoadMore" |
|
|
@scroll="handleScroll" |
|
|
|
|
|
:refresher-enabled="true" |
|
|
:refresher-enabled="true" |
|
|
:refresher-triggered="refreshing" |
|
|
:refresher-triggered="refreshing" |
|
|
@refresherrefresh="handleRefresh" |
|
|
@refresherrefresh="handleRefresh" |
|
|
:scroll-top="scrollTop" |
|
|
|
|
|
:scroll-with-animation="false" |
|
|
|
|
|
:enable-back-to-top="true" |
|
|
:enable-back-to-top="true" |
|
|
> |
|
|
> |
|
|
<view |
|
|
<view |
|
@ -72,16 +69,18 @@ |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<!-- 底部加载与无更多提示 --> |
|
|
<!-- 底部加载与无更多提示 --> |
|
|
<view class="list-footer" v-if="loadingMore">加载中...</view> |
|
|
<view v-if="loading" class="loading-more"> |
|
|
<view class="list-footer" v-else-if="!hasMore && appointmentList.length > 0">没有更多了</view> |
|
|
<text>加载中...</text> |
|
|
|
|
|
</view> |
|
|
|
|
|
<view v-if="!hasMore && appointmentList.length > 0" class="no-more"> |
|
|
|
|
|
<text>没有更多数据了</text> |
|
|
|
|
|
</view> |
|
|
</scroll-view> |
|
|
</scroll-view> |
|
|
|
|
|
|
|
|
<!-- 空状态 --> |
|
|
<!-- 空状态 --> |
|
|
<u-empty |
|
|
<view v-if="appointmentList.length === 0 && !loading" class="empty-state"> |
|
|
v-if="appointmentList.length === 0 && !loading" |
|
|
<text class="empty-text">暂无预约信息</text> |
|
|
text="暂无预约信息" |
|
|
</view> |
|
|
mode="list" |
|
|
|
|
|
></u-empty> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 加载状态 --> |
|
|
<!-- 加载状态 --> |
|
|
<u-loading-page |
|
|
<u-loading-page |
|
@ -199,20 +198,16 @@ import { listViewing, viewingRegister,viewingDetail } from "@/pages/api"; |
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
searchPhone: "", // 搜索手机号 |
|
|
|
|
|
loading: false, // 加载状态 |
|
|
loading: false, // 加载状态 |
|
|
appointmentList: [], |
|
|
appointmentList: [], |
|
|
queryParams: { |
|
|
queryParams: { |
|
|
pageNum: 1, |
|
|
pageNum: 1, |
|
|
pageSize: 10, |
|
|
pageSize: 10, |
|
|
|
|
|
telephone: "", |
|
|
}, |
|
|
}, |
|
|
total: 0, |
|
|
total: 0, |
|
|
hasMore: true, |
|
|
hasMore: true, |
|
|
refreshing: false, |
|
|
refreshing: false, |
|
|
loadingMore: false, |
|
|
|
|
|
scrollTop: 0, |
|
|
|
|
|
isScrolling: false, |
|
|
|
|
|
scrollTimer: null, |
|
|
|
|
|
showRegisterPopup: false, // 看房登记弹框显示状态 |
|
|
showRegisterPopup: false, // 看房登记弹框显示状态 |
|
|
currentAppointment: {}, // 当前选中的预约信息 |
|
|
currentAppointment: {}, // 当前选中的预约信息 |
|
|
viewingStatus: "1", // 看房状态 (1: 已看房, 0: 未看房,2: 已取消) |
|
|
viewingStatus: "1", // 看房状态 (1: 已看房, 0: 未看房,2: 已取消) |
|
@ -227,16 +222,16 @@ export default { |
|
|
], |
|
|
], |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
onLoad() { |
|
|
async onLoad() { |
|
|
this.resetAndLoad(); |
|
|
await this.resetAndLoad(); |
|
|
}, |
|
|
}, |
|
|
// 下拉刷新 |
|
|
// 下拉刷新 |
|
|
onPullDownRefresh() { |
|
|
async onPullDownRefresh() { |
|
|
this.handleRefresh(); |
|
|
await this.handleRefresh(); |
|
|
}, |
|
|
}, |
|
|
// 上拉加载 |
|
|
// 上拉加载 |
|
|
onReachBottom() { |
|
|
async onReachBottom() { |
|
|
this.handleLoadMore(); |
|
|
await this.handleLoadMore(); |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
formatCheckInTime(fromTime, toTime) { |
|
|
formatCheckInTime(fromTime, toTime) { |
|
@ -268,97 +263,84 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
// 重置并加载 |
|
|
// 重置并加载 |
|
|
resetAndLoad() { |
|
|
async resetAndLoad() { |
|
|
this.appointmentList = []; |
|
|
this.appointmentList = []; |
|
|
this.queryParams.pageNum = 1; |
|
|
this.queryParams.pageNum = 1; |
|
|
this.hasMore = true; |
|
|
this.hasMore = true; |
|
|
this.refreshing = false; |
|
|
this.refreshing = false; |
|
|
this.loadingMore = false; |
|
|
await this.loadAppointmentList(true); |
|
|
this.scrollTop = 0; // 重置滚动位置 |
|
|
|
|
|
this.loadAppointmentList(); |
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 下拉刷新 |
|
|
// 下拉刷新 |
|
|
handleRefresh() { |
|
|
async handleRefresh() { |
|
|
if (this.loading || this.refreshing) return; |
|
|
|
|
|
this.refreshing = true; |
|
|
|
|
|
this.queryParams.pageNum = 1; |
|
|
this.queryParams.pageNum = 1; |
|
|
|
|
|
this.refreshing = true; |
|
|
this.hasMore = true; |
|
|
this.hasMore = true; |
|
|
this.scrollTop = 0; // 重置滚动位置 |
|
|
await this.loadAppointmentList(true); |
|
|
this.loadAppointmentList(); |
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 滚动事件处理 |
|
|
|
|
|
handleScroll(e) { |
|
|
|
|
|
this.isScrolling = true; |
|
|
|
|
|
// 防抖处理 |
|
|
|
|
|
clearTimeout(this.scrollTimer); |
|
|
|
|
|
this.scrollTimer = setTimeout(() => { |
|
|
|
|
|
this.isScrolling = false; |
|
|
|
|
|
}, 100); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 上拉加载更多 |
|
|
// 上拉加载更多 |
|
|
handleLoadMore() { |
|
|
async handleLoadMore() { |
|
|
if (this.loading || this.loadingMore || !this.hasMore || this.isScrolling) return; |
|
|
if (!this.hasMore || this.loading) return; |
|
|
this.loadingMore = true; |
|
|
|
|
|
this.loadAppointmentList(); |
|
|
await this.loadAppointmentList(); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 加载预约列表 |
|
|
// 加载预约列表 |
|
|
loadAppointmentList() { |
|
|
async loadAppointmentList(isRefresh = false) { |
|
|
if (this.loading || this.refreshing || this.loadingMore) { |
|
|
if (this.loading) return; |
|
|
// 防抖,避免重复请求 |
|
|
|
|
|
} |
|
|
this.loading = true; |
|
|
// 首屏或非刷新加载时展示整页 loading |
|
|
|
|
|
if (this.queryParams.pageNum === 1 && !this.refreshing) { |
|
|
try { |
|
|
this.loading = true; |
|
|
const response = await listViewing(this.queryParams); |
|
|
} |
|
|
|
|
|
listViewing(this.queryParams) |
|
|
if (response.code === 200) { |
|
|
.then((response) => { |
|
|
|
|
|
const rows = Array.isArray(response?.rows) ? response.rows : []; |
|
|
const rows = Array.isArray(response?.rows) ? response.rows : []; |
|
|
if (this.queryParams.pageNum === 1) { |
|
|
|
|
|
|
|
|
if (isRefresh) { |
|
|
this.appointmentList = rows; |
|
|
this.appointmentList = rows; |
|
|
} else if (rows.length) { |
|
|
this.queryParams.pageNum = 1; |
|
|
|
|
|
} else { |
|
|
this.appointmentList = [...this.appointmentList, ...rows]; |
|
|
this.appointmentList = [...this.appointmentList, ...rows]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.total = Number(response?.total || 0); |
|
|
this.total = Number(response?.total || 0); |
|
|
// 是否还有更多:优先用返回条数与 pageSize 判断,兼容 total |
|
|
|
|
|
const pageHasMore = rows.length >= this.queryParams.pageSize; |
|
|
// 判断是否还有更多数据 |
|
|
const totalHasMore = this.appointmentList.length < this.total; |
|
|
if (rows.length < this.queryParams.pageSize) { |
|
|
this.hasMore = pageHasMore && (this.total ? totalHasMore : true); |
|
|
this.hasMore = false; |
|
|
if (this.hasMore) { |
|
|
} else { |
|
|
|
|
|
this.hasMore = true; |
|
|
this.queryParams.pageNum++; |
|
|
this.queryParams.pageNum++; |
|
|
} |
|
|
} |
|
|
}) |
|
|
} |
|
|
.catch((err) => { |
|
|
} catch (error) { |
|
|
// 错误时不改变已有列表,仅结束本次加载状态 |
|
|
console.error("加载预约列表失败:", error); |
|
|
}) |
|
|
} finally { |
|
|
.finally(() => { |
|
|
this.loading = false; |
|
|
// 统一收敛状态 |
|
|
this.refreshing = false; |
|
|
if (this.refreshing) { |
|
|
} |
|
|
uni.stopPullDownRefresh(); |
|
|
|
|
|
this.refreshing = false; |
|
|
|
|
|
} |
|
|
|
|
|
this.loading = false; |
|
|
|
|
|
this.loadingMore = false; |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 搜索预约 |
|
|
// 搜索预约 |
|
|
handleSearch(value) { |
|
|
async handleSearch(value) { |
|
|
this.queryParams.pageNum = 1; |
|
|
this.queryParams.pageNum = 1; |
|
|
this.loadAppointmentList(); |
|
|
this.hasMore = true; |
|
|
|
|
|
await this.loadAppointmentList(true); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 清空搜索 |
|
|
// 清空搜索 |
|
|
handleClear() { |
|
|
async handleClear() { |
|
|
this.queryParams = { |
|
|
this.queryParams = { |
|
|
pageNum: 1, |
|
|
pageNum: 1, |
|
|
pageSize: 10, |
|
|
pageSize: 10, |
|
|
telephone: "", |
|
|
telephone: "", |
|
|
}; |
|
|
}; |
|
|
this.loadAppointmentList(); |
|
|
this.hasMore = true; |
|
|
|
|
|
await this.loadAppointmentList(true); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
// 看房登记 |
|
|
// 看房登记 |
|
@ -696,4 +678,26 @@ export default { |
|
|
font-size: 26rpx; |
|
|
font-size: 26rpx; |
|
|
padding: 20rpx 0; |
|
|
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> |
|
|
</style> |
|
|