| | |
| | | }) |
| | | }, |
| | | handleLocation() { |
| | | uni.showToast({ |
| | | title: '定位功能待接入', |
| | | icon: 'none' |
| | | }) |
| | | var that = this; |
| | | uni.openSetting({ |
| | | success: (res) => { |
| | | if (res.authSetting['scope.userLocation']) { |
| | | that.positioning() |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | // 定位 |
| | | positioning() { |
| | | var that = this; |
| | | uni.getLocation({ |
| | | type: 'gcj02', |
| | | highAccuracyExpireTime: 3000, |
| | | isHighAccuracy: true, |
| | | success: function (addr) { |
| | | const locParam = { latitude: addr.latitude, longitude: addr.longitude }; |
| | | const qqmapsdk = new QQMapWX({ |
| | | key: 'WE3BZ-HN6WS-ONDOH-62QCV-MNL6F-5NFNE' |
| | | }); |
| | | qqmapsdk.reverseGeocoder({ |
| | | locParam, |
| | | success: async function(res) { |
| | | console.log(res, '==================获取地址'); |
| | | let info = res.result; |
| | | locParam.province = info.address_component.province; |
| | | locParam.city = info.address_component.city; |
| | | locParam.area = info.address_component.district; |
| | | locParam.street = info.address_component.street; |
| | | var ta = info.address || '地址获取失败' ; |
| | | if(info.formatted_addresses && info.formatted_addresses.recommend){ |
| | | ta =info.formatted_addresses.recommend |
| | | } |
| | | locParam.address = ta |
| | | const resCity = await that.$u.api.getCityByName({ cityName: locParam.city }) |
| | | if (resCity.code === 200) { |
| | | locParam.cityId = resCity.data.id |
| | | } |
| | | that.$store.commit('setPosition',locParam) |
| | | that.$isResolve() |
| | | }, |
| | | fail: (err) => { |
| | | that.$isResolve() |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | goStoragePage() { |
| | | uni.navigateTo({ |