|
|
@@ -3,19 +3,19 @@
|
|
|
<div class="box">
|
|
|
<div class="item" style="justify-content: space-between;">
|
|
|
<text>国家</text>
|
|
|
- <text>中国</text>
|
|
|
+ <text>{{ info.country }}</text>
|
|
|
</div>
|
|
|
<div class="item">
|
|
|
<text>省份</text>
|
|
|
- <text>福建省</text>
|
|
|
+ <text>{{ info.province }}</text>
|
|
|
</div>
|
|
|
<div class="item">
|
|
|
<text>城市</text>
|
|
|
- <text>厦门市</text>
|
|
|
+ <text>{{ info.city }}</text>
|
|
|
</div>
|
|
|
<div class="item">
|
|
|
<text>地区</text>
|
|
|
- <text>湖里区</text>
|
|
|
+ <text>{{ info.district }}</text>
|
|
|
</div>
|
|
|
<div class="item">
|
|
|
<text>运营商</text>
|
|
|
@@ -42,23 +42,26 @@ import network from '@system.network'
|
|
|
import device from '@system.device'
|
|
|
import telecom from '@system.telecom'
|
|
|
import geolocation from '@system.geolocation'
|
|
|
+import fetch from '@system.fetch'
|
|
|
export default {
|
|
|
private: {
|
|
|
title: '欢迎体验快应用开发',
|
|
|
location:{longitude: 114.060682, latitude: 22.5606468},
|
|
|
+ info:{
|
|
|
+ country: "中国",
|
|
|
+ province: "福建省",
|
|
|
+ city: "厦门市",
|
|
|
+ district:'湖里区',
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
onInit() {
|
|
|
- network.getType({
|
|
|
- success: function(data) {
|
|
|
- console.log(`handling success: ${data.type}`)
|
|
|
- }
|
|
|
- })
|
|
|
device.getInfo({
|
|
|
success: function(ret) {
|
|
|
- console.log(`handling success, brand = ${ret.brand}`)
|
|
|
+ console.log(`handling success, brand = ${JSON.stringify(ret)}`)
|
|
|
}
|
|
|
})
|
|
|
+ var that = this
|
|
|
geolocation.getLocation({
|
|
|
success: function(data) {
|
|
|
console.log(
|
|
|
@@ -66,6 +69,21 @@ export default {
|
|
|
data.latitude
|
|
|
}`
|
|
|
)
|
|
|
+ var key = '948b7da20bd04112e259c809fca83671' // 个人高德web服务 key
|
|
|
+ fetch.fetch({
|
|
|
+ url: `https://restapi.amap.com/v3/geocode/regeo?output=JSON&location=${data.longitude},${data.latitude}&key=${key}&extensions=base`,
|
|
|
+ header:{
|
|
|
+ 'Content-Type':'application/json',
|
|
|
+ },
|
|
|
+ success: function(response) {
|
|
|
+ const info = JSON.parse(response.data)
|
|
|
+ that.info = info.regeocode.addressComponent // info.regeocode.formatted_address
|
|
|
+ console.log('info',info.regeocode)
|
|
|
+ },
|
|
|
+ fail: function(data, code) {
|
|
|
+ console.log(`handling fail, errMsg = ${data}`)
|
|
|
+ }
|
|
|
+ })
|
|
|
console.log('data',data)
|
|
|
|
|
|
},
|
|
|
@@ -73,31 +91,6 @@ export default {
|
|
|
console.log(`handling fail, code = ${code}, errorMsg=${data}`)
|
|
|
}
|
|
|
})
|
|
|
- // https://restapi.amap.com/v3/geocode/regeo?output=xml&location=116.310003,39.991957&key=<用户的key>&radius=1000&extensions=all
|
|
|
- geolocation.reverseGeocodeQuery({
|
|
|
- latitude: 30.513070973744515,
|
|
|
- longitude: 114.41322124959942,
|
|
|
- coordType: "gcj02",
|
|
|
- includePoiInfo:true,
|
|
|
- success: function (ret) {
|
|
|
- console.info(`### geolocation.reverseGeocodeQuery ###` + JSON.stringify(ret))
|
|
|
- },
|
|
|
- fail: function (erromsg, errocode) {
|
|
|
- console.info(`### geolocation.reverseGeocodeQuery ### ${errocode}: ${erromsg}`)
|
|
|
- }
|
|
|
- })
|
|
|
- // var that = this
|
|
|
- // geolocation.reverseGeocodeQuery({
|
|
|
- // latitude: that.location.latitude,
|
|
|
- // longitude: that.location.longitude,
|
|
|
- // coordType: "wgs84",
|
|
|
- // success: function (ret) {
|
|
|
- // console.info(`### geolocation.reverseGeocodeQuery ###` + JSON.stringify(ret))
|
|
|
- // },
|
|
|
- // fail: function (erromsg, errocode) {
|
|
|
- // console.info(`### geolocation.reverseGeocodeQuery ### ${errocode}: ${erromsg}`)
|
|
|
- // }
|
|
|
- // })
|
|
|
}
|
|
|
}
|
|
|
</script>
|