修改
This commit is contained in:
parent
a94dc0b6b8
commit
d48b754b90
@ -31,11 +31,47 @@
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
let location = uni.getStorageSync('location')
|
||||
if (!location) {
|
||||
this.getAddress()
|
||||
}
|
||||
this.phonecode = undefined
|
||||
this.logincode = undefined
|
||||
// this.scenenurseStationId = uni.getStorageSync('scenenurseStationId');
|
||||
},
|
||||
methods: {
|
||||
//获取当前位置
|
||||
getAddress() {
|
||||
let that = this;
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: (res) => {
|
||||
let location = res.latitude + ',' + res.longitude
|
||||
//调用逆解析接口
|
||||
uni.request({
|
||||
url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=location', //腾讯官方逆解析接口,可直接复制
|
||||
data: {
|
||||
location: location,
|
||||
'key': "Q4DBZ-UIMC2-B63UX-CUZ6A-S3UT7-TBF3V", //自己申请的Key
|
||||
},
|
||||
method: "GET",
|
||||
success(res) {
|
||||
uni.setStorageSync('location', res.data.result.address_component.city)
|
||||
},
|
||||
fail: res => {
|
||||
console.log(res.errMsg, '解析失败返回的错误信息');
|
||||
}
|
||||
})
|
||||
},
|
||||
//失败
|
||||
fail: (res) => {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '获取地址失败,请打开定位',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
getPhoneNumberp(val) {
|
||||
let that = this;
|
||||
if (val.detail.code) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user