修复bug
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user