修复bug

This commit is contained in:
zhouyanli
2026-08-06 10:36:06 +08:00
parent 81e0ccf574
commit d44ebd075e
8 changed files with 121 additions and 78 deletions

View File

@@ -247,6 +247,7 @@
import {
onReachBottom,
onLoad,
onShow,
onUnload,
onPullDownRefresh
} from '@dcloudio/uni-app'
@@ -496,6 +497,25 @@
}
})
// 页面显示时从 storage 同步选择数据(从选择小区/楼栋等页面返回时)
// 注意:不用 || 兜底,否则 storage 被清空后旧值会残留导致页面显示与实际数据不一致
const syncFormDataFromStorage = () => {
formData.community = uni.getStorageSync('communityName')
formData.communityId = uni.getStorageSync('communityId')
formData.building = uni.getStorageSync('buildingName')
formData.buildingId = uni.getStorageSync('buildingId')
formData.unit = uni.getStorageSync('unitName')
formData.unitId = uni.getStorageSync('unitId')
formData.floor = uni.getStorageSync('floorName')
formData.floorId = uni.getStorageSync('floorId')
formData.houseNumber = uni.getStorageSync('houseNumberName')
formData.houseNumberId = uni.getStorageSync('houseNumberId')
formData.status = uni.getStorageSync('houseStatus')
}
onShow(() => {
syncFormDataFromStorage()
})
const chooseIdCard = async (type) => {
try {
const tempPath = await (type === 'front' ? idCardFrontUpload.chooseImage() : idCardBackUpload
@@ -764,7 +784,21 @@
uni.removeStorageSync("houseStatus");
uni.removeStorageSync("houseIsDefault");
uni.removeStorageSync("updateHouseId");
uni.redirectTo({ url: "/pageSubPack/my/myHouseIndex" })
// 在页面栈中找到 myHouseIndex 并精准返回
const pages = getCurrentPages()
let targetIndex = -1
for (let i = pages.length - 1; i >= 0; i--) {
if (pages[i].route && pages[i].route.includes('myHouseIndex')) {
targetIndex = i
break
}
}
if (targetIndex >= 0) {
const delta = pages.length - 1 - targetIndex
uni.navigateBack({ delta })
} else {
uni.redirectTo({ url: "/pageSubPack/my/myHouseIndex" })
}
}, 1500)
} catch (err) {

View File

@@ -449,8 +449,9 @@
.photo-list {
display: flex;
flex-direction: column;
gap: 20rpx;
/* gap: 20rpx; */
margin-top: 20rpx;
}
.photo-item {
@@ -458,6 +459,10 @@
height: 170px;
background-color: #f6f6f6;
border-radius: 8rpx;
margin-bottom: 20rpx;
}
.photo-item:last-child{
margin-bottom: 0;
}
.bottom-btn-wrap {

View File

@@ -68,8 +68,10 @@
import {
ref,
onMounted,
} from 'vue'
import {
onShow
} from '@dcloudio/uni-app'
import {
getMyHouseList,
setMyHouseDefault
@@ -141,6 +143,13 @@
getList()
})
// 页面显示时刷新列表(从添加/编辑房屋页返回时)
onShow(() => {
pageNum.value = 1
noMoreData.value = false
getList()
})
const onSwitchChange = async (e, i) => {

View File

@@ -275,6 +275,7 @@
color: #FF8F40;
margin-top: 8rpx;
text-align: left;
width: 100%;
}
/* ===== 更多积分兑换 ===== */

View File

@@ -14,7 +14,7 @@
{{ '暂无数据'}}
</text>
</view>
<view class="building-grid">
<view class="building-grid" :class="{ disabled: isNavigating }">
<view class="building-item"
:class="{ active:(checkType=='楼栋'&& selectedBuilding === item.id)||(checkType=='单元'&& selectedUnit === item.id)||(checkType=='楼层'&&selectedFloor === item.id) ||(checkType=='户号'&&selectedHouseNumber === item.id) }"
v-for="(item, index) in dataList" :key="index" @click="selectBuilding(item)">
@@ -52,6 +52,9 @@
// 从缓存获取类型
const checkType = ref(uni.getStorageSync('checkType') || '')
const dataList = ref([])
// 添加防重复点击锁
const isNavigating = ref(false)
@@ -78,75 +81,63 @@
// 选择项方法
const selectBuilding = (item) => {
const modalContent = `确认选择此${checkType.value}吗?`
uni.showModal({
title: '确认选择',
content: modalContent,
success: (res) => {
if (!res.confirm) return
uni.showLoading({
title: '选择中...',
mask: true
})
if (checkType.value === '楼栋') {
selectedBuilding.value = item.id
uni.setStorageSync('buildingId', item.id)
uni.setStorageSync('buildingName', item.name)
uni.removeStorageSync('unitId')
uni.removeStorageSync('unitName')
uni.removeStorageSync('floorId')
uni.removeStorageSync('floorName')
uni.removeStorageSync('houseNumberId')
uni.removeStorageSync('houseNumberName')
uni.setStorageSync('checkType', '单元')
} else if (checkType.value === '单元') {
selectedUnit.value = item.id
uni.setStorageSync('unitId', item.id)
uni.setStorageSync('unitName', item.name)
uni.removeStorageSync('floorId')
uni.removeStorageSync('floorName')
uni.removeStorageSync('houseNumberId')
uni.removeStorageSync('houseNumberName')
uni.setStorageSync('checkType', '楼层')
} else if (checkType.value === '楼层') {
selectedFloor.value = item.id
uni.setStorageSync('floorId', item.id)
uni.setStorageSync('floorName', item.name)
uni.removeStorageSync('houseNumberId')
uni.removeStorageSync('houseNumberName')
uni.setStorageSync('checkType', '户号')
} else if (checkType.value === '户号') {
selectedHouseNumber.value = item.id
uni.setStorageSync('houseNumberId', item.id)
uni.setStorageSync('houseNumberName', item.name)
}
// 防重复点击
if (isNavigating.value) return
isNavigating.value = true
setTimeout(() => {
uni.showToast({
title: '选择成功',
icon: 'success'
})
}, 500)
if (checkType.value === '楼栋') {
selectedBuilding.value = item.id
uni.setStorageSync('buildingId', item.id)
uni.setStorageSync('buildingName', item.name)
uni.removeStorageSync('unitId')
uni.removeStorageSync('unitName')
uni.removeStorageSync('floorId')
uni.removeStorageSync('floorName')
uni.removeStorageSync('houseNumberId')
uni.removeStorageSync('houseNumberName')
uni.setStorageSync('checkType', '单元')
} else if (checkType.value === '单元') {
selectedUnit.value = item.id
uni.setStorageSync('unitId', item.id)
uni.setStorageSync('unitName', item.name)
uni.removeStorageSync('floorId')
uni.removeStorageSync('floorName')
uni.removeStorageSync('houseNumberId')
uni.removeStorageSync('houseNumberName')
uni.setStorageSync('checkType', '楼层')
} else if (checkType.value === '楼层') {
selectedFloor.value = item.id
uni.setStorageSync('floorId', item.id)
uni.setStorageSync('floorName', item.name)
uni.removeStorageSync('houseNumberId')
uni.removeStorageSync('houseNumberName')
uni.setStorageSync('checkType', '户号')
} else if (checkType.value === '户号') {
selectedHouseNumber.value = item.id
uni.setStorageSync('houseNumberId', item.id)
uni.setStorageSync('houseNumberName', item.name)
}
setTimeout(() => {
uni.hideLoading()
goFreash()
}, 2000)
}
uni.showToast({
title: '选择成功',
icon: 'success'
})
}
setTimeout(() => {
goFreash()
}, 1000)
}
// 刷新跳转
const goFreash = () => {
console.log(checkType.value, '刷新页面')
if (checkType.value !== '户号') {
uni.navigateTo({
// 楼栋/单元/楼层:替换当前页,链式选择不堆叠
uni.redirectTo({
url: '/pageSubPack/my/selectBuilding'
})
} else {
uni.navigateTo({
url: '/pageSubPack/my/addHouse'
})
// 户号选择完成:返回已有的 addHouse 页面addHouse 通过 onShow 重新读取 storage
uni.navigateBack()
}
}
@@ -268,6 +259,11 @@
gap: 30rpx;
}
/* 正在跳转时禁用点击 */
.building-grid.disabled {
pointer-events: none;
}
/* 空状态 */
.empty-state {
display: flex;

View File

@@ -125,11 +125,9 @@
uni.removeStorageSync('parkingSpaceName');
console.log(sourcePage.value);
if (sourcePage.value == 'addHouse') {
uni.navigateTo({
url: '/pageSubPack/my/selectBuilding',
success: res => {},
fail: () => {},
complete: () => {}
// 替换当前页进入楼栋选择,避免页面堆叠
uni.redirectTo({
url: '/pageSubPack/my/selectBuilding'
});
} else if (sourcePage.value == 'addParkingSpace') {
uni.setStorageSync('checkType', '停车场')

View File

@@ -58,12 +58,12 @@
title: '注销账号',
type: 'arrow'
},
// {
// title: '升级版本',
// type: 'text',
// value: '当前版本 1.0.0',
// valueClass: 'item-version'
// }
{
title: '升级版本',
type: 'text',
value: '当前版本 1.0.0',
valueClass: 'item-version'
}
])
// 格式化字节大小