修复bug

This commit is contained in:
zhouyanli
2026-08-07 18:05:16 +08:00
parent 3851aebe66
commit 92dd39cf4b
7 changed files with 128 additions and 16 deletions

View File

@@ -83,6 +83,7 @@
const id = ref(undefined)
const type = ref('')
const isSubmitting = ref(false)
const formData = ref({
// carNum: uni.getStorageSync('carNum'),
// carBrand: uni.getStorageSync('carBrand'),
@@ -202,14 +203,25 @@
}
}
// 车牌号正则:省份简称 + 城市代码字母 + 5位(蓝牌)或6位(新能源绿牌)字母数字
const CAR_NUM_REGEX = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤川青藏琼宁][A-Z][A-Z0-9]{5,6}$/
const saveCar = async () => {
if (isSubmitting.value) return
if (!formData.value.carNum) {
return uni.showToast({
title: "请输入车牌号",
icon: "none"
})
}
if (!CAR_NUM_REGEX.test(formData.value.carNum)) {
return uni.showToast({
title: "请输入正确的车牌号",
icon: "none"
})
}
isSubmitting.value = true
uni.showLoading({
title: '提交中...',
mask: true
@@ -232,6 +244,7 @@
submitCarData(carImageUrl)
} catch (err) {
isSubmitting.value = false
uni.hideLoading()
uni.showToast({
title: err.msg || '网络异常',
@@ -260,6 +273,7 @@
params.id = id.value
putCar(params).then(res => {
console.log(res);
isSubmitting.value = false
uni.hideLoading()
if (res.code === 200) {
uni.showToast({
@@ -274,9 +288,10 @@
uni.removeStorageSync("carImageUrl")
uni.removeStorageSync("carBrandId")
uni.removeStorageSync("checkType")
uni.redirectTo({ url: "/pageSubPack/my/myCarIndex" })
uni.navigateBack()
}, 1500)
} else {
isSubmitting.value = false
uni.showToast({
title: res.msg || '提交失败',
icon: 'none'
@@ -285,6 +300,7 @@
})
}else{
postCar(params).then(res => {
isSubmitting.value = false
uni.hideLoading()
if (res.code === 200) {
uni.showToast({
@@ -299,9 +315,10 @@
uni.removeStorageSync("carImageUrl")
uni.removeStorageSync("carBrandId")
uni.removeStorageSync("checkType")
uni.redirectTo({ url: "/pageSubPack/my/myCarIndex" })
uni.navigateBack()
}, 1500)
} else {
isSubmitting.value = false
uni.showToast({
title: res.msg || '提交失败',
icon: 'none'
@@ -467,4 +484,4 @@
color: #999 !important;
font-size: 28rpx !important;
}
</style>
</style>

View File

@@ -63,6 +63,7 @@
const statusBarHeight = ref(20)
const currentStatus = ref('')
const isDeleting = ref(false)
const id = ref(undefined)
const form = ref({
plateNo: '',
@@ -110,11 +111,13 @@
}
const onDelete = () => {
if (isDeleting.value) return
uni.showModal({
title: "确认删除",
content: "确认删除此车辆信息吗?",
success: (res) => {
if (res.confirm) {
isDeleting.value = true
uni.showLoading({
title: '删除中...',
mask: true
@@ -122,6 +125,7 @@
deleteCar({
carId: id.value
}).then(deleteRes => {
isDeleting.value = false
uni.hideLoading()
if (deleteRes.code === 200) {
uni.showToast({
@@ -129,7 +133,7 @@
icon: 'success'
})
setTimeout(() => {
uni.redirectTo({ url: "/pageSubPack/my/myCarIndex" })
uni.navigateBack()
}, 1500)
} else {
uni.showToast({

View File

@@ -40,6 +40,9 @@
import {
getMyCarList
} from '@/pageSubPack/api/apiSub.js'
import {
onShow
} from '@dcloudio/uni-app'
const statusBarHeight = ref(20)
const defaultCarImg = "http://47.104.199.163:9090/images/propertyImgs/defaultCarImg.png"
const carList = ref([])
@@ -61,9 +64,17 @@
}
// 页面加载时请求第一页
onMounted(() => {
getList()
})
onMounted(() => {
getList()
})
// 从子页面返回时刷新列表(如新增/编辑/删除车辆后)
onShow(() => {
pageNum.value = 1
noMoreData.value = false
loadingMore.value = false
carList.value = []
getList()
})
const getList = async () => {
// 防重复请求
if (loadingMore.value || noMoreData.value) return
@@ -268,4 +279,4 @@
width: 100vw;
height: 46px;
}
</style>
</style>