修复bug
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { navigateToLogin } from '@/common/checkLogin.js'
|
||||
|
||||
let baseUrl = '';
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
baseUrl = 'http://192.168.1.222:8080'; // 开发环境
|
||||
@@ -42,7 +44,7 @@ export default function request(url, data = {}, method = "GET") {
|
||||
if (resData.code === 401) {
|
||||
if (token) {
|
||||
uni.clearStorageSync('token');
|
||||
uni.reLaunch({ url: '/pageSubPack/loginSub/login?mode=pwd' });
|
||||
navigateToLogin({ method: 'reLaunch' });
|
||||
}
|
||||
reject({ msg: '登录过期', code: 401 });
|
||||
return;
|
||||
|
||||
@@ -90,6 +90,7 @@ import { ref, computed, onUnmounted } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { getLoginBySms, getLoginPassword, getSendCode } from '../api/api.js'
|
||||
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
|
||||
import { resetLoginLock } from '@/common/checkLogin.js'
|
||||
|
||||
// ========== 模式切换 ==========
|
||||
// 'sms' = 手机验证码登录, 'pwd' = 账号密码登录
|
||||
@@ -113,6 +114,8 @@ const pendingAction = ref('')
|
||||
|
||||
// ========== onLoad: 读取 mode 参数 ==========
|
||||
onLoad((options) => {
|
||||
// 重置登录跳转锁,允许下次未登录时再次跳转
|
||||
resetLoginLock()
|
||||
if (options && options.mode === 'sms') {
|
||||
loginMode.value = 'sms'
|
||||
} else if (options && options.mode === 'pwd') {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user