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