Browse Source

看房记录

dev
wangyx 1 week ago
parent
commit
44c7eb21a1
  1. 178
      pagesA/kfPage/list.vue

178
pagesA/kfPage/list.vue

@ -3,7 +3,7 @@
<!-- 搜索框 -->
<view class="search-container">
<u-search
v-model="searchPhone"
v-model="queryParams.telephone"
placeholder="请输入手机号"
:show-action="false"
:clearabled="true"
@ -20,7 +20,14 @@
<!-- 预约列表 -->
<view class="appointment-list">
<scroll-view scroll-y="true">
<scroll-view
scroll-y="true"
:lower-threshold="80"
@scrolltolower="handleLoadMore"
:refresher-enabled="true"
:refresher-triggered="refreshing"
@refresherrefresh="handleRefresh"
>
<view
class="appointment-card"
v-for="item in filteredAppointmentList"
@ -30,7 +37,7 @@
<view class="card-header">
<u-icon name="home" size="16" color="#08B3B3"></u-icon>
<text class="community-info"
>{{ item.community }} | {{ item.houseType }}</text
>{{ item.apartmentName }} | {{ item.houseTypeName }}</text
>
</view>
@ -38,25 +45,31 @@
<view class="card-content">
<view class="info-row">
<text class="label">预约人</text>
<text class="value">{{ item.appointee }}</text>
<text class="value">{{ item.graduateName }}</text>
</view>
<view class="info-row">
<text class="label">预约人电话</text>
<text class="value">{{ item.phone }}</text>
<text class="value">{{ item.telephone }}</text>
</view>
<view class="info-row">
<text class="label">预约时间</text>
<text class="value">{{ item.appointmentTime }}</text>
<text class="value">{{ formatCheckInTime(
item.reservationTimeFrom,
item.reservationTimeTo
) }}</text>
</view>
</view>
<!-- 操作按钮 -->
<view class="actionButtons">
<view class="actionButtons" v-if="item.state == 0">
<button class="btn process" @click="handleViewHouse(item)">
看房登记
</button>
</view>
</view>
<!-- 底部加载与无更多提示 -->
<view class="list-footer" v-if="loadingMore">加载中...</view>
<view class="list-footer" v-else-if="!hasMore && appointmentList.length > 0">没有更多了</view>
</scroll-view>
</view>
@ -179,6 +192,7 @@
</template>
<script>
import { listViewing, viewingRegister,viewingDetail } from "@/pages/api";
export default {
data() {
return {
@ -204,9 +218,17 @@ export default {
idCard: "370832199606062002",
},
],
queryParams: {
pageNum: 1,
pageSize: 10,
},
total: 0,
hasMore: true,
refreshing: false,
loadingMore: false,
showRegisterPopup: false, //
currentAppointment: {}, //
viewingStatus: "1", // (1: , 2: )
viewingStatus: "1", // (1: , 0: ,2: )
viewingStatusText: "已看房", //
viewingDescription: "", //
showStatusDropdown: false, //
@ -232,35 +254,125 @@ export default {
},
},
onLoad() {
this.loadAppointmentList();
this.resetAndLoad();
},
//
onPullDownRefresh() {
this.loadAppointmentList();
this.handleRefresh();
},
//
onReachBottom() {},
onReachBottom() {
this.handleLoadMore();
},
methods: {
formatCheckInTime(fromTime, toTime) {
if (!fromTime || !toTime) {
return "";
}
try {
//
const fromDate = new Date(fromTime);
const fromDateStr = fromDate.toISOString().split("T")[0]; // YYYY-MM-DD
const fromTimeStr = fromDate.toTimeString().substring(0, 5); // HH:MM
//
const toDate = new Date(toTime);
const toTimeStr = toDate.toTimeString().substring(0, 5); // HH:MM
//
if (fromDateStr === toDate.toISOString().split("T")[0]) {
return `${fromDateStr} ${fromTimeStr}-${toTimeStr}`;
} else {
//
const toDateStr = toDate.toISOString().split("T")[0];
return `${fromDateStr} ${fromTimeStr}-${toDateStr} ${toTimeStr}`;
}
} catch (error) {
console.error("日期格式化错误:", error);
return "";
}
},
//
resetAndLoad() {
this.appointmentList = [];
this.queryParams.pageNum = 1;
this.hasMore = true;
this.refreshing = false;
this.loadingMore = false;
this.loadAppointmentList();
},
//
handleRefresh() {
if (this.loading || this.refreshing) return;
this.refreshing = true;
this.queryParams.pageNum = 1;
this.hasMore = true;
this.loadAppointmentList();
},
//
handleLoadMore() {
if (this.loading || this.loadingMore || !this.hasMore) return;
this.loadingMore = true;
this.loadAppointmentList();
},
//
loadAppointmentList() {
if (this.loading || this.refreshing || this.loadingMore) {
//
}
// loading
if (this.queryParams.pageNum === 1 && !this.refreshing) {
this.loading = true;
// API
setTimeout(() => {
this.loading = false;
//
}
listViewing(this.queryParams)
.then((response) => {
const rows = Array.isArray(response?.rows) ? response.rows : [];
if (this.queryParams.pageNum === 1) {
this.appointmentList = rows;
} else if (rows.length) {
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) {
this.queryParams.pageNum++;
}
})
.catch((err) => {
//
})
.finally(() => {
//
if (this.refreshing) {
uni.stopPullDownRefresh();
}, 1000);
this.refreshing = false;
}
this.loading = false;
this.loadingMore = false;
});
},
//
handleSearch(value) {
console.log("搜索:", value);
// computed
this.queryParams.pageNum = 1;
this.loadAppointmentList();
},
//
handleClear() {
this.searchPhone = "";
this.queryParams = {
pageNum: 1,
pageSize: 10,
telephone: "",
};
this.loadAppointmentList();
},
//
@ -303,6 +415,27 @@ export default {
});
return;
}
const params = {
id: this.currentAppointment.id,
state: this.viewingStatus,
remark: this.viewingDescription,
};
viewingRegister(params)
.then((res) => {
if (res.code === 200) {
// toast
this.handleClosePopup();
this.$nextTick(() => {
uni.showToast({
title: '提交成功',
icon: 'none',
});
//
this.resetAndLoad();
});
}
})
.catch(() => {})
},
//
@ -568,4 +701,11 @@ export default {
}
}
}
.list-footer {
text-align: center;
color: #999;
font-size: 26rpx;
padding: 20rpx 0;
}
</style>

Loading…
Cancel
Save