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