修复bug

This commit is contained in:
zhouyanli
2026-08-10 14:15:59 +08:00
parent 92dd39cf4b
commit 5f8f5fc73d
7 changed files with 103 additions and 42 deletions

View File

@@ -50,7 +50,7 @@
</view>
</scroll-view>
<view class="bottom-btn-wrap">
<button class="next-btn" @click="saveCar">保存</button>
<button class="next-btn" :disabled="isSubmitting" @click="saveCar">保存</button>
</view>
</view>
</template>
@@ -85,12 +85,6 @@
const type = ref('')
const isSubmitting = ref(false)
const formData = ref({
// carNum: uni.getStorageSync('carNum'),
// carBrand: uni.getStorageSync('carBrand'),
// carModel: uni.getStorageSync('carModel'),
// carColor: uni.getStorageSync('carColor'),
// carImageUrl: uni.getStorageSync('carImageUrl'),
// carBrandId: uni.getStorageSync('carBrandId')
carNum: '',
carBrand: '',
carModel: '',
@@ -253,6 +247,7 @@
}
}
const submitCarData = (carImageUrl) => {
// 处理 carImageUrl 可能是对象 { url: string } 的情况
const imageUrl = typeof carImageUrl === 'object' ? carImageUrl.url : carImageUrl
@@ -273,7 +268,6 @@
params.id = id.value
putCar(params).then(res => {
console.log(res);
isSubmitting.value = false
uni.hideLoading()
if (res.code === 200) {
uni.showToast({
@@ -291,16 +285,22 @@
uni.navigateBack()
}, 1500)
} else {
isSubmitting.value = false
isSubmitting.value = false
uni.showToast({
title: res.msg || '提交失败',
icon: 'none'
})
}
})
}else{
postCar(params).then(res => {
}).catch((err) => {
isSubmitting.value = false
uni.hideLoading()
uni.showToast({
title: err.msg || '提交失败',
icon: 'none'
})
})
} else {
postCar(params).then(res => {
uni.hideLoading()
if (res.code === 200) {
uni.showToast({
@@ -318,16 +318,23 @@
uni.navigateBack()
}, 1500)
} else {
isSubmitting.value = false
isSubmitting.value = false
uni.showToast({
title: res.msg || '提交失败',
icon: 'none'
})
}
}).catch((err) => {
isSubmitting.value = false
uni.hideLoading()
uni.showToast({
title: err.msg || '提交失败',
icon: 'none'
})
})
}
}
const selectItem = (typeStr) => {

View File

@@ -145,6 +145,18 @@
} else if (uni.getStorageSync('operationType') == 'add') {
id.value = undefined
type.value = '添加'
// 添加模式下清空上次残留的缓存,保证每次进入都是干净的
uni.removeStorageSync('communityName')
uni.removeStorageSync('communityId')
uni.removeStorageSync('parkingLotName')
uni.removeStorageSync('parkingLotId')
uni.removeStorageSync('parkingSpaceName')
uni.removeStorageSync('parkingSpaceId')
uni.removeStorageSync('parkingStatus')
uni.removeStorageSync('bindCarName')
uni.removeStorageSync('bindCarId')
uni.removeStorageSync('ownerName')
uni.removeStorageSync('ownerId')
}
})

View File

@@ -64,6 +64,7 @@
const statusBarHeight = ref(20)
const currentStatus = ref('')
const isDeleting = ref(false)
const isUpdating = ref(false)
const id = ref(undefined)
const form = ref({
plateNo: '',
@@ -72,6 +73,7 @@
color: '',
carImg: ''
})
let isFirstLoad = true
onLoad((options) => {
console.log(options);
id.value = options.id
@@ -80,7 +82,17 @@
})
onShow(() => {
// 首次加载由 onLoad 处理,仅从编辑页返回时刷新
if (isFirstLoad) {
isFirstLoad = false
return
}
isUpdating.value = false
if (id.value) {
loadCarDetail()
}
})
const loadCarDetail = async () => {
// 防重复请求
@@ -104,6 +116,8 @@
}
}
const clickUpdate = () => {
if (isUpdating.value) return
isUpdating.value = true
uni.setStorageSync('operationType', 'update')
uni.navigateTo({
url: '/pageSubPack/my/addCar?id=' + id.value
@@ -112,12 +126,12 @@
const onDelete = () => {
if (isDeleting.value) return
isDeleting.value = true
uni.showModal({
title: "确认删除",
content: "确认删除此车辆信息吗?",
success: (res) => {
if (res.confirm) {
isDeleting.value = true
uni.showLoading({
title: '删除中...',
mask: true
@@ -125,7 +139,6 @@
deleteCar({
carId: id.value
}).then(deleteRes => {
isDeleting.value = false
uni.hideLoading()
if (deleteRes.code === 200) {
uni.showToast({
@@ -136,12 +149,22 @@
uni.navigateBack()
}, 1500)
} else {
isDeleting.value = false
uni.showToast({
title: deleteRes.msg || '删除失败',
icon: 'none'
})
}
}).catch(() => {
isDeleting.value = false
uni.hideLoading()
uni.showToast({
title: '删除失败',
icon: 'none'
})
})
} else {
isDeleting.value = false
}
}
})

View File

@@ -131,13 +131,7 @@
});
} else if (sourcePage.value == 'addParkingSpace') {
uni.setStorageSync('checkType', '停车场')
uni.navigateTo({
// url: '/pageSubPack/my/bindHouse',
url: '/pageSubPack/my/selectParingLot',
success: res => {},
fail: () => {},
complete: () => {}
});
uni.navigateBack()
} else {
}