注释定位失败提示代码

This commit is contained in:
冯辉
2025-11-18 19:31:17 +08:00
parent b6e3e2749e
commit 4dd938e886
4 changed files with 29 additions and 30 deletions

View File

@@ -514,34 +514,34 @@ const getCurrentLocation = () => {
isLocating.value = false
// 根据错误类型给出不同提示
let errorMsg = '定位失败'
if (err.errMsg.includes('auth deny')) {
errorMsg = '定位权限被拒绝,请在设置中开启'
} else if (err.errMsg.includes('timeout')) {
errorMsg = '定位超时,请重试'
} else if (err.errMsg.includes('network')) {
errorMsg = '网络异常,请检查网络连接'
}
// let errorMsg = '定位失败'
// if (err.errMsg.includes('auth deny')) {
// errorMsg = '定位权限被拒绝,请在设置中开启'
// } else if (err.errMsg.includes('timeout')) {
// errorMsg = '定位超时,请重试'
// } else if (err.errMsg.includes('network')) {
// errorMsg = '网络异常,请检查网络连接'
// }
uni.showModal({
title: '定位失败',
content: errorMsg + ',是否使用默认位置?',
confirmText: '使用默认位置',
cancelText: '重试',
success: (modalRes) => {
if (modalRes.confirm) {
// 使用默认位置(北京)
longitude.value = 116.397428
latitude.value = 39.90923
reverseGeocode(longitude.value, latitude.value)
} else {
// 重试定位
setTimeout(() => {
getCurrentLocation()
}, 2000)
}
}
})
// uni.showModal({
// title: '定位失败',
// content: errorMsg + ',是否使用默认位置?',
// confirmText: '使用默认位置',
// cancelText: '重试',
// success: (modalRes) => {
// if (modalRes.confirm) {
// // 使用默认位置(北京)
// longitude.value = 116.397428
// latitude.value = 39.90923
// reverseGeocode(longitude.value, latitude.value)
// } else {
// // 重试定位
// setTimeout(() => {
// getCurrentLocation()
// }, 2000)
// }
// }
// })
}
})
},