修复bug
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
<!-- 报修类型Tab -->
|
||||
<scroll-view class="scroll-container" scroll-y="true"
|
||||
:lower-threshold="100">
|
||||
:lower-threshold="100" @scrolltolower="loadMore">
|
||||
<view class="repair-type-tabs">
|
||||
<view
|
||||
class="type-tab"
|
||||
@@ -102,12 +102,18 @@
|
||||
<text class="empty-text">暂无数据</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 加载更多提示 -->
|
||||
<view v-if="repairList.length > 0" class="load-more-tip">
|
||||
<text v-if="loading">加载中...</text>
|
||||
<text v-else-if="!hasMoreData">没有更多数据了</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue';
|
||||
import { ref, watch, computed } from 'vue';
|
||||
import { onLoad, onShow, onUnload } from '@dcloudio/uni-app';
|
||||
import { getQueryRepair } from '../api/api.js';
|
||||
|
||||
@@ -120,6 +126,8 @@ const repairList = ref([]);
|
||||
const loading = ref(false);
|
||||
const pageNum = ref(1);
|
||||
const pageSize = ref(10);
|
||||
const total = ref(0);
|
||||
const hasMoreData = computed(() => repairList.value.length < total.value);
|
||||
const maintenanceItemId = ref('');
|
||||
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight || 0)
|
||||
|
||||
@@ -138,14 +146,23 @@ const getStatusInfo = (val) => {
|
||||
};
|
||||
|
||||
// 获取报修列表
|
||||
const fetchRepairList = async () => {
|
||||
// reset = true 时重置到第一页;否则按当前 pageNum 追加加载
|
||||
const fetchRepairList = async (reset = false) => {
|
||||
const villageId = uni.getStorageSync('currentVillageId');
|
||||
if (!villageId || villageId === '0') {
|
||||
uni.showToast({ title: '请先选择小区', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
// 防止重复请求
|
||||
if (loading.value) return;
|
||||
loading.value = true;
|
||||
|
||||
if (reset) {
|
||||
pageNum.value = 1;
|
||||
repairList.value = [];
|
||||
total.value = 0;
|
||||
}
|
||||
try {
|
||||
const params = {
|
||||
villageId,
|
||||
@@ -158,7 +175,8 @@ const fetchRepairList = async () => {
|
||||
// console.log('接口返回:', res);
|
||||
if (res.code === 200) {
|
||||
const list = res.rows || [];
|
||||
repairList.value = list.map(item => {
|
||||
total.value = Number(res.total) || 0;
|
||||
const mapped = list.map(item => {
|
||||
const statusInfo = getStatusInfo(item.problemStatus);
|
||||
const images = item.problemImageUrl ? item.problemImageUrl.split(',').filter(Boolean) : [];
|
||||
if (statusInfo) {
|
||||
@@ -166,6 +184,7 @@ const fetchRepairList = async () => {
|
||||
}
|
||||
return { ...item, imageList: images };
|
||||
});
|
||||
repairList.value = pageNum.value === 1 ? mapped : [...repairList.value, ...mapped];
|
||||
} else {
|
||||
uni.showToast({ title: res.msg || '获取失败', icon: 'none' });
|
||||
}
|
||||
@@ -176,10 +195,16 @@ const fetchRepairList = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 监听状态变化自动刷新(切换 tab 时重置页码)
|
||||
watch(activeStatus, () => {
|
||||
pageNum.value = 1;
|
||||
// 加载更多(滚动到底部触发)
|
||||
const loadMore = () => {
|
||||
if (loading.value || !hasMoreData.value) return;
|
||||
pageNum.value++;
|
||||
fetchRepairList();
|
||||
};
|
||||
|
||||
// 监听状态变化自动刷新(切换 tab 时重置到第一页)
|
||||
watch(activeStatus, () => {
|
||||
fetchRepairList(true);
|
||||
});
|
||||
|
||||
function publicClick(){
|
||||
@@ -219,11 +244,11 @@ const goDetail = (item) => {
|
||||
|
||||
onLoad(() => {
|
||||
// maintenanceItemId.value = option.maintenanceProjectId || '' // 接收维修项目id
|
||||
fetchRepairList()
|
||||
fetchRepairList(true)
|
||||
});
|
||||
onShow(() => {
|
||||
// 从其他页面返回时刷新列表
|
||||
fetchRepairList()
|
||||
fetchRepairList(true)
|
||||
});
|
||||
onUnload(() =>{
|
||||
|
||||
@@ -382,6 +407,10 @@ onUnload(() =>{
|
||||
color: #333;
|
||||
padding-right: 20rpx;
|
||||
width: 77%;
|
||||
word-break: break-all;
|
||||
word-wrap: break-word;
|
||||
white-space: normal;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.item-status {
|
||||
font-size: 14px;
|
||||
@@ -472,6 +501,16 @@ onUnload(() =>{
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
/* 加载更多提示 */
|
||||
.load-more-tip {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 30rpx 0;
|
||||
color: #999;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
/* 底部时间和详情 */
|
||||
.item-footer {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user