fix: 地图key增加。
This commit is contained in:
@@ -73,6 +73,16 @@
|
||||
"mp-toutiao" : {
|
||||
"usingComponents" : true
|
||||
},
|
||||
/* H5特有相关 */
|
||||
"h5" : {
|
||||
"sdkConfigs" : {
|
||||
"maps" : {
|
||||
"qqmap" : {
|
||||
"key" : "7C7BZ-VY6L4-Q2LUN-KTJDR-HL7K6-RRFNN"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"uniStatistics" : {
|
||||
"enable" : false
|
||||
},
|
||||
|
||||
@@ -547,30 +547,53 @@ onLoad((option) => {
|
||||
form.value.latitude = null
|
||||
}
|
||||
|
||||
function stopLocationLoading() {
|
||||
locationLoading.value = false
|
||||
}
|
||||
|
||||
function loadCurrentCoordinate() {
|
||||
if (typeof uni.getLocation !== 'function') {
|
||||
locationLoading.value = false
|
||||
stopLocationLoading()
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '当前端暂不支持定位', type: 'warning'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 超时保护:10秒后强制结束 loading
|
||||
const timer = setTimeout(() => {
|
||||
stopLocationLoading()
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '定位超时,请检查定位权限或网络后重试', type: 'warning'
|
||||
})
|
||||
}, 10000)
|
||||
|
||||
uni.getLocation({
|
||||
type: 'gcj02',
|
||||
isHighAccuracy: true,
|
||||
success(res) {
|
||||
clearTimeout(timer)
|
||||
applyLocationResult(res)
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '已获取当前位置坐标,可补充地点名称', type: 'success'
|
||||
})
|
||||
},
|
||||
fail() {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '定位失败,请检查定位权限后重试', type: 'warning'
|
||||
})
|
||||
fail(err) {
|
||||
clearTimeout(timer)
|
||||
const msg = (err && err.errMsg) ? err.errMsg : ''
|
||||
if (msg.indexOf('auth') !== -1 || msg.indexOf('deny') !== -1 || msg.indexOf('permission') !== -1) {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '定位权限被拒绝,请到系统设置中开启定位权限', type: 'warning'
|
||||
})
|
||||
} else {
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '定位失败,请检查GPS或网络后重试', type: 'warning'
|
||||
})
|
||||
}
|
||||
},
|
||||
complete() {
|
||||
locationLoading.value = false
|
||||
clearTimeout(timer)
|
||||
stopLocationLoading()
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -580,24 +603,41 @@ onLoad((option) => {
|
||||
return
|
||||
}
|
||||
locationLoading.value = true
|
||||
|
||||
// 总体超时保护:15秒后强制重置 loading 状态,防止按钮永久卡住
|
||||
const safeTimer = setTimeout(() => {
|
||||
if (locationLoading.value) {
|
||||
stopLocationLoading()
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '定位服务响应超时,已自动重置,请重试', type: 'warning'
|
||||
})
|
||||
}
|
||||
}, 15000)
|
||||
|
||||
if (typeof uni.chooseLocation !== 'function') {
|
||||
clearTimeout(safeTimer)
|
||||
loadCurrentCoordinate()
|
||||
return
|
||||
}
|
||||
|
||||
uni.chooseLocation({
|
||||
success(res) {
|
||||
clearTimeout(safeTimer)
|
||||
applyLocationResult(res)
|
||||
proxy.$refs['uToast'].show({
|
||||
message: '定位成功', type: 'success'
|
||||
})
|
||||
locationLoading.value = false
|
||||
stopLocationLoading()
|
||||
},
|
||||
fail(err) {
|
||||
const errMsg = err && err.errMsg ? err.errMsg : ''
|
||||
clearTimeout(safeTimer)
|
||||
const errMsg = (err && err.errMsg) ? err.errMsg : ''
|
||||
// 用户取消选择,直接重置 loading,不降级
|
||||
if (errMsg.indexOf('cancel') !== -1) {
|
||||
locationLoading.value = false
|
||||
stopLocationLoading()
|
||||
return
|
||||
}
|
||||
// 其他失败降级到坐标定位
|
||||
loadCurrentCoordinate()
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user