|
@@ -456,45 +456,38 @@ export default {
|
|
|
|
|
|
// 地图选点
|
|
|
getLocation() {
|
|
|
- // 页面加载时预请求权限(可选)
|
|
|
- uni.getLocation({
|
|
|
- type: 'gcj02',
|
|
|
- success: () => {
|
|
|
- uni.chooseLocation({
|
|
|
- success: async res => {
|
|
|
- // uni.setStorageSync('formData',{name: this.name,phone: this.phone,address: res.address})
|
|
|
- let addressData = await this.getRegionByLatLng(res.latitude, res.longitude)
|
|
|
- this.address = addressData.provinceName + addressData.cityName + addressData.areaName + res.address
|
|
|
- },
|
|
|
- fail: res => {
|
|
|
- uni.getSetting({
|
|
|
- success: res => {
|
|
|
- if (!res.authSetting['scope.userLocation']) {
|
|
|
- uni.showModal({
|
|
|
- title: '是否授权当前位置',
|
|
|
- content: '需要获取您的地理位置,请确认授权,否则地图功能将无法使用',
|
|
|
- success: tip => {
|
|
|
- if (tip.confirm) {
|
|
|
- uni.openSetting({
|
|
|
- success: data => {
|
|
|
- if (data.authSetting['scope.userLocation'] === true) {
|
|
|
- this.$successToast('授权成功')
|
|
|
- setTimeout(() => {
|
|
|
- this.getLocation()
|
|
|
- }, 1000)
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
+ uni.chooseLocation({
|
|
|
+ success: async res => {
|
|
|
+ // uni.setStorageSync('formData',{name: this.name,phone: this.phone,address: res.address})
|
|
|
+ let addressData = await this.getRegionByLatLng(res.latitude, res.longitude)
|
|
|
+ this.address = addressData.provinceName + addressData.cityName + addressData.areaName + res.address
|
|
|
+ },
|
|
|
+ fail: res => {
|
|
|
+ uni.getSetting({
|
|
|
+ success: res => {
|
|
|
+ if (!res.authSetting['scope.userLocation']) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '是否授权当前位置',
|
|
|
+ content: '需要获取您的地理位置,请确认授权,否则地图功能将无法使用',
|
|
|
+ success: tip => {
|
|
|
+ if (tip.confirm) {
|
|
|
+ uni.openSetting({
|
|
|
+ success: data => {
|
|
|
+ if (data.authSetting['scope.userLocation'] === true) {
|
|
|
+ this.$successToast('授权成功')
|
|
|
+ setTimeout(() => {
|
|
|
+ this.getLocation()
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
- }, // 空函数仅用于触发权限请求
|
|
|
- fail: err => console.log('请求权限失败', err)
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
}
|