修复bug

This commit is contained in:
zhouyanli
2026-08-14 16:22:44 +08:00
parent 9e8f5d6acc
commit 53ea3996a0
17 changed files with 164 additions and 76 deletions

View File

@@ -26,6 +26,9 @@
ref,
onMounted
} from 'vue'
import {
onUnload
} from '@dcloudio/uni-app'
import {
getResidentCarAreaManageAreaListByVillageId,
getResidentCarAreaManageParkingListByAreaId
@@ -37,6 +40,8 @@
const selectedParkingLot = ref(uni.getStorageSync('parkingLotId'))
const selectedParkingSpace = ref(uni.getStorageSync('parkingSpaceId'))
const isSubmitting = ref(false)
let navTimer = null
let lockTimer = null
onMounted(() => {
checkType.value = uni.getStorageSync('checkType')
@@ -94,37 +99,38 @@
}
const selectedParking = (item) => {
// 防重复点击锁:处理中直接返回,避免重复选择/重复跳转
if (isSubmitting.value) return
isSubmitting.value = true
console.log(item);
if (checkType.value == '停车场') {
selectedParkingLot.value = item.id
} else if (checkType.value == '车位编号') {
selectedParkingSpace.value = item.id
}
setTimeout(() => {
uni.showToast({
title: '选择成功',
icon: 'success'
})
console.log(checkType.value);
try {
if (checkType.value == '停车场') {
selectedParkingLot.value = item.id
uni.setStorageSync('parkingLotId', item.id)
uni.setStorageSync('parkingLotName', item.name)
uni.removeStorageSync('parkingSpaceId')
uni.removeStorageSync('parkingSpaceName')
uni.setStorageSync('checkType', '车位编号')
} else if (checkType.value == '车位编号') {
console.log(item.id);
selectedParkingSpace.value = item.id
uni.setStorageSync('parkingSpaceId', item.id)
uni.setStorageSync('parkingSpaceName', item.name)
}
}, 1000)
setTimeout(() => {
goFreash()
}, 2500)
uni.showToast({
title: '选择成功',
icon: 'success'
})
navTimer = setTimeout(() => {
goFreash()
}, 1500)
} finally {
// 正常跳转后页面会销毁,防止异常时锁死
lockTimer = setTimeout(() => {
isSubmitting.value = false
}, 1500)
}
}
const goFreash = () => {
@@ -149,6 +155,18 @@
}
uni.navigateBack()
}
// 页面销毁时清理定时器,避免手势返回后延迟跳转仍触发
onUnload(() => {
if (navTimer) {
clearTimeout(navTimer)
navTimer = null
}
if (lockTimer) {
clearTimeout(lockTimer)
lockTimer = null
}
})
</script>
<style lang="scss">